예제 #1
0
        private void OnStartJoystickButtonClicked(object sender, EventArgs e)
        {
            JoystickInfo joystickInfo = JoystickInfo.ConfiguredJoystick;

            if (joystickInfo == null)
            {
                MessageBox.Show("Ensure that joystick is connected and enter settings", "No joystick configured",
                                MessageBoxButtons.OK);
                return;
            }

            if (String.IsNullOrEmpty(Settings.Default.JoystickButton))
            {
                MessageBox.Show("Ensure that joystick is connected and enter settings and detect the button", "No joystick button configured",
                                MessageBoxButtons.OK);
                return;
            }

            if (!Enum.TryParse(Settings.Default.JoystickButton, out _joystickOffset))
            {
                MessageBox.Show("Ensure that joystick is connected and enter settings and detect the button", "Incorrect joystick button configured",
                                MessageBoxButtons.OK);
                return;
            }

            _startJoystickButton.Enabled = false;

            _joystickObserver = new JoystickObserver(joystickInfo);
            _joystickObserver.OnJoystickUpdate += OnJoystickUpdated;

            _joystickObserver.Start();

            _stopJoystickButton.Enabled = true;
        }
예제 #2
0
 public JoystickObserver(JoystickInfo joystickInfo)
 {
     JoystickInfo = joystickInfo;
 }