Update: win7支持同时使用Serial和HID
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
goog.loadJs('web', () => {
|
||||
|
||||
goog.require('Mixly.Serial');
|
||||
goog.require('Mixly.Registry');
|
||||
goog.require('Mixly.Web');
|
||||
goog.provide('Mixly.Web.HID');
|
||||
|
||||
const {
|
||||
Serial,
|
||||
Registry,
|
||||
Web
|
||||
} = Mixly;
|
||||
|
||||
@@ -15,8 +13,6 @@ const {
|
||||
class WebHID extends Serial {
|
||||
static {
|
||||
this.type = 'hid';
|
||||
this.portToNameRegistry = new Registry();
|
||||
this.nameToPortRegistry = new Registry();
|
||||
|
||||
this.getConfig = function () {
|
||||
return Serial.getConfig();
|
||||
@@ -31,11 +27,7 @@ class WebHID extends Serial {
|
||||
}
|
||||
|
||||
this.refreshPorts = function () {
|
||||
let portsName = [];
|
||||
for (let name of this.nameToPortRegistry.keys()) {
|
||||
portsName.push({ name });
|
||||
}
|
||||
Serial.renderSelectBox(portsName);
|
||||
Serial.refreshPorts();;
|
||||
}
|
||||
|
||||
this.requestPort = async function () {
|
||||
@@ -52,35 +44,35 @@ class WebHID extends Serial {
|
||||
}
|
||||
|
||||
this.getPort = function (name) {
|
||||
return this.nameToPortRegistry.getItem(name);
|
||||
return Serial.nameToPortRegistry.getItem(name);
|
||||
}
|
||||
|
||||
this.addPort = function (device) {
|
||||
if (this.portToNameRegistry.hasKey(device)) {
|
||||
if (Serial.portToNameRegistry.hasKey(device)) {
|
||||
return;
|
||||
}
|
||||
let name = '';
|
||||
for (let i = 1; i <= 20; i++) {
|
||||
name = `hid${i}`;
|
||||
if (this.nameToPortRegistry.hasKey(name)) {
|
||||
if (Serial.nameToPortRegistry.hasKey(name)) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
this.portToNameRegistry.register(device, name);
|
||||
this.nameToPortRegistry.register(name, device);
|
||||
Serial.portToNameRegistry.register(device, name);
|
||||
Serial.nameToPortRegistry.register(name, device);
|
||||
}
|
||||
|
||||
this.removePort = function (device) {
|
||||
if (!this.portToNameRegistry.hasKey(device)) {
|
||||
if (!Serial.portToNameRegistry.hasKey(device)) {
|
||||
return;
|
||||
}
|
||||
const name = this.portToNameRegistry.getItem(device);
|
||||
const name = Serial.portToNameRegistry.getItem(device);
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
this.portToNameRegistry.unregister(device);
|
||||
this.nameToPortRegistry.unregister(name);
|
||||
Serial.portToNameRegistry.unregister(device);
|
||||
Serial.nameToPortRegistry.unregister(name);
|
||||
}
|
||||
|
||||
this.addEventsListener = function () {
|
||||
|
||||
Reference in New Issue
Block a user