-#region --- License ---
-/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
- * Contributions from Erik Ylvisaker
- * See license.txt for license info
- */
+#region License
+//
+// WinRawJoystick.cs
+//
+// Author:
+// Stefanos A. <stapostol@gmail.com>
+//
+// Copyright (c) 2006 Stefanos Apostolopoulos
+// Copyright (c) 2007 Erik Ylvisaker
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
#endregion
-#region --- Using Directives ---
-
using System;
#if !MINIMAL
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Security;
-
-#endregion
+using OpenTK.Platform.Common;
/* TODO: Update the description of TimeBeginPeriod and other native methods. Update Timer. */
/// <summary>
/// Top level collection Usage page for the raw input device.
/// </summary>
- //internal USHORT UsagePage;
- internal SHORT UsagePage;
+ internal HIDPage UsagePage;
/// <summary>
/// Top level collection Usage for the raw input device.
/// </summary>
/// </summary>
internal HWND Target;
+ public RawInputDevice(HIDUsageGD usage, RawInputDeviceFlags flags, HWND target)
+ {
+ UsagePage = HIDPage.GenericDesktop;
+ Usage = (short)usage;
+ Flags = flags;
+ Target = target;
+ }
+
+ public RawInputDevice(HIDUsageSim usage, RawInputDeviceFlags flags, HWND target)
+ {
+ UsagePage = HIDPage.Simulation;
+ Usage = (short)usage;
+ Flags = flags;
+ Target = target;
+ }
+
public override string ToString()
{
return String.Format("{0}/{1}, flags: {2}, window: {3}", UsagePage, Usage, Flags, Target);
/// <summary>
/// Size, in bytes, of each HID input in bRawData.
/// </summary>
- internal DWORD SizeHid;
+ internal DWORD Size;
/// <summary>
/// Number of HID inputs in bRawData.
/// </summary>
internal DWORD Count;
- // The RawData field must be marshalled manually.
- ///// <summary>
- ///// Raw input data as an array of bytes.
- ///// </summary>
- //internal IntPtr RawData;
+ /// <summary>
+ /// Raw input data as an array of bytes.
+ /// </summary>
+ internal IntPtr RawData;
}
#endregion
using Microsoft.Win32;
#endif
using OpenTK.Input;
+using OpenTK.Platform.Common;
namespace OpenTK.Platform.Windows
{
static void RegisterKeyboardDevice(IntPtr window, string name)
{
- RawInputDevice[] rid = new RawInputDevice[1];
- // Keyboard is 1/6 (page/id). See http://www.microsoft.com/whdc/device/input/HID_HWID.mspx
- rid[0] = new RawInputDevice();
- rid[0].UsagePage = 1;
- rid[0].Usage = 6;
- rid[0].Flags = RawInputDeviceFlags.INPUTSINK;
- rid[0].Target = window;
+ RawInputDevice[] rid = new RawInputDevice[]
+ {
+ new RawInputDevice(HIDUsageGD.Keyboard, RawInputDeviceFlags.INPUTSINK, window)
+ };
if (!Functions.RegisterRawInputDevices(rid, 1, API.RawInputDeviceSize))
{
using System.Runtime.InteropServices;
using Microsoft.Win32;
using OpenTK.Input;
+using OpenTK.Platform.Common;
namespace OpenTK.Platform.Windows
{
static void RegisterRawDevice(IntPtr window, string device)
{
- RawInputDevice[] rid = new RawInputDevice[1];
- // Mouse is 1/2 (page/id). See http://www.microsoft.com/whdc/device/input/HID_HWID.mspx
- rid[0] = new RawInputDevice();
- rid[0].UsagePage = 1;
- rid[0].Usage = 2;
- rid[0].Flags = RawInputDeviceFlags.INPUTSINK;
- rid[0].Target = window;
+ RawInputDevice[] rid = new RawInputDevice[]
+ {
+ new RawInputDevice(HIDUsageGD.Mouse, RawInputDeviceFlags.INPUTSINK, window)
+ };
if (!Functions.RegisterRawInputDevices(rid, 1, API.RawInputDeviceSize))
{