예제 #1
0
        public JoystickButton(string name, KeyCode key)
        {
            this.name = name;
            this.key = key;

            joystick = InputSystem.KeyToJoystick(key);
            button = InputSystem.KeyToJoystickButton(key);
        }
예제 #2
0
        public JoystickButton(string name, Joysticks joystick, JoystickButtons button)
        {
            this.name = name;
            this.joystick = joystick;
            this.button = button;

            key = InputSystem.JoystickInputToKey(joystick, button);
        }
예제 #3
0
 void Start()
 {
     for (int i = 0; i < buttons.Length; i++) {
         buttons[i] = new JoystickButtons();
     }
     //whichJoystick = GetJoystick.getJoystick ();
     //joystickName = GetJoystick.getName (whichJoystick);
     //print (joystickName);
 }
예제 #4
0
		private void UpdateNormalButtons(JoystickButtons buttons)
		{
			UpdateButton(IsButtonPressed(buttons, JoystickButtons.A), GamePadButton.A);
			UpdateButton(IsButtonPressed(buttons, JoystickButtons.B), GamePadButton.B);
			UpdateButton(IsButtonPressed(buttons, JoystickButtons.X), GamePadButton.X);
			UpdateButton(IsButtonPressed(buttons, JoystickButtons.Y), GamePadButton.Y);
			UpdateButton(IsButtonPressed(buttons, JoystickButtons.Back), GamePadButton.Back);
			UpdateButton(IsButtonPressed(buttons, JoystickButtons.Start), GamePadButton.Start);
		}
예제 #5
0
		private void UpdateStickAndShoulderButtons(JoystickButtons buttons)
		{
			UpdateButton(IsButtonPressed(buttons, JoystickButtons.ShoulderLeft),
				GamePadButton.LeftShoulder);
			UpdateButton(IsButtonPressed(buttons, JoystickButtons.ThumbStickLeft),
				GamePadButton.LeftStick);
			UpdateButton(IsButtonPressed(buttons, JoystickButtons.ShoulderRight),
				GamePadButton.RightShoulder);
			UpdateButton(IsButtonPressed(buttons, JoystickButtons.ThumbStickRight),
				GamePadButton.RightStick);
		}
