Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="deviceHandle"></param>
        /// <returns></returns>
        private static Native.DeviceInfo GetDeviceInfo(IntPtr deviceHandle)
        {
            var ptrDeviceInfo = GetDeviceData(
                deviceHandle,
                Native.RawInputDeviceInfoCommand.DeviceInfo);

            if (ptrDeviceInfo == IntPtr.Zero)
            {
                return(new Native.DeviceInfo());
            }

            Native.DeviceInfo deviceInfo = (Native.DeviceInfo)Marshal.PtrToStructure(
                ptrDeviceInfo, typeof(Native.DeviceInfo));

            Marshal.FreeHGlobal(ptrDeviceInfo);
            return(deviceInfo);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rawInputDeviceList"></param>
        /// <returns></returns>
        protected HIDDevice CreateHIDDeviceFrom(Native.RawInputDeviceList rawInputDeviceList)
        {
            Native.DeviceInfo deviceInfo = GetDeviceInfo(rawInputDeviceList.DeviceHandle);
            //  UnityEngine.Debug.Log("PID:" + deviceInfo.HIDInfo.ProductID + " VID:" + deviceInfo.HIDInfo.VendorID);

            string devicePath = GetDevicePath(rawInputDeviceList.DeviceHandle);



            // string name = ReadRegKey(Native.HKEY_LOCAL_MACHINE, @"SYSTEM\CurrentControlSet\Control\MediaProperties\PrivateProperties\Joystick\OEM\" + "VID_" + deviceInfo.HIDInfo.VendorID.ToString("X4") + "&PID_" + deviceInfo.HIDInfo.ProductID.ToString("X4"), Native.REGSTR_VAL_JOYOEMNAME);


            //devicePath used as ID
            return(new GenericHIDDevice(GetIndexForDeviceWithID(devicePath), Convert.ToInt32(deviceInfo.HIDInfo.VendorID), Convert.ToInt32(deviceInfo.HIDInfo.ProductID), devicePath, rawInputDeviceList.DeviceHandle, this, devicePath));

            //this have problems with
            // return GetHIDDeviceInfo(GetDevicePath(rawInputDeviceList.DeviceHandle));
        }