protected override DeviceStream OpenDeviceDirectly(OpenConfiguration openConfig) { var stream = new MacHidStream(this); try { stream.Init(_path); return(stream); } catch { stream.Close(); throw; } }
protected override DeviceStream OpenDeviceDirectly(OpenConfiguration openConfig) { var stream = new WinSerialStream(this); stream.Init(DevicePath); return(stream); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); app.UseExceptionHandler("/Shared/Error"); } app.UseCors(builder => { //builder.WithOrigins("http://localhost:55811").AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod(); builder.AllowAnyOrigin(); builder.AllowAnyHeader(); builder.AllowAnyMethod(); builder.AllowCredentials(); }); app.UseStaticHttpContext(); OpenConfiguration.Configure(Configuration); app.UseSession(); app.UseHttpsRedirection(); //异常中间件 // app.UseMiddleware(typeof(ErrorHandlingMiddleware)); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v2/swagger.json", "OneTest API V1"); c.ShowRequestHeaders(); }); //app.UseAuthentication(); app.UseIocConfiguration(); app.UseResponseCompression(); app.UseMvc(); app.UseSignalR(routes => { routes.MapHub <ChatHub>("/chatHub"); }); app.UseSignalR(routes => { routes.MapHub <ChatHubNew>("/ChatHubNew"); }); }
public BleStream Open(BleService service, OpenConfiguration openConfig) { Throw.If.Null(service).Null(openConfig); openConfig = openConfig.Clone(); openConfig.SetOption(OpenOption.BleService, service); return(Open(openConfig)); }
protected override DeviceStream OpenDeviceDirectly(OpenConfiguration openConfig) { var streamPath = GetStreamPath(openConfig); var stream = new WinBleStream(this, GetService(openConfig)); try { stream.Init(streamPath); return(stream); } catch { stream.Close(); throw; } }
protected override DeviceStream OpenDeviceDirectly(OpenConfiguration openConfig) { RequiresGetInfo(GetInfoFlags.ReportInfo); var stream = new WinHidStream(this); try { stream.Init(_path, openConfig); return(stream); } catch { stream.Close(); throw; } }
private void Setup() { var config = new OpenConfiguration(); config.SetOption(OpenOption.Priority, OpenPriority.Low); for (int retries = 3; retries > 0; retries--) { if (Device.TryOpen(config, out var stream, out var exception)) { ReportStream = (HidStream)stream; break; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); OpenConfiguration.Configure(Configuration); //app.UseMvc(routes => //{ // routes.MapRoute( // name: "default", // template: "{controller=Home}/{action=Index}/{id?}"); //}); var logic = (IUserLogic)app.ApplicationServices.GetService(typeof(IUserLogic)); var list = logic.GetAll(); var apiList = new List <string>() { "One", "Two" }; app.UseSwagger(c => { c.RouteTemplate = "/{documentName}/swagger.json"; }); app.UseSwaggerUI(c => { apiList.ForEach(apiItem => { c.SwaggerEndpoint($"/{apiItem}/{apiItem}/swagger.json", apiItem); }); c.ShowRequestHeaders(); }); app.UseOcelot().Wait(); }
public void init_hid_device() { //var device_list = (from x in hid.enumerate(this.VENDOR_ID, this.PRODUCT_ID) // where x["interface_number"] == this.IFACE_NUM // select x).ToList(); //if (device_list.Count == 0) //{ // throw Exception("No devices found. See: https://github.com/gfduszynski/cm-rgb/issues/9"); //} //this.device = hid.device(); //try //{ // this.device.open_path(device_list[0]["path"]); //} //catch (OSError) //{ // Console.WriteLine("Failed to access usb device. See: https://github.com/gfduszynski/cm-rgb/wiki/1.-Installation-&-Configuration#3-configuration"); // Console.WriteLine("Also check if other process is not using the device.\n"); // throw; //} var terp = new OpenConfiguration(); terp.SetOption(OpenOption.Exclusive, true); var loader = new HidDeviceLoader(); var devices = loader.GetDevices(VENDOR_ID, PRODUCT_ID).ToArray(); foreach (var tdevice in devices) { try { stream = tdevice.Open(terp); this.init_controller(); Debug.WriteLine("Well, that seemed to work"); break; } catch (Exception e) { Debug.WriteLine(e.Message); } } }
void Monitor() { while (runMonitor) { var compatibleDevices = DeviceList.Local.GetHidDevices(StadiaController.VID, StadiaController.PID); var existingDevices = gamepads.Select(g => g._device).ToList(); var newDevices = compatibleDevices.Where(d => !existingDevices.Select(e => e.DevicePath).Contains(d.DevicePath)); foreach (var gamepad in gamepads.ToList()) { if (!gamepad.running) { gamepads.Remove(gamepad); } } foreach (var deviceInstance in newDevices) { var device = deviceInstance; HidStream stream; try { reEnableDevice(devicePathToInstanceId(device.DevicePath)); OpenConfiguration oc = new OpenConfiguration(); oc.SetOption(OpenOption.Exclusive, true); oc.SetOption(OpenOption.Priority, OpenPriority.VeryHigh); stream = device.Open(oc); } catch { stream = device.Open(); } var usedIndexes = gamepads.Select(g => g._index); int index = 1; while (usedIndexes.Contains(index)) { index++; } gamepads.Add(new StadiaController(device, stream, client, index)); } Thread.Sleep(1000); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); app.UseExceptionHandler("/Shared/Error"); } //app.ApplicationServices.GetService app.UseCors(builder => { builder.AllowAnyOrigin(); builder.AllowAnyHeader(); builder.AllowAnyMethod(); }); app.UseStaticHttpContext(); OpenConfiguration.Configure(Configuration); app.UseSession(); app.UseHttpsRedirection(); //异常中间件 app.UseMiddleware(typeof(ErrorHandlingMiddleware)); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v2/swagger.json", "OneTest API V1"); c.ShowRequestHeaders(); }); app.UseMvc(); }
internal void Init(string path, OpenConfiguration openConfig) { IntPtr handle = NativeMethods.CreateFileFromDevice(path, NativeMethods.EFileAccess.Read | NativeMethods.EFileAccess.Write, openConfig.IsOptionSet(OpenOption.Exclusive) ? NativeMethods.EFileShare.None : NativeMethods.EFileShare.Read | NativeMethods.EFileShare.Write); if (handle == (IntPtr)(-1)) { throw DeviceException.CreateIOException(Device, "Unable to open HID class device (" + path + ")."); } int maxInputBuffers = Environment.OSVersion.Version >= new Version(5, 1) ? 512 : 200; // Windows 2000 supports 200. Windows XP supports 512. if (!NativeMethods.HidD_SetNumInputBuffers(handle, maxInputBuffers)) { NativeMethods.CloseHandle(handle); throw new IOException("Failed to set input buffers.", new Win32Exception()); } _handle = handle; HandleInitAndOpen(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseBrowserLink(); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseCors(builder => { builder.AllowAnyOrigin(); builder.AllowAnyHeader(); builder.AllowAnyMethod(); }); app.UseStaticHttpContext(); OpenConfiguration.Configure(Configuration); app.UseSession(); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); app.UseSignalR(routes => { routes.MapHub <ChatHub>("/chatHub"); }); }
static void InitializeDevices() { exclusive = new OpenConfiguration(); exclusive.SetOption(OpenOption.Exclusive, true); exclusive.SetOption(OpenOption.Interruptible, false); corsairLNP = DeviceList.Local.GetHidDevices().Where(d => d.ProductID == 0x0C0B).First(); lnpStream = corsairLNP.Open(exclusive); LightingNodeUtils.FirstTransaction(lnpStream); surface = RGBSurface.Instance; surface.Exception += args => Debug.WriteLine(args.Exception.Message); surface.LoadDevices(AsusDeviceProvider.Instance, RGBDeviceType.Mainboard); surface.LoadDevices(CorsairDeviceProvider.Instance); auraMb = surface.Devices.OfType <AsusMainboardRGBDevice>().First(); auraMb.UpdateMode = DeviceUpdateMode.SyncBack; corsairKeyboard = surface.Devices.OfType <CorsairKeyboardRGBDevice>().First(); corsairMousepad = surface.Devices.OfType <CorsairMousepadRGBDevice>().First(); corsairHeadsetStand = surface.Devices.OfType <CorsairHeadsetStandRGBDevice>().First(); GetAsusColors(); }
public List <IT8297ControlDevice> GetDevices() { var mbmanu = MotherboardInfo.Manufacturer; var mbmodel = MotherboardInfo.Model; var mbpn = MotherboardInfo.PartNumber; var mbproduct = MotherboardInfo.Product; var bm = MotherboardInfo.SystemName; var terp = new OpenConfiguration(); terp.SetOption(OpenOption.Transient, true); var loader = new HidDeviceLoader(); HidDevice device = null; HidSharp.HidDevice[] devices = null; foreach (var supportedId in supportedIds) { HidSharp.HidDevice[] tempdevices = loader.GetDevices(VENDOR_ID, supportedId).ToArray(); if (tempdevices.Length > 0) { devices = tempdevices; } } if (devices == null || devices.Length == 0) { return(new List <IT8297ControlDevice>()); } int attempts = 0; bool success = false; foreach (HidDevice ddevice in devices) { device = ddevice; try { var ps = attempts % devices.Count(); Console.WriteLine("Trying connection " + ps); // device = devices[attempts % devices.Count()]; Console.WriteLine(device.DevicePath); byte[] t = device.GetRawReportDescriptor(); Debug.WriteLine("got raw"); Console.WriteLine(device.GetFriendlyName()); Debug.WriteLine("got friendly name"); stream = device.Open(terp); Debug.WriteLine("got strean"); stream.SetCalibration(); Debug.WriteLine("set callibration"); stream.SendPacket(0x60, 0); success = true; } catch { attempts++; Thread.Sleep(100); } } if (!success) { return(new List <IT8297ControlDevice>()); } Bitmap pcieArea; Bitmap rgbPins; Bitmap vrm; Debug.WriteLine("Loading PCI Area png"); pcieArea = (Bitmap)Image.FromStream(new MemoryStream(PCIArea_png.binary)); Debug.WriteLine("Loading RGB Pins png"); rgbPins = (Bitmap)Image.FromStream(new MemoryStream(rgbpins_png.binary)); Debug.WriteLine("Loading VRM Area png"); vrm = (Bitmap)Image.FromStream(new MemoryStream(VRM_png.binary)); byte[] buffer = new byte[64]; buffer[0] = 0xCC; stream.GetFeature(buffer); It8297ReportComplete report = GetReport(buffer); stream.SetLedCount(); stream.Init(); string name = report.ProductName; boardname = mbproduct; string layout = ""; if (!GBMaps.ContainsKey(name)) { name = "IT8297BX-GBX570"; } layout = GBMaps[name]; if (GBoverrides.ContainsKey(mbproduct)) { layout = GBoverrides[mbproduct]; } List <IT8297ControlDevice> result = new List <IT8297ControlDevice>(); switch (layout) { case "FALLBACK": { result.Add(new IT8297ControlDevice { OverrideSupport = OverrideSupport.All, Driver = this, DeviceType = DeviceTypes.Fan, Name = "ARGB Header 1", ProductImage = rgbPins, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 0x58, Setter = RGBSetter.Strip } }); result.Add(new IT8297ControlDevice { OverrideSupport = OverrideSupport.All, Driver = this, DeviceType = DeviceTypes.Fan, Name = "ARGB Header 2", ProductImage = rgbPins, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 0x59, Setter = RGBSetter.Strip } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, Name = "VRM Block", ProductImage = vrm, DeviceType = DeviceTypes.MotherBoard, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 32, Setter = RGBSetter.Single } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, Name = "PCI Area", ProductImage = pcieArea, DeviceType = DeviceTypes.MotherBoard, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 35, Setter = RGBSetter.Single } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, DeviceType = DeviceTypes.Fan, Name = "C1C2 Header", ProductImage = rgbPins, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 0x24, Setter = RGBSetter.Single } }); break; } case "390": { result.Add(new IT8297ControlDevice { OverrideSupport = OverrideSupport.All, Driver = this, DeviceType = DeviceTypes.Fan, Name = "ARGB Header 1", ProductImage = rgbPins, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 0x58, Setter = RGBSetter.Strip } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[21], Driver = this, DeviceType = DeviceTypes.MotherBoard, Name = "VRM", ProductImage = vrm, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 0x59, Setter = RGBSetter.Strip, RGBOrder = RGBOrder.GRB } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, Name = "Thing 1", ProductImage = vrm, DeviceType = DeviceTypes.MotherBoard, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 0x20, Setter = RGBSetter.Single } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, Name = "Thing 2", ProductImage = vrm, DeviceType = DeviceTypes.MotherBoard, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 0x21, Setter = RGBSetter.Single } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, Name = "Thing 3", ProductImage = vrm, DeviceType = DeviceTypes.MotherBoard, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 0x22, Setter = RGBSetter.Single } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, Name = "Chipset", ProductImage = vrm, DeviceType = DeviceTypes.MotherBoard, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 0x23, Setter = RGBSetter.Single } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, Name = "Thing 4", ProductImage = vrm, DeviceType = DeviceTypes.MotherBoard, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 0x24, Setter = RGBSetter.Single } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, Name = "Thing 5", ProductImage = vrm, DeviceType = DeviceTypes.MotherBoard, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 0x25, Setter = RGBSetter.Single } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, Name = "Thing 6", ProductImage = vrm, DeviceType = DeviceTypes.MotherBoard, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 0x26, Setter = RGBSetter.Single } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, Name = "Thing 7", ProductImage = vrm, DeviceType = DeviceTypes.MotherBoard, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 0x27, Setter = RGBSetter.Single } }); break; } case "MINI_ITX": { result.Add(new IT8297ControlDevice { OverrideSupport = OverrideSupport.All, Driver = this, DeviceType = DeviceTypes.Fan, Name = "ARGB Header 1", ProductImage = rgbPins, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 0x58, Setter = RGBSetter.Strip } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, Name = "Back I/O", ProductImage = vrm, DeviceType = DeviceTypes.MotherBoard, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = HDR_BACK_IO, Setter = RGBSetter.Single } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[4], Driver = this, Name = "MOBO Backlight", ProductImage = pcieArea, DeviceType = DeviceTypes.MotherBoard, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = HDR_CPU, Setter = RGBSetter.Composite, CompositeOrder = new int[] { 0x20, 0x21, 0x22, 0x23 } } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, DeviceType = DeviceTypes.Fan, Name = "C1C2 Header", ProductImage = rgbPins, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 0x24, Setter = RGBSetter.Single } }); //result.Add(new IT8297ControlDevice //{ // LEDs = new ControlDevice.LedUnit[1], // Driver = this, // Name = "PCIExpress", // ProductImage = pcieArea, // DeviceType = DeviceTypes.MotherBoard, // GigabyteRGBDevice = new GigabyteRGBDevice // { // FirstAddress = HDR_PCIE, // Setter = RGBSetter.Single // } //}); //result.Add(new IT8297ControlDevice //{ // LEDs = new ControlDevice.LedUnit[1], // Driver = this, // DeviceType = DeviceTypes.Fan, // Name = "C1C2 Header", // ProductImage = rgbPins, // GigabyteRGBDevice = new GigabyteRGBDevice // { // FirstAddress = 0x24, // Setter = RGBSetter.Single // } //}); break; } case "ITX": { result.Add(new IT8297ControlDevice { OverrideSupport = OverrideSupport.All, Driver = this, DeviceType = DeviceTypes.Fan, Name = "ARGB Header 1", ProductImage = rgbPins, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 0x58, Setter = RGBSetter.Strip } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, Name = "Back I/O", ProductImage = vrm, DeviceType = DeviceTypes.MotherBoard, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = HDR_BACK_IO, Setter = RGBSetter.Single } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, Name = "CPU Header", ProductImage = vrm, DeviceType = DeviceTypes.MotherBoard, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = HDR_CPU, Setter = RGBSetter.Single } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, Name = "PCIExpress", ProductImage = pcieArea, DeviceType = DeviceTypes.MotherBoard, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = HDR_PCIE, Setter = RGBSetter.Single } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, DeviceType = DeviceTypes.Fan, Name = "C1C2 Header", ProductImage = rgbPins, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 0x24, Setter = RGBSetter.Single } }); break; } case "STD_ATX": { result.Add(new IT8297ControlDevice { OverrideSupport = OverrideSupport.All, Driver = this, DeviceType = DeviceTypes.Fan, Name = "ARGB Header 1", ProductImage = rgbPins, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 0x58, Setter = RGBSetter.Strip } }); result.Add(new IT8297ControlDevice { OverrideSupport = OverrideSupport.All, Driver = this, DeviceType = DeviceTypes.Fan, Name = "ARGB Header 2", ProductImage = rgbPins, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 0x59, Setter = RGBSetter.Strip } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, Name = "Back I/O", ProductImage = vrm, DeviceType = DeviceTypes.MotherBoard, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = HDR_BACK_IO, Setter = RGBSetter.Single } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, Name = "CPU Header", ProductImage = vrm, DeviceType = DeviceTypes.MotherBoard, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = HDR_CPU, Setter = RGBSetter.Single } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, Name = "PCIExpress", ProductImage = pcieArea, DeviceType = DeviceTypes.MotherBoard, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = HDR_PCIE, Setter = RGBSetter.Single } }); result.Add(new IT8297ControlDevice { LEDs = new ControlDevice.LedUnit[1], Driver = this, DeviceType = DeviceTypes.Fan, Name = "C1C2 Header", ProductImage = rgbPins, GigabyteRGBDevice = new GigabyteRGBDevice { FirstAddress = 0x24, Setter = RGBSetter.Single } }); break; } } foreach (IT8297ControlDevice it8297ControlDevice in result.Where(x => x.LEDs == null || x.LEDs.Length < 1)) { SetDeviceOverride(it8297ControlDevice, new GenericFan()); } foreach (IT8297ControlDevice it8297ControlDevice in result) { for (int i = 0; i < it8297ControlDevice.LEDs.Length; i++) { it8297ControlDevice.LEDs[i] = new ControlDevice.LedUnit { Color = new LEDColor(0, 0, 0), Data = new ControlDevice.LEDData { LEDNumber = i }, LEDName = it8297ControlDevice.Name + " " + (i + 1) }; } } return(result); }
public List <ControlDevice> GetDevices() { var terp = new OpenConfiguration(); terp.SetOption(OpenOption.Transient, true); var loader = new HidDeviceLoader(); HidDevice device = null; HidSharp.HidDevice[] devices = null; foreach (var supportedId in supportedIds) { HidSharp.HidDevice[] tempdevices = loader.GetDevices(VENDOR_ID, supportedId).ToArray(); if (tempdevices.Length > 0) { devices = tempdevices; } } if (devices == null || devices.Length == 0) { return(new List <ControlDevice>()); } int attempts = 0; bool success = false; while (attempts < 100 && !success) { try { Console.WriteLine("Attempting connection"); device = devices[attempts % devices.Count()]; byte[] t = device.GetRawReportDescriptor(); Console.WriteLine(device.GetFriendlyName()); stream = device.Open(terp); stream.SetCalibration(); stream.SendPacket(0x60, 0); success = true; } catch { attempts++; Thread.Sleep(100); } } if (!success) { return(new List <ControlDevice>()); } Bitmap pcieArea; Bitmap rgbPins; Bitmap vrm; Assembly myAssembly = Assembly.GetExecutingAssembly(); using (Stream myStream = myAssembly.GetManifestResourceStream("IT8297Driver.PCIArea.png")) { pcieArea = (Bitmap)Image.FromStream(myStream); } using (Stream myStream = myAssembly.GetManifestResourceStream("IT8297Driver.rgbpins.png")) { rgbPins = (Bitmap)Image.FromStream(myStream); } using (Stream myStream = myAssembly.GetManifestResourceStream("IT8297Driver.VRM.png")) { vrm = (Bitmap)Image.FromStream(myStream); } byte[] buffer = new byte[64]; buffer[0] = 0xCC; stream.GetFeature(buffer); It8297ReportComplete report = GetReport(buffer); stream.SetLedCount(); stream.Init(); List <ControlDevice> result = new List <ControlDevice>(); result.Add(new ControlDevice { LEDs = leds1, Driver = this, DeviceType = DeviceTypes.Fan, Name = "ARGB Header 1", ProductImage = rgbPins, SupportsLEDCountOverride = true }); result.Add(new ControlDevice { LEDs = leds2, Driver = this, DeviceType = DeviceTypes.Fan, Name = "ARGB Header 2", ProductImage = rgbPins, SupportsLEDCountOverride = true }); result.Add(new ControlDevice { LEDs = vrmLeds, Driver = this, DeviceType = DeviceTypes.MotherBoard, Name = "VRM Block", ProductImage = vrm }); result.Add(new ControlDevice { LEDs = pciLeds, Driver = this, DeviceType = DeviceTypes.MotherBoard, Name = "PCI area", ProductImage = pcieArea }); return(result); }
public HidDeviceWrap Initialize() { Error = null; Opened = false; _ready = false; DevicePath = Device.DevicePath; Change(); Task.Run(() => { Opening = true; try { //Stream = Device.Open(); Descriptor = Device.GetReportDescriptor(); MaxInputReportLength = Device.GetMaxInputReportLength(); InputReportCount = 0; InputReportOffsets.Clear(); foreach (var report in Descriptor.InputReports) { InputReportOffsets.Add(report.ReportID, InputReportCount * MaxInputReportLength); InputReportCount++; } InputLength = MaxInputReportLength * InputReportCount; OutputLength = Device.GetMaxOutputReportLength(); _inputBytes = new byte[InputLength]; _rawInputBytes = new byte[MaxInputReportLength]; _outputBytes = new byte[OutputLength]; Receiver = Descriptor.CreateHidDeviceInputReceiver(); var options = new OpenConfiguration(); options.SetOption(OpenOption.Exclusive, false); options.SetOption(OpenOption.Transient, false); options.SetOption(OpenOption.Interruptible, false); options.SetOption(OpenOption.Priority, OpenPriority.High); Stream = Device.Open(options); Receiver.Start(Stream); Receiver.Received += (sender, args) => { Opened = true; _ready = true; Change(); }; Opened = true; } catch (Exception e) { Opened = false; Error = e; } Opening = false; Change(); _ready = Opened; }); return(this); }
public new BleStream Open(OpenConfiguration openConfig) { return((BleStream)base.Open(openConfig)); }
protected override void RunScan() { var devList = DeviceList.Local; var hidDevices = devList.GetHidDevices(); var serialDevices = devList.GetSerialDevices(); foreach (var device in hidDevices) { var hidFinder = new HIDProtocolConfiguration((ushort)device.VendorID, (ushort)device.ProductID); var factory = DeviceConfigurationManager.Manager.Find(hidFinder); if (factory == null) { continue; } // We're already connected, just keep going. if (_connectedAddresses.Contains(device.DevicePath)) { continue; } var bpDevice = factory.CreateDevice(LogManager, new HidSharpHidDeviceImpl(LogManager, device)).Result; _connectedAddresses.Add(bpDevice.Identifier); void Removed(object aObj, EventArgs aArgs) { _connectedAddresses.Remove(bpDevice.Identifier); bpDevice.DeviceRemoved -= Removed; } bpDevice.DeviceRemoved += Removed; InvokeDeviceAdded(new DeviceAddedEventArgs(bpDevice)); } foreach (var port in serialDevices) { var serialFinder = new SerialProtocolConfiguration(port.GetFileSystemName()); var factory = DeviceConfigurationManager.Manager.Find(serialFinder); if (factory == null) { continue; } // We're already connected, just keep going. if (_connectedAddresses.Contains(port.DevicePath)) { continue; } var config = new OpenConfiguration(); config.SetOption(OpenOption.Exclusive, true); config.SetOption(OpenOption.Interruptible, true); config.SetOption(OpenOption.TimeoutIfInterruptible, 1000); config.SetOption(OpenOption.TimeoutIfTransient, 1000); if (!port.TryOpen(config, out var stream)) { continue; } var deviceConfig = factory.Config as SerialProtocolConfiguration; stream.BaudRate = (int)deviceConfig.BaudRate; stream.DataBits = (int)deviceConfig.DataBits; stream.StopBits = (int)deviceConfig.StopBits; stream.Parity = SerialParity.None; var bpDevice = factory.CreateDevice(LogManager, new HidSharpSerialDeviceImpl(LogManager, stream)).Result; _connectedAddresses.Add(bpDevice.Identifier); void Removed(object aObj, EventArgs aArgs) { _connectedAddresses.Remove(bpDevice.Identifier); bpDevice.DeviceRemoved -= Removed; } bpDevice.DeviceRemoved += Removed; InvokeDeviceAdded(new DeviceAddedEventArgs(bpDevice)); } }
protected override string GetStreamPath(OpenConfiguration openConfig) { var service = GetService(openConfig); if (service == null) { throw DeviceException.CreateIOException(this, "BLE service not specified."); } if (service.Device != this) { throw DeviceException.CreateIOException(this, "BLE service is on a different device."); } uint devInst; if (0 == NativeMethods.CM_Locate_DevNode(out devInst, _id)) { if (0 == NativeMethods.CM_Get_Child(out devInst, devInst)) { do { string serviceDeviceID; if (0 == NativeMethods.CM_Get_Device_ID(devInst, out serviceDeviceID)) { NativeMethods.HDEVINFO devInfo = NativeMethods.SetupDiGetClassDevs( service.Uuid, serviceDeviceID, IntPtr.Zero, NativeMethods.DIGCF.DeviceInterface | NativeMethods.DIGCF.Present ); if (devInfo.IsValid) { try { NativeMethods.SP_DEVINFO_DATA dvi = new NativeMethods.SP_DEVINFO_DATA(); dvi.Size = Marshal.SizeOf(dvi); for (int j = 0; NativeMethods.SetupDiEnumDeviceInfo(devInfo, j, ref dvi); j++) { NativeMethods.SP_DEVICE_INTERFACE_DATA did = new NativeMethods.SP_DEVICE_INTERFACE_DATA(); did.Size = Marshal.SizeOf(did); for (int k = 0; NativeMethods.SetupDiEnumDeviceInterfaces(devInfo, ref dvi, service.Uuid, k, ref did); k++) { string devicePath; if (NativeMethods.SetupDiGetDeviceInterfaceDevicePath(devInfo, ref did, out devicePath)) { // FIXME: Take the attribute handle into account as well. // Right now, if there are multiple services with the same GUID, we do not distinguish between them. return(devicePath); } } } } finally { NativeMethods.SetupDiDestroyDeviceInfoList(devInfo); } } } }while (0 == NativeMethods.CM_Get_Sibling(out devInst, devInst)); } } throw DeviceException.CreateIOException(this, string.Format("BLE service {0} not found.", service.Uuid)); }
protected override DeviceStream OpenDeviceDirectly(OpenConfiguration openConfig) { return(new LinuxSerialStream(this)); }
void Monitor() { while (runMonitor) { var compatibleDevices = DeviceList.Local.GetHidDevices(StadiaController.VID, StadiaController.PID); compatibleDevices = compatibleDevices.Concat(DeviceList.Local.GetHidDevices(RB3KeyboardController.VID, RB3KeyboardController.PID)); compatibleDevices = compatibleDevices.Concat(DeviceList.Local.GetHidDevices(LunaController.VID, LunaController.PID) // Luna controllers present a vendor-defined HID device as well, but for now we're only interested in the standard gamepad device .Where(device => device.GetMaxOutputReportLength() > 3)); var existingDevices = gamepads.Select(g => g._device).ToList(); var newDevices = compatibleDevices.Where(d => !existingDevices.Select(e => e.DevicePath).Contains(d.DevicePath)); foreach (var gamepad in gamepads.ToList()) { if (!gamepad.running) { gamepads.Remove(gamepad); } if (gamepads.Count == 0) { GCSettings.LatencyMode = GCLatencyMode.Interactive; } } foreach (var deviceInstance in newDevices) { var device = deviceInstance; HidStream stream = null; try { OpenConfiguration oc = new OpenConfiguration(); // reEnable doesn't seem to play nicely with Luna, and exclusive mode never works if (!(device.VendorID == LunaController.VID && device.ProductID == LunaController.PID)) { reEnableDevice(devicePathToInstanceId(device.DevicePath)); oc.SetOption(OpenOption.Exclusive, true); oc.SetOption(OpenOption.Transient, true); } oc.SetOption(OpenOption.Priority, OpenPriority.VeryHigh); stream = device.Open(oc); } catch (DeviceIOException) { try { stream = device.Open(); NotifyUser("Unable to open device in exclusive mode. Try reconnecting the controller; you may also need to close other apps (Steam, Discord, internet browser, etc)."); } catch (DeviceIOException) { // well, shit happens I guess. give up on this round of Monitor. I've run into this when unplugging RB3 keyboard dongles. goto IOErrorSkip; } } var usedIndexes = gamepads.Select(g => g._index); int index = 1; while (usedIndexes.Contains(index)) { index++; } switch (device.VendorID) { case StadiaController.VID: if (device.ProductID == StadiaController.PID) { gamepads.Add(new StadiaController(device, stream, client, index)); } break; case RB3KeyboardController.VID: if (device.ProductID == RB3KeyboardController.PID) { gamepads.Add(new RB3KeyboardController(device, stream, client, index)); } break; case LunaController.VID: if (device.ProductID == LunaController.PID) { gamepads.Add(new LunaController(device, stream, client, index)); } break; } GCSettings.LatencyMode = GCLatencyMode.SustainedLowLatency; } IOErrorSkip: Thread.Sleep(1000); } }
public HyperXKeyboardSupport(int vid, int pid, int usb) { List <uint> order = new List <uint>(); xy = new List <XY>(); int pp = 0; humm = new XY[106]; for (int x = 0; x < 23; x++) { for (int y = 0; y < 6; y++) { var tt = matrixMap[y][x]; if (tt == 4294967295) { } else { humm[tt] = new XY { X = x, Y = y, Order = (int)tt, DebugName = KeyNames[tt], }; } } } string shitmap = @"[ { ""X"": 0, ""Y"": 0, ""Key"": 0, ""Order"": 0, ""Color"": null, ""DebugName"": ""ESC"", ""DebugName2"": null, ""ScanCode"": 1 }, { ""X"": 0, ""Y"": 1, ""Key"": 0, ""Order"": 1, ""Color"": null, ""DebugName"": ""OEM8"", ""DebugName2"": null, ""ScanCode"": 41 }, { ""X"": 0, ""Y"": 2, ""Key"": 0, ""Order"": 2, ""Color"": null, ""DebugName"": ""TAB"", ""DebugName2"": null, ""ScanCode"": 15 }, { ""X"": 0, ""Y"": 3, ""Key"": 0, ""Order"": 3, ""Color"": null, ""DebugName"": ""CAPITAL"", ""DebugName2"": null, ""ScanCode"": 58 }, { ""X"": 0, ""Y"": 4, ""Key"": 0, ""Order"": 4, ""Color"": null, ""DebugName"": ""LSHIFT"", ""DebugName2"": null, ""ScanCode"": 42 }, { ""X"": 0, ""Y"": 5, ""Key"": 0, ""Order"": 5, ""Color"": null, ""DebugName"": ""LCONTROL"", ""DebugName2"": null, ""ScanCode"": 29 }, { ""X"": 15, ""Y"": 0, ""Key"": 0, ""Order"": 6, ""Color"": null, ""DebugName"": ""F12"", ""DebugName2"": null, ""ScanCode"": 88 }, { ""X"": 13, ""Y"": 1, ""Key"": 0, ""Order"": 7, ""Color"": null, ""DebugName"": ""OEMPLUS"", ""DebugName2"": null, ""ScanCode"": 13 }, { ""X"": 12, ""Y"": 0, ""Key"": 0, ""Order"": 8, ""Color"": null, ""DebugName"": ""F9"", ""DebugName2"": null, ""ScanCode"": 67 }, { ""X"": 9, ""Y"": 1, ""Key"": 0, ""Order"": 9, ""Color"": null, ""DebugName"": ""D9"", ""DebugName2"": null, ""ScanCode"": 10 }, { ""X"": 11, ""Y"": 2, ""Key"": 0, ""Order"": 10, ""Color"": null, ""DebugName"": ""O"", ""DebugName2"": null, ""ScanCode"": 24 }, { ""X"": 11, ""Y"": 3, ""Key"": 0, ""Order"": 11, ""Color"": null, ""DebugName"": ""L"", ""DebugName2"": null, ""ScanCode"": 38 }, { ""X"": 11, ""Y"": 4, ""Key"": 0, ""Order"": 12, ""Color"": null, ""DebugName"": ""OEMCOMMA"", ""DebugName2"": null, ""ScanCode"": 51 }, { ""X"": 14, ""Y"": 5, ""Key"": 0, ""Order"": 13, ""Color"": null, ""DebugName"": ""APPS"", ""DebugName2"": null, ""ScanCode"": 56 }, { ""X"": 15, ""Y"": 3, ""Key"": 0, ""Order"": 14, ""Color"": null, ""DebugName"": ""ENTER"", ""DebugName2"": null, ""ScanCode"": 28 }, { ""X"": 16, ""Y"": 5, ""Key"": 0, ""Order"": 15, ""Color"": null, ""DebugName"": ""LEFT"", ""DebugName2"": null, ""ScanCode"": 107 }, { ""X"": 2, ""Y"": 0, ""Key"": 0, ""Order"": 16, ""Color"": null, ""DebugName"": ""F1"", ""DebugName2"": null, ""ScanCode"": 59 }, { ""X"": 1, ""Y"": 1, ""Key"": 0, ""Order"": 17, ""Color"": null, ""DebugName"": ""D1"", ""DebugName2"": null, ""ScanCode"": 2 }, { ""X"": 2, ""Y"": 2, ""Key"": 0, ""Order"": 18, ""Color"": null, ""DebugName"": ""Q"", ""DebugName2"": null, ""ScanCode"": 16 }, { ""X"": 2, ""Y"": 3, ""Key"": 0, ""Order"": 19, ""Color"": null, ""DebugName"": ""A"", ""DebugName2"": null, ""ScanCode"": 30 }, { ""X"": 1, ""Y"": 4, ""Key"": 0, ""Order"": 20, ""Color"": null, ""DebugName"": ""OEMPIPE"", ""DebugName2"": null, ""ScanCode"": 86 }, { ""X"": 1, ""Y"": 5, ""Key"": 0, ""Order"": 21, ""Color"": null, ""DebugName"": ""LWIN"", ""DebugName2"": null, ""ScanCode"": 91 }, { ""X"": 16, ""Y"": 0, ""Key"": 0, ""Order"": 22, ""Color"": null, ""DebugName"": ""PRINTSCREEN"", ""DebugName2"": null, ""ScanCode"": 55 }, { ""X"": 13, ""Y"": 0, ""Key"": 0, ""Order"": 23, ""Color"": null, ""DebugName"": ""F10"", ""DebugName2"": null, ""ScanCode"": 68 }, { ""X"": 10, ""Y"": 1, ""Key"": 0, ""Order"": 24, ""Color"": null, ""DebugName"": ""D0"", ""DebugName2"": null, ""ScanCode"": 11 }, { ""X"": 12, ""Y"": 2, ""Key"": 0, ""Order"": 25, ""Color"": null, ""DebugName"": ""P"", ""DebugName2"": null, ""ScanCode"": 25 }, { ""X"": 12, ""Y"": 3, ""Key"": 0, ""Order"": 26, ""Color"": null, ""DebugName"": ""OEMSEMICOLON"", ""DebugName2"": null, ""ScanCode"": 39 }, { ""X"": 12, ""Y"": 4, ""Key"": 0, ""Order"": 27, ""Color"": null, ""DebugName"": ""OEMPERIOD"", ""DebugName2"": null, ""ScanCode"": 52 }, { ""X"": 14, ""Y"": 3, ""Key"": 0, ""Order"": 28, ""Color"": null, ""DebugName"": ""ENTER"", ""DebugName2"": null, ""ScanCode"": 28 }, { ""X"": 17, ""Y"": 5, ""Key"": 0, ""Order"": 29, ""Color"": null, ""DebugName"": ""DOWN"", ""DebugName2"": null, ""ScanCode"": 72 }, { ""X"": 3, ""Y"": 0, ""Key"": 0, ""Order"": 30, ""Color"": null, ""DebugName"": ""F2"", ""DebugName2"": null, ""ScanCode"": 60 }, { ""X"": 2, ""Y"": 1, ""Key"": 0, ""Order"": 31, ""Color"": null, ""DebugName"": ""D2"", ""DebugName2"": null, ""ScanCode"": 3 }, { ""X"": 3, ""Y"": 2, ""Key"": 0, ""Order"": 32, ""Color"": null, ""DebugName"": ""W"", ""DebugName2"": null, ""ScanCode"": 17 }, { ""X"": 3, ""Y"": 3, ""Key"": 0, ""Order"": 33, ""Color"": null, ""DebugName"": ""S"", ""DebugName2"": null, ""ScanCode"": 31 }, { ""X"": 2, ""Y"": 4, ""Key"": 0, ""Order"": 34, ""Color"": null, ""DebugName"": ""Z"", ""DebugName2"": null, ""ScanCode"": 44 }, { ""X"": 2, ""Y"": 5, ""Key"": 0, ""Order"": 35, ""Color"": null, ""DebugName"": ""LMENU"", ""DebugName2"": null, ""ScanCode"": 56 }, { ""X"": 17, ""Y"": 0, ""Key"": 0, ""Order"": 36, ""Color"": null, ""DebugName"": ""SCROLL"", ""DebugName2"": null, ""ScanCode"": 70 }, { ""X"": 14, ""Y"": 1, ""Key"": 0, ""Order"": 37, ""Color"": null, ""DebugName"": ""BACK"", ""DebugName2"": null, ""ScanCode"": 14 }, { ""X"": 14, ""Y"": 0, ""Key"": 0, ""Order"": 38, ""Color"": null, ""DebugName"": ""F11"", ""DebugName2"": null , ""ScanCode"": 87 }, { ""X"": 12, ""Y"": 1, ""Key"": 0, ""Order"": 39, ""Color"": null, ""DebugName"": ""OEMMINUS"", ""DebugName2"": null, ""ScanCode"": 12 }, { ""X"": 13, ""Y"": 2, ""Key"": 0, ""Order"": 40, ""Color"": null, ""DebugName"": ""OEMOPENBRACKETS"", ""DebugName2"": null, ""ScanCode"": 26 }, { ""X"": 13, ""Y"": 3, ""Key"": 0, ""Order"": 41, ""Color"": null, ""DebugName"": ""OEMTILDE"", ""DebugName2"": null, ""ScanCode"": 41 }, { ""X"": 13, ""Y"": 4, ""Key"": 0, ""Order"": 42, ""Color"": null, ""DebugName"": ""OEMQUESTION"", ""DebugName2"": null, ""ScanCode"": 53 }, { ""X"": 18, ""Y"": 5, ""Key"": 0, ""Order"": 43, ""Color"": null, ""DebugName"": ""RIGHT"", ""DebugName2"": null, ""ScanCode"": 77 }, { ""X"": 4, ""Y"": 0, ""Key"": 0, ""Order"": 44, ""Color"": null, ""DebugName"": ""F3"", ""DebugName2"": null, ""ScanCode"": 61 }, { ""X"": 3, ""Y"": 1, ""Key"": 0, ""Order"": 45, ""Color"": null, ""DebugName"": ""D3"", ""DebugName2"": null, ""ScanCode"": 4 }, { ""X"": 4, ""Y"": 2, ""Key"": 0, ""Order"": 46, ""Color"": null, ""DebugName"": ""E"", ""DebugName2"": null, ""ScanCode"": 18 }, { ""X"": 4, ""Y"": 3, ""Key"": 0, ""Order"": 47, ""Color"": null, ""DebugName"": ""D"", ""DebugName2"": null, ""ScanCode"": 32 }, { ""X"": 3, ""Y"": 4, ""Key"": 0, ""Order"": 48, ""Color"": null, ""DebugName"": ""X"", ""DebugName2"": null, ""ScanCode"": 45 }, { ""X"": 18, ""Y"": 0, ""Key"": 0, ""Order"": 49, ""Color"": null, ""DebugName"": ""PAUSE"", ""DebugName2"": null , ""ScanCode"": 29 }, { ""X"": 16, ""Y"": 2, ""Key"": 0, ""Order"": 50, ""Color"": null, ""DebugName"": ""DELETE"", ""DebugName2"": null, ""ScanCode"": 83 }, { ""X"": 19, ""Y"": 2, ""Key"": 0, ""Order"": 51, ""Color"": null, ""DebugName"": ""NUMPAD7"", ""DebugName2"": null, ""ScanCode"": 71 }, { ""X"": 19, ""Y"": 1, ""Key"": 0, ""Order"": 52, ""Color"": null, ""DebugName"": ""NUMLOCK"", ""DebugName2"": null, ""ScanCode"": 69 }, { ""X"": 21, ""Y"": 3, ""Key"": 0, ""Order"": 53, ""Color"": null, ""DebugName"": ""NUMPAD6"", ""DebugName2"": null, ""ScanCode"": 77 }, { ""X"": 5, ""Y"": 0, ""Key"": 0, ""Order"": 54, ""Color"": null, ""DebugName"": ""F4"", ""DebugName2"": null, ""ScanCode"": 62 }, { ""X"": 4, ""Y"": 1, ""Key"": 0, ""Order"": 55, ""Color"": null, ""DebugName"": ""D4"", ""DebugName2"": null, ""ScanCode"": 5 }, { ""X"": 5, ""Y"": 2, ""Key"": 0, ""Order"": 56, ""Color"": null, ""DebugName"": ""R"", ""DebugName2"": null, ""ScanCode"": 19 }, { ""X"": 5, ""Y"": 3, ""Key"": 0, ""Order"": 57, ""Color"": null, ""DebugName"": ""F"", ""DebugName2"": null, ""ScanCode"": 33 }, { ""X"": 4, ""Y"": 4, ""Key"": 0, ""Order"": 58, ""Color"": null, ""DebugName"": ""C"", ""DebugName2"": null, ""ScanCode"": 46 }, { ""X"": 7, ""Y"": 5, ""Key"": 0, ""Order"": 59, ""Color"": null, ""DebugName"": ""SPACE"", ""DebugName2"": null, ""ScanCode"": 57 }, { ""X"": 16, ""Y"": 1, ""Key"": 0, ""Order"": 60, ""Color"": null, ""DebugName"": ""INSERT"", ""DebugName2"": null, ""ScanCode"": 82 }, { ""X"": 17, ""Y"": 2, ""Key"": 0, ""Order"": 61, ""Color"": null, ""DebugName"": ""END"", ""DebugName2"": null, ""ScanCode"": 79 }, { ""X"": 20, ""Y"": 2, ""Key"": 0, ""Order"": 62, ""Color"": null, ""DebugName"": ""NUMPAD8"", ""DebugName2"": null, ""ScanCode"": 72 }, { ""X"": 20, ""Y"": 1, ""Key"": 0, ""Order"": 63, ""Color"": null, ""DebugName"": ""DIVIDE"", ""DebugName2"": null, ""ScanCode"": 53 }, { ""X"": 19, ""Y"": 4, ""Key"": 0, ""Order"": 64, ""Color"": null, ""DebugName"": ""NUMPAD1"", ""DebugName2"": null, ""ScanCode"": 79 }, { ""X"": 7, ""Y"": 0, ""Key"": 0, ""Order"": 65, ""Color"": null, ""DebugName"": ""F5"", ""DebugName2"": null, ""ScanCode"": 63 }, { ""X"": 5, ""Y"": 1, ""Key"": 0, ""Order"": 66, ""Color"": null, ""DebugName"": ""D5"", ""DebugName2"": null, ""ScanCode"": 6 }, { ""X"": 7, ""Y"": 2, ""Key"": 0, ""Order"": 67, ""Color"": null, ""DebugName"": ""T"", ""DebugName2"": null, ""ScanCode"": 20 }, { ""X"": 7, ""Y"": 3, ""Key"": 0, ""Order"": 68, ""Color"": null, ""DebugName"": ""G"", ""DebugName2"": null, ""ScanCode"": 34 }, { ""X"": 5, ""Y"": 4, ""Key"": 0, ""Order"": 69, ""Color"": null, ""DebugName"": ""V"", ""DebugName2"": null, ""ScanCode"": 47 }, { ""X"": 17, ""Y"": 1, ""Key"": 0, ""Order"": 70, ""Color"": null, ""DebugName"": ""HOME"", ""DebugName2"": null, ""ScanCode"": 71 }, { ""X"": 18, ""Y"": 2, ""Key"": 0, ""Order"": 71, ""Color"": null, ""DebugName"": ""NEXT"", ""DebugName2"": null, ""ScanCode"": 81 }, { ""X"": 21, ""Y"": 2, ""Key"": 0, ""Order"": 72, ""Color"": null, ""DebugName"": ""NUMPAD9"", ""DebugName2"": null, ""ScanCode"": 73 }, { ""X"": 21, ""Y"": 1, ""Key"": 0, ""Order"": 73, ""Color"": null, ""DebugName"": ""MULTIPLY"", ""DebugName2"": null, ""ScanCode"": 55 }, { ""X"": 20, ""Y"": 4, ""Key"": 0, ""Order"": 74, ""Color"": null, ""DebugName"": ""NUMPAD2"", ""DebugName2"": null, ""ScanCode"": 80 }, { ""X"": 8, ""Y"": 0, ""Key"": 0, ""Order"": 75, ""Color"": null, ""DebugName"": ""F6"", ""DebugName2"": null, ""ScanCode"": 64 }, { ""X"": 6, ""Y"": 1, ""Key"": 0, ""Order"": 76, ""Color"": null, ""DebugName"": ""D6"", ""DebugName2"": null, ""ScanCode"": 7 }, { ""X"": 8, ""Y"": 2, ""Key"": 0, ""Order"": 77, ""Color"": null, ""DebugName"": ""Y"", ""DebugName2"": null, ""ScanCode"": 21 }, { ""X"": 8, ""Y"": 3, ""Key"": 0, ""Order"": 78, ""Color"": null, ""DebugName"": ""H"", ""DebugName2"": null, ""ScanCode"": 35 }, { ""X"": 7, ""Y"": 4, ""Key"": 0, ""Order"": 79, ""Color"": null, ""DebugName"": ""B"", ""DebugName2"": null, ""ScanCode"": 48 }, { ""X"": 18, ""Y"": 1, ""Key"": 0, ""Order"": 80, ""Color"": null, ""DebugName"": ""PRIOR"", ""DebugName2"": null, ""ScanCode"": 73 }, { ""X"": 14, ""Y"": 4, ""Key"": 0, ""Order"": 81, ""Color"": null, ""DebugName"": ""RSHIFT"", ""DebugName2"": null, ""ScanCode"": 54 }, { ""X"": 22, ""Y"": 1, ""Key"": 0, ""Order"": 82, ""Color"": null, ""DebugName"": ""SUBTRACT"", ""DebugName2"": null, ""ScanCode"": 74 }, { ""X"": 21, ""Y"": 4, ""Key"": 0, ""Order"": 83, ""Color"": null, ""DebugName"": ""NUMPAD3"", ""DebugName2"": null, ""ScanCode"": 81 }, { ""X"": 9, ""Y"": 0, ""Key"": 0, ""Order"": 84, ""Color"": null, ""DebugName"": ""F7"", ""DebugName2"": null, ""ScanCode"": 65 }, { ""X"": 7, ""Y"": 1, ""Key"": 0, ""Order"": 85, ""Color"": null, ""DebugName"": ""D7"", ""DebugName2"": null, ""ScanCode"": 8 }, { ""X"": 9, ""Y"": 2, ""Key"": 0, ""Order"": 86, ""Color"": null, ""DebugName"": ""U"", ""DebugName2"": null, ""ScanCode"": 22 }, { ""X"": 9, ""Y"": 3, ""Key"": 0, ""Order"": 87, ""Color"": null, ""DebugName"": ""J"", ""DebugName2"": null, ""ScanCode"": 36 }, { ""X"": 9, ""Y"": 4, ""Key"": 0, ""Order"": 88, ""Color"": null, ""DebugName"": ""N"", ""DebugName2"": null, ""ScanCode"": 49 }, { ""X"": 12, ""Y"": 5, ""Key"": 0, ""Order"": 89, ""Color"": null, ""DebugName"": ""RMENU"", ""DebugName2"": null, ""ScanCode"": 56 }, { ""X"": 14, ""Y"": 2, ""Key"": 0, ""Order"": 90, ""Color"": null, ""DebugName"": ""OEMCLOSEBRACKETS"", ""DebugName2"": null, ""ScanCode"": 27 }, { ""X"": 15, ""Y"": 5, ""Key"": 0, ""Order"": 91, ""Color"": null, ""DebugName"": ""RCONTROL"", ""DebugName2"": null, ""ScanCode"": 29 }, { ""X"": 19, ""Y"": 3, ""Key"": 0, ""Order"": 92, ""Color"": null, ""DebugName"": ""NUMPAD4"", ""DebugName2"": null, ""ScanCode"": 75 }, { ""X"": 22, ""Y"": 2, ""Key"": 0, ""Order"": 93, ""Color"": null, ""DebugName"": ""ADD"", ""DebugName2"": null, ""ScanCode"": 78 }, { ""X"": 19, ""Y"": 5, ""Key"": 0, ""Order"": 94, ""Color"": null, ""DebugName"": ""NUMPAD0"", ""DebugName2"": null, ""ScanCode"": 82 }, { ""X"": 10, ""Y"": 0, ""Key"": 0, ""Order"": 95, ""Color"": null, ""DebugName"": ""F8"", ""DebugName2"": null, ""ScanCode"": 88 }, { ""X"": 8, ""Y"": 1, ""Key"": 0, ""Order"": 96, ""Color"": null, ""DebugName"": ""D8"", ""DebugName2"": null, ""ScanCode"": 9 }, { ""X"": 10, ""Y"": 2, ""Key"": 0, ""Order"": 97, ""Color"": null, ""DebugName"": ""I"", ""DebugName2"": null, ""ScanCode"": 23 }, { ""X"": 10, ""Y"": 3, ""Key"": 0, ""Order"": 98, ""Color"": null, ""DebugName"": ""K"", ""DebugName2"": null, ""ScanCode"": 37 }, { ""X"": 10, ""Y"": 4, ""Key"": 0, ""Order"": 99, ""Color"": null, ""DebugName"": ""M"", ""DebugName2"": null, ""ScanCode"": 50 }, { ""X"": 13, ""Y"": 5, ""Key"": 0, ""Order"": 100, ""Color"": null, ""DebugName"": ""RWIN"", ""DebugName2"": null, ""ScanCode"": 92 }, { ""X"": 15, ""Y"": 2, ""Key"": 0, ""Order"": 101, ""Color"": null, ""DebugName"": ""OEMPIPE"", ""DebugName2"": null, ""ScanCode"": 43 }, { ""X"": 17, ""Y"": 4, ""Key"": 0, ""Order"": 102, ""Color"": null, ""DebugName"": ""UP"", ""DebugName2"": null, ""ScanCode"": 72 }, { ""X"": 20, ""Y"": 3, ""Key"": 0, ""Order"": 103, ""Color"": null, ""DebugName"": ""NUMPAD5"", ""DebugName2"": null, ""ScanCode"": 76 }, { ""X"": 21, ""Y"": 5, ""Key"": 0, ""Order"": 105, ""Color"": null, ""DebugName"": ""DECIMAL"", ""DebugName2"": null, ""ScanCode"": 83 } ]"; //xy = JsonConvert.DeserializeObject<List<XY>>(shitmap); //Debug.WriteLine("---------------------"); //foreach (XY xy1 in xy) //{ // Debug.Write(xy1.X+","+xy1.Y+","+xy1.ScanCode+","); //} //Debug.WriteLine(""); //Debug.WriteLine("---------------------"); //string jshumm = JsonConvert.SerializeObject(xy); //Debug.WriteLine(jshumm); //for (int x = 0; x < 23; x++) //{ // for (int y = 0; y < 6; y++) // { // var tt = matrixMap[y][x]; // if (tt != NA) // { // int ypos = (int)(tt % 6); // int xpos = (int) ((tt - ypos) / 6); // var poopoo = new XY // { // X = x, // Y = y, // Key = tt, // Order = pp, // DebugName = KeyNames[pp], // DebugName2 = KeyNames[tt] // }; // xy.Add(poopoo); // Debug.WriteLine(tt); // order.Add(tt); // pp++; // } // } //} xy = humm.ToList(); OrderOfKeys = order.ToArray(); OrderOfKeys = xy.OrderBy(p => (p.X * 6) + p.Y).Select(p => p.Key).ToArray(); VENDOR_ID = vid; PRODUCT_ID = pid; USB_INTERFACE = usb; var terp = new OpenConfiguration(); terp.SetOption(OpenOption.Interruptible, true); var loader = new HidDeviceLoader(); var devices = loader.GetDevices(VENDOR_ID, PRODUCT_ID).ToArray(); int ct = 0; foreach (var tdevice in devices) { ct++; HidStream tmpstream;// = tdevice.Open(terp); try { tmpstream = tdevice.Open(terp); if (tmpstream != null) { Debug.WriteLine(""); Debug.WriteLine("device opened " + ct + " " + tdevice.DevicePath); SwitchProfile(0, tmpstream); Debug.WriteLine("Well, that seemed to work"); stream = tmpstream; } } catch (Exception e) { Debug.WriteLine(e.Message); } } if (stream == null) { throw new Exception("Stream null"); } }
WinBleService GetService(OpenConfiguration openConfig) { return((WinBleService)openConfig.GetOption(OpenOption.BleService)); }