예제 #6
0
        public bool IsMatchFrom(JoystickButtons joyBtns, byte[] keyState)
        {
            if (FromStores.Count == 0)
                return false;

            bool isMatch = false;
            foreach (KeyStoreInfo keyInfo in FromStores)
            {
                if (keyInfo.IsJoystick())
                {
                    if ((joyBtns & keyInfo._Joystick) == keyInfo._Joystick)
                    {
                        isMatch = true;
                    }
                    else
                    {
                        return false;
                    }
                }
                else
                {
                    int idx = (int)keyInfo._Keyboard;
                    if (idx >= 0 && idx < 256)
                    {
                        if ((keyState[idx] & 0xff) == 1)
                        {
                            isMatch = true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                }
            }
            return isMatch;
        }
예제 #7
0
 /// <summary>
 /// 获取X,Y轴的状态
 /// </summary>
 /// <param name="lParam"></param>
 /// <param name="buttons"></param>
 private void GetXYButtonsStateFromLParam(long lParam, ref JoystickButtons buttons)
 {
     //处理X,Y轴
     int x = (int)(lParam & 0x0000FFFE);                //低16位存储X轴坐标
     int y = (int)((lParam & 0xFFFE0000) >> 16); //高16位存储Y轴坐标(不直接移位是为避免0xFFFFFF)
     int m = 0x7FFE;                            //中心点的值,
     if (x > m)
     {
         buttons |= JoystickButtons.Right;
     }
     else if (x < m)
     {
         buttons |= JoystickButtons.Left;
     }
     if (y > m)
     {
         buttons |= JoystickButtons.Down;
     }
     else if (y < m)
     {
         buttons |= JoystickButtons.UP;
     }
 }
 public SystemJoystickValue(SystemJoystickValue source)
 {
     type = source.Type;
     button = source.Button;
     axis = source.Axis;
     axisFilter = source.AxisFilter;
     pov = source.POV;
     povDirection = source.POVDirection;
     _parent = source.Parent;
     strength = source.strength;
 }
 /// <summary>
 /// Check if the Given Input is Binded. Return the currently binded control to the input
 /// </summary>
 public bool IsAlreadyBinded(JoystickButtons button, out SystemJoystickValue control)
 {
     control = null;
     foreach (GameControlItem item in Items)
     {
         if (item.BindedJoystickValues.Count <= 0)
             continue;
         foreach (SystemJoystickValue value in item.BindedJoystickValues)
         {
             if (value.Type == SystemJoystickValue.Types.Button && value.Button == button)
             {
                 control = value;
                 return true;
             }
         }
     }
     return false;
 }
예제 #10
0
 public void SetStoreValue(JoystickButtons joystick)
 {
     _Keyboard = Keys.None;
     _Joystick = joystick;
     RefreshBtnName();
 }
예제 #11
0
        private void HandleXinput(JoystickButtons joystickButtons, State state, State previousState, int index)
        {
            var button = joystickButtons.XInputButton;

            switch (joystickButtons.InputMapping)
            {
            case InputMapping.Test:
            {
                if (InputCode.ButtonMode == EmulationProfile.NamcoMkdx ||
                    InputCode.ButtonMode == EmulationProfile.NamcoMachStorm ||
                    InputCode.ButtonMode == EmulationProfile.NamcoWmmt5)
                {
                    var result     = DigitalHelper.GetButtonPressXinput(button, state, index);
                    var prevResult = DigitalHelper.GetButtonPressXinput(button, previousState, index);
                    if ((result != null && result.Value) && ((prevResult == null) || (!prevResult.Value)))
                    {
                        if (mkdxTest)
                        {
                            InputCode.PlayerDigitalButtons[0].Test = false;
                            mkdxTest = false;
                        }
                        else
                        {
                            InputCode.PlayerDigitalButtons[0].Test = true;
                            mkdxTest = true;
                        }
                    }
                }
                else
                {
                    InputCode.PlayerDigitalButtons[0].Test = DigitalHelper.GetButtonPressXinput(button, state, index);
                }
                break;
            }

            case InputMapping.Service1:
                InputCode.PlayerDigitalButtons[0].Service = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.Service2:
                InputCode.PlayerDigitalButtons[1].Service = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.Coin1:
                InputCode.PlayerDigitalButtons[0].Coin = DigitalHelper.GetButtonPressXinput(button, state, index);
                JvsPackageEmulator.UpdateCoinCount(0);
                break;

            case InputMapping.Coin2:
                InputCode.PlayerDigitalButtons[1].Coin = DigitalHelper.GetButtonPressXinput(button, state, index);
                JvsPackageEmulator.UpdateCoinCount(1);
                break;

            case InputMapping.P1Button1:
                if (_gameProfile.EmulationProfile == EmulationProfile.Theatrhythm)
                {
                    DigitalHelper.GetDirectionPressXinput(InputCode.PlayerDigitalButtons[0], button, state, Direction.FFUp, index);
                }
                else
                {
                    InputCode.PlayerDigitalButtons[0].Button1 = DigitalHelper.GetButtonPressXinput(button, state, index);
                }
                break;

            case InputMapping.P1Button2:
                if (_gameProfile.EmulationProfile == EmulationProfile.Theatrhythm)
                {
                    DigitalHelper.GetDirectionPressXinput(InputCode.PlayerDigitalButtons[0], button, state, Direction.FFDown, index);
                }
                else
                {
                    InputCode.PlayerDigitalButtons[0].Button2 = DigitalHelper.GetButtonPressXinput(button, state, index);
                }
                break;

            case InputMapping.P1Button3:
                if (_gameProfile.EmulationProfile == EmulationProfile.Theatrhythm)
                {
                    DigitalHelper.GetDirectionPressXinput(InputCode.PlayerDigitalButtons[0], button, state, Direction.FFLeft, index);
                }
                else
                {
                    InputCode.PlayerDigitalButtons[0].Button3 = DigitalHelper.GetButtonPressXinput(button, state, index);
                }
                break;

            case InputMapping.P1Button4:
                if (_gameProfile.EmulationProfile == EmulationProfile.Theatrhythm)
                {
                    DigitalHelper.GetDirectionPressXinput(InputCode.PlayerDigitalButtons[0], button, state, Direction.FFRight, index);
                }
                else
                {
                    InputCode.PlayerDigitalButtons[0].Button4 = DigitalHelper.GetButtonPressXinput(button, state, index);
                }
                break;

            case InputMapping.P1Button5:
                InputCode.PlayerDigitalButtons[0].Button5 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.P1Button6:
                InputCode.PlayerDigitalButtons[0].Button6 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.P1ButtonUp:
                DigitalHelper.GetDirectionPressXinput(InputCode.PlayerDigitalButtons[0], button, state, Direction.Up, index);
                break;

            case InputMapping.P1ButtonDown:
                DigitalHelper.GetDirectionPressXinput(InputCode.PlayerDigitalButtons[0], button, state, Direction.Down, index);
                break;

            case InputMapping.P1ButtonLeft:
                DigitalHelper.GetDirectionPressXinput(InputCode.PlayerDigitalButtons[0], button, state, Direction.Left, index);
                break;

            case InputMapping.P1ButtonRight:
                DigitalHelper.GetDirectionPressXinput(InputCode.PlayerDigitalButtons[0], button, state, Direction.Right, index);
                break;

            case InputMapping.P1ButtonStart:
                InputCode.PlayerDigitalButtons[0].Start = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.P2Button1:
                InputCode.PlayerDigitalButtons[1].Button1 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.P2Button2:
                InputCode.PlayerDigitalButtons[1].Button2 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.P2Button3:
                InputCode.PlayerDigitalButtons[1].Button3 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.P2Button4:
                InputCode.PlayerDigitalButtons[1].Button4 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.P2Button5:
                InputCode.PlayerDigitalButtons[1].Button5 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.P2Button6:
                InputCode.PlayerDigitalButtons[1].Button6 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.P2ButtonUp:
                DigitalHelper.GetDirectionPressXinput(InputCode.PlayerDigitalButtons[1], button, state, Direction.Up, index);
                break;

            case InputMapping.P2ButtonDown:
                DigitalHelper.GetDirectionPressXinput(InputCode.PlayerDigitalButtons[1], button, state, Direction.Down, index);
                break;

            case InputMapping.P2ButtonLeft:
                DigitalHelper.GetDirectionPressXinput(InputCode.PlayerDigitalButtons[1], button, state, Direction.Left, index);
                break;

            case InputMapping.P2ButtonRight:
                DigitalHelper.GetDirectionPressXinput(InputCode.PlayerDigitalButtons[1], button, state, Direction.Right, index);
                break;

            case InputMapping.P2ButtonStart:
                InputCode.PlayerDigitalButtons[1].Start = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.Analog0:
                InputCode.SetAnalogByte(0, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog1:
                InputCode.SetAnalogByte(1, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog2:
                InputCode.SetAnalogByte(2, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog3:
                InputCode.SetAnalogByte(3, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog4:
                InputCode.SetAnalogByte(4, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog5:
                InputCode.SetAnalogByte(5, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog6:
                InputCode.SetAnalogByte(6, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog7:
                InputCode.SetAnalogByte(7, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog8:
                InputCode.SetAnalogByte(8, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog9:
                InputCode.SetAnalogByte(9, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog10:
                InputCode.SetAnalogByte(10, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog11:
                InputCode.SetAnalogByte(11, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog12:
                InputCode.SetAnalogByte(12, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog13:
                InputCode.SetAnalogByte(13, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog14:
                InputCode.SetAnalogByte(14, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog15:
                InputCode.SetAnalogByte(15, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog16:
                InputCode.SetAnalogByte(16, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog17:
                InputCode.SetAnalogByte(17, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog18:
                InputCode.SetAnalogByte(18, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog19:
                InputCode.SetAnalogByte(19, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog20:
                InputCode.SetAnalogByte(20, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.SrcGearChange1:
            {
                if (DigitalHelper.GetButtonPressXinput(joystickButtons.XInputButton, state, index) == true)
                {
                    DigitalHelper.ChangeSrcGear(1);
                }
            }
            break;

            case InputMapping.SrcGearChange2:
            {
                if (DigitalHelper.GetButtonPressXinput(joystickButtons.XInputButton, state, index) == true)
                {
                    DigitalHelper.ChangeSrcGear(2);
                }
            }
            break;

            case InputMapping.SrcGearChange3:
            {
                if (DigitalHelper.GetButtonPressXinput(joystickButtons.XInputButton, state, index) == true)
                {
                    DigitalHelper.ChangeSrcGear(3);
                }
            }
            break;

            case InputMapping.SrcGearChange4:
            {
                if (DigitalHelper.GetButtonPressXinput(joystickButtons.XInputButton, state, index) == true)
                {
                    DigitalHelper.ChangeSrcGear(4);
                }
            }
            break;

            case InputMapping.ExtensionOne1:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionOne2:
                InputCode.PlayerDigitalButtons[0].ExtensionButton2 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionOne3:
                InputCode.PlayerDigitalButtons[0].ExtensionButton3 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionOne4:
                InputCode.PlayerDigitalButtons[0].ExtensionButton4 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionOne11:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_1 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionOne12:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_2 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionOne13:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_3 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionOne14:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_4 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionOne15:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_5 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionOne16:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_6 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionOne17:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_7 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionOne18:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_8 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionTwo1:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionTwo2:
                InputCode.PlayerDigitalButtons[1].ExtensionButton2 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionTwo3:
                InputCode.PlayerDigitalButtons[1].ExtensionButton3 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionTwo4:
                InputCode.PlayerDigitalButtons[1].ExtensionButton4 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionTwo11:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_1 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionTwo12:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_2 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionTwo13:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_3 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionTwo14:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_4 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionTwo15:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_5 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionTwo16:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_6 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionTwo17:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_7 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.ExtensionTwo18:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_8 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            // Jvs Board 2

            case InputMapping.JvsTwoService1:
                InputCode.PlayerDigitalButtons[2].Service = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoService2:
                InputCode.PlayerDigitalButtons[3].Service = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoCoin1:
                InputCode.PlayerDigitalButtons[2].Coin = DigitalHelper.GetButtonPressXinput(button, state, index);
                JvsPackageEmulator.UpdateCoinCount(2);
                break;

            case InputMapping.JvsTwoCoin2:
                InputCode.PlayerDigitalButtons[3].Coin = DigitalHelper.GetButtonPressXinput(button, state, index);
                JvsPackageEmulator.UpdateCoinCount(3);
                break;

            case InputMapping.JvsTwoP1Button1:
                InputCode.PlayerDigitalButtons[2].Button1 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoP1Button2:
                InputCode.PlayerDigitalButtons[2].Button2 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoP1Button3:
                InputCode.PlayerDigitalButtons[2].Button3 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoP1Button4:
                InputCode.PlayerDigitalButtons[2].Button4 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoP1Button5:
                InputCode.PlayerDigitalButtons[2].Button5 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoP1Button6:
                InputCode.PlayerDigitalButtons[2].Button6 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoP1ButtonUp:
                DigitalHelper.GetDirectionPressXinput(InputCode.PlayerDigitalButtons[2], button, state, Direction.Up, index);
                break;

            case InputMapping.JvsTwoP1ButtonDown:
                DigitalHelper.GetDirectionPressXinput(InputCode.PlayerDigitalButtons[2], button, state, Direction.Down, index);
                break;

            case InputMapping.JvsTwoP1ButtonLeft:
                DigitalHelper.GetDirectionPressXinput(InputCode.PlayerDigitalButtons[2], button, state, Direction.Left, index);
                break;

            case InputMapping.JvsTwoP1ButtonRight:
                DigitalHelper.GetDirectionPressXinput(InputCode.PlayerDigitalButtons[2], button, state, Direction.Right, index);
                break;

            case InputMapping.JvsTwoP1ButtonStart:
                InputCode.PlayerDigitalButtons[2].Start = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoP2Button1:
                InputCode.PlayerDigitalButtons[3].Button1 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoP2Button2:
                InputCode.PlayerDigitalButtons[3].Button2 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoP2Button3:
                InputCode.PlayerDigitalButtons[3].Button3 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoP2Button4:
                InputCode.PlayerDigitalButtons[3].Button4 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoP2Button5:
                InputCode.PlayerDigitalButtons[3].Button5 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoP2Button6:
                InputCode.PlayerDigitalButtons[3].Button6 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoP2ButtonUp:
                DigitalHelper.GetDirectionPressXinput(InputCode.PlayerDigitalButtons[3], button, state, Direction.Up, index);
                break;

            case InputMapping.JvsTwoP2ButtonDown:
                DigitalHelper.GetDirectionPressXinput(InputCode.PlayerDigitalButtons[3], button, state, Direction.Down, index);
                break;

            case InputMapping.JvsTwoP2ButtonLeft:
                DigitalHelper.GetDirectionPressXinput(InputCode.PlayerDigitalButtons[3], button, state, Direction.Left, index);
                break;

            case InputMapping.JvsTwoP2ButtonRight:
                DigitalHelper.GetDirectionPressXinput(InputCode.PlayerDigitalButtons[3], button, state, Direction.Right, index);
                break;

            case InputMapping.JvsTwoP2ButtonStart:
                InputCode.PlayerDigitalButtons[3].Start = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionOne1:
                InputCode.PlayerDigitalButtons[2].ExtensionButton1 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionOne2:
                InputCode.PlayerDigitalButtons[2].ExtensionButton2 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionOne3:
                InputCode.PlayerDigitalButtons[2].ExtensionButton3 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionOne4:
                InputCode.PlayerDigitalButtons[2].ExtensionButton4 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionOne11:
                InputCode.PlayerDigitalButtons[2].ExtensionButton1_1 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionOne12:
                InputCode.PlayerDigitalButtons[2].ExtensionButton1_2 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionOne13:
                InputCode.PlayerDigitalButtons[2].ExtensionButton1_3 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionOne14:
                InputCode.PlayerDigitalButtons[2].ExtensionButton1_4 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionOne15:
                InputCode.PlayerDigitalButtons[2].ExtensionButton1_5 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionOne16:
                InputCode.PlayerDigitalButtons[2].ExtensionButton1_6 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionOne17:
                InputCode.PlayerDigitalButtons[2].ExtensionButton1_7 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionOne18:
                InputCode.PlayerDigitalButtons[2].ExtensionButton1_8 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionTwo1:
                InputCode.PlayerDigitalButtons[3].ExtensionButton1 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionTwo2:
                InputCode.PlayerDigitalButtons[3].ExtensionButton2 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionTwo3:
                InputCode.PlayerDigitalButtons[3].ExtensionButton3 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionTwo4:
                InputCode.PlayerDigitalButtons[3].ExtensionButton4 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionTwo11:
                InputCode.PlayerDigitalButtons[3].ExtensionButton1_1 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionTwo12:
                InputCode.PlayerDigitalButtons[3].ExtensionButton1_2 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionTwo13:
                InputCode.PlayerDigitalButtons[3].ExtensionButton1_3 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionTwo14:
                InputCode.PlayerDigitalButtons[3].ExtensionButton1_4 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionTwo15:
                InputCode.PlayerDigitalButtons[3].ExtensionButton1_5 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionTwo16:
                InputCode.PlayerDigitalButtons[3].ExtensionButton1_6 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionTwo17:
                InputCode.PlayerDigitalButtons[3].ExtensionButton1_7 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoExtensionTwo18:
                InputCode.PlayerDigitalButtons[3].ExtensionButton1_8 = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.JvsTwoAnalog0:
                InputCode.SetAnalogByte(0, ModifyAnalog(joystickButtons, state, index), true);
                break;

            case InputMapping.JvsTwoAnalog1:
                InputCode.SetAnalogByte(1, ModifyAnalog(joystickButtons, state, index), true);
                break;

            case InputMapping.JvsTwoAnalog2:
                InputCode.SetAnalogByte(2, ModifyAnalog(joystickButtons, state, index), true);
                break;

            case InputMapping.JvsTwoAnalog3:
                InputCode.SetAnalogByte(3, ModifyAnalog(joystickButtons, state, index), true);
                break;

            case InputMapping.JvsTwoAnalog4:
                InputCode.SetAnalogByte(4, ModifyAnalog(joystickButtons, state, index), true);
                break;

            case InputMapping.JvsTwoAnalog5:
                InputCode.SetAnalogByte(5, ModifyAnalog(joystickButtons, state, index), true);
                break;

            case InputMapping.JvsTwoAnalog6:
                InputCode.SetAnalogByte(6, ModifyAnalog(joystickButtons, state, index), true);
                break;

            case InputMapping.JvsTwoAnalog7:
                InputCode.SetAnalogByte(7, ModifyAnalog(joystickButtons, state, index), true);
                break;

            case InputMapping.JvsTwoAnalog8:
                InputCode.SetAnalogByte(8, ModifyAnalog(joystickButtons, state, index), true);
                break;

            case InputMapping.JvsTwoAnalog9:
                InputCode.SetAnalogByte(9, ModifyAnalog(joystickButtons, state, index), true);
                break;

            case InputMapping.JvsTwoAnalog10:
                InputCode.SetAnalogByte(10, ModifyAnalog(joystickButtons, state, index), true);
                break;

            case InputMapping.JvsTwoAnalog11:
                InputCode.SetAnalogByte(11, ModifyAnalog(joystickButtons, state, index), true);
                break;

            case InputMapping.JvsTwoAnalog12:
                InputCode.SetAnalogByte(12, ModifyAnalog(joystickButtons, state, index), true);
                break;

            case InputMapping.JvsTwoAnalog13:
                InputCode.SetAnalogByte(13, ModifyAnalog(joystickButtons, state, index), true);
                break;

            case InputMapping.JvsTwoAnalog14:
                InputCode.SetAnalogByte(14, ModifyAnalog(joystickButtons, state, index), true);
                break;

            case InputMapping.JvsTwoAnalog15:
                InputCode.SetAnalogByte(15, ModifyAnalog(joystickButtons, state, index), true);
                break;

            case InputMapping.JvsTwoAnalog16:
                InputCode.SetAnalogByte(16, ModifyAnalog(joystickButtons, state, index), true);
                break;

            case InputMapping.JvsTwoAnalog17:
                InputCode.SetAnalogByte(17, ModifyAnalog(joystickButtons, state, index), true);
                break;

            case InputMapping.JvsTwoAnalog18:
                InputCode.SetAnalogByte(18, ModifyAnalog(joystickButtons, state, index), true);
                break;

            case InputMapping.JvsTwoAnalog19:
                InputCode.SetAnalogByte(19, ModifyAnalog(joystickButtons, state, index), true);
                break;

            case InputMapping.JvsTwoAnalog20:
                InputCode.SetAnalogByte(20, ModifyAnalog(joystickButtons, state, index), true);
                break;


            case InputMapping.Analog0Special1:
            case InputMapping.Analog0Special2:
                InputCode.SetAnalogByte(0, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Analog2Special1:
            case InputMapping.Analog2Special2:
                InputCode.SetAnalogByte(2, ModifyAnalog(joystickButtons, state, index));
                break;

            case InputMapping.Wmmt5GearChange1:
            {
                if (DigitalHelper.GetButtonPressXinput(joystickButtons.XInputButton, state, index) == true)
                {
                    DigitalHelper.ChangeWmmt5Gear(1);
                }
            }
            break;

            case InputMapping.Wmmt5GearChange2:
            {
                if (DigitalHelper.GetButtonPressXinput(joystickButtons.XInputButton, state, index) == true)
                {
                    DigitalHelper.ChangeWmmt5Gear(2);
                }
            }
            break;

            case InputMapping.Wmmt5GearChange3:
            {
                if (DigitalHelper.GetButtonPressXinput(joystickButtons.XInputButton, state, index) == true)
                {
                    DigitalHelper.ChangeWmmt5Gear(3);
                }
            }
            break;

            case InputMapping.Wmmt5GearChange4:
            {
                if (DigitalHelper.GetButtonPressXinput(joystickButtons.XInputButton, state, index) == true)
                {
                    DigitalHelper.ChangeWmmt5Gear(4);
                }
            }
            break;

            case InputMapping.Wmmt5GearChange5:
            {
                if (DigitalHelper.GetButtonPressXinput(joystickButtons.XInputButton, state, index) == true)
                {
                    DigitalHelper.ChangeWmmt5Gear(5);
                }
            }
            break;

            case InputMapping.Wmmt5GearChange6:
            {
                if (DigitalHelper.GetButtonPressXinput(joystickButtons.XInputButton, state, index) == true)
                {
                    DigitalHelper.ChangeWmmt5Gear(6);
                }
            }
            break;

            case InputMapping.Wmmt5GearChangeUp:
            {
                if (DigitalHelper.GetButtonPressXinput(joystickButtons.XInputButton, state, index) == true)
                {
                    if (!changeWmmt5GearUp)
                    {
                        DigitalHelper.ChangeWmmt5GearUp();
                    }
                    changeWmmt5GearUp = true;
                }
                else
                {
                    changeWmmt5GearUp = false;
                }
            }
            break;

            case InputMapping.Wmmt5GearChangeDown:
            {
                if (DigitalHelper.GetButtonPressXinput(joystickButtons.XInputButton, state, index) == true)
                {
                    if (!changeWmmt5GearDown)
                    {
                        DigitalHelper.ChangeWmmt5GearDown();
                    }
                    changeWmmt5GearDown = true;
                }
                else
                {
                    changeWmmt5GearDown = false;
                }
            }
            break;

            case InputMapping.SrcGearChangeUp:
            {
                if (DigitalHelper.GetButtonPressXinput(joystickButtons.XInputButton, state, index) == true)
                {
                    if (!changeSrcGearUp)
                    {
                        DigitalHelper.ChangeSrcGearUp();
                    }
                    changeSrcGearUp = true;
                }
                else
                {
                    changeSrcGearUp = false;
                }
            }
            break;

            case InputMapping.SrcGearChangeDown:
            {
                if (DigitalHelper.GetButtonPressXinput(joystickButtons.XInputButton, state, index) == true)
                {
                    if (!changeSrcGearDown)
                    {
                        DigitalHelper.ChangeSrcGearDown();
                    }
                    changeSrcGearDown = true;
                }
                else
                {
                    changeSrcGearDown = false;
                }
            }
            break;

            case InputMapping.PokkenButtonUp:
                DigitalHelper.GetDirectionPressXinput(InputCode.PokkenInputButtons, button, state, Direction.Up, index);
                break;

            case InputMapping.PokkenButtonDown:
                DigitalHelper.GetDirectionPressXinput(InputCode.PokkenInputButtons, button, state, Direction.Down, index);
                break;

            case InputMapping.PokkenButtonLeft:
                DigitalHelper.GetDirectionPressXinput(InputCode.PokkenInputButtons, button, state, Direction.Left, index);
                break;

            case InputMapping.PokkenButtonRight:
                DigitalHelper.GetDirectionPressXinput(InputCode.PokkenInputButtons, button, state, Direction.Right, index);
                break;

            case InputMapping.PokkenButtonStart:
                InputCode.PokkenInputButtons.Start = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.PokkenButtonA:
                InputCode.PokkenInputButtons.ButtonA = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.PokkenButtonB:
                InputCode.PokkenInputButtons.ButtonB = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.PokkenButtonX:
                InputCode.PokkenInputButtons.ButtonX = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.PokkenButtonY:
                InputCode.PokkenInputButtons.ButtonY = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.PokkenButtonL:
                InputCode.PokkenInputButtons.ButtonL = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            case InputMapping.PokkenButtonR:
                InputCode.PokkenInputButtons.ButtonR = DigitalHelper.GetButtonPressXinput(button, state, index);
                break;

            default:
                break;
                //throw new ArgumentOutOfRangeException();
            }
        }
예제 #12
0
 //
 public DefaultJoystickValueAttribute( JoystickButtons button )
 {
     value = new GameControlsManager.SystemJoystickValue( button );
 }
        private byte?ModifyAnalog(JoystickButtons joystickButtons, JoystickUpdate state)
        {
            if (joystickButtons.DirectInputButton == null)
            {
                return(null);
            }
            if ((JoystickOffset)joystickButtons.DirectInputButton.Button != state.Offset)
            {
                return(null);
            }

            switch (joystickButtons.AnalogType)
            {
            case AnalogType.None:
                break;

            case AnalogType.AnalogJoystick:
            {
                var analogPos = JvsHelper.CalculateWheelPos(state.Value);

                if (_gameProfile.EmulationProfile == EmulationProfile.Mballblitz)
                {
                    if (joystickButtons.InputMapping == InputMapping.Analog0)
                    {
                        JvsHelper.StateView.Write(8, analogPos);
                    }
                    if (joystickButtons.InputMapping == InputMapping.Analog2)
                    {
                        JvsHelper.StateView.Write(12, analogPos);
                    }
                }

                return(analogPos);
            }

            case AnalogType.AnalogJoystickReverse:
            {
                return((byte)~JvsHelper.CalculateWheelPos(state.Value));
            }

            case AnalogType.Gas:
            {
                var gas = HandleGasBrakeForJvs(state.Value, joystickButtons.DirectInputButton?.IsAxisMinus, Lazydata.ParrotData.ReverseAxisGas, Lazydata.ParrotData.FullAxisGas, true);
                //Console.WriteLine("Gas: " + gas.ToString("X2"));
                if (InputCode.ButtonMode == EmulationProfile.NamcoWmmt5)
                {
                    gas /= 3;
                }
                return(gas);
            }

            case AnalogType.Brake:
            {
                var brake = HandleGasBrakeForJvs(state.Value, joystickButtons.DirectInputButton?.IsAxisMinus, Lazydata.ParrotData.ReverseAxisGas, Lazydata.ParrotData.FullAxisGas, false);
                if (InputCode.ButtonMode == EmulationProfile.NamcoWmmt5)
                {
                    brake /= 3;
                }
                //Console.WriteLine("Brake: " + brake.ToString("X2"));
                return(brake);
            }

            case AnalogType.Wheel:
            {
                int minVal = 0;
                int maxVal = 255;
                switch (_gameProfile.EmulationProfile)
                {
                case EmulationProfile.SegaInitialD:
                    minVal = 0x1F;
                    maxVal = 0xE1;
                    break;

                case EmulationProfile.SegaInitialDLindbergh:
                    minVal = 0x1F;
                    maxVal = 0xE1;
                    break;

                case EmulationProfile.SegaSonicAllStarsRacing:
                    minVal = 0x1D;
                    maxVal = 0xED;
                    break;

                default:
                    minVal = 0;
                    maxVal = 0xFF;
                    break;
                }
                var wheelPos = Lazydata.ParrotData.UseSto0ZDrivingHack
                        ? JvsHelper.CalculateSto0ZWheelPos(state.Value, Lazydata.ParrotData.StoozPercent)
                        : JvsHelper.CalculateWheelPos(state.Value, false, false, minVal, maxVal);

                if (_gameProfile.EmulationProfile == EmulationProfile.TaitoTypeXBattleGear ||
                    _gameProfile.EmulationProfile == EmulationProfile.VirtuaRLimit)
                {
                    JvsHelper.StateView.Write(4, wheelPos);
                }

                return(wheelPos);
            }

            case AnalogType.Minimum:
                if (state.Value == 0x80)
                {
                    return(0x00);
                }
                else
                {
                    return(0x7F);
                }

            case AnalogType.Maximum:
                if (state.Value == 0x80)
                {
                    return(0xFF);
                }
                else
                {
                    return(0x7F);
                }

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(null);
        }
예제 #14
0
 public JoystickButton(Joysticks joystick, JoystickButtons button)
 {
     this.joystick = joystick;
     this.button   = button;
     this.key      = InputUtility.JoystickInputToKey(joystick, button);
 }
예제 #15
0
파일: Input.cs 프로젝트: itsarabbit/Jacot
 public static bool IsReleased(uint index, JoystickButtons button)
 {
     return(isJoyButtonReleased[(int)button][index]);
 }
예제 #16
0
파일: Input.cs 프로젝트: itsarabbit/Jacot
        public static bool IsPressed(uint index, JoystickButtons button)
        {
            int code = (int)button;

            return(isJoyButtonPressed[(int)button][index]);
        }
예제 #17
0
파일: Input.cs 프로젝트: itsarabbit/Jacot
 public static bool IsDown(uint index, JoystickButtons button)
 {
     return(isJoyButtonDown[(int)button][index]);
 }
예제 #18
0
        public static JoystickButtons GetClickButton(JoystickButtons btns)
        {
            if ((btns & JoystickButtons.UP) == JoystickButtons.UP)
            {
                return(JoystickButtons.UP);
            }

            if ((btns & JoystickButtons.Down) == JoystickButtons.Down)
            {
                return(JoystickButtons.Down);
            }

            if ((btns & JoystickButtons.Left) == JoystickButtons.Left)
            {
                return(JoystickButtons.Left);
            }

            if ((btns & JoystickButtons.Right) == JoystickButtons.Right)
            {
                return(JoystickButtons.Right);
            }

            if ((btns & JoystickButtons.B1) == JoystickButtons.B1)
            {
                return(JoystickButtons.B1);
            }

            if ((btns & JoystickButtons.B2) == JoystickButtons.B2)
            {
                return(JoystickButtons.B2);
            }

            if ((btns & JoystickButtons.B3) == JoystickButtons.B3)
            {
                return(JoystickButtons.B3);
            }

            if ((btns & JoystickButtons.B4) == JoystickButtons.B4)
            {
                return(JoystickButtons.B4);
            }

            if ((btns & JoystickButtons.B5) == JoystickButtons.B5)
            {
                return(JoystickButtons.B5);
            }

            if ((btns & JoystickButtons.B6) == JoystickButtons.B6)
            {
                return(JoystickButtons.B6);
            }

            if ((btns & JoystickButtons.B7) == JoystickButtons.B7)
            {
                return(JoystickButtons.B7);
            }

            if ((btns & JoystickButtons.B8) == JoystickButtons.B8)
            {
                return(JoystickButtons.B8);
            }

            if ((btns & JoystickButtons.B9) == JoystickButtons.B9)
            {
                return(JoystickButtons.B9);
            }

            if ((btns & JoystickButtons.B10) == JoystickButtons.B10)
            {
                return(JoystickButtons.B10);
            }

            if ((btns & JoystickButtons.POVUp) == JoystickButtons.POVUp)
            {
                return(JoystickButtons.POVUp);
            }

            if ((btns & JoystickButtons.POVDown) == JoystickButtons.POVDown)
            {
                return(JoystickButtons.POVDown);
            }

            if ((btns & JoystickButtons.POVLeft) == JoystickButtons.POVLeft)
            {
                return(JoystickButtons.POVLeft);
            }

            if ((btns & JoystickButtons.POVRight) == JoystickButtons.POVRight)
            {
                return(JoystickButtons.POVRight);
            }

            if ((btns & JoystickButtons.MoveZDown) == JoystickButtons.MoveZDown)
            {
                return(JoystickButtons.MoveZDown);
            }

            if ((btns & JoystickButtons.MoveZUp) == JoystickButtons.MoveZUp)
            {
                return(JoystickButtons.MoveZUp);
            }

            return(JoystickButtons.None);
        }
예제 #19
0
 public JoystickButton(KeyCode key)
 {
     this.key      = key;
     this.joystick = InputUtility.KeyToJoystick(key);
     this.button   = InputUtility.KeyToJoystickButton(key);
 }
예제 #20
0
        private JoystickButtons GetButtonFromJoyInfoEx(API.JoyInfoEx joyInfo)
        {
            JoystickButtons buttons = JoystickButtons.None;

            //pov
            if (joyInfo.dwPOV == API.JOY_POVFORWARD)
            {
                buttons |= JoystickButtons.POVUp;
            }
            else if (joyInfo.dwPOV == API.JOY_POVBACKWARD)
            {
                buttons |= JoystickButtons.POVDown;
            }
            else if (joyInfo.dwPOV == API.JOY_POVLEFT)
            {
                buttons |= JoystickButtons.POVLeft;
            }
            else if (joyInfo.dwPOV == API.JOY_POVRIGHT)
            {
                buttons |= JoystickButtons.POVRight;
            }
            else if (joyInfo.dwPOV == API.JOY_POVFORWARDLEFT)
            {
                buttons |= JoystickButtons.POVUp;
                buttons |= JoystickButtons.POVLeft;
            }
            else if (joyInfo.dwPOV == API.JOY_POVFORWARDRIGHT)
            {
                buttons |= JoystickButtons.POVUp;
                buttons |= JoystickButtons.POVRight;
            }
            else if (joyInfo.dwPOV == API.JOY_POVBACKWARDLEFT)
            {
                buttons |= JoystickButtons.POVDown;
                buttons |= JoystickButtons.POVLeft;
            }
            else if (joyInfo.dwPOV == API.JOY_POVBACKWARDRIGHT)
            {
                buttons |= JoystickButtons.POVDown;
                buttons |= JoystickButtons.POVRight;
            }

            //move
            if (joyInfo.dwYpos > API.JOY_MOVE_Y_ZERO)
            {
                buttons |= JoystickButtons.Down;
            }
            else if (joyInfo.dwYpos < API.JOY_MOVE_Y_ZERO)
            {
                buttons |= JoystickButtons.UP;
            }

            if (joyInfo.dwXpos > API.JOY_MOVE_X_ZERO)
            {
                buttons |= JoystickButtons.Right;
            }
            else if (joyInfo.dwXpos < API.JOY_MOVE_X_ZERO)
            {
                buttons |= JoystickButtons.Left;
            }

            if (joyInfo.dwZpos > API.JOY_MOVE_Z_ZERO)
            {
                buttons |= JoystickButtons.MoveZUp;
            }
            else if (joyInfo.dwZpos < API.JOY_MOVE_Z_ZERO)
            {
                buttons |= JoystickButtons.MoveZDown;
            }

            //normal button
            if ((joyInfo.dwButtons & API.JOY_BUTTON1) == API.JOY_BUTTON1)
            {
                buttons |= JoystickButtons.B1;
            }
            if ((joyInfo.dwButtons & API.JOY_BUTTON2) == API.JOY_BUTTON2)
            {
                buttons |= JoystickButtons.B2;
            }
            if ((joyInfo.dwButtons & API.JOY_BUTTON3) == API.JOY_BUTTON3)
            {
                buttons |= JoystickButtons.B3;
            }
            if ((joyInfo.dwButtons & API.JOY_BUTTON4) == API.JOY_BUTTON4)
            {
                buttons |= JoystickButtons.B4;
            }
            if ((joyInfo.dwButtons & API.JOY_BUTTON5) == API.JOY_BUTTON5)
            {
                buttons |= JoystickButtons.B5;
            }
            if ((joyInfo.dwButtons & API.JOY_BUTTON6) == API.JOY_BUTTON6)
            {
                buttons |= JoystickButtons.B6;
            }
            if ((joyInfo.dwButtons & API.JOY_BUTTON7) == API.JOY_BUTTON7)
            {
                buttons |= JoystickButtons.B7;
            }
            if ((joyInfo.dwButtons & API.JOY_BUTTON8) == API.JOY_BUTTON8)
            {
                buttons |= JoystickButtons.B8;
            }
            if ((joyInfo.dwButtons & API.JOY_BUTTON9) == API.JOY_BUTTON9)
            {
                buttons |= JoystickButtons.B9;
            }
            if ((joyInfo.dwButtons & API.JOY_BUTTON10) == API.JOY_BUTTON10)
            {
                buttons |= JoystickButtons.B10;
            }

            return(buttons);
        }
예제 #21
0
            //

            public Button(JoystickButtons name, int index)
            {
                this.name  = name;
                this.index = index;
            }
예제 #22
0
 public JoystickButton(KeyCode key)
 {
     this.key = key;
     this.joystick = InputUtility.KeyToJoystick(key);
     this.button = InputUtility.KeyToJoystickButton(key);
 }
예제 #23
0
 public static KeyCode JoystickInputToKey(Joysticks joystick, JoystickButtons button)
 {
     return GetJoystickKeys(joystick)[(int)button];
 }
예제 #24
0
        //

        public DefaultJoystickValueAttribute(JoystickButtons button)
        {
            value = new GameControlsManager.SystemJoystickValue(button);
        }
예제 #25
0
 // Is this button down?
 public bool GetButton( JoystickButtons button, int joystickIndex = 0 )
 {
     return _joystickButtons[joystickIndex,(int)button];
 }
예제 #26
0
        private byte?ModifyAnalog(JoystickButtons joystickButtons, State state, int index)
        {
            if (joystickButtons.XInputButton?.XInputIndex != index)
            {
                return(null);
            }
            switch (joystickButtons.AnalogType)
            {
            case AnalogType.None:
                break;

            case AnalogType.AnalogJoystick:
            {
                var analogPos = AnalogHelper.CalculateWheelPosXinput(joystickButtons.XInputButton, state, false, 0, _gameProfile);
                if (_gameProfile.EmulationProfile == EmulationProfile.Mballblitz)
                {
                    if (joystickButtons.InputMapping == InputMapping.Analog0)
                    {
                        JvsHelper.StateView.Write(8, analogPos);
                    }
                    if (joystickButtons.InputMapping == InputMapping.Analog2)
                    {
                        JvsHelper.StateView.Write(12, analogPos);
                    }
                }
                return(analogPos);
            }

            case AnalogType.AnalogJoystickReverse:
            {
                byte analogReversePos = 0;
                if (ReverseYAxis)
                {
                    analogReversePos = AnalogHelper.CalculateWheelPosXinput(joystickButtons.XInputButton, state, false, 0, _gameProfile);
                }
                else
                {
                    analogReversePos = (byte)~AnalogHelper.CalculateWheelPosXinput(joystickButtons.XInputButton, state, false, 0, _gameProfile);
                }
                return(analogReversePos);
            }

            case AnalogType.Gas:
            case AnalogType.Brake:
                return(AnalogHelper.CalculateAxisOrTriggerGasBrakeXinput(joystickButtons.XInputButton, state));

            case AnalogType.SWThrottle:
                byte SWThrottlePos = 0;
                if (ReverseSWThrottleAxis)
                {
                    SWThrottlePos = (byte)~AnalogHelper.CalculateSWThrottleXinput(joystickButtons.XInputButton, state);
                }
                else
                {
                    SWThrottlePos = AnalogHelper.CalculateSWThrottleXinput(joystickButtons.XInputButton, state);
                }
                return(SWThrottlePos);

            case AnalogType.Wheel:
            {
                var wheelPos = AnalogHelper.CalculateWheelPosXinput(joystickButtons.XInputButton, state, _useSto0Z, _stoozPercent, _gameProfile);
                if (_gameProfile.EmulationProfile == EmulationProfile.TaitoTypeXBattleGear || _gameProfile.EmulationProfile == EmulationProfile.VirtuaRLimit)
                {
                    JvsHelper.StateView.Write(4, wheelPos);
                }

                return(wheelPos);
            }
            }
            return(null);
        }
예제 #27
0
 public JoystickButton(Joysticks joystick, JoystickButtons button)
 {
     this.joystick = joystick;
     this.button = button;
     this.key = InputUtility.JoystickInputToKey(joystick, button);
 }
예제 #28
0
        public void MatchKeyItem(JoystickButtons joyBtns, byte[] keyState, ref List<KeyChangeItem> changeKeys)
        {
            foreach (KeyChangeItem keyItem in KeyChangeItemCollection)
            {
                if (keyItem.IsDown)
                {
                    if (!keyItem.IsMatchFrom(joyBtns, keyState))
                    {
                        changeKeys.Add(keyItem);
                    }
                }
                else
                {
                    if (keyItem.IsMatchFrom(joyBtns, keyState))
                    {
                        changeKeys.Add(keyItem);
                    }
                }
            }

            if (changeKeys.Count == 0)
                return;

            _tRemoveKey.Clear();
            for (int i = 0; i < changeKeys.Count; ++i)
            {
                if (_tRemoveKey.Contains(changeKeys[i]))
                        continue;

                for (int j = i + 1; j < changeKeys.Count; ++j)
                {
                    int compare = CompareKeyPrior(changeKeys[i], changeKeys[j]);
                    if (compare > 0)
                    {
                        _tRemoveKey.Add(changeKeys[j]);
                    }
                    else if (compare < 0)
                    {
                        _tRemoveKey.Add(changeKeys[i]);
                    }
                }
            }

            foreach (KeyChangeItem removeItem in _tRemoveKey)
            {
                changeKeys.Remove(removeItem);
            }
        }
예제 #29
0
            //

            public SystemJoystickValue(JoystickButtons button)
            {
                type        = Types.Button;
                this.button = button;
            }
예제 #30
0
 public JoystickButton(string name, Joysticks joystick, JoystickButtons button)
     : base(name, InputSystem.JoystickInputToKey(joystick, button))
 {
     _joystick = joystick;
     _button = button;
 }
예제 #31
0
 public void SetStoreValue(Keys key)
 {
     _Joystick = JoystickButtons.None;
     _Keyboard = key;
     RefreshBtnName();
 }
예제 #32
0
 public JoystickButton(string name, KeyCode key)
     : base(name, key)
 {
     _joystick = InputSystem.KeyToJoystick(key);
     _button = InputSystem.KeyToJoystickButton(key);
 }
        //

        public DefaultJoystickValueAttribute(JoystickButtons button, float strength)
        {
            value = new GameControlsManager.SystemJoystickValue(button, strength);
        }
예제 #34
0
파일: Input.cs 프로젝트: itsarabbit/Jacot
 public static bool IsDown(uint index, JoystickButtons button)
 {
     return isJoyButtonDown[(int)button][index];
 }
 public SystemJoystickValue(JoystickButtons button, float strength)
 {
     type = Types.Button;
     this.button = button;
     this.strength = strength;
 }
예제 #36
0
파일: Input.cs 프로젝트: itsarabbit/Jacot
 public static bool IsPressed(uint index, JoystickButtons button)
 {
     int code = (int)button;
     return isJoyButtonPressed[(int)button][index];
 }
예제 #37
0
        /// <summary>
        /// 处理系统消息.
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            //没有关注的,直接返回
            if (IsClickEventEmpty())
                return IntPtr.Zero;

            bool flag = false;
            if (hwnd != IntPtr.Zero && (wParam != IntPtr.Zero || lParam != IntPtr.Zero))
            {
                if (msg != API.MM_JOY1MOVE && msg != API.MM_JOY2MOVE)
                    return IntPtr.Zero;

                Action<JoystickEventArgs> action = null;
                JoystickButtons buttons = JoystickButtons.None;
                int joystickId = -1;
                API.JoyInfoEx joyInfo1 = new API.JoyInfoEx();
                joyInfo1.dwSize = (uint)Marshal.SizeOf(typeof(API.JoyInfoEx));
                joyInfo1.dwFlags = (int)API.JOY_RETURNALL;

                if (API.joyGetPosEx(API.JOYSTICKID1, ref joyInfo1) == API.JOYERR_NOERROR)
                {
                    buttons = GetButtonFromJoyInfoEx(joyInfo1);
                    action = this.OnClick;
                }
                joystickId = msg == API.MM_JOY1MOVE ? API.JOYSTICKID1 : API.JOYSTICKID2;

                //switch (msg)
                //{
                //    case API.MM_JOY1MOVE:
                //    case API.MM_JOY2MOVE:
                //        //单击事件
                //        //buttons = GetButtonsStateFromMessageParam(wParam.ToInt64(), lParam.ToInt64());
                //        if (API.joyGetPosEx(API.JOYSTICKID1, ref joyInfo1) == API.JOYERR_NOERROR)
                //        {
                //            buttons = GetButtonFromJoyInfoEx(joyInfo1);
                //            action = this.OnClick;
                //        }
                //        joystickId = msg == API.MM_JOY1MOVE ? API.JOYSTICKID1 : API.JOYSTICKID2;
                //        break;
                //    case API.MM_JOY1BUTTONDOWN:
                //    case API.MM_JOY2BUTTONDOWN:
                //        //按钮被按下
                //        //buttons = GetButtonsPressedStateFromMessageParam(wParam.ToInt32(), lParam.ToInt32());
                //        if (API.joyGetPosEx(API.JOYSTICKID1, ref joyInfo1) == API.JOYERR_NOERROR)
                //        {
                //            buttons = GetButtonFromJoyInfoEx(joyInfo1);
                //            action = this.OnButtonDown;
                //        }
                //        joystickId = msg == API.MM_JOY1BUTTONDOWN ? API.JOYSTICKID1 : API.JOYSTICKID2;
                //        break;
                //    case API.MM_JOY1BUTTONUP:
                //    case API.MM_JOY2BUTTONUP:
                //        //按钮被弹起
                //        //buttons = GetButtonsPressedStateFromMessageParam(wParam.ToInt32(), lParam.ToInt32());
                //        if (API.joyGetPosEx(API.JOYSTICKID1, ref joyInfo1) == API.JOYERR_NOERROR)
                //        {
                //            buttons = GetButtonFromJoyInfoEx(joyInfo1);
                //            action = this.OnButtonUp;
                //        }
                //        joystickId = msg == API.MM_JOY1BUTTONUP ? API.JOYSTICKID1 : API.JOYSTICKID2;
                //        break;

                //    case API.MM_JOY1ZMOVE:
                //    case API.MM_JOY2ZMOVE:
                //        break;
                //}
                if (action != null && joystickId != -1 && buttons != JoystickButtons.None)
                {
                    //阻止消息继续传递
                    flag = true;
                    //触发事件
                    action(new JoystickEventArgs(joystickId, buttons));
                }

                if (joystickId != -1 && _LastButtonsInfo != buttons)
                {
                    //无论是否有按键按下,发送move消息
                    this.OnMove(new JoystickEventArgs(joystickId, buttons));
                    _LastButtonsInfo = buttons;

                }
                
            }
            handled = flag;
            return IntPtr.Zero;
        }
예제 #38
0
파일: Input.cs 프로젝트: itsarabbit/Jacot
 public static bool IsReleased(uint index, JoystickButtons button)
 {
     return isJoyButtonReleased[(int)button][index];
 }
예제 #39
0
 public void GetJoyStickThread()
 {
     while (true)
     {
         API.JoyInfoEx joyInfo1 = new API.JoyInfoEx();
         joyInfo1.dwSize = (uint)Marshal.SizeOf(typeof(API.JoyInfoEx));
         joyInfo1.dwFlags = (int)API.JOY_RETURNALL;
         if (API.joyGetPosEx(API.JOYSTICKID1, ref joyInfo1) == API.JOYERR_NOERROR)
         {
             _ButtonInfos = GetButtonFromJoyInfoEx(joyInfo1);
             if (_ButtonInfos != JoystickButtons.None)
                 return;
             //OnClick(new JoystickEventArgs(API.JOYSTICKID1, _ButtonInfos));
         }
         Thread.Sleep(10);
     }
 }
예제 #40
0
        ///<summary>
        /// ____MADE IN THE +
        /// USA + France +
        /// ___ InCin filtering by combo boxes and listboxes --- all me
        ///void CreateAdd_Custom_Control_Dialogue()
        ///populate all drop downs and comboboxes
        ///filter by device or device Type
        ///hide unneeded info or unhide pages
        /// </summary>
        private void CreateAdd_Custom_Control_Dialogue()
        {
            //load custom binding window
            Control Add_Custom_Control = ControlDeclarationManager.Instance.CreateControl(@"GUI\Add_Custom_Control.gui");
            Add_Custom_Control.TopMost = true;
            Add_Custom_Control.MouseCover = true;

            //Add
            Controls.Add(Add_Custom_Control);

            #region AddCustomControl.Gui

            #region MainControls

            ComboBox cmbDeviceType;
            cmbDeviceType = (ComboBox)Add_Custom_Control.Controls["cmbDeviceType"];
            //cmbDeviceType.Items.Add("Nothing_Selected"); //using enum Nothing_Selected
            foreach (var value in Enum.GetValues(typeof(Devices)))
            {
                //if(!(value.ToString().Contains(Devices.GetServices.ToString())) && !(value.ToString().Contains(Devices.All_Devices.ToString()))) //exclude for internal use

                cmbDeviceType.Items.Add(value);
            }
            cmbDeviceType.SelectedIndex = 0;
            ComboBox cmbDevice;
            cmbDevice = (ComboBox)Add_Custom_Control.Controls["cmbDevice"];
            cmbDevice.Items.Add("Nothing_Selected");
            cmbDevice.Items.Add("Keyboard"); //unhandled object as multiple devices
            cmbDevice.Items.Add("Mouse");   //unhandled object as a multiple devices
            if (InputDeviceManager.Instance != null)
            {
                foreach (InputDevice devicename in InputDeviceManager.Instance.Devices)
                    cmbDevice.Items.Add(devicename); //handled objects
                //filter
            }
            cmbDevice.SelectedIndex = 0;

            Control cntrlCommands = (Control)Add_Custom_Control.Controls["cntrlCommands"];
            cntrlCommands.Visible = false;
            //Commands Available
            ListBox lstCommand;
            lstCommand = (ListBox)Add_Custom_Control.Controls["cntrlCommands"].Controls["lstCommand"];
            lstCommand.Items.Add("Nothing_Selected");
            lstCommand.SelectedIndex = 0;
            foreach (var value in Enum.GetValues(typeof(GameControlKeys)))
            {
                lstCommand.Items.Add(value);
            }

            //control Tab Controls
            //TabControl MainOptionsTabControl;
            MainOptionsTabControl = (TabControl)Add_Custom_Control.Controls["MainOptionsTabControl"];
            MainOptionsTabControl.SelectedIndexChange += MainOptionsTabControl_SelectedIndexChange;
            MainOptionsTabControl.Visible = true;

            MainOptionsTabControl.Visible = false; //hide all subcontrols for now

            pageControlsButtons[0] = (Button)Add_Custom_Control.Controls["MainOptionsTabControl"].Controls["btnMouseOptions"];
            pageControlsButtons[1] = (Button)Add_Custom_Control.Controls["MainOptionsTabControl"].Controls["btnKeyboardOptions"];
            pageControlsButtons[2] = (Button)Add_Custom_Control.Controls["MainOptionsTabControl"].Controls["btnJoystickOptions"];
            foreach (Button pageButton in pageControlsButtons)
            {
                pageButton.Click += new Button.ClickDelegate(pageControlsButton_Click);
            }

            pageControlsButtons[0].PerformClick();

            TextBox lblMessage = (TextBox)Add_Custom_Control.Controls["lblMessage"]; // holds message of selected items
            lblMessage.Text = "Nothing_Selected";

            ScrollBar scrlSelectedStrength;
            scrlSelectedStrength = (ScrollBar)MainOptionsTabControl.Controls["scrlSelectedStrength"];

            //incin -- not updating the strength atm, gotta figure this out..
            scrlSelectedStrength.ValueChange += delegate(ScrollBar sender)
            {
                while (sender.Value != Strength_selected)
                {
                    Strength_selected = sender.Value;
                }
                if (message != null)
                {
                    if (message.Contains(" Strength: "))
                    {
                        message = message.Replace(" Strength: " + old_strength.ToString("F2"), " Strength: " + Strength_selected.ToString("F2"));
                        lblMessage.Text = message;
                    }
                }
                old_strength = Strength_selected;
            };

            #endregion MainControls

            #region pageMouseoptions

            Control pageMouseOptions;
            pageMouseOptions = (Control)Add_Custom_Control.Controls["MainOptionsTabControl"].Controls["pageMouseOptions"];
            //Page visible= false || true;

            #region MouseTabControls

            //MainOptionsTabControl.MouseTabControl.pageMouseButtonOptions
            TabControl MouseTabControl = (TabControl)pageMouseOptions.Controls["MouseTabControl"];

            ComboBox cmbMouseButtonChoices;
            cmbMouseButtonChoices = (ComboBox)MouseTabControl.Controls["pageMouseButtonOptions"].Controls["cmbMouseButtonChoices"];
            cmbMouseButtonChoices.Items.Add("Nothing_Selected");
            foreach (var value in Enum.GetValues(typeof(EMouseButtons)))
            {
                cmbMouseButtonChoices.Items.Add(value);
            }

            cmbMouseButtonChoices.SelectedIndex = 0;

            //MainOptionsTabControl.MouseTabControl.pageMouseScrollOptions.cmbMouseScrollChoices
            ComboBox cmbMouseScrollChoices;
            cmbMouseScrollChoices = (ComboBox)MouseTabControl.Controls["pageMouseScrollOptions"].Controls["cmbMouseScrollChoices"];
            cmbMouseScrollChoices.Items.Add("Nothing_Selected");
            foreach (var value in Enum.GetValues(typeof(MouseScroll)))
            {
                cmbMouseScrollChoices.Items.Add(value);
            }
            cmbMouseScrollChoices.SelectedIndex = 0;

            #endregion MouseTabControls

            #endregion pageMouseoptions

            #region pageKeyboardOptions

            Control pageKeyboardOptions = (Control)Add_Custom_Control.Controls["MainOptionsTabControl"].Controls["pageKeyboardOptions"];
            //visible false true?

            ListBox lstKeyboardButtonChoices;
            lstKeyboardButtonChoices = (ListBox)pageKeyboardOptions.Controls["lstKeyboardButtonChoices"];
            lstKeyboardButtonChoices.Items.Add("Nothing_Selected");
            foreach (var value in Enum.GetValues(typeof(EKeys)))
            {
                lstKeyboardButtonChoices.Items.Add(value);
            }
            lstKeyboardButtonChoices.SelectedIndex = 0;
            //if (lstKeyboardButtonChoices.ItemButtons["lstKeyboardButtonChoices"]Text.Contains("Nothing_Selected") != null)
            //    lstKeyboardButtonChoices.SelectedIndex = -1;

            #endregion pageKeyboardOptions

            //MainOptionsTabControl.pageJoystickOptions
            //tabJoystickControlOptions

            #region pageJoystickOptions

            Control pageJoystickOptions;
            pageJoystickOptions = (Control)Add_Custom_Control.Controls["MainOptionsTabControl"].Controls["pageJoystickOptions"];//.Controls["tabJoystickControlOptions"];

            tabJoystickControlOptions = (TabControl)pageJoystickOptions.Controls["tabJoystickControlOptions"];
            tabJoystickControlOptions.SelectedIndexChange += tabJoystickControlOptions_SelectedIndexChange;

            pagejoystickButtons[0] = (Button)tabJoystickControlOptions.Controls["btnSliderOptions"];
            pagejoystickButtons[1] = (Button)tabJoystickControlOptions.Controls["btnAxisOptions"];
            pagejoystickButtons[2] = (Button)tabJoystickControlOptions.Controls["btnButtonOptions"];

            foreach (Button pageButton in pagejoystickButtons)
            {
                pageButton.Click += new Button.ClickDelegate(joystickPageTabButtons_Click);
            }

            #region pageSliderOptions

            Control pageSliderOptions = tabJoystickControlOptions.Controls["pageSliderOptions"];

            #region cmbSliderChoices

            ComboBox cmbSliderChoices;

            cmbSliderChoices = (ComboBox)pageSliderOptions.Controls["cmbSliderChoices"];
            cmbSliderChoices.Items.Add("Nothing_Selected");
            foreach (var value in Enum.GetValues(typeof(JoystickSliders)))
            {
                cmbSliderChoices.Items.Add(value);
            }
            cmbSliderChoices.SelectedIndex = 0;

            ComboBox cmbSliderAxisChoices;
            cmbSliderAxisChoices = (ComboBox)pageSliderOptions.Controls["cmbSliderAxisChoices"];
            cmbSliderAxisChoices.Items.Add("Nothing_Selected");
            foreach (var value in Enum.GetValues(typeof(JoystickSliderAxes)))
            {
                cmbSliderAxisChoices.Items.Add(value);
            }
            cmbSliderAxisChoices.SelectedIndex = 0;

            ComboBox cmbSliderAxisFilterChoices;
            cmbSliderAxisFilterChoices = (ComboBox)pageSliderOptions.Controls["cmbSliderAxisFilterChoices"];
            cmbSliderAxisFilterChoices.Items.Add("Nothing_Selected");
            foreach (var value in Enum.GetValues(typeof(JoystickAxisFilters)))
            {
                cmbSliderAxisFilterChoices.Items.Add(value);
            }
            cmbSliderAxisFilterChoices.SelectedIndex = 0;

            #endregion cmbSliderChoices

            #endregion pageSliderOptions

            #region pageAxisOptions

            Control pageAxisOptions = tabJoystickControlOptions.Controls["pageAxisOptions"];
            ComboBox cmbAxisChoices;
            cmbAxisChoices = (ComboBox)pageAxisOptions.Controls["cmbAxisChoices"];
            cmbAxisChoices.Items.Add("Nothing_Selected");
            foreach (var value in Enum.GetValues(typeof(JoystickSliderAxes)))
            {
                cmbAxisChoices.Items.Add(value);
            }
            cmbAxisChoices.SelectedIndex = 0;

            ComboBox cmbAxisFilterChoices;
            cmbAxisFilterChoices = (ComboBox)pageAxisOptions.Controls["cmbAxisFilterChoices"];
            cmbAxisFilterChoices.Items.Add("Nothing_Selected");
            foreach (var value in Enum.GetValues(typeof(JoystickAxisFilters)))
            {
                cmbAxisFilterChoices.Items.Add(value);
            }
            cmbAxisFilterChoices.SelectedIndex = 0;

            Control pageJoystickButtonOptions = tabJoystickControlOptions.Controls["pageJoystickButtonOptions"];
            ListBox lstJoyButtonChoices = (ListBox)pageJoystickButtonOptions.Controls["lstJoyButtonChoices"];
            lstJoyButtonChoices.Items.Add("Nothing_Selected");
            foreach (var value in Enum.GetValues(typeof(JoystickButtons)))
            {
                lstJoyButtonChoices.Items.Add(value);
            }
            lstJoyButtonChoices.SelectedIndex = 0;

            #endregion pageAxisOptions

            #endregion pageJoystickOptions

            //___ InCin filtering by combo boxes and listboxes --- all me
            // setting all indexes at 0 -- tracks "Nothing_Selected"

            #region IndexChanged

            //if(page visible == enabled){
            cmbMouseButtonChoices.SelectedIndexChange += delegate(ComboBox sender)
            {
                message = null;
                if (cmbDeviceType.SelectedIndex == 0 || lstCommand.SelectedIndex == 0) //Nothing_Selected
                    return;

                if (sender.SelectedIndex == 0)
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " MouseButton: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                else
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " MouseButton: " + sender.SelectedItem.ToString();
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                lblMessage.Text = message;
            };

            cmbMouseScrollChoices.SelectedIndexChange += delegate(ComboBox sender)
            {
                message = null;
                if (cmbDeviceType.SelectedIndex == 0 || lstCommand.SelectedIndex == 0)// Nothing_Selected
                    return;

                if (sender.SelectedIndex == 0)
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " MouseScroll: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                    lstKeyboardButtonChoices.Visible = false;
                }
                else
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " MouseScroll: " + sender.SelectedItem.ToString();
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                    lstKeyboardButtonChoices.Visible = true;
                }
                lblMessage.Text = message;
            };

            lstKeyboardButtonChoices.SelectedIndexChange += delegate(ListBox sender)
            {
                message = null;
                //MainOptionsTabControl.Visible = false;
                if (cmbDeviceType.SelectedIndex == 0 || lstCommand.SelectedIndex == 0)
                    return;

                if (sender.SelectedIndex == 0) // Nothing_Selected
                {
                    //Nothing_Selected
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " KeyboardButton: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                else
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " KeyboardButton: " + sender.SelectedItem.ToString();
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                lblMessage.Text = message;
            };

            //}
            //if(page visible == enabled)
            cmbSliderChoices.SelectedIndexChange += delegate(ComboBox sender)
            {
                message = null;
                //MainOptionsTabControl.Visible = false;
                if (cmbDeviceType.SelectedIndex == 0 || lstCommand.SelectedIndex == 0)  // Nothing_Selected
                {
                    return;
                }

                if (sender.SelectedIndex == 0)
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Slider: Nothing_Selected";
                    message += " Axis: Nothing_Selected";
                    message += " AxisFilter: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                    //cmbSliderChoices.Visible = false;
                }
                else //if( sender.SelectedIndex != 0)
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Slider: " + sender.SelectedItem.ToString(); //sender
                    message += " Axis: Nothing_Selected";
                    message += " AxisFilter: Nothing_Selected";
                    //event update
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2"); //recursive scroll change
                    //cmbSliderAxisChoices.Visible = true;
                }
                lblMessage.Text = message;
            };

            cmbSliderAxisChoices.SelectedIndexChange += delegate(ComboBox sender)
            {
                message = null;
                if (cmbDeviceType.SelectedIndex == 0 || lstCommand.SelectedIndex == 0 || cmbSliderChoices.SelectedIndex == 0) // Nothing_Selected
                    return;

                if (sender.SelectedIndex == 0)
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Slider: " + cmbSliderChoices.SelectedItem.ToString();
                    message += " Axis: Nothing_Selected";
                    message += " AxisFilter: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                    cmbSliderAxisFilterChoices.Visible = false;
                }
                else
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Slider: " + cmbSliderChoices.SelectedItem.ToString();
                    message += " Axis: " + sender.SelectedItem.ToString();
                    message += " AxisFilter: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                    cmbSliderAxisFilterChoices.Visible = true;
                }
                lblMessage.Text = message;
            };

            cmbSliderAxisFilterChoices.SelectedIndexChange += delegate(ComboBox sender)
            {
                message = null;
                if (cmbDeviceType.SelectedIndex == 0 || lstCommand.SelectedIndex == 0 || cmbSliderChoices.SelectedIndex == 0 || cmbSliderAxisChoices.SelectedIndex == 0)// Nothing_Selected
                    return;

                if (sender.SelectedIndex == 0)
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Slider: " + cmbSliderChoices.SelectedItem.ToString();
                    message += " Axis: " + cmbSliderAxisChoices.SelectedItem.ToString();
                    message += " AxisFilter: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                else
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Slider: " + cmbSliderChoices.SelectedItem;
                    message += " Axis: " + cmbSliderChoices.SelectedItem.ToString();
                    message += " AxisFilter: " + sender.SelectedItem.ToString();
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                lblMessage.Text = message;
            };
            //}
            //if(page visible == enabled){
            cmbAxisChoices.SelectedIndexChange += delegate(ComboBox sender)
            {
                message = null;
                if (cmbDeviceType.SelectedIndex == 0 || lstCommand.SelectedIndex == 0)// Nothing_Selected
                {
                    cntrlCommands.Visible = false;
                    //MainOptionsTabControl.Visible = false;
                    return;
                }

                if (cmbAxisChoices.SelectedIndex == 0)
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Axis: Nothing_Selected";
                    message += " AxisFilter: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                else
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Axis: " + sender.SelectedItem.ToString();
                    message += " AxisFilter: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                lblMessage.Text = message;
            };

            cmbAxisFilterChoices.SelectedIndexChange += delegate(ComboBox sender)
            {
                message = null;
                if (cmbDeviceType.SelectedIndex == 0 || lstCommand.SelectedIndex == 0 || cmbAxisChoices.SelectedIndex == 0)
                {
                    //MainOptionsTabControl.Visible = false;
                    return;
                }
                if (cmbAxisFilterChoices.SelectedIndex == 0)
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Axis: " + cmbAxisChoices.SelectedItem.ToString();
                    message += " AxisFilter: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                else
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Axis: " + cmbAxisChoices.SelectedItem.ToString();
                    message += " AxisFilter: " + sender.SelectedItem.ToString();
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                lblMessage.Text = message;
            };

            lstJoyButtonChoices.SelectedIndexChange += delegate(ListBox sender)
            {
                message = null;
                if (cmbDeviceType.SelectedIndex == 0 || lstCommand.SelectedIndex == 0)
                {
                    //MainOptionsTabControl.Visible = false;

                    return;
                }
                if (lstJoyButtonChoices.SelectedIndex == 0)
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " JoystickButton: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                else
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " JoystickButton: " + sender.SelectedItem.ToString();
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                }
                lblMessage.Text = message;
            };
            //}

            lstCommand.SelectedIndexChange += delegate(ListBox sender)
            {
                message = null;
                if (cmbDeviceType.SelectedIndex == 0)
                    return;

                if (sender.SelectedIndex == 0)
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + "Nothing_Selected";
                    message += " Bind: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                    MainOptionsTabControl.Visible = false;
                }
                else
                {
                    //message = "Device: " + cmbDevice.SelectedItem.ToString();
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: " + lstCommand.SelectedItem.ToString();
                    message += " Bind: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                    MainOptionsTabControl.Visible = true;
                }
                lblMessage.Text = message;
            };

            #region comboDeviceType

            // Filters down through each TabControl hides what isn't needed
            // MainOptionsTabControl
            // MouseTabControl
            //  Primary choices

            cmbDeviceType.SelectedIndexChange += delegate(ComboBox sender)
            {
                message = null;
                if (sender.SelectedIndex == -1)
                {
                    cntrlCommands.Visible = false;
                    MainOptionsTabControl.Visible = false;
                    return;
                }
                if (sender.SelectedIndex != 0)
                {
                    Devices devicetype = devicetype_selected = (Devices)sender.SelectedItem;
                    cntrlCommands.Visible = true;
                    MainOptionsTabControl.Visible = false;
                    switch (devicetype)
                    {
                        case Devices.Mouse:
                            {
                                pageControlsButton_Click(pageControlsButtons[0]);
                                pageControlsButtons[0].Enable = true;
                                pageControlsButtons[1].Enable = false;
                                pageControlsButtons[2].Enable = false;
                                break;
                            }
                        case Devices.Keyboard:
                            {
                                pageControlsButton_Click(pageControlsButtons[1]);
                                pageControlsButtons[0].Enable = false;
                                pageControlsButtons[1].Enable = true;
                                pageControlsButtons[2].Enable = false;
                                break;
                            }

                        case Devices.Joystick:
                            {
                                pageControlsButton_Click(pageControlsButtons[2]);
                                pageControlsButtons[0].Enable = false;
                                pageControlsButtons[1].Enable = false;
                                pageControlsButtons[2].Enable = true;
                                break;
                            }

                        case Devices.Joystick_Xbox360:
                            {
                                pageControlsButton_Click(pageControlsButtons[2]);
                                pageControlsButtons[0].Enable = false;
                                pageControlsButtons[1].Enable = true;
                                pageControlsButtons[2].Enable = true;
                                break;
                            }
                        case Devices.Joystick_Playstation:
                            {
                                pageControlsButton_Click(pageControlsButtons[2]);
                                pageControlsButtons[0].Enable = false;
                                pageControlsButtons[1].Enable = true;
                                pageControlsButtons[2].Enable = true;
                                break;
                            }
                        case Devices.Joystick_WII:
                            {
                                pageControlsButton_Click(pageControlsButtons[2]);
                                pageControlsButtons[0].Enable = false;
                                pageControlsButtons[1].Enable = true;
                                pageControlsButtons[2].Enable = true;
                                break;
                            }
                        //case Devices.Custom_Audio:
                        //    {
                        //        pageControlsButton_Click(pageControlsButtons[2]);
                        //        pageControlsButtons[0].Enable = true;
                        //        pageControlsButtons[1].Enable = true;
                        //        pageControlsButtons[2].Enable = true;
                        //        break;
                        //    }
                        case Devices.Custom:
                            {
                                pageControlsButton_Click(pageControlsButtons[0]);
                                pageControlsButtons[0].Enable = true;
                                pageControlsButtons[1].Enable = true;
                                pageControlsButtons[2].Enable = true;
                                break;
                            }
                        default:
                            {
                                pageControlsButton_Click(pageControlsButtons[0]);
                                pageControlsButtons[0].Enable = true;
                                pageControlsButtons[1].Enable = true;
                                pageControlsButtons[2].Enable = true;
                                break;
                            }
                    }
                    message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                    message += " Command: Nothing_Selected";
                    message += " Bind: Nothing_Selected";
                    message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");

                    if (lstCommand.SelectedIndex != 0)
                    {
                        message = "DeviceType: " + cmbDeviceType.SelectedItem.ToString();
                        message += " Command: " + lstCommand.SelectedItem.ToString();
                        message += " Bind: Nothing_Selected";
                        message += " Strength: " + scrlSelectedStrength.Value.ToString("F2");
                    }
                }
                else
                {
                    message = " Nothing_Selected";
                    cntrlCommands.Visible = false;
                    MainOptionsTabControl.Visible = false;
                    pageControlsButtons[0].Enable = true;
                    pageControlsButtons[1].Enable = true;
                    pageControlsButtons[2].Enable = true;
                }
                lblMessage.Text = message;
            };

            #endregion comboDeviceType

            #region comboDevice

            // server  selected.music == "<station>"
            //cmbDevice.SelectedIndexChange += delegate(ComboBox sender)
            //{
            //    //if (sender.SelectedIndex != -1)
            //    //{
            //    //    InputDevice inputdevices = (InputDevice)sender.SelectedItem;
            //    //    //Set deviceType
            //    //    // continue
            //    //}
            //    //lblMessage.Text = message;
            //    ;
            //    //hidden for now
            //};

            #endregion comboDevice

            #endregion IndexChanged

            #region ButtonOK

            ((Button)Add_Custom_Control.Controls["buttonOK"]).Click += delegate(Button sender)
            {
                if (cmbDeviceType.SelectedIndex == 0)
                {
                    CreateMessageBox("No Device selected, select a device first!");
                    return;
                }
                else //(cmbDeviceType.SelectedIndex != 0)
                    devicetype_selected = (Devices)cmbDeviceType.SelectedItem;

                if (lstCommand.SelectedIndex == 0)
                {
                    CreateMessageBox("No Command binding selected, select a Command first!");
                    return;
                }
                else // if (lstCommand.SelectedIndex != 0)
                    command_selected = (GameControlKeys)lstCommand.SelectedItem;

                float currentstrength = float.Parse(Strength_selected.ToString("F2"));
                //if (pageControlsButtons[0].Enable == true || pageControlsButtons[1].Enable == true || pageControlsButtons[2].Enable == true)

                switch (devicetype_selected) //devicetype
                {
                    case Devices.Nothing_Selected:
                        {
                            CreateMessageBox("No Device selected, select a device first!");
                            return;
                        }
                    //break;
                    case Devices.Keyboard:
                        {
                            // group Keyboard
                            if (lstKeyboardButtonChoices.SelectedIndex != 0)
                            {
                                GameControlsManager.SystemKeyboardMouseValue key;
                                lstKeyboardButtonChoices_selected = (EKeys)lstKeyboardButtonChoices.SelectedItem;
                                Strength_selected = currentstrength;

                                if (!GameControlsManager.Instance.IsAlreadyBinded((EKeys)lstKeyboardButtonChoices_selected/*, currentstrength*/, out key) && key == null)
                                {
                                    //GameControlsManager.Instance.GetItemByControlKey(command_selected).BindedKeyboardMouseValues.Add(new GameControlsManager.SystemKeyboardMouseValue(lstKeyboardButtonChoices_selected)); //devicetype_selected));
                                    var controlItem = GameControlsManager.Instance.GetItemByControlKey(command_selected);
                                    var newSystemValue = new GameControlsManager.SystemKeyboardMouseValue(lstKeyboardButtonChoices_selected);
                                    newSystemValue.Parent = controlItem;
                                    newSystemValue.Strength = Strength_selected;
                                    controlItem.BindedKeyboardMouseValues.Add(newSystemValue);
                                    //Game.OptionsWindow.UpdateBindedInputControlsListBox();
                                }
                                else
                                {
                                    message = "Key" + cmbMouseButtonChoices_selected + ": Command: " + command_selected + " Strength: 1 is already bound";
                                    lblMessage.Text = message;
                                    CreateMessageBox(message);
                                    message = "";
                                    cmbMouseButtonChoices_selected = 0;
                                    lstCommand.SelectedIndex = 0;
                                    return;
                                }
                            }
                            else
                            {
                                lstKeyboardButtonChoices.SelectedIndex = 0;
                                lstKeyboardButtonChoices_selected = (EKeys)0;
                            }

                            break;
                        }
                    case Devices.Mouse:
                        {
                            // group Mouse

                            if (cmbMouseButtonChoices.SelectedIndex != 0)
                            {
                                ////check for existing matching binds before saving
                                GameControlsManager.SystemKeyboardMouseValue key;
                                cmbMouseButtonChoices_selected = (EMouseButtons)cmbMouseButtonChoices.SelectedItem;

                                if (GameControlsManager.Instance.IsAlreadyBinded((EMouseButtons)cmbMouseButtonChoices_selected, out key)) //currentstrength,
                                {
                                    message = "Mouse Button" + cmbMouseButtonChoices_selected + ": Command: " + command_selected + " is already bound"; //" Strength: " + currentstrength +
                                    //new MessageBoxWindow( text, "Key already bound. Clearing , try again", null );
                                    CreateMessageBox(message);
                                    cmbMouseButtonChoices_selected = 0;
                                    cmbMouseButtonChoices.SelectedIndex = 0;
                                    lstCommand.SelectedIndex = 0;
                                    message = "";
                                    return;
                                }

                                var cmbMouseButtonChoicesControlItem = GameControlsManager.Instance.GetItemByControlKey(command_selected);
                                var cmbMouseButtonChoicesSystemValue = new GameControlsManager.SystemKeyboardMouseValue(cmbMouseButtonChoices_selected, currentstrength);
                                cmbMouseButtonChoicesSystemValue.Parent = cmbMouseButtonChoicesControlItem;
                                cmbMouseButtonChoicesControlItem.BindedKeyboardMouseValues.Add(cmbMouseButtonChoicesSystemValue);
                                //UpdateBindedInputControlsListBox();
                            }
                            else if (cmbMouseScrollChoices.SelectedIndex != 0)
                            {
                                GameControlsManager.SystemKeyboardMouseValue key;
                                cmbMouseScrollChoices_selected = (MouseScroll)cmbMouseScrollChoices.SelectedItem;

                                if (GameControlsManager.Instance.IsAlreadyBinded((MouseScroll)cmbMouseScrollChoices_selected, currentstrength, out key))
                                {
                                    message = "Mouse Button" + cmbMouseScrollChoices_selected + ": Command: " + command_selected + " is already bound"; //+ " Strength: " + currentstrength
                                    //new MessageBoxWindow( text, "Key already bound. Clearing , try again", null );
                                    CreateMessageBox(message);
                                    message = "";
                                    return;
                                }

                                var cmbMouseScrollChoicescontrolItem = GameControlsManager.Instance.GetItemByControlKey(command_selected);
                                var cmbMouseScrollChoicesSystemValue = new GameControlsManager.SystemKeyboardMouseValue(cmbMouseScrollChoices_selected, currentstrength);
                                cmbMouseScrollChoicesSystemValue.Parent = cmbMouseScrollChoicescontrolItem;
                                //cmbMouseScrollChoicesSystemValue.Strength = Strength_selected;
                                cmbMouseScrollChoicescontrolItem.BindedKeyboardMouseValues.Add(cmbMouseScrollChoicesSystemValue);
                                //UpdateBindedInputControlsListBox();
                            }
                            else
                            {
                                cmbMouseButtonChoices.SelectedIndex = 0;
                                cmbMouseButtonChoices_selected = (EMouseButtons)0;
                                cmbMouseScrollChoices.SelectedIndex = 0;
                                cmbMouseScrollChoices_selected = (MouseScroll)0;
                            }
                            break;
                        }

                    case Devices.Joystick:
                    case Devices.Joystick_Playstation:
                    case Devices.Joystick_WII:
                    case Devices.Joystick_Xbox360:
                        {
                            //Filter by tab
                            //group joystick //slider options

                            if (cmbSliderChoices.SelectedIndex != 0 && cmbSliderAxisChoices.SelectedIndex != 0 && cmbSliderAxisFilterChoices.SelectedIndex != 0)
                            {
                                //if (cmbSliderChoices.SelectedIndex != 0)
                                cmbSliderChoices_selected = (JoystickSliders)cmbSliderChoices.SelectedItem;
                                //if (cmbSliderAxisChoices.SelectedIndex != 0)
                                cmbSliderAxisChoices_selected = (JoystickSliderAxes)cmbSliderAxisChoices.SelectedItem;
                                //if (cmbSliderAxisFilterChoices.SelectedIndex != 0)
                                cmbSliderAxisFilterChoices_selected = (JoystickAxisFilters)cmbSliderAxisFilterChoices.SelectedItem;

                                var cmbSliderChoicescontrolItem = GameControlsManager.Instance.GetItemByControlKey(command_selected);
                                var cmbSliderChoicesSystemValue = new GameControlsManager.SystemJoystickValue(cmbSliderChoices_selected, cmbSliderAxisChoices_selected, cmbSliderAxisFilterChoices_selected, currentstrength);
                                cmbSliderChoicesSystemValue.Parent = cmbSliderChoicescontrolItem;
                                cmbSliderChoicescontrolItem.bindedJoystickValues.Add(cmbSliderChoicesSystemValue);
                                //UpdateBindedInputControlsListBox();
                                break;
                            }
                            else
                            {
                                cmbSliderChoices.SelectedIndex = 0;
                                cmbSliderChoices_selected = (JoystickSliders)0;
                                cmbSliderAxisChoices.SelectedIndex = 0;
                                cmbSliderAxisChoices_selected = (JoystickSliderAxes)0;
                                cmbSliderAxisFilterChoices.SelectedIndex = 0;
                                cmbSliderAxisFilterChoices_selected = (JoystickAxisFilters)0;
                            }

                            //axis filter
                            if (cmbAxisChoices.SelectedIndex != 0)
                                cmbAxisChoices_selected = (JoystickSliderAxes)cmbAxisChoices.SelectedItem;
                            else
                            {
                                cmbAxisChoices.SelectedIndex = 0;
                                cmbAxisChoices_selected = (JoystickSliderAxes)0;
                            }

                            if (cmbAxisFilterChoices.SelectedIndex == 0)
                                cmbAxisFilterChoices_selected = (JoystickAxisFilters)cmbAxisFilterChoices.SelectedItem;
                            else
                            {
                                cmbAxisFilterChoices.SelectedIndex = 0;
                                cmbAxisFilterChoices_selected = (JoystickAxisFilters)0;
                            }

                            //buttons
                            if (lstJoyButtonChoices.SelectedIndex == 0)
                                lstJoyButtonChoices_selected = (JoystickButtons)lstJoyButtonChoices.SelectedItem;
                            else
                            {
                                lstJoyButtonChoices.SelectedIndex = 0;
                                lstJoyButtonChoices_selected = (JoystickButtons)0;
                            }
                            break;
                        }

                    case Devices.Custom:
                        {
                            break;
                        }
                    //case Devices.Custom_Audio:
                    //    {
                    //        break;
                    //    }
                }
                //GameControlsManager.Instance.GetItemByControlKey(command_selected).BindedKeyboardMouseValues.Add(new GameControlsManager.SystemKeyboardMouseValue(lstKeyboardButtonChoices_selected));
                //save bind

                //GameControlsManager.Instance.SaveCustomConfig();
                //GameControlsManager.Instance.LoadCustomConfig();
                Add_Custom_Control.SetShouldDetach();
            };

            #endregion ButtonOK

            ((Button)Add_Custom_Control.Controls["buttonReset"]).Click += delegate(Button sender)
            {
                cmbDevice.SelectedIndex = 0;
                cmbDeviceType.SelectedIndex = 0;
                lstCommand.SelectedIndex = 0;
                cmbMouseButtonChoices.SelectedIndex = 0;
                cmbMouseScrollChoices.SelectedIndex = 0;
                lstKeyboardButtonChoices.SelectedIndex = 0;
                cmbSliderChoices.SelectedIndex = 0;
                cmbSliderAxisChoices.SelectedIndex = 0;
                cmbSliderAxisFilterChoices.SelectedIndex = 0;
                cmbAxisChoices.SelectedIndex = 0;
                cmbAxisFilterChoices.SelectedIndex = 0;
                lstJoyButtonChoices.SelectedIndex = 0;
                cntrlCommands.Visible = false;
                scrlSelectedStrength.Value = 1f;
                MainOptionsTabControl.Visible = false;
                message = " Nothing_Selected";
                lblMessage.Text = message;
            };

            ((Button)Add_Custom_Control.Controls["buttonCancel"]).Click += delegate(Button sender)
            {
                Add_Custom_Control.SetShouldDetach();
            };

            #endregion AddCustomControl.Gui

            MainOptionsTabControl.SelectedIndex = lastPageIndex2;
            UpdateMainOptionsPageButtonsState();
        }
예제 #41
0
 /// <summary>
 /// 游戏手柄的事件参数
 /// </summary>
 /// <param name="joystickId">手柄Id</param>
 /// <param name="buttons">按钮</param>
 public JoystickEventArgs(int joystickId, JoystickButtons buttons)
 {
     this.JoystickId = joystickId;
     this.Buttons    = buttons;
 }
예제 #42
0
 private void UpdateAllButtons(JoystickButtons buttons)
 {
     UpdateNormalButtons(buttons);
     UpdateStickAndShoulderButtons(buttons);
 }
예제 #43
0
 public static KeyCode JoystickInputToKey(Joysticks joystick, JoystickButtons button)
 {
     return(KeyCode.JoystickButton0 + ((int)joystick * 20 + (int)button));
 }
예제 #44
0
 private static bool IsButtonPressed(JoystickButtons buttons, JoystickButtons button)
 {
     return((buttons | button) == buttons);
 }
        private void HandleDirectInput(JoystickButtons joystickButtons, JoystickUpdate state)
        {
            var button = joystickButtons.DirectInputButton;

            switch (joystickButtons.InputMapping)
            {
            case InputMapping.Test:
            {
                if (InputCode.ButtonMode == EmulationProfile.NamcoMkdx || InputCode.ButtonMode == EmulationProfile.NamcoMachStorm || InputCode.ButtonMode == EmulationProfile.NamcoWmmt5)
                {
                    var result = DigitalHelper.GetButtonPressDirectInput(button, state);
                    if (result != null && result.Value)
                    {
                        if (mkdxTest)
                        {
                            InputCode.PlayerDigitalButtons[0].Test = false;
                            mkdxTest = false;
                        }
                        else
                        {
                            InputCode.PlayerDigitalButtons[0].Test = true;
                            mkdxTest = true;
                        }
                    }
                }
                else
                {
                    InputCode.PlayerDigitalButtons[0].Test = DigitalHelper.GetButtonPressDirectInput(button, state);
                }
                break;
            }

            case InputMapping.Service1:
                InputCode.PlayerDigitalButtons[0].Service = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.Service2:
                InputCode.PlayerDigitalButtons[1].Service = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.Coin1:
                InputCode.PlayerDigitalButtons[0].Coin = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.Coin2:
                InputCode.PlayerDigitalButtons[1].Coin = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.P1Button1:
                InputCode.PlayerDigitalButtons[0].Button1 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.P1Button2:
                InputCode.PlayerDigitalButtons[0].Button2 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.P1Button3:
                InputCode.PlayerDigitalButtons[0].Button3 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.P1Button4:
                InputCode.PlayerDigitalButtons[0].Button4 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.P1Button5:
                InputCode.PlayerDigitalButtons[0].Button5 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.P1Button6:
                InputCode.PlayerDigitalButtons[0].Button6 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.P1ButtonUp:
                DigitalHelper.GetDirectionPressDirectInput(InputCode.PlayerDigitalButtons[0], button, state, Direction.Up);
                break;

            case InputMapping.P1ButtonDown:
                DigitalHelper.GetDirectionPressDirectInput(InputCode.PlayerDigitalButtons[0], button, state,
                                                           Direction.Down);
                break;

            case InputMapping.P1ButtonLeft:
                DigitalHelper.GetDirectionPressDirectInput(InputCode.PlayerDigitalButtons[0], button, state,
                                                           Direction.Left);
                break;

            case InputMapping.P1ButtonRight:
                DigitalHelper.GetDirectionPressDirectInput(InputCode.PlayerDigitalButtons[0], button, state,
                                                           Direction.Right);
                break;

            case InputMapping.P1ButtonStart:
                InputCode.PlayerDigitalButtons[0].Start = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.P2Button1:
                InputCode.PlayerDigitalButtons[1].Button1 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.P2Button2:
                InputCode.PlayerDigitalButtons[1].Button2 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.P2Button3:
                InputCode.PlayerDigitalButtons[1].Button3 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.P2Button4:
                InputCode.PlayerDigitalButtons[1].Button4 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.P2Button5:
                InputCode.PlayerDigitalButtons[1].Button5 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.P2Button6:
                InputCode.PlayerDigitalButtons[1].Button6 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.P2ButtonUp:
                DigitalHelper.GetDirectionPressDirectInput(InputCode.PlayerDigitalButtons[1], button, state, Direction.Up);
                break;

            case InputMapping.P2ButtonDown:
                DigitalHelper.GetDirectionPressDirectInput(InputCode.PlayerDigitalButtons[1], button, state,
                                                           Direction.Down);
                break;

            case InputMapping.P2ButtonLeft:
                DigitalHelper.GetDirectionPressDirectInput(InputCode.PlayerDigitalButtons[1], button, state,
                                                           Direction.Left);
                break;

            case InputMapping.P2ButtonRight:
                DigitalHelper.GetDirectionPressDirectInput(InputCode.PlayerDigitalButtons[1], button, state,
                                                           Direction.Right);
                break;

            case InputMapping.P2ButtonStart:
                InputCode.PlayerDigitalButtons[1].Start = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.Analog0:
                InputCode.SetAnalogByte(0, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog1:
                InputCode.SetAnalogByte(1, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog2:
                InputCode.SetAnalogByte(2, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog3:
                InputCode.SetAnalogByte(3, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog4:
                InputCode.SetAnalogByte(4, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog5:
                InputCode.SetAnalogByte(5, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog6:
                InputCode.SetAnalogByte(6, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog7:
                InputCode.SetAnalogByte(7, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog8:
                InputCode.SetAnalogByte(8, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog9:
                InputCode.SetAnalogByte(9, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog10:
                InputCode.SetAnalogByte(10, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog11:
                InputCode.SetAnalogByte(11, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog12:
                InputCode.SetAnalogByte(12, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog13:
                InputCode.SetAnalogByte(13, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog14:
                InputCode.SetAnalogByte(14, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog15:
                InputCode.SetAnalogByte(15, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog16:
                InputCode.SetAnalogByte(16, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog17:
                InputCode.SetAnalogByte(17, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog18:
                InputCode.SetAnalogByte(18, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog19:
                InputCode.SetAnalogByte(19, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog20:
                InputCode.SetAnalogByte(20, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.SrcGearChange1:
            {
                if (DigitalHelper.GetButtonPressDirectInput(joystickButtons.DirectInputButton, state) == true)
                {
                    DigitalHelper.ChangeSrcGear(1);
                }
            }
            break;

            case InputMapping.SrcGearChange2:
            {
                if (DigitalHelper.GetButtonPressDirectInput(joystickButtons.DirectInputButton, state) == true)
                {
                    DigitalHelper.ChangeSrcGear(2);
                }
            }
            break;

            case InputMapping.SrcGearChange3:
            {
                if (DigitalHelper.GetButtonPressDirectInput(joystickButtons.DirectInputButton, state) == true)
                {
                    DigitalHelper.ChangeSrcGear(3);
                }
            }
            break;

            case InputMapping.SrcGearChange4:
            {
                if (DigitalHelper.GetButtonPressDirectInput(joystickButtons.DirectInputButton, state) == true)
                {
                    DigitalHelper.ChangeSrcGear(4);
                }
            }
            break;

            case InputMapping.ExtensionOne1:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionOne2:
                InputCode.PlayerDigitalButtons[0].ExtensionButton2 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionOne3:
                InputCode.PlayerDigitalButtons[0].ExtensionButton3 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionOne4:
                InputCode.PlayerDigitalButtons[0].ExtensionButton4 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionOne11:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_1 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionOne12:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_2 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionOne13:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_3 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionOne14:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_4 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionOne15:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_5 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionOne16:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_6 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionOne17:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_7 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionOne18:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_8 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionTwo1:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionTwo2:
                InputCode.PlayerDigitalButtons[1].ExtensionButton2 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionTwo3:
                InputCode.PlayerDigitalButtons[1].ExtensionButton3 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionTwo4:
                InputCode.PlayerDigitalButtons[1].ExtensionButton4 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionTwo11:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_1 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionTwo12:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_2 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionTwo13:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_3 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionTwo14:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_4 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionTwo15:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_5 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionTwo16:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_6 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionTwo17:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_7 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.ExtensionTwo18:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_8 =
                    DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.Analog0Special1:
            case InputMapping.Analog0Special2:
                InputCode.SetAnalogByte(0, ModifyAnalog(joystickButtons, state));
                break;

            case InputMapping.Analog2Special1:
            case InputMapping.Analog2Special2:
                InputCode.SetAnalogByte(2, ModifyAnalog(joystickButtons, state));
                break;

            // Jvs Board 2

            case InputMapping.JvsTwoService1:
                InputCode.PlayerDigitalButtons[2].Service = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoService2:
                InputCode.PlayerDigitalButtons[3].Service = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoCoin1:
                InputCode.PlayerDigitalButtons[2].Coin = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoCoin2:
                InputCode.PlayerDigitalButtons[3].Coin = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoP1Button1:
                InputCode.PlayerDigitalButtons[2].Button1 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoP1Button2:
                InputCode.PlayerDigitalButtons[2].Button2 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoP1Button3:
                InputCode.PlayerDigitalButtons[2].Button3 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoP1Button4:
                InputCode.PlayerDigitalButtons[2].Button4 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoP1Button5:
                InputCode.PlayerDigitalButtons[2].Button5 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoP1Button6:
                InputCode.PlayerDigitalButtons[2].Button6 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoP1ButtonUp:
                DigitalHelper.GetDirectionPressDirectInput(InputCode.PlayerDigitalButtons[2], button, state, Direction.Up);
                break;

            case InputMapping.JvsTwoP1ButtonDown:
                DigitalHelper.GetDirectionPressDirectInput(InputCode.PlayerDigitalButtons[2], button, state, Direction.Down);
                break;

            case InputMapping.JvsTwoP1ButtonLeft:
                DigitalHelper.GetDirectionPressDirectInput(InputCode.PlayerDigitalButtons[2], button, state, Direction.Left);
                break;

            case InputMapping.JvsTwoP1ButtonRight:
                DigitalHelper.GetDirectionPressDirectInput(InputCode.PlayerDigitalButtons[2], button, state, Direction.Right);
                break;

            case InputMapping.JvsTwoP1ButtonStart:
                InputCode.PlayerDigitalButtons[2].Start = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoP2Button1:
                InputCode.PlayerDigitalButtons[3].Button1 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoP2Button2:
                InputCode.PlayerDigitalButtons[3].Button2 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoP2Button3:
                InputCode.PlayerDigitalButtons[3].Button3 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoP2Button4:
                InputCode.PlayerDigitalButtons[3].Button4 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoP2Button5:
                InputCode.PlayerDigitalButtons[3].Button5 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoP2Button6:
                InputCode.PlayerDigitalButtons[3].Button6 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoP2ButtonUp:
                DigitalHelper.GetDirectionPressDirectInput(InputCode.PlayerDigitalButtons[3], button, state, Direction.Up);
                break;

            case InputMapping.JvsTwoP2ButtonDown:
                DigitalHelper.GetDirectionPressDirectInput(InputCode.PlayerDigitalButtons[3], button, state, Direction.Down);
                break;

            case InputMapping.JvsTwoP2ButtonLeft:
                DigitalHelper.GetDirectionPressDirectInput(InputCode.PlayerDigitalButtons[3], button, state, Direction.Left);
                break;

            case InputMapping.JvsTwoP2ButtonRight:
                DigitalHelper.GetDirectionPressDirectInput(InputCode.PlayerDigitalButtons[3], button, state, Direction.Right);
                break;

            case InputMapping.JvsTwoP2ButtonStart:
                InputCode.PlayerDigitalButtons[3].Start = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionOne1:
                InputCode.PlayerDigitalButtons[2].ExtensionButton1 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionOne2:
                InputCode.PlayerDigitalButtons[2].ExtensionButton2 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionOne3:
                InputCode.PlayerDigitalButtons[2].ExtensionButton3 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionOne4:
                InputCode.PlayerDigitalButtons[2].ExtensionButton4 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionOne11:
                InputCode.PlayerDigitalButtons[2].ExtensionButton1_1 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionOne12:
                InputCode.PlayerDigitalButtons[2].ExtensionButton1_2 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionOne13:
                InputCode.PlayerDigitalButtons[2].ExtensionButton1_3 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionOne14:
                InputCode.PlayerDigitalButtons[2].ExtensionButton1_4 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionOne15:
                InputCode.PlayerDigitalButtons[2].ExtensionButton1_5 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionOne16:
                InputCode.PlayerDigitalButtons[2].ExtensionButton1_6 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionOne17:
                InputCode.PlayerDigitalButtons[2].ExtensionButton1_7 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionOne18:
                InputCode.PlayerDigitalButtons[2].ExtensionButton1_8 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionTwo1:
                InputCode.PlayerDigitalButtons[3].ExtensionButton1 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionTwo2:
                InputCode.PlayerDigitalButtons[3].ExtensionButton2 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionTwo3:
                InputCode.PlayerDigitalButtons[3].ExtensionButton3 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionTwo4:
                InputCode.PlayerDigitalButtons[3].ExtensionButton4 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionTwo11:
                InputCode.PlayerDigitalButtons[3].ExtensionButton1_1 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionTwo12:
                InputCode.PlayerDigitalButtons[3].ExtensionButton1_2 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionTwo13:
                InputCode.PlayerDigitalButtons[3].ExtensionButton1_3 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionTwo14:
                InputCode.PlayerDigitalButtons[3].ExtensionButton1_4 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionTwo15:
                InputCode.PlayerDigitalButtons[3].ExtensionButton1_5 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionTwo16:
                InputCode.PlayerDigitalButtons[3].ExtensionButton1_6 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionTwo17:
                InputCode.PlayerDigitalButtons[3].ExtensionButton1_7 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoExtensionTwo18:
                InputCode.PlayerDigitalButtons[3].ExtensionButton1_8 = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.JvsTwoAnalog0:
                InputCode.SetAnalogByte(0, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.JvsTwoAnalog1:
                InputCode.SetAnalogByte(1, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.JvsTwoAnalog2:
                InputCode.SetAnalogByte(2, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.JvsTwoAnalog3:
                InputCode.SetAnalogByte(3, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.JvsTwoAnalog4:
                InputCode.SetAnalogByte(4, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.JvsTwoAnalog5:
                InputCode.SetAnalogByte(5, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.JvsTwoAnalog6:
                InputCode.SetAnalogByte(6, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.JvsTwoAnalog7:
                InputCode.SetAnalogByte(7, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.JvsTwoAnalog8:
                InputCode.SetAnalogByte(8, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.JvsTwoAnalog9:
                InputCode.SetAnalogByte(9, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.JvsTwoAnalog10:
                InputCode.SetAnalogByte(10, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.JvsTwoAnalog11:
                InputCode.SetAnalogByte(11, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.JvsTwoAnalog12:
                InputCode.SetAnalogByte(12, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.JvsTwoAnalog13:
                InputCode.SetAnalogByte(13, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.JvsTwoAnalog14:
                InputCode.SetAnalogByte(14, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.JvsTwoAnalog15:
                InputCode.SetAnalogByte(15, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.JvsTwoAnalog16:
                InputCode.SetAnalogByte(16, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.JvsTwoAnalog17:
                InputCode.SetAnalogByte(17, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.JvsTwoAnalog18:
                InputCode.SetAnalogByte(18, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.JvsTwoAnalog19:
                InputCode.SetAnalogByte(19, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.JvsTwoAnalog20:
                InputCode.SetAnalogByte(20, ModifyAnalog(joystickButtons, state), true);
                break;

            case InputMapping.Wmmt5GearChange1:
            {
                var pressed = DigitalHelper.GetButtonPressDirectInput(joystickButtons.DirectInputButton, state);
                if (pressed != null)
                {
                    DigitalHelper.ChangeWmmt5Gear((bool)pressed ? 1 : 0);
                }
            }
            break;

            case InputMapping.Wmmt5GearChange2:
            {
                var pressed = DigitalHelper.GetButtonPressDirectInput(joystickButtons.DirectInputButton, state);
                if (pressed != null)
                {
                    DigitalHelper.ChangeWmmt5Gear((bool)pressed ? 2 : 0);
                }
            }
            break;

            case InputMapping.Wmmt5GearChange3:
            {
                var pressed = DigitalHelper.GetButtonPressDirectInput(joystickButtons.DirectInputButton, state);
                if (pressed != null)
                {
                    DigitalHelper.ChangeWmmt5Gear((bool)pressed ? 3 : 0);
                }
            }
            break;

            case InputMapping.Wmmt5GearChange4:
            {
                var pressed = DigitalHelper.GetButtonPressDirectInput(joystickButtons.DirectInputButton, state);
                if (pressed != null)
                {
                    DigitalHelper.ChangeWmmt5Gear((bool)pressed ? 4 : 0);
                }
            }
            break;

            case InputMapping.Wmmt5GearChange5:
            {
                var pressed = DigitalHelper.GetButtonPressDirectInput(joystickButtons.DirectInputButton, state);
                if (pressed != null)
                {
                    DigitalHelper.ChangeWmmt5Gear((bool)pressed ? 5 : 0);
                }
            }
            break;

            case InputMapping.Wmmt5GearChange6:
            {
                var pressed = DigitalHelper.GetButtonPressDirectInput(joystickButtons.DirectInputButton, state);
                if (pressed != null)
                {
                    DigitalHelper.ChangeWmmt5Gear((bool)pressed ? 6 : 0);
                }
            }
            break;

            case InputMapping.Wmmt5GearChangeUp:
            {
                if (DigitalHelper.GetButtonPressDirectInput(joystickButtons.DirectInputButton, state) == true)
                {
                    if (!changeWmmt5GearUp)
                    {
                        DigitalHelper.ChangeWmmt5GearUp();
                    }
                    changeWmmt5GearUp = true;
                }
                else
                {
                    changeWmmt5GearUp = false;
                }
            }
            break;

            case InputMapping.Wmmt5GearChangeDown:
            {
                if (DigitalHelper.GetButtonPressDirectInput(joystickButtons.DirectInputButton, state) == true)
                {
                    if (!changeWmmt5GearDown)
                    {
                        DigitalHelper.ChangeWmmt5GearDown();
                    }
                    changeWmmt5GearDown = true;
                }
                else
                {
                    changeWmmt5GearDown = false;
                }
            }
            break;

            case InputMapping.SrcGearChangeUp:
            {
                if (DigitalHelper.GetButtonPressDirectInput(joystickButtons.DirectInputButton, state) == true)
                {
                    if (!changeSrcGearUp)
                    {
                        DigitalHelper.ChangeSrcGearUp();
                    }
                    changeSrcGearUp = true;
                }
                else
                {
                    changeSrcGearUp = false;
                }
            }
            break;

            case InputMapping.SrcGearChangeDown:
            {
                if (DigitalHelper.GetButtonPressDirectInput(joystickButtons.DirectInputButton, state) == true)
                {
                    if (!changeSrcGearDown)
                    {
                        DigitalHelper.ChangeSrcGearDown();
                    }
                    changeSrcGearDown = true;
                }
                else
                {
                    changeSrcGearDown = false;
                }
            }
            break;

            case InputMapping.InitialDRealGear1:
            {
                if (DigitalHelper.GetButtonPressDirectInput(joystickButtons.DirectInputButton, state) == true)
                {
                    DigitalHelper.ChangeIdGear(1);
                }
            }
            break;

            case InputMapping.InitialDRealGear2:
            {
                if (DigitalHelper.GetButtonPressDirectInput(joystickButtons.DirectInputButton, state) == true)
                {
                    DigitalHelper.ChangeIdGear(2);
                }
            }
            break;

            case InputMapping.InitialDRealGear3:
            {
                if (DigitalHelper.GetButtonPressDirectInput(joystickButtons.DirectInputButton, state) == true)
                {
                    DigitalHelper.ChangeIdGear(3);
                }
            }
            break;

            case InputMapping.InitialDRealGear4:
            {
                if (DigitalHelper.GetButtonPressDirectInput(joystickButtons.DirectInputButton, state) == true)
                {
                    DigitalHelper.ChangeIdGear(4);
                }
            }
            break;

            case InputMapping.InitialDRealGear5:
            {
                if (DigitalHelper.GetButtonPressDirectInput(joystickButtons.DirectInputButton, state) == true)
                {
                    DigitalHelper.ChangeIdGear(5);
                }
            }
            break;

            case InputMapping.InitialDRealGear6:
            {
                if (DigitalHelper.GetButtonPressDirectInput(joystickButtons.DirectInputButton, state) == true)
                {
                    DigitalHelper.ChangeIdGear(6);
                }
            }
            break;

            case InputMapping.PokkenButtonUp:
                DigitalHelper.GetDirectionPressDirectInput(InputCode.PokkenInputButtons, button, state, Direction.Up);
                break;

            case InputMapping.PokkenButtonDown:
                DigitalHelper.GetDirectionPressDirectInput(InputCode.PokkenInputButtons, button, state, Direction.Down);
                break;

            case InputMapping.PokkenButtonLeft:
                DigitalHelper.GetDirectionPressDirectInput(InputCode.PokkenInputButtons, button, state, Direction.Left);
                break;

            case InputMapping.PokkenButtonRight:
                DigitalHelper.GetDirectionPressDirectInput(InputCode.PokkenInputButtons, button, state, Direction.Right);
                break;

            case InputMapping.PokkenButtonStart:
                InputCode.PokkenInputButtons.Start = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.PokkenButtonA:
                InputCode.PokkenInputButtons.ButtonA = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.PokkenButtonB:
                InputCode.PokkenInputButtons.ButtonB = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.PokkenButtonX:
                InputCode.PokkenInputButtons.ButtonX = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.PokkenButtonY:
                InputCode.PokkenInputButtons.ButtonY = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.PokkenButtonL:
                InputCode.PokkenInputButtons.ButtonL = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            case InputMapping.PokkenButtonR:
                InputCode.PokkenInputButtons.ButtonR = DigitalHelper.GetButtonPressDirectInput(button, state);
                break;

            default:
                break;
                //throw new ArgumentOutOfRangeException();
            }
        }
예제 #46
0
        private void HandleRawInputButton(JoystickButtons joystickButton, bool pressed)
        {
            // Ignore when alt+tabbed
            if (!_windowFocus && pressed)
            {
                return;
            }

            switch (joystickButton.InputMapping)
            {
            case InputMapping.Test:
                InputCode.PlayerDigitalButtons[0].Test = pressed;
                break;

            case InputMapping.Service1:
                InputCode.PlayerDigitalButtons[0].Service = pressed;
                break;

            case InputMapping.Service2:
                InputCode.PlayerDigitalButtons[1].Service = pressed;
                break;

            case InputMapping.Coin1:
                InputCode.PlayerDigitalButtons[0].Coin = pressed;
                JvsPackageEmulator.UpdateCoinCount(0);
                break;

            case InputMapping.Coin2:
                InputCode.PlayerDigitalButtons[1].Coin = pressed;
                JvsPackageEmulator.UpdateCoinCount(1);
                break;

            // P1
            case InputMapping.P1ButtonStart:
                InputCode.PlayerDigitalButtons[0].Start = pressed;
                break;

            case InputMapping.P1Button1:
                InputCode.PlayerDigitalButtons[0].Button1 = pressed;
                break;

            case InputMapping.P1Button2:
                InputCode.PlayerDigitalButtons[0].Button2 = pressed;
                break;

            case InputMapping.P1Button3:
                InputCode.PlayerDigitalButtons[0].Button3 = pressed;
                break;

            case InputMapping.P1Button4:
                InputCode.PlayerDigitalButtons[0].Button4 = pressed;
                break;

            case InputMapping.P1Button5:
                InputCode.PlayerDigitalButtons[0].Button5 = pressed;
                break;

            case InputMapping.P1Button6:
                InputCode.PlayerDigitalButtons[0].Button6 = pressed;
                break;

            case InputMapping.P1ButtonLeft:
                if (pressed)
                {
                    InputCode.SetPlayerDirection(InputCode.PlayerDigitalButtons[0], Direction.Left);
                }
                else
                {
                    InputCode.SetPlayerDirection(InputCode.PlayerDigitalButtons[0], Direction.HorizontalCenter);
                }
                break;

            case InputMapping.P1ButtonRight:
                if (pressed)
                {
                    InputCode.SetPlayerDirection(InputCode.PlayerDigitalButtons[0], Direction.Right);
                }
                else
                {
                    InputCode.SetPlayerDirection(InputCode.PlayerDigitalButtons[0], Direction.HorizontalCenter);
                }
                break;

            // P2
            case InputMapping.P2ButtonStart:
                InputCode.PlayerDigitalButtons[1].Start = pressed;
                break;

            case InputMapping.P2Button1:
                InputCode.PlayerDigitalButtons[1].Button1 = pressed;
                break;

            case InputMapping.P2Button2:
                InputCode.PlayerDigitalButtons[1].Button2 = pressed;
                break;

            case InputMapping.P2Button3:
                InputCode.PlayerDigitalButtons[1].Button3 = pressed;
                break;

            case InputMapping.P2Button4:
                InputCode.PlayerDigitalButtons[1].Button4 = pressed;
                break;

            case InputMapping.P2Button5:
                InputCode.PlayerDigitalButtons[1].Button5 = pressed;
                break;

            case InputMapping.P2Button6:
                InputCode.PlayerDigitalButtons[1].Button6 = pressed;
                break;

            // Ext1
            case InputMapping.ExtensionOne1:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1 = pressed;
                break;

            case InputMapping.ExtensionOne2:
                InputCode.PlayerDigitalButtons[0].ExtensionButton2 = pressed;
                break;

            case InputMapping.ExtensionOne3:
                InputCode.PlayerDigitalButtons[0].ExtensionButton3 = pressed;
                break;

            case InputMapping.ExtensionOne4:
                InputCode.PlayerDigitalButtons[0].ExtensionButton4 = pressed;
                break;

            case InputMapping.ExtensionOne11:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_1 = pressed;
                break;

            case InputMapping.ExtensionOne12:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_2 = pressed;
                break;

            case InputMapping.ExtensionOne13:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_3 = pressed;
                break;

            case InputMapping.ExtensionOne14:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_4 = pressed;
                break;

            case InputMapping.ExtensionOne15:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_5 = pressed;
                break;

            case InputMapping.ExtensionOne16:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_6 = pressed;
                break;

            case InputMapping.ExtensionOne17:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_7 = pressed;
                break;

            case InputMapping.ExtensionOne18:
                InputCode.PlayerDigitalButtons[0].ExtensionButton1_8 = pressed;
                break;

            // Ext2
            case InputMapping.ExtensionTwo1:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1 = pressed;
                break;

            case InputMapping.ExtensionTwo2:
                InputCode.PlayerDigitalButtons[1].ExtensionButton2 = pressed;
                break;

            case InputMapping.ExtensionTwo3:
                InputCode.PlayerDigitalButtons[1].ExtensionButton3 = pressed;
                break;

            case InputMapping.ExtensionTwo4:
                InputCode.PlayerDigitalButtons[1].ExtensionButton4 = pressed;
                break;

            case InputMapping.ExtensionTwo11:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_1 = pressed;
                break;

            case InputMapping.ExtensionTwo12:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_2 = pressed;
                break;

            case InputMapping.ExtensionTwo13:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_3 = pressed;
                break;

            case InputMapping.ExtensionTwo14:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_4 = pressed;
                break;

            case InputMapping.ExtensionTwo15:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_5 = pressed;
                break;

            case InputMapping.ExtensionTwo16:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_6 = pressed;
                break;

            case InputMapping.ExtensionTwo17:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_7 = pressed;
                break;

            case InputMapping.ExtensionTwo18:
                InputCode.PlayerDigitalButtons[1].ExtensionButton1_8 = pressed;
                break;

            default:
                break;
            }
        }
예제 #47
0
 public static KeyCode JoystickInputToKey(Joysticks joystick, JoystickButtons button)
 {
     return KeyCode.JoystickButton0 + ((int)joystick * 20 + (int)button);
 }
예제 #48
0
        private void HandleRawInputGun(JoystickButtons joystickButton, int inputX, int inputY, bool moveAbsolute)
        {
            // Ignore when alt+tabbed
            if (!_windowFocus)
            {
                return;
            }

            // Calculate where the mouse is inside the game window
            // 0.0, 0.0 top left
            // 1.0, 1.0 right bottom
            float factorX = 0.0f;
            float factorY = 0.0f;

            // Windowed
            if (_windowed)
            {
                // Translate absolute units to pixels
                if (moveAbsolute)
                {
                    inputX = (int)((float)inputX / (float)0xFFFF * SystemParameters.PrimaryScreenWidth);
                    inputY = (int)((float)inputY / (float)0xFFFF * SystemParameters.PrimaryScreenHeight);
                }

                // X
                if (inputX <= _windowLocationX)
                {
                    factorX = 0.0f;
                }
                else if (inputX >= _windowLocationX + _windowWidth)
                {
                    factorX = 1.0f;
                }
                else
                {
                    factorX = (float)(inputX - _windowLocationX) / (float)_windowWidth;
                }

                // Y
                if (inputY <= _windowLocationY)
                {
                    factorY = 0.0f;
                }
                else if (inputY >= _windowLocationY + _windowHeight)
                {
                    factorY = 1.0f;
                }
                else
                {
                    factorY = (float)(inputY - _windowLocationY) / (float)_windowHeight;
                }
            }
            // Fullscreen
            else
            {
                if (moveAbsolute)
                {
                    factorX = (float)inputX / (float)0xFFFF;
                    factorY = (float)inputY / (float)0xFFFF;
                }
                else
                {
                    factorX = (float)inputX / (float)SystemParameters.PrimaryScreenWidth;
                    factorY = (float)inputY / (float)SystemParameters.PrimaryScreenHeight;
                }
            }

            float minX = _minX;
            float maxX = _maxX;
            float minY = _minY;
            float maxY = _maxY;

            // Convert to game specific units
            ushort x = (ushort)Math.Round(minX + factorX * (maxX - minX));
            ushort y = (ushort)Math.Round(minY + factorY * (maxY - minY));

            /*
             * InvertedMouseAxis:
             * AnalogBytes[0] = X, Left = 0, Right = 255
             * AnalogBytes[2] = Y, Top = 0,  Bottom = 255
             *
             * NOT InvertedMouseAxis:
             * AnalogBytes[2] = X, Left = 255, Right = 0
             * AnalogBytes[0] = Y, Top = 255,  Bottom = 0
             *
             * Luigi is different ofcourse:
             * AnalogBytes[2] = X, Left = 0, Right = 255
             * AnalogBytes[0] = Y, Top = 0,  Bottom = 255
             */

            if (joystickButton.InputMapping == InputMapping.P1LightGun)
            {
                if (_isLuigisMansion)
                {
                    InputCode.AnalogBytes[2] = (byte)x;
                    InputCode.AnalogBytes[0] = (byte)y;
                }
                else if (_invertedMouseAxis)
                {
                    InputCode.AnalogBytes[0] = (byte)x;
                    InputCode.AnalogBytes[2] = (byte)y;
                }
                else
                {
                    InputCode.AnalogBytes[2] = (byte)~x;
                    InputCode.AnalogBytes[0] = (byte)~y;
                }
            }
            else if (joystickButton.InputMapping == InputMapping.P2LightGun)
            {
                if (_isLuigisMansion)
                {
                    InputCode.AnalogBytes[6] = (byte)x;
                    InputCode.AnalogBytes[4] = (byte)y;
                }
                else if (_invertedMouseAxis)
                {
                    InputCode.AnalogBytes[4] = (byte)x;
                    InputCode.AnalogBytes[6] = (byte)y;
                }
                else
                {
                    InputCode.AnalogBytes[6] = (byte)~x;
                    InputCode.AnalogBytes[4] = (byte)~y;
                }
            }
        }
예제 #49
0
 //
 public SystemJoystickValue( JoystickButtons button )
 {
     type = Types.Button;
     this.button = button;
 }
예제 #50
0
 public JoystickEventArgs(int joystickId, JoystickButtons buttons, Point move)
 {
     this.JoystickId = joystickId;
     this.Buttons    = buttons;
     this.Move       = move;
 }
예제 #51
0
 // Was this button released?
 public bool GetButtonUp( JoystickButtons button, int joystickIndex = 0 )
 {
     return (_joystickButtonsLastFrame[joystickIndex,(int)button] && !_joystickButtons[joystickIndex,(int)button]);
 }
예제 #52
0
        /// <summary>
        /// 处理系统消息.
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            //没有关注的,直接返回
            if (IsClickEventEmpty())
            {
                return(IntPtr.Zero);
            }

            bool flag = false;

            if (hwnd != IntPtr.Zero && (wParam != IntPtr.Zero || lParam != IntPtr.Zero))
            {
                if (msg != API.MM_JOY1MOVE && msg != API.MM_JOY2MOVE)
                {
                    return(IntPtr.Zero);
                }

                Action <JoystickEventArgs> action  = null;
                JoystickButtons            buttons = JoystickButtons.None;
                int           joystickId           = -1;
                API.JoyInfoEx joyInfo1             = new API.JoyInfoEx();
                joyInfo1.dwSize  = (uint)Marshal.SizeOf(typeof(API.JoyInfoEx));
                joyInfo1.dwFlags = (int)API.JOY_RETURNALL;

                if (API.joyGetPosEx(API.JOYSTICKID1, ref joyInfo1) == API.JOYERR_NOERROR)
                {
                    buttons = GetButtonFromJoyInfoEx(joyInfo1);
                    action  = this.OnClick;
                }
                joystickId = msg == API.MM_JOY1MOVE ? API.JOYSTICKID1 : API.JOYSTICKID2;

                //switch (msg)
                //{
                //    case API.MM_JOY1MOVE:
                //    case API.MM_JOY2MOVE:
                //        //单击事件
                //        //buttons = GetButtonsStateFromMessageParam(wParam.ToInt64(), lParam.ToInt64());
                //        if (API.joyGetPosEx(API.JOYSTICKID1, ref joyInfo1) == API.JOYERR_NOERROR)
                //        {
                //            buttons = GetButtonFromJoyInfoEx(joyInfo1);
                //            action = this.OnClick;
                //        }
                //        joystickId = msg == API.MM_JOY1MOVE ? API.JOYSTICKID1 : API.JOYSTICKID2;
                //        break;
                //    case API.MM_JOY1BUTTONDOWN:
                //    case API.MM_JOY2BUTTONDOWN:
                //        //按钮被按下
                //        //buttons = GetButtonsPressedStateFromMessageParam(wParam.ToInt32(), lParam.ToInt32());
                //        if (API.joyGetPosEx(API.JOYSTICKID1, ref joyInfo1) == API.JOYERR_NOERROR)
                //        {
                //            buttons = GetButtonFromJoyInfoEx(joyInfo1);
                //            action = this.OnButtonDown;
                //        }
                //        joystickId = msg == API.MM_JOY1BUTTONDOWN ? API.JOYSTICKID1 : API.JOYSTICKID2;
                //        break;
                //    case API.MM_JOY1BUTTONUP:
                //    case API.MM_JOY2BUTTONUP:
                //        //按钮被弹起
                //        //buttons = GetButtonsPressedStateFromMessageParam(wParam.ToInt32(), lParam.ToInt32());
                //        if (API.joyGetPosEx(API.JOYSTICKID1, ref joyInfo1) == API.JOYERR_NOERROR)
                //        {
                //            buttons = GetButtonFromJoyInfoEx(joyInfo1);
                //            action = this.OnButtonUp;
                //        }
                //        joystickId = msg == API.MM_JOY1BUTTONUP ? API.JOYSTICKID1 : API.JOYSTICKID2;
                //        break;

                //    case API.MM_JOY1ZMOVE:
                //    case API.MM_JOY2ZMOVE:
                //        break;
                //}
                if (action != null && joystickId != -1 && buttons != JoystickButtons.None)
                {
                    //阻止消息继续传递
                    flag = true;
                    //触发事件
                    action(new JoystickEventArgs(joystickId, buttons));
                }

                if (joystickId != -1 && _LastButtonsInfo != buttons)
                {
                    //无论是否有按键按下,发送move消息
                    this.OnMove(new JoystickEventArgs(joystickId, buttons));
                    _LastButtonsInfo = buttons;
                }
            }
            handled = flag;
            return(IntPtr.Zero);
        }