diff --git a/Source/OpenTK/Input/IKeyboard.cs b/Source/OpenTK/Input/IKeyboard.cs
index 11eef01b..92fb1ac8 100644
--- a/Source/OpenTK/Input/IKeyboard.cs
+++ b/Source/OpenTK/Input/IKeyboard.cs
@@ -1,6 +1,8 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+#region --- License ---
+/* Copyright (c) 2007 Stefanos Apostolopoulos
+ * See license.txt for license info
+ */
+#endregion
namespace OpenTK.Input
{
diff --git a/Source/OpenTK/Input/Keyboard.cs b/Source/OpenTK/Input/Keyboard.cs
index e7156ab6..bf4b04b8 100644
--- a/Source/OpenTK/Input/Keyboard.cs
+++ b/Source/OpenTK/Input/Keyboard.cs
@@ -1,6 +1,14 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+#region --- License ---
+/* Copyright (c) 2007 Stefanos Apostolopoulos
+ * See license.txt for license info
+ */
+#endregion
+
+#region --- Using directives ---
+
+using System;
+
+#endregion
namespace OpenTK.Input
{
diff --git a/Source/OpenTK/Platform/Windows/API.cs b/Source/OpenTK/Platform/Windows/API.cs
index 824775b7..ef17f13a 100644
--- a/Source/OpenTK/Platform/Windows/API.cs
+++ b/Source/OpenTK/Platform/Windows/API.cs
@@ -56,6 +56,7 @@ namespace OpenTK.Platform.Windows
{
RawInputHeaderSize = (uint)Marshal.SizeOf(typeof(RawInputHeader));
RawInputSize = (uint)Marshal.SizeOf(typeof(RawInput));
+ RawInputDeviceSize = (uint)Marshal.SizeOf(typeof(RawInputDevice));
}
#region Constants
@@ -905,7 +906,7 @@ namespace OpenTK.Platform.Windows
public static extern UINT GetRawInputData(
HRAWINPUT RawInput,
GetRawInputDataEnum Command,
- [MarshalAs(UnmanagedType.Struct)] [Out] RawInput Data,
+ [MarshalAs(UnmanagedType.LPStruct)] [Out] RawInput Data,
[In, Out] ref UINT Size,
UINT SizeHeader
);
@@ -1316,6 +1317,8 @@ namespace OpenTK.Platform.Windows
#region RawInputDevice
+ public static readonly uint RawInputDeviceSize;
+
///
/// Defines information for the raw input devices.
///
@@ -1323,7 +1326,7 @@ namespace OpenTK.Platform.Windows
/// If RIDEV_NOLEGACY is set for a mouse or a keyboard, the system does not generate any legacy message for that device for the application. For example, if the mouse TLC is set with RIDEV_NOLEGACY, WM_LBUTTONDOWN and related legacy mouse messages are not generated. Likewise, if the keyboard TLC is set with RIDEV_NOLEGACY, WM_KEYDOWN and related legacy keyboard messages are not generated.
///
[StructLayout(LayoutKind.Sequential)]
- public class RawInputDevice
+ public struct RawInputDevice
{
///
/// Top level collection Usage page for the raw input device.
@@ -1344,6 +1347,11 @@ namespace OpenTK.Platform.Windows
/// Handle to the target window. If NULL it follows the keyboard focus.
///
public HWND Target;
+
+ public override string ToString()
+ {
+ return String.Format("{0}/{1}, flags: {2}, window: {3}", UsagePage, Usage, Flags, Target);
+ }
}
#endregion
@@ -1769,6 +1777,7 @@ namespace OpenTK.Platform.Windows
#region RawInputDeviceFlags enum
+ [Flags]
public enum RawInputDeviceFlags : int
{
///
diff --git a/Source/OpenTK/Platform/Windows/WinRawInput.cs b/Source/OpenTK/Platform/Windows/WinRawInput.cs
index 1e74cb23..b34d3516 100644
--- a/Source/OpenTK/Platform/Windows/WinRawInput.cs
+++ b/Source/OpenTK/Platform/Windows/WinRawInput.cs
@@ -1,9 +1,19 @@
-using System;
+#region --- License ---
+/* Copyright (c) 2007 Stefanos Apostolopoulos
+ * See license.txt for license info
+ */
+#endregion
+
+#region --- Using directives ---
+
+using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
+#endregion
+
namespace OpenTK.Platform.Windows
{
static class WinRawInput
diff --git a/Source/OpenTK/Platform/Windows/WinRawKeyboard.cs b/Source/OpenTK/Platform/Windows/WinRawKeyboard.cs
index 19464352..a079366b 100644
--- a/Source/OpenTK/Platform/Windows/WinRawKeyboard.cs
+++ b/Source/OpenTK/Platform/Windows/WinRawKeyboard.cs
@@ -1,10 +1,20 @@
-using System;
+#region --- License ---
+/* Copyright (c) 2007 Stefanos Apostolopoulos
+ * See license.txt for license info
+ */
+#endregion
+
+#region --- Using directives ---
+
+using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using OpenTK.Input;
+#endregion
+
namespace OpenTK.Platform.Windows
{
internal class WinRawKeyboard : OpenTK.Input.IKeyboard
@@ -24,17 +34,18 @@ namespace OpenTK.Platform.Windows
rid[0].UsagePage = 1;
rid[0].Usage = 6;
- rid[0].Flags =
- API.RawInputDeviceFlags.APPKEYS |
- API.RawInputDeviceFlags.NOLEGACY;
+ rid[0].Flags = API.RawInputDeviceFlags.INPUTSINK;
rid[0].Target = windowHandle;
- if (!API.RegisterRawInputDevices(rid, 1, API.RawInputHeaderSize))
+ if (!API.RegisterRawInputDevices(rid, 1, API.RawInputDeviceSize))
{
- /*throw new ApplicationException(
- String.Format("Raw input registration failed for keyboard. Error {0}", Marshal.GetLastWin32Error())
- );*/
+ throw new ApplicationException(
+ String.Format(
+ "Raw input registration failed with error: {0}. Device: {1}",
+ Marshal.GetLastWin32Error(),
+ rid[0].ToString())
+ );
}
}