Пример #1
0
        /// <summary>
        /// Identifies the handler for a device.
        /// </summary>
        /// <param name="lParam">The handle to a raw input dataset.</param>
        /// <param name="rih">Returns the <see cref="RAWINPUTHEADER"/> of the raw input dataset.</param>
        /// <returns>The id of the handler.</returns>
        public T GetHandlerFromWmInput(IntPtr lParam, out RAWINPUTHEADER rih)
        {
            rih = RawInput.GetRawInputDataHeader(lParam);

            T ret;

            if (!front.TryGetValue(rih.hDevice, out ret))
            {
                return(default(T));
            }

            return(ret);
        }
Пример #2
0
        /// <summary>
        /// Retrieves the raw input header from the specified device.
        /// </summary>
        /// <remarks>See <see cref="GetRawInputData"/> for more information.</remarks>
        /// <param name="hRawInput">A handle to the <see cref="RAWINPUT"/> structure. This comes from the
        /// <b>lParam</b> in <see cref="WM.INPUT">WM_INPUT</see>.</param>
        /// <returns>The raw input header as <see cref="RAWINPUTHEADER"/>.</returns>
        public static RAWINPUTHEADER GetRawInputDataHeader(HRAWINPUT hRawInput)
        {
            uint size = RAWINPUTHEADER.SIZE;

            RAWINPUTHEADER ret = new RAWINPUTHEADER();

            ret.dwSize = size;

            uint err = GetRawInputDataH(hRawInput, RID.HEADER, ref ret, ref size, RAWINPUTHEADER.SIZE);

            if (err == uint.MaxValue)
            {
                throw new Exception(string.Format("Error getting header of WM_INPUT data. (Error code: 0x{0:X8})", WinKernel.GetLastError()));
            }

            return(ret);
        }
Пример #3
0
 extern static uint GetRawInputDataH(HRAWINPUT hRawInput, RID uiCommand, ref RAWINPUTHEADER pData, ref uint pcbSize, uint cbSizeHeader);