From bef43af969c8faec5fedfd4b2c447ffbc8bc63d0 Mon Sep 17 00:00:00 2001 From: Christopher Lees Date: Thu, 27 Jul 2017 16:39:37 +0100 Subject: [PATCH] Implement generic Consumer device which returns a button collection --- src/OpenTK/Platform/Common/Hid.cs | 3 ++- src/OpenTK/Platform/Windows/API.cs | 8 ++++++++ src/OpenTK/Platform/Windows/WinRawJoystick.cs | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/OpenTK/Platform/Common/Hid.cs b/src/OpenTK/Platform/Common/Hid.cs index 27815575..41884694 100644 --- a/src/OpenTK/Platform/Common/Hid.cs +++ b/src/OpenTK/Platform/Common/Hid.cs @@ -141,7 +141,8 @@ namespace OpenTK.Platform.Common // Consumer electronic devices internal enum HIDUsageCD { - ACPan = 0x0238 + ACPan = 0x0238, + ConsumerControl = 0x01 } // Generic desktop usage diff --git a/src/OpenTK/Platform/Windows/API.cs b/src/OpenTK/Platform/Windows/API.cs index 4e84df64..434d2987 100644 --- a/src/OpenTK/Platform/Windows/API.cs +++ b/src/OpenTK/Platform/Windows/API.cs @@ -2126,6 +2126,14 @@ namespace OpenTK.Platform.Windows Target = target; } + public RawInputDevice(HIDUsageCD usage, RawInputDeviceFlags flags, HWND target) + { + UsagePage = HIDPage.Consumer; + Usage = (short)usage; + Flags = flags; + Target = target; + } + public RawInputDevice(HIDUsageSim usage, RawInputDeviceFlags flags, HWND target) { UsagePage = HIDPage.Simulation; diff --git a/src/OpenTK/Platform/Windows/WinRawJoystick.cs b/src/OpenTK/Platform/Windows/WinRawJoystick.cs index 055456b4..fe09fa2f 100644 --- a/src/OpenTK/Platform/Windows/WinRawJoystick.cs +++ b/src/OpenTK/Platform/Windows/WinRawJoystick.cs @@ -194,6 +194,7 @@ namespace OpenTK.Platform.Windows { new RawInputDevice(HIDUsageGD.Joystick, RawInputDeviceFlags.DEVNOTIFY | RawInputDeviceFlags.INPUTSINK, window), new RawInputDevice(HIDUsageGD.GamePad, RawInputDeviceFlags.DEVNOTIFY | RawInputDeviceFlags.INPUTSINK, window), + new RawInputDevice(HIDUsageCD.ConsumerControl, RawInputDeviceFlags.DEVNOTIFY | RawInputDeviceFlags.INPUTSINK, window), }; if (!Functions.RegisterRawInputDevices(DeviceTypes, DeviceTypes.Length, API.RawInputDeviceSize))