public void MouseData(int dx, int dy, int dw, USBC_Mouse.Buttons buttons) { if (USBClientController.GetState() != USBClientController.State.Running || _KeyboardMouseClient == null) { return; } _KeyboardMouseClient.SendMouseData(dx, dy, dw, buttons); }
public void KeyUp(USBC_Key key) { if (USBClientController.GetState() != USBClientController.State.Running || _KeyboardMouseClient == null) { return; } _KeyboardMouseClient.KeyUp(key); }
public void Stop() { if (USBClientController.GetState() != USBClientController.State.Stopped) { USBClientController.Stop(); } _KeyboardMouseClient = null; }
public void Send(byte[] data) { if (USBClientController.GetState() == USBClientController.State.Running) { if (data != null && data.Length != 0) { cdc.Write(data, 0, data.Length); } } }
private static void InitDevice() { // Check debug interface if (Configuration.DebugInterface.GetCurrent() == Configuration.DebugInterface.Port.USB1) { throw new InvalidOperationException("Current debug interface is USB. It must be changed to something else before proceeding. Refer to your platform user manual to change the debug interface."); } ushort myVID = 0x1234; ushort myPID = 0x0006; ushort myDeviceVersion = 0x100; ushort myDeviceMaxPower = 250; // in milli amps string companyName = "DevDotNet.ORG"; string productName = "Virtual Keyboard and Mouse"; string myDeviceSerialNumber = "12345"; // Create the device device = new USBC_Device(myVID, myPID, myDeviceVersion, myDeviceMaxPower, companyName, productName, myDeviceSerialNumber); // Add a Keyboard kb = new USBC_Keyboard(device, "FEZ Domino Keyboard Interface"); // Add a Mouse mouse = new USBC_Mouse(device, "FEZ Domino Mouse Interface"); // Start CDC // When ready, you can start your device as follows: USBClientController.Start(device); // Debug.Print("Waiting to connect to PC..."); bool isConnect = false; while (!isConnect) { // Check if connected to PC if (USBClientController.GetState() != USBClientController.State.Running) { Debug.Print("Waiting to connect to PC..."); } else { isConnect = true; } } }
static void stopButton_OnInterrupt(uint data1, uint data2, DateTime time) { Debug.Print(data1.ToString() + " " + data2.ToString()); led.Write(!led.Read()); state = USBClientController.GetState(); if (state != USBClientController.State.Stopped && state != USBClientController.State.Suspended) { //Write("Attempting to write a B."); if (data1 == 3) { keyboardDevice.KeyTap(USBC_Key.B); } else if (data1 == 8) { keyboardDevice.KeyTap(USBC_Key.S); } } }
public static void Main() { cdc = USBClientController.StandardDevices.StartCDC_WithDebugging(); UART = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One); UART.Open(); UART.Flush(); UART.DataReceived += new SerialDataReceivedEventHandler(UART_DataReceived); if (USBClientController.GetState() != USBClientController.State.Running) { Debug.Print("Waiting to connect to PC..."); } else { while (true) { UART.Flush(); Thread.Sleep(1000); } } }
static void collector_OnInterrupt(uint data1, uint data2, DateTime time) { // Right Engine: data1 == 41 // Left Engine: data1 == 40 if (data1 == 41) { currentEngine = leftEngine; } else if (data1 == 40) { currentEngine = rightEngine; } else { Debug.Print("Unknown engine: " + data1); return; } if (data2 == 0) // Edge going low, start of pulse. { currentEngine.sample = time; } else // Edge going high, end of pulse. { currentEngine.lastSample = currentEngine.sample; currentEngine.sample = time; currentEngine.pulseCodeComplete = !currentEngine.pulseCodeComplete; if (!currentEngine.pulseCodeComplete) { currentEngine.interval = (currentEngine.sample - currentEngine.lastSample).Ticks / 10000; } else { currentEngine.lastInterval = currentEngine.interval; currentEngine.interval = (currentEngine.sample - currentEngine.lastSample).Ticks / 10000; if (USBClientController.GetState() == USBClientController.State.Running) { if (currentEngine == leftEngine) { Debug.Print("x"); keyboardDevice.KeyTap(USBC_Key.X); } else { Debug.Print("."); keyboardDevice.KeyTap(USBC_Key.Period); } } Debug.Print(currentEngine.lastInterval + "/" + currentEngine.interval + ", rotation direction: " + (currentEngine.IsForward ? "+" : "-")); // Reset timers. currentEngine.lastInterval = 0; currentEngine.interval = 0; currentEngine.sample = DateTime.MinValue; currentEngine.lastSample = DateTime.MinValue; } } }