RegisterRawInputDevices() private method

private RegisterRawInputDevices ( RawInputDevice RawInputDevices, INT NumDevices, INT Size ) : BOOL
RawInputDevices RawInputDevice
NumDevices INT
Size INT
return BOOL
示例#1
0
        public WinRawJoystick(IntPtr window)
        {
            Debug.WriteLine("Using WinRawJoystick.");
            Debug.Indent();

            if (window == IntPtr.Zero)
            {
                throw new ArgumentNullException("window");
            }

            DeviceTypes = new RawInputDevice[]
            {
                new RawInputDevice(HIDUsageGD.Joystick, RawInputDeviceFlags.DEVNOTIFY | RawInputDeviceFlags.INPUTSINK, window),
                new RawInputDevice(HIDUsageGD.GamePad, RawInputDeviceFlags.DEVNOTIFY | RawInputDeviceFlags.INPUTSINK, window),
            };

            if (!Functions.RegisterRawInputDevices(DeviceTypes, DeviceTypes.Length, API.RawInputDeviceSize))
            {
                Debug.Print("[Warning] Raw input registration failed with error: {0}.",
                            Marshal.GetLastWin32Error());
            }
            else
            {
                Debug.Print("[WinRawJoystick] Registered for raw input");
            }

            RefreshDevices();

            Debug.Unindent();
        }
示例#2
0
        internal void RegisterRawDevice(OpenTK.Input.MouseDevice mouse)
        {
            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;

            if (!Functions.RegisterRawInputDevices(rid, 1, API.RawInputDeviceSize))
            {
                throw new ApplicationException(
                          String.Format(
                              "Raw input registration failed with error: {0}. Device: {1}",
                              Marshal.GetLastWin32Error(),
                              rid[0].ToString())
                          );
            }
            else
            {
                Debug.Print("Registered mouse {0}", mouse.ToString());
                System.Drawing.Point p = new System.Drawing.Point();
                if (Functions.GetCursorPos(ref p))
                {
                    mouse.Position = p;
                }
            }
        }
示例#3
0
 private static void RegisterKeyboardDevice(IntPtr window, string name)
 {
     RawInputDevice[] RawInputDevices = new RawInputDevice[1]
     {
         new RawInputDevice()
     };
     RawInputDevices[0].UsagePage = (short)1;
     RawInputDevices[0].Usage     = (short)6;
     RawInputDevices[0].Flags     = RawInputDeviceFlags.INPUTSINK;
     RawInputDevices[0].Target    = window;
     Functions.RegisterRawInputDevices(RawInputDevices, 1, API.RawInputDeviceSize);
 }
示例#4
0
        static void RegisterRawDevice(IntPtr window, string device)
        {
            RawInputDevice[] rid = new RawInputDevice[]
            {
                new RawInputDevice(HIDUsageGD.Mouse, RawInputDeviceFlags.INPUTSINK, window)
            };

            if (!Functions.RegisterRawInputDevices(rid, 1, API.RawInputDeviceSize))
            {
                Debug.Print("[Warning] Raw input registration failed with error: {0}. Device: {1}",
                            Marshal.GetLastWin32Error(), rid[0].ToString());
            }
            else
            {
                Debug.Print("Registered mouse {0}", device);
            }
        }
示例#5
0
        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;

            if (!Functions.RegisterRawInputDevices(rid, 1, API.RawInputDeviceSize))
            {
                Debug.Print("[Warning] Raw input registration failed with error: {0}. Device: {1}",
                            Marshal.GetLastWin32Error(), rid[0].ToString());
            }
            else
            {
                Debug.Print("Registered keyboard {0}", name);
            }
        }
示例#6
0
 internal void RegisterKeyboardDevice(KeyboardDevice kb)
 {
     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;
     if (!Functions.RegisterRawInputDevices(rid, 1, API.RawInputDeviceSize))
     {
         throw new ApplicationException(
                   String.Format(
                       "Raw input registration failed with error: {0}. Device: {1}",
                       Marshal.GetLastWin32Error(),
                       rid[0].ToString())
                   );
     }
     else
     {
         Debug.Print("Registered keyboard {0}", kb.ToString());
     }
 }