Ejemplo n.º 1
0
        public void TestOneButtonRelease()
        {
            ControlBoardListenerAccessor target = new ControlBoardListenerAccessor();

            JoystickVal val = new JoystickVal();
            val.Buttons = 0x04;

            List<ControlButton> buttons = target.GetButtonListList(val);

            Assert.AreEqual(1, buttons.Count);
            Assert.AreEqual(0, buttons[0].ButtonNr);
            Assert.AreEqual(false, buttons[0].IsPressed);
            Assert.AreEqual(true, buttons[0].IsReleased);
        }
Ejemplo n.º 2
0
        protected static List<ControlButton> GetButtonValues(JoystickVal val)
        {
            List<ControlButton> listButtons = new List<ControlButton>();

            int j = 0;
            for (int i = 1; i <= 0x10; i <<= 4)
            {
                ControlButton b = GetButton(val, i, j++);

                if (b != null) listButtons.Add(b);
            }

            return listButtons;
        }
Ejemplo n.º 3
0
 private void SetDefault()
 {
     val = new JoystickVal();
     ButtonVal = 1;
 }
Ejemplo n.º 4
0
 private void ControlListener_OnAchsisChanged(int methodid, JoystickVal val)
 {
     TurnContinuous(val.Value, val.Nr);
 }
Ejemplo n.º 5
0
 public List<ControlButton> GetButtonListList(JoystickVal val)
 {
     return ControlBoardListener.GetButtonValues(val);
 }
Ejemplo n.º 6
0
        private static ControlButton GetButton(JoystickVal val, int mask, int nr)
        {
            ControlButton b = null;

            if ((val.Buttons & mask) > 0)
            {
                b = new ControlButton();
                b.IsPressed = true;
            }
            else if ((val.Buttons & (mask << 2)) > 0)
            {
                b = new ControlButton();
                b.IsReleased = true;
            }

            // The MH-Nr is also the player-nr!
            if (b != null)
            {
                b.ButtonNr = nr;
                b.PlayerNr = val.Nr;
            }

            return b;
        }