예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RawKeyboard"/> class.
        /// </summary>
        /// <param name="hwnd">
        /// The hwnd.
        /// </param>
        /// <exception cref="ApplicationException">
        /// </exception>
        public RawKeyboard(IntPtr hwnd)
        {
            var rid = new RawInputDevice[1];

            rid[0].UsagePage = HidUsagePage.GENERIC;
            rid[0].Usage = HidUsage.Keyboard;
            rid[0].Flags = RawInputDeviceFlags.INPUTSINK;
            rid[0].Target = hwnd;

            if (!Win32.RegisterRawInputDevices(rid, (uint)rid.Length, (uint)Marshal.SizeOf(rid[0])))
            {
                throw new ApplicationException("Failed to register raw input device(s).");
            }
        }
예제 #2
0
파일: Win32.cs 프로젝트: mparsin/Elements
 internal static extern bool RegisterRawInputDevices(RawInputDevice[] pRawInputDevice, uint numberDevices, uint size);