コード例 #1
0
ファイル: RawDevices.cs プロジェクト: MSH3P/2ndKeyboard
        public static RAWINPUT GetRawInputData(IntPtr handle)
        {
            int dwSize = 0;

            RawDevices.GetRawInputData(handle, RawDevices.RawInputCommand.Input, IntPtr.Zero, ref dwSize, Marshal.SizeOf <RawDevices.RAWINPUTHEADER>());
            IntPtr buffer = Marshal.AllocHGlobal((int)dwSize);

            RawDevices.GetRawInputData(handle, RawDevices.RawInputCommand.Input, buffer, ref dwSize, Marshal.SizeOf <RawDevices.RAWINPUTHEADER>());

            return((RawDevices.RAWINPUT)Marshal.PtrToStructure(buffer, typeof(RawDevices.RAWINPUT)));
        }
コード例 #2
0
ファイル: RawDevices.cs プロジェクト: MSH3P/2ndKeyboard
        public static void RegisterInputDevice(IntPtr windowHandle)
        {
            RAWINPUTDEVICELIST[] devices = GetDeviceList();

            RAWINPUTDEVICE[] rawInputDevice = new RAWINPUTDEVICE[1];
            rawInputDevice[0].UsagePage    = 1;
            rawInputDevice[0].Usage        = 6;
            rawInputDevice[0].Flags        = 0x00000100;
            rawInputDevice[0].WindowHandle = windowHandle;

            bool result = RawDevices.RegisterRawInputDevices(rawInputDevice, (uint)rawInputDevice.Length, (uint)Marshal.SizeOf(rawInputDevice[0]));
        }
コード例 #3
0
 private void Window_Shown(object sender, EventArgs e)
 {
     RawDevices.RegisterInputDevice(this.Handle);
     InstallingHook(this.Handle);
 }