Ejemplo n.º 1
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;
                }
            }
        }
Ejemplo n.º 2
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);
 }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
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());
     }
 }
Ejemplo n.º 6
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);
            }
        }
Ejemplo n.º 7
0
 internal static extern BOOL RegisterRawInputDevices(
     RawInputDevice[] RawInputDevices,
     INT NumDevices,
     INT Size
 );
Ejemplo n.º 8
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);
 }
Ejemplo n.º 9
0
        static void RegisterKeyboardDevice(IntPtr window, string name)
        {
            RawInputDevice[] rid = new RawInputDevice[]
            {
                new RawInputDevice(HIDUsageGD.Keyboard, 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 keyboard {0}", name);
            }
        }
Ejemplo n.º 10
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());
            }
        }
Ejemplo n.º 11
0
 internal static bool RegisterRawInputDevices(RawInputDevice[] RawInputDevices, int NumDevices, int Size);
Ejemplo n.º 12
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());
                Point p = new Point();
                if (Functions.GetCursorPos(ref p))
                    mouse.Position = p;
            }
        }