//static USBHIDDRIVER.USBInterface usbI = new USBInterface("vid_3353", "pid_3713"); public static void Main(string[] args) { bool conn = usbI.Connect(); usbI.enableUsbBufferEvent(new EventHandler(handler)); Thread.Sleep(5); usbI.startRead(); //Console.Write("Press any key to continue . . . "); Console.ReadKey(true); }
public static void Start() { usb = new USBInterface(vid, pid); Console.WriteLine("USB Connection: "+usb.Connect()); usb.startRead(); //usb.stopRead(); //MyPause(); }
private static void Main(string[] args) { var usb = new USBInterface(@"vid_0a81", @"pid_ff01"); usb.Connect(); WriteData(usb, 64); WriteData(usb, 16); WriteData(usb, 64); WriteData(usb, 64); WriteData(usb, 32); Console.ReadLine(); }
public UsbHID(string vendorId, string productId) { usb = new USBInterface(vendorId, productId); if (!usb.Connect()) { throw new InvalidOperationException("Usb can't connect to devices"); return; } usbLog = new Log(productId, vendorId); usbLog.connectLog(); }
private static void Main(string[] args) { _device = new USBInterface("vid_1294", "pid_1320"); _device.Connect(); var line = Console.ReadLine(); while (line != null && line != "E") { var b = Convert.ToByte(line); WriteDataEx(b); line = Console.ReadLine(); } Console.ReadLine(); }
static void Main(string[] args) { var usb = new USBInterface(@"vid_0a81", @"pid_ff01"); usb.Connect(); // sample to file a missile WriteData(usb, 8); Thread.Sleep(2000); WriteData(usb, 0); Thread.Sleep(2500); WriteData(usb, 8); Thread.Sleep(2500); WriteData(usb, 0); Thread.Sleep(2500); Console.ReadLine(); }
private void Form1_Load(object sender, EventArgs e) { keyMapping["101"] = 0xAF; //"VOLUME_UP" keyMapping["102"] = 0xAE; //"VOLUME_DOWN" keyMapping["110"] = 0xB3; //"MEDIA_PLAY_PAUSE" keyMapping["120"] = 0xB0; //"MEDIA_NEXT" keyMapping["140"] = 0xB1; //"MEDIA_PREVIOUS" if (usb.Connect()) { updateConnectionStatus(true); } else { updateConnectionStatus(false); } usb.write(new byte[] { 0 }); usb.enableUsbBufferEvent(new System.EventHandler(headsetEventCatcher)); usb.startRead(); this.Show(); while (true) { Application.DoEvents(); if (usbOut != "" && usbOut.Length == 3) { if (keyMapping.ContainsKey(usbOut)) { if (settingsMode) { //pressedLabel.Text = usbOut; currentAssignmentText.Text = keyMapping[usbOut].ToString(); } else { //SendKeys.Send("{" + keyMapping[usbOut] + "}"); keybd_event(keyMapping[usbOut], 0, KEYEVENTF_EXTENDEDKEY, 0); keybd_event(keyMapping[usbOut], 0, KEYEVENTF_KEYUP, 0); } } usbOut = ""; } System.Threading.Thread.Sleep(100); } }
private static void Main(string[] args) { Console.WriteLine("Press key (1 ... 8) to change color in Light Notifier"); Console.WriteLine("Press key (E) to exit app"); Console.WriteLine("Press other key to crash the app"); _device = new USBInterface("vid_1294", "pid_1320"); _device.Connect(); var line = Console.ReadLine(); while (line != null && line.ToUpper() != "E") { var b = Convert.ToByte(line); WriteDataEx(b); line = Console.ReadLine(); } Console.ReadLine(); }
public static void Find() { USBInterface = new USBInterface("vid_067b", "pid_2303"); USBInterface.Connect(); }
static void Main(string[] args) { try { if (args.Length > 0) VirtualKeys = false; string VID = ConfigurationManager.AppSettings["VID"] ?? "vid_05f3"; string PID = ConfigurationManager.AppSettings["PID"] ?? "pid_00ff"; Left = ConfigurationManager.AppSettings["Left"] ?? "L"; Middle = ConfigurationManager.AppSettings["Middle"] ?? "M"; Right = ConfigurationManager.AppSettings["Right"] ?? "R"; VKeyLeft = ConfigurationManager.AppSettings["Left"] ?? "{LEFT}"; VKeyMiddle = ConfigurationManager.AppSettings["Middle"] ?? " "; VKeyRight = ConfigurationManager.AppSettings["Right"] ?? "{RIGHT}"; usbI = new USBInterface(VID, PID); savehandle = new EventHandler(HIDhandler); bool conn = usbI.Connect(); if (conn) { usbI.enableUsbBufferEvent(savehandle); Thread.Sleep(5); usbI.startRead(); } Console.Read(); if (conn) { usbI.stopRead(); try { usbI.Disconnect(); } catch { } } } finally { Environment.Exit(0); //Force close application } }
static void Main(string[] args) { if (args.Length > 0) VirtualKeys = false; string VID = ConfigurationManager.AppSettings["VID"] ?? "vid_05f3"; string PID = ConfigurationManager.AppSettings["PID"] ?? "pid_00ff"; Left = ConfigurationManager.AppSettings["Left"] ?? "L"; Middle = ConfigurationManager.AppSettings["Middle"] ?? "M"; Right = ConfigurationManager.AppSettings["Right"] ?? "R"; VKeyLeft = ConfigurationManager.AppSettings["Left"] ?? "{LEFT}"; VKeyMiddle = ConfigurationManager.AppSettings["Middle"] ?? " "; VKeyRight = ConfigurationManager.AppSettings["Right"] ?? "{RIGHT}"; usbI = new USBInterface(VID, PID); savehandle = new EventHandler(HIDhandler); bool conn = usbI.Connect(); if (conn) { usbI.enableUsbBufferEvent(savehandle); Thread.Sleep(5); usbI.startRead(); } else Console.WriteLine("Cannot connect to device"); Console.Read(); if (conn) { usbI.stopRead(); try { usbI.Disconnect(); } catch { } } System.Diagnostics.Process.GetCurrentProcess().Kill(); }