示例#1
0
        void RelinquishDevice(uint deviceID)
        {
            ownedDevices.Remove(deviceID);
            pressedButtons.Remove(deviceID);
            var args = new JoystickDeviceEventArgs();

            args.DeviceID = deviceID;
            OnJoystickRelinquished(args);
        }
示例#2
0
 void OnJoystickRelinquished(object joystick, JoystickDeviceEventArgs e)
 {
     // once a device is no longer used by any clients it should get relinquished
     if (joysticks.Any(j => j.IsDeviceOwned(e.DeviceID)))
     {
         return;
     }
     joystickManager.RelinquishDevice(e.DeviceID);
     Console.WriteLine("Relinquished device {0}", e.DeviceID);
 }
示例#3
0
        void RequestDevice(uint deviceID)
        {
            var args = new JoystickDeviceEventArgs();

            args.DeviceID = deviceID;
            OnJoystickRequested(args);
            if (args.Acquired)
            {
                ownedDevices.Add(deviceID);
                pressedButtons.Add(deviceID, new List <byte> {
                });
            }
        }
示例#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();
        }
示例#5
0
        void OnJoystickRequested(object joystick, JoystickDeviceEventArgs e)
        {
            var acquired = joystickManager.AcquireDevice(e.DeviceID);

            e.Acquired = acquired;
        }
示例#6
0
 protected virtual void OnJoystickRelinquished(JoystickDeviceEventArgs e)
 {
     JoystickRelinquished?.Invoke(this, e);
 }