Exemple #1
0
 private static void updateRemote(wiimote_t w)
 {
     remoteState.a = WiiUseC.IS_PRESSED(w, WiiUseC.WIIMOTE_BUTTON_A) ? ButtonState.Pressed : ButtonState.Released;
     remoteState.b = WiiUseC.IS_PRESSED(w, WiiUseC.WIIMOTE_BUTTON_B) ? ButtonState.Pressed : ButtonState.Released;
     remoteState.dDown = WiiUseC.IS_PRESSED(w, WiiUseC.WIIMOTE_BUTTON_DOWN) ? ButtonState.Pressed : ButtonState.Released;
     remoteState.dLeft = WiiUseC.IS_PRESSED(w, WiiUseC.WIIMOTE_BUTTON_LEFT) ? ButtonState.Pressed : ButtonState.Released;
     remoteState.dRight = WiiUseC.IS_PRESSED(w, WiiUseC.WIIMOTE_BUTTON_RIGHT) ? ButtonState.Pressed : ButtonState.Released;
     remoteState.dUp = WiiUseC.IS_PRESSED(w, WiiUseC.WIIMOTE_BUTTON_UP) ? ButtonState.Pressed : ButtonState.Released;
     remoteState.home = WiiUseC.IS_PRESSED(w, WiiUseC.WIIMOTE_BUTTON_HOME) ? ButtonState.Pressed : ButtonState.Released;
     remoteState.minus = WiiUseC.IS_PRESSED(w, WiiUseC.WIIMOTE_BUTTON_MINUS) ? ButtonState.Pressed : ButtonState.Released;
     remoteState.plus = WiiUseC.IS_PRESSED(w, WiiUseC.WIIMOTE_BUTTON_PLUS) ? ButtonState.Pressed : ButtonState.Released;
     remoteState.one = WiiUseC.IS_PRESSED(w, WiiUseC.WIIMOTE_BUTTON_ONE) ? ButtonState.Pressed : ButtonState.Released;
     remoteState.two = WiiUseC.IS_PRESSED(w, WiiUseC.WIIMOTE_BUTTON_TWO) ? ButtonState.Pressed : ButtonState.Released;
     remoteState.roll = w.orient.roll;
     remoteState.pitch = w.orient.pitch;
     remoteState.ir.x = MathHelper.Lerp(-1, 1, MathHelper.Clamp((float)w.ir.x / w.ir.vres[0], 0.0f, 1.0f));
     remoteState.ir.y = -MathHelper.Lerp(-1, 1, MathHelper.Clamp((float)w.ir.y / w.ir.vres[1], 0.0f, 1.0f));
     remoteState.ir.distance = w.ir.z;
     remoteState.accel.X = w.gforce.x;
     remoteState.accel.Y = w.gforce.y;
     remoteState.accel.Z = w.gforce.z;
 }
Exemple #2
0
        private static void updateNunchuck(wiimote_t w)
        {
            nunchuckState.c = WiiUseC.IS_PRESSED(w, WiiUseC.NUNCHUK_BUTTON_C) ? ButtonState.Pressed : ButtonState.Released;
            nunchuckState.z = WiiUseC.IS_PRESSED(w, WiiUseC.NUNCHUK_BUTTON_Z) ? ButtonState.Pressed : ButtonState.Released;
            nunchuckState.roll = w.exp.nunchuk.orient.roll;
            nunchuckState.pitch = w.exp.nunchuk.orient.pitch;
            nunchuckState.joyAngle = w.exp.nunchuk.js.ang;
            nunchuckState.joyMagnitude = w.exp.nunchuk.js.mag;
            nunchuckState.accel.X = w.gforce.x;
            nunchuckState.accel.Y = w.gforce.y;
            nunchuckState.accel.Z = w.gforce.z;

            if (float.IsNaN(nunchuckState.joyAngle))
            {
                nunchuckState.joyAngle = 0;
            }
        }
Exemple #3
0
 public static wiimote_t[] MarshalWiimotes()
 {
     wiimote_t[] wms = new wiimote_t[numWiimotes];
     for (int i = 0; i < numWiimotes; i++)
     {
         wms[i] = (wiimote_t)Marshal.PtrToStructure(pWiimote[i], typeof(wiimote_t));
     }
     return wms;
 }
Exemple #4
0
 private static void updateBalance(wiimote_t w)
 {
     balanceState.button = WiiUseC.IS_PRESSED(w, WiiUseC.WIIMOTE_BUTTON_A) ? ButtonState.Pressed : ButtonState.Released;
     balanceState.frontLeft = w.exp.balance.feet.fl;
     balanceState.frontRight = w.exp.balance.feet.fr;
     balanceState.backLeft = w.exp.balance.feet.bl;
     balanceState.backRight = w.exp.balance.feet.br;
 }
Exemple #5
0
 /**
  *	@brief Check if a button is pressed.
  *	@param dev		Pointer to a wiimote_t or expansion structure.
  *	@param button	The button you are interested in.
  *	@return 1 if the button is pressed, 0 if not.
  */
 public static bool IS_PRESSED(wiimote_t dev, int button)
 {
     return ((dev.btns & button) == button);
 }