/// <summary>
        /// Initializes the device via LibUSB, and sets the refresh interval of the controller data
        /// </summary>
        /// <param name="Interval">The interval that the device is polled for information.</param>
        public void Init(int Interval)
        {
            //ErrorCode ec = ErrorCode.None;

            //zadig creates a new device GUID everytime you install, so I placed file in
            //C:\Users\salds_000\Documents\Visual Studio 2013\Projects\steel_batallion-64\steelbattalionnet\winusb\usb_driver
            //check inf file for guid. Right clicking the inf file installs it.

            //after installation you can find this in regedit
            //HKEY_LOCAL_MACHINE\System\CurrentControlSet\Enum\USB\VID_0A7B&PID_D000\6&688a3b8&0&1\Device Parameters\DeviceInterfaceGUIDs
            USBDeviceInfo[] details = USBDevice.GetDevices("{5C2B3F1A-E9B8-4BD6-9D19-8A283B85726E}");
            USBDeviceInfo   match   = details.First(info => info.VID == 0x0A7B && info.PID == 0xD000);

            MyUsbDevice = new USBDevice(match);
            reader      = MyUsbDevice.Interfaces.First().InPipe;
            writer      = MyUsbDevice.Interfaces.First().OutPipe;

            byte[] buf = new byte[64];

            reader.Read(buf);//can't remember why I do this.

            ButtonMasks.InitializeMasks();

            SetPollingInterval(Interval);
            pollTimer.Elapsed += new ElapsedEventHandler(pollTimer_Elapsed);
            pollTimer.Start();

            TestLEDs();
            if (updateGearLights)
            {
                GearLightsRefresh((int)unchecked ((sbyte)buf[25]));
            }
            RefreshLEDState();
        }
Пример #2
0
        /// <summary>
        /// Initializes the device via LibUSB, and sets the refresh interval of the controller data
        /// </summary>
        /// <param name="Interval">The interval that the device is polled for information.</param>
        public void Init(int Interval)
        {
            //ErrorCode ec = ErrorCode.None;


            //HKEY_LOCAL_MACHINE\System\CurrentControlSet\Enum\USB\VID_0A7B&PID_D000\6&688a3b8&0&1\Device Parameters\DeviceInterfaceGUIDs
            USBDeviceInfo[] details = USBDevice.GetDevices("{5C2B3F1A-E9B8-4BD6-9D19-8A283B85726E}");
            USBDeviceInfo   match   = details.First(info => info.VID == 0x0A7B && info.PID == 0xD000);

            MyUsbDevice = new USBDevice(match);
            reader      = MyUsbDevice.Interfaces.First().InPipe;
            writer      = MyUsbDevice.Interfaces.First().OutPipe;

            byte[] buf = new byte[64];

            reader.Read(buf);//can't remember why I do this.

            ButtonMasks.InitializeMasks();

            SetPollingInterval(Interval);
            pollTimer.Elapsed += new ElapsedEventHandler(pollTimer_Elapsed);
            pollTimer.Start();

            TestLEDs();
            if (updateGearLights)
            {
                GearLightsRefresh((int)unchecked ((sbyte)buf[25]));
            }
            RefreshLEDState();
        }
        /// <summary>
        /// Initializes the device via LibUSB, and sets the refresh interval of the controller data
        /// </summary>
        /// <param name="Interval">The interval that the device is polled for information.</param>
        public void Init(int Interval)
        {
            //ErrorCode ec = ErrorCode.None;

            // Find and open the usb device.
            MyUsbDevice = UsbDevice.OpenUsbDevice(MyUsbFinder);
            if (MyUsbDevice == null)
            {
                throw new Exception("Device Not Found.");
            }

            IUsbDevice wholeUsbDevice = MyUsbDevice as IUsbDevice;

            if (!ReferenceEquals(wholeUsbDevice, null))
            {
                wholeUsbDevice.SetConfiguration(1);
                wholeUsbDevice.ClaimInterface(0);
            }

            reader = MyUsbDevice.OpenEndpointReader(ReadEndpointID.Ep02);
            writer = MyUsbDevice.OpenEndpointWriter(WriteEndpointID.Ep01);

            ButtonMasks.InitializeMasks();

            SetPollingInterval(Interval);
            pollTimer.Elapsed += new ElapsedEventHandler(pollTimer_Elapsed);
            pollTimer.Start();

            TestLEDs();
            RefreshLEDState();
        }
Пример #4
0
        /// <summary>
        /// Initializes the device via LibUSB, and sets the refresh interval of the controller data
        /// </summary>
        /// <param name="Interval">The interval that the device is polled for information.</param>
        public void Init(int Interval)
        {
            //ErrorCode ec = ErrorCode.None;

            // Find and open the usb device.
            MyUsbDevice = UsbDevice.OpenUsbDevice(MyUsbFinder);
            if (MyUsbDevice == null)
            {
                throw new Exception("Device Not Found.");
            }

            IUsbDevice wholeUsbDevice = MyUsbDevice as IUsbDevice;

            if (!ReferenceEquals(wholeUsbDevice, null))
            {
                wholeUsbDevice.SetConfiguration(1);
                wholeUsbDevice.ClaimInterface(0);
            }

            reader = MyUsbDevice.OpenEndpointReader(ReadEndpointID.Ep02);
            writer = MyUsbDevice.OpenEndpointWriter(WriteEndpointID.Ep01);

            int readByteCount = 0;

            byte[] buf = new byte[64];
            reader.Read(buf, 0, 64, 1000, out readByteCount);


            ButtonMasks.InitializeMasks();

            SetPollingInterval(Interval);
            pollTimer.Elapsed += new ElapsedEventHandler(pollTimer_Elapsed);
            pollTimer.Start();

            TestLEDs();
            if (updateGearLights)
            {
                GearLightsRefresh((int)unchecked ((sbyte)buf[25]));
            }
            RefreshLEDState();
        }