Example #1
0
 void OnButtonReleased(object joystick, JoystickEventArgs e)
 {
     if (joysticks.Any(j => j.IsButtonPressed(e.DeviceID, e.Button)))
     {
         return;
     }
     ReleaseButton(e.DeviceID, e.Button);
 }
Example #2
0
        void PressButton(uint deviceID, byte button)
        {
            pressedButtons[deviceID].Add(button);
            var args = new JoystickEventArgs();

            args.DeviceID = deviceID;
            args.Button   = button;
            OnButtonPressed(args);
        }
Example #3
0
        void ReleaseButton(uint deviceID, byte button)
        {
            pressedButtons[deviceID].Remove(button);
            if (IsButtonPressed(deviceID, button))
            {
                return;
            }
            var args = new JoystickEventArgs();

            args.DeviceID = deviceID;
            args.Button   = button;
            OnButtonReleased(args);
        }
Example #4
0
        public void OnDisconnected()
        {
            var ownedDevices2 = new List <uint>(ownedDevices);

            ownedDevices.Clear();
            foreach (var device in ownedDevices2)
            {
                foreach (var button in pressedButtons[device])
                {
                    var args = new JoystickEventArgs();
                    args.DeviceID = device;
                    args.Button   = button;
                    OnButtonReleased(args);
                }
                var args2 = new JoystickDeviceEventArgs();
                args2.DeviceID = device;
                OnJoystickRelinquished(args2);
            }
            pressedButtons.Clear();
        }
Example #5
0
 void OnButtonPressed(object joystick, JoystickEventArgs e)
 {
     PressButton(e.DeviceID, e.Button);
 }
Example #6
0
 protected virtual void OnButtonReleased(JoystickEventArgs e)
 {
     ButtonReleased?.Invoke(this, e);
 }