Example #1
0
        public static bool Parse(HidInputEventArgs hidInput, out List <ushort> pressedButtons)
        {
            var preparsedData = IntPtr.Zero;

            pressedButtons = new List <ushort>();

            try
            {
                preparsedData = GetPreparsedData(hidInput.Device);
                if (preparsedData == IntPtr.Zero)
                {
                    return(false);
                }

                HIDP_CAPS hidCaps;
                CheckError(HidP_GetCaps(preparsedData, out hidCaps));

                pressedButtons = GetPressedButtons(hidCaps, preparsedData, hidInput.RawData);
            }
            catch (Win32Exception e)
            {
                return(false);
            }
            finally
            {
                if (preparsedData != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(preparsedData);
                }
            }

            return(true);
        }
Example #2
0
        private void HandleRawInput(object sender, RawInputEventArgs e)
        {
            HidInputEventArgs hidArgs = e as HidInputEventArgs;

            if (hidArgs == null || HidInputEvent == null)
            {
                return;
            }
            HidInputEvent(sender, new HidEventArgs(hidArgs));
        }
Example #3
0
 public HidEventArgs(HidInputEventArgs e)
 {
     Count    = e.Count;
     DataSize = e.DataSize;
     RawData  = e.RawData;
 }