Extract uhk.switchKeymap()
This commit is contained in:
@@ -1,9 +1,8 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
const uhk = require('./uhk');
|
const uhk = require('./uhk');
|
||||||
|
|
||||||
|
(async function() {
|
||||||
const device = uhk.getUhkDevice();
|
const device = uhk.getUhkDevice();
|
||||||
const sendData = Buffer.concat([new Buffer([uhk.usbCommands.switchKeymap, 3]), new Buffer('TES')]);
|
const sendData = await uhk.switchKeymap(device, 'TES');
|
||||||
console.log(sendData)
|
console.log(sendData)
|
||||||
device.write(uhk.getTransferData(sendData));
|
})();
|
||||||
const response = Buffer.from(device.readSync());
|
|
||||||
console.log(response);
|
|
||||||
|
|||||||
@@ -206,6 +206,12 @@ async function jumpToModuleBootloader(device, moduleSlotId) {
|
|||||||
await uhk.writeDevice(device, [uhk.usbCommands.jumpToModuleBootloader, moduleSlotId]);
|
await uhk.writeDevice(device, [uhk.usbCommands.jumpToModuleBootloader, moduleSlotId]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async function switchKeymap(device, keymapAbbreviation) {
|
||||||
|
const keymapAbbreviationAscii = keymapAbbreviation.split('').map(char => char.charCodeAt(0));
|
||||||
|
const payload = [uhk.usbCommands.switchKeymap, keymapAbbreviation.length, ...keymapAbbreviationAscii];
|
||||||
|
return await uhk.writeDevice(device, payload);
|
||||||
|
}
|
||||||
|
|
||||||
async function waitForKbootIdle(device) {
|
async function waitForKbootIdle(device) {
|
||||||
const intervalMs = 100;
|
const intervalMs = 100;
|
||||||
const pingMessageInterval = 500;
|
const pingMessageInterval = 500;
|
||||||
@@ -279,6 +285,7 @@ uhk = exports = module.exports = moduleExports = {
|
|||||||
reenumerate,
|
reenumerate,
|
||||||
sendKbootCommandToModule,
|
sendKbootCommandToModule,
|
||||||
jumpToModuleBootloader,
|
jumpToModuleBootloader,
|
||||||
|
switchKeymap,
|
||||||
waitForKbootIdle,
|
waitForKbootIdle,
|
||||||
updateModuleFirmware,
|
updateModuleFirmware,
|
||||||
usbCommands: {
|
usbCommands: {
|
||||||
|
|||||||
Reference in New Issue
Block a user