public static void handler(object sender, System.EventArgs e) { USBHIDDRIVER.List.ListWithEvent ev = (USBHIDDRIVER.List.ListWithEvent)sender; foreach (object o in ev) { if (o is byte[]) { byte[] data = (byte[])o; string s = ""; for (int i = 0; i < data.Length; i++) { s += data[i]; if (i + 1 < data.Length) { s += ", "; } } Console.WriteLine("{" + s + "}"); } } ev.Clear(); }
static void HIDhandler(object sender, System.EventArgs e) { USBHIDDRIVER.List.ListWithEvent ev = (USBHIDDRIVER.List.ListWithEvent)sender; foreach (object o in ev) { if (o is byte[]) { byte[] data = (byte[])o; byte stat = data[1]; if (FCstatus != FCPedal.Invalid) { if ((((byte)FCPedal.Left) & stat) != 0) { if ((byte)(FCPedal.Left & FCstatus) == 0) //down event { Bleft = true; Console.WriteLine("+" + Left); if (VirtualKeys) { System.Windows.Forms.SendKeys.SendWait(VKeyLeft); } } } else if (Bleft) { Bleft = false; Console.WriteLine("-" + Left); } if ((((byte)FCPedal.Middle) & stat) != 0) { if ((byte)(FCPedal.Middle & FCstatus) == 0) //down event { Bmiddle = true; Console.WriteLine("+" + Middle); if (VirtualKeys) { System.Windows.Forms.SendKeys.SendWait(VKeyMiddle); } } } else if (Bmiddle) { Bmiddle = false; Console.WriteLine("-" + Middle); } if ((((byte)FCPedal.Right) & stat) != 0) { if ((byte)(FCPedal.Right & FCstatus) == 0) //down event { Bright = true; Console.WriteLine("+" + Right); if (VirtualKeys) { System.Windows.Forms.SendKeys.SendWait(VKeyRight); } } } else if (Bright) { Bright = false; Console.WriteLine("-" + Right); } } FCstatus = (FCPedal)stat; } } ev.Clear(); }