예제 #1
0
        public IEnumerable <GamepadModel> GetGamepads()
        {
            int[] deviceIds = InputDevice.GetDeviceIds();

            List <GamepadModel> models = new List <GamepadModel>(deviceIds.Length);

            InputDevice         device;
            GamepadModelWrapper wrapper;

            for (int i = 0; i < deviceIds.Length; ++i)
            {
                if (!gamepads.ContainsKey(deviceIds[i]))
                {
                    device = InputDevice.GetDevice(deviceIds[i]);

                    if ((device.Sources & InputSourceType.Gamepad) == InputSourceType.Gamepad)
                    {
                        wrapper = new GamepadModelWrapper(device);

                        gamepads.Add(deviceIds[i], wrapper);

                        models.Add(wrapper.GamepadModel);
                    }
                }
                else
                {
                    models.Add(gamepads[deviceIds[i]].GamepadModel);
                }
            }

            return(models.ToArray());
        }
예제 #2
0
 internal static void Initialize()
 {
     //Iterate and 'connect' any detected gamepads
     foreach (var deviceId in InputDevice.GetDeviceIds())
     {
         GetGamePad(InputDevice.GetDevice(deviceId));
     }
 }