public void InformNewWiimoteState(WiimoteLib.WiimoteState ws) { // make a report vJoy.JoystickState iReport = new vJoy.JoystickState(); // specify device iReport.bDevice = (byte)wrappedJoystickId; // now position data: iReport.AxisX = RescaleAxis(-ws.AccelState.Values.Y, Xmax); iReport.AxisY = RescaleAxis(ws.AccelState.Values.X, Ymax); iReport.AxisZ = RescaleAxis(ws.AccelState.Values.Z, Zmax); // now buttons iReport.Buttons = WiimoteToUint(ws); wrappedJoystick.UpdateVJD(wrappedJoystickId, ref iReport); }
public Position(WiimoteLib.Point point, DateTime time) { this.point = point; this.time = time; }
private uint WiimoteToUint(WiimoteLib.WiimoteState ws) { // field goes: // a, b, +, -, home, 1, 2, any directional uint output = 0; output = (uint)(((ws.ButtonState.Left ? 0x1 : 0x0) << 10) | ((ws.ButtonState.Down ? 0x1 : 0x0) << 9) | ((ws.ButtonState.Up ? 0x1 : 0x0) << 8) | ((ws.ButtonState.Right ? 0x1 : 0x0) << 7) | ((ws.ButtonState.A ? 0x1 : 0x0) << 6) | ((ws.ButtonState.B ? 0x1 : 0x0) << 5) | ((ws.ButtonState.Plus ? 0x1 : 0x0) << 4) | ((ws.ButtonState.Minus ? 0x1 : 0x0) << 3) | ((ws.ButtonState.Home ? 0x1 : 0x0) << 2) | ((ws.ButtonState.One ? 0x1 : 0x0) << 1) | ((ws.ButtonState.Two ? 0x1 : 0x0) << 0)); return output; }
public Spell addPosition(WiimoteLib.Point pointF, DateTime dateTime) { return handleAdd(new Position(pointF, dateTime)); }
void wm_WiimoteChanged(object sender, WiimoteLib.WiimoteChangedEventArgs e) { SetRotationLabel(e.WiimoteState.AccelState.Values.Y); pj.InformNewWiimoteState(e.WiimoteState); }
public Position(WiimoteLib.Point point, DateTime time) { wiiPoint = point; this.point = new Point((1023 - point.X) / 4, (760 - point.Y) / 4); this.time = time; }
public Spell addPosition(WiimoteLib.Point pointF, DateTime dateTime) { if (spellNames.Count == 0 && !cloudBitWarningShown) { cloudBitWarningShown = true; MessageBox.Show( "You need to choose the spells and set the cloudBit configurations before casting spells", "Configuration required", MessageBoxButtons.OK, MessageBoxIcon.Error); return null; } if (spell == null) { addPosition(new Position(pointF, dateTime)); if (positions.Count > 10) { if (wandIsPaused(positions)) { Spell chosen = brain.chooseSpell(positions); if (chosen != null && authorization != null && device != null && spellNames != null) { for (int i = 0; i < spellNames.Count; i++) { if (spellNames[i].Equals(chosen.GetType().Name)) { spell = chosen; ((CloudBitSpell)spell).setConfigurations(device, authorization, spellVoltages[i], spellDurations[i]); spell.castSpell(); startSpell = DateTime.Now; } } } /* strokes = decomposer.determineStrokes(positions); // TODO: move to class for choosing which spell was cast foreach (SpellTrigger trigger in spells) { if (trigger.triggered(strokes)) { spell = trigger; trigger.castSpell(); startSpell = DateTime.Now; } } */ } } } else if (!spell.casting()) { spell = null; positions.Clear(); if (strokes != null) { strokes.Clear(); } } return spell; }