public UsbBlankGamepad(HidDevice device, string header, string dumpFileName) { VendorId = (short) device.VendorID; ProductId = (short) device.ProductID; _dumper = new DumpHelper(header, dumpFileName); }
public UsbBlankGamepad(string header, string dumpFileName) : this() { _dumper = new DumpHelper(header, dumpFileName); }
private void L2CapWorker(object o) { var token = (CancellationToken)o; var buffer = new byte[512]; var transfered = 0; Log.InfoFormat("-- Bluetooth : L2CAP_Worker_Thread Starting (IN: {0:X2}, OUT: {1:X2})", BulkIn, BulkOut); #if HID_REPORT_BENCH var sw = new Stopwatch(); var counter = 0; const int samples = 250; var values = new List<long>(samples); byte rate = 0x01; #endif #if HID_REPORT_DUMP var dumper = new DumpHelper(System.IO.Path.Combine(WorkingDirectory, string.Format("hid_{0}.dump", Guid.NewGuid()))); #endif // poll device buffer until cancellation requested while (!token.IsCancellationRequested) { try { #if HID_REPORT_BENCH sw.Restart(); #endif if (ReadBulkPipe(buffer, buffer.Length, ref transfered) && transfered > 0) { #if HID_REPORT_BENCH sw.Stop(); if (counter++ >= samples) { Log.DebugFormat("[{0:X2}] Average input delay: {1}", rate - 1, values.Average()); values.Clear(); counter = 0; rate++; } else { values.Add(sw.ElapsedMilliseconds); } #endif #if HID_REPORT_DUMP // for diagnostics only; dumps every received report to a file if (Settings.Default.DumpHidReports) dumper.DumpArray(buffer, transfered); #endif var connection = GetConnection(buffer[0], buffer[1]); if (connection == null) continue; if (connection.Model == DsModel.DS4) { ParseBufferDs4(connection, buffer, transfered); #if HID_REPORT_BENCH_INC if (counter == samples - 1) (connection as BthDs4).HidReportUpdateRate = rate; #endif } else { ParseBufferDs3(connection, buffer, transfered); } } } catch (Exception ex) { Log.ErrorFormat("Unexpected error in L2CAP_Worker_Thread: {0}", ex); } } Log.Info("-- Bluetooth : L2CAP_Worker_Thread Exiting"); }