/// <summary> /// Constructor taking a device handle. From this device handle /// very specific device information can be found. /// </summary> public MouseDevice(IntPtr hDevice) : base(hDevice) { // Now get more detailed information RID_DEVICE_INFO deviceInfo = RawInputDevice.GetRawInputDeviceInfo(fDeviceHandle); fMouseID = (int)deviceInfo.Union1.mouse.dwId; fNumButtons = (int)deviceInfo.Union1.mouse.dwNumberOfButtons; fSampleRate = (int)deviceInfo.Union1.mouse.dwSampleRate; fRIDRegister = new RAWINPUTDEVICE(); if (ClassName != null) { IsPhysical = ClassName.ToUpper() == "MOUSE"; } }
/// <summary> /// Constructor taking a device handle. From this device handle /// very specific device information can be found. /// </summary> public HIDDevice(IntPtr hDevice) : base(hDevice) { // Now get more detailed information RID_DEVICE_INFO deviceInfo = RawInputDevice.GetRawInputDeviceInfo(fDeviceHandle); dwProductId = deviceInfo.Union1.hid.dwProductId; dwVendorId = deviceInfo.Union1.hid.dwVendorId; dwVersionNumber = deviceInfo.Union1.hid.dwVersionNumber; usUsage = deviceInfo.Union1.hid.usUsage; usUsagePage = deviceInfo.Union1.hid.usUsagePage; fRIDRegister = new RAWINPUTDEVICE(); if (ClassName != null) { IsPhysical = ClassName.ToUpper() == "HIDCLASS"; } }
/// <summary> /// Register a raw input device based on a structure being passed in. /// </summary> /// <param name="device">Device information.</param> /// <returns>TRUE if successful, FALSE if not.</returns> public static bool RegisterRawInputDevice(RAWINPUTDEVICE device) { RAWINPUTDEVICE[] devices = new RAWINPUTDEVICE[1]; // Raw input devices. devices[0] = device; return RegisterRawInputDevices(devices, 1, Marshal.SizeOf(typeof(RAWINPUTDEVICE))); }
public static extern bool RegisterRawInputDevices(RAWINPUTDEVICE[] pRawInputDevices, uint uiNumDevices, int cbSize);