コード例 #1
0
ファイル: HidDevice.cs プロジェクト: ClimbTheWorld/HidLibrary
        internal HidDevice(string devicePath)
        {
            this.devicePath = devicePath;

            try
            {
                var hidHandle = OpenDeviceIO(devicePath, NativeMethods.ACCESS_NONE);

                deviceAttributes = GetDeviceAttributes(hidHandle);
                deviceCapabilities = GetDeviceCapabilities(hidHandle);

                CloseDeviceIO(hidHandle);
            }
            catch (Exception exception)
            {
                throw new Exception(string.Format("Error querying HID device '{0}'.", devicePath), exception);
            }

            deviceEventMonitor = new HidDeviceEventMonitor(this);
            deviceEventMonitor.Inserted += DeviceEventMonitorInserted;
            deviceEventMonitor.Removed += DeviceEventMonitorRemoved;

            readWorker = new BackgroundWorker<HidDeviceData>();
            readWorker.Updated += new EventHandler<EventArgs<HidDeviceData>>(readWorker_Updated);
            readWorker.DoWork += new System.ComponentModel.DoWorkEventHandler(readWorker_DoWork);
        }
コード例 #2
0
		internal HidDevice(string devicePath, string description = null)
        {
            _deviceEventMonitor = new HidDeviceEventMonitor(this);
            _deviceEventMonitor.Inserted += DeviceEventMonitorInserted;
            _deviceEventMonitor.Removed += DeviceEventMonitorRemoved;

            _devicePath = devicePath;
            _description = description;

            try
            {
                var hidHandle = OpenDeviceIO(_devicePath, NativeMethods.ACCESS_NONE);

                _deviceAttributes = GetDeviceAttributes(hidHandle);
                _deviceCapabilities = GetDeviceCapabilities(hidHandle);
                Serial = GetIndexedString(hidHandle, 3);
                ManufacturerName = GetIndexedString(hidHandle, 1);
                ProductName = GetIndexedString(hidHandle, 2);

                CloseDeviceIO(hidHandle);
            }
            catch (Exception exception)
            {
                throw new Exception(string.Format("Error querying HID device '{0}'.", devicePath), exception);
            }
        }
コード例 #3
0
        internal HidDevice(string devicePath)
        {
            this.devicePath = devicePath;

            try
            {
                var hidHandle = OpenDeviceIO(devicePath, NativeMethods.ACCESS_NONE);

                deviceAttributes   = GetDeviceAttributes(hidHandle);
                deviceCapabilities = GetDeviceCapabilities(hidHandle);

                CloseDeviceIO(hidHandle);
            }
            catch (Exception exception)
            {
                throw new Exception(string.Format("Error querying HID device '{0}'.", devicePath), exception);
            }

            deviceEventMonitor           = new HidDeviceEventMonitor(this);
            deviceEventMonitor.Inserted += DeviceEventMonitorInserted;
            deviceEventMonitor.Removed  += DeviceEventMonitorRemoved;

            readWorker          = new BackgroundWorker <HidDeviceData>();
            readWorker.Updated += new EventHandler <EventArgs <HidDeviceData> >(readWorker_Updated);
            readWorker.DoWork  += new System.ComponentModel.DoWorkEventHandler(readWorker_DoWork);
        }
コード例 #4
0
ファイル: HidDevice.cs プロジェクト: wdatkinson/KFDtool
 internal HidDevice(string devicePath, string description = null)
 {
     _deviceEventMonitor           = new HidDeviceEventMonitor(this);
     _deviceEventMonitor.Inserted += DeviceEventMonitorInserted;
     _deviceEventMonitor.Removed  += DeviceEventMonitorRemoved;
     _devicePath  = devicePath;
     _description = description;
     try
     {
         IntPtr intPtr = OpenDeviceIO(_devicePath, 0u);
         _deviceAttributes   = GetDeviceAttributes(intPtr);
         _deviceCapabilities = GetDeviceCapabilities(intPtr);
         CloseDeviceIO(intPtr);
     }
     catch (Exception innerException)
     {
         throw new Exception($"Error querying HID device '{devicePath}'.", innerException);
     }
 }
コード例 #5
0
ファイル: HidDevice.cs プロジェクト: xammer23/DS4Windows
        internal HidDevice(string devicePath, string description = null)
        {
            _devicePath  = devicePath;
            _description = description;

            try
            {
                var hidHandle = OpenHandle(_devicePath, false);

                _deviceAttributes   = GetDeviceAttributes(hidHandle);
                _deviceCapabilities = GetDeviceCapabilities(hidHandle);

                hidHandle.Close();
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                throw new Exception(string.Format("Error querying HID device '{0}'.", devicePath), exception);
            }
        }
コード例 #6
0
        internal HidDevice(string devicePath, string description = null)
        {
            _deviceEventMonitor = new HidDeviceEventMonitor(this);
            _devicePath         = devicePath;
            _description        = description;

            try
            {
                var hidHandle = OpenDeviceIO(_devicePath, NativeMethods.ACCESS_NONE);

                _deviceAttributes   = GetDeviceAttributes(hidHandle);
                _deviceCapabilities = GetDeviceCapabilities(hidHandle);

                CloseDeviceIO(hidHandle);
            }
            catch (Exception exception)
            {
                throw new Exception(string.Format("Error querying HID device '{0}'.", devicePath), exception);
            }
        }
コード例 #7
0
ファイル: HidDevice.cs プロジェクト: Swizzy/ControllerTester
        internal HidDevice(string devicePath, string description = null)
        {
            _deviceEventMonitor = new HidDeviceEventMonitor(this);
            _deviceEventMonitor.Removed += DeviceEventMonitorRemoved;

            _devicePath = devicePath;
            _description = description;

            try {
                var hidHandle = OpenHandle(_devicePath, false);

                _deviceAttributes = GetDeviceAttributes(hidHandle);
                _deviceCapabilities = GetDeviceCapabilities(hidHandle);

                hidHandle.Close();
            }
            catch(Exception exception) {
                Console.WriteLine(exception.Message);
                throw new Exception(string.Format("Error querying HID device '{0}'.", devicePath), exception);
            }
        }
コード例 #8
0
ファイル: HidDevice.cs プロジェクト: GotenXiao/blink1
        internal HidDevice(string devicePath)
        {
            _deviceEventMonitor = new HidDeviceEventMonitor(this);
            _deviceEventMonitor.Inserted += DeviceEventMonitorInserted;
            _deviceEventMonitor.Removed += DeviceEventMonitorRemoved;

            _devicePath = devicePath;

            try
            {
                var hidHandle = OpenDeviceIO(_devicePath, NativeMethods.ACCESS_NONE);

                _deviceAttributes = GetDeviceAttributes(hidHandle);
                _deviceCapabilities = GetDeviceCapabilities(hidHandle);

                CloseDeviceIO(hidHandle);
            }
            catch (Exception exception)
            {
                throw new Exception(string.Format("Error querying HID device '{0}'.", devicePath), exception);
            }
        }