Make code more readable. Remove the writeLedDriver that doesn't do anything anymore.
This commit is contained in:
@@ -13,37 +13,30 @@ function bufferToString(buffer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getUhkDevice() {
|
function getUhkDevice() {
|
||||||
const devs = HID.devices()
|
const foundDevice = HID.devices().find(device =>
|
||||||
|
device.vendorId === 0x1d50 && device.productId === 0x6122 &&
|
||||||
|
((device.usagePage === 128 && device.usage === 129) || device.interface === 0));
|
||||||
|
|
||||||
const dev = devs.find(x =>
|
if (!foundDevice) {
|
||||||
x.vendorId === 0x1d50 &&
|
console.error('UHK Device not found:');
|
||||||
x.productId === 0x6122 &&
|
return null;
|
||||||
((x.usagePage === 128 && x.usage === 129) || x.interface === 0))
|
|
||||||
|
|
||||||
if (!dev) {
|
|
||||||
console.error('UHK Device not found:')
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HID.HID(dev.path)
|
return new HID.HID(foundDevice.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBootloaderDevice() {
|
function getBootloaderDevice() {
|
||||||
const devs = HID.devices()
|
const foundDevice = HID.devices().find(device =>
|
||||||
|
device.vendorId === 0x1d50 && device.productId === 0x6120);
|
||||||
|
|
||||||
const dev = devs.find(x =>
|
if (!foundDevice) {
|
||||||
x.vendorId === 0x1d50
|
console.error('UHK Bootloader not found:');
|
||||||
&& x.productId === 0x6120)
|
return null;
|
||||||
|
} else {
|
||||||
if (!dev) {
|
console.info(foundDevice);
|
||||||
console.error('UHK Bootloader not found:')
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.info(dev)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new HID.HID(dev.path)
|
return new HID.HID(foundDevice.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
exports = module.exports = moduleExports = {
|
exports = module.exports = moduleExports = {
|
||||||
@@ -55,7 +48,6 @@ exports = module.exports = moduleExports = {
|
|||||||
getProperty: 0,
|
getProperty: 0,
|
||||||
jumpToBootloader: 1,
|
jumpToBootloader: 1,
|
||||||
setTestLed: 2,
|
setTestLed: 2,
|
||||||
writeLedDriver: 3,
|
|
||||||
readMergeSensor: 7,
|
readMergeSensor: 7,
|
||||||
writeUserConfig: 8,
|
writeUserConfig: 8,
|
||||||
applyConfig: 9,
|
applyConfig: 9,
|
||||||
|
|||||||
Reference in New Issue
Block a user