Ejemplo n.º 1
0
        internal HidDevice(HidControl control, string devicePath)
        {
            controller = control;

            dev = new DeviceAccess(devicePath);

            if (dev.OpenDeviceForIoctl())
            {
                NativeApi.HidD_GetAttributes(dev.Handle, ref Attributes);

                using (HidPreparsedData preparsedData = new HidPreparsedData(dev.Handle))
                {
                    NativeApi.HidP_GetCaps(preparsedData.Handle, ref Capabilities);
                }

                if (dev.OpenDeviceForRead())
                {
                    ReadThread = new DeviceReadThread(new DeviceAccess(devicePath), new ReceivedReportDelegate(InputPipeReportHandler));
                }
                else
                {
                    ReadThread = null;
                }
            }
            else
            {
                throw new Exception("Unable to access device!");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Clean up managed and unmanged ressources by hand.
        /// </summary>
        /// <param name="Disposing"></param>
        protected void Dispose(bool Disposing)
        {
            if (!IsDisposed)
            {
                if (Disposing)
                {
                    //Clean Up managed resources
                    Disconnect();
                    m_HidControl = null;
                    m_IHidDevice = null;
                    m_Sensor.Dispose();
                    m_Keyboard.Dispose();

                    //Ensure we clean-up references to event
                    m_DeviceChange = null;
                }
                //Clean up unmanaged resources

            }
            IsDisposed = true;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Default constructor needed by COM to create objects.
 /// </summary>
 public Device()
 {
     m_HidControl = HidControl.GetInstance();
 }