From a7d07dbf4cdc47ab12e49b863de9f1d8abad49cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Tue, 3 Apr 2018 21:04:47 +0200 Subject: [PATCH] Make factory-update.js allow the layout to be set. --- packages/usb/factory-update.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/usb/factory-update.js b/packages/usb/factory-update.js index 37e382d1..4be1a829 100755 --- a/packages/usb/factory-update.js +++ b/packages/usb/factory-update.js @@ -11,18 +11,30 @@ require('shelljs/global'); .usage(`firmwarePath`) .parse(process.argv); - if (program.args.length == 0) { + if (program.args.length < 1) { console.error('No firmware path specified.'); exit(1); } + const firmwarePath = program.args[0]; + + if (program.args.length < 2) { + console.error('No layout specified.'); + exit(1); + } + const layout = program.args[1]; + if (!['ansi', 'iso'].includes(layout)) { + console.error('The specified layout is neither ansi nor iso.'); + exit(1); + } + const isIso = layout === 'iso'; config.verbose = true; - const firmwarePath = program.args[0]; await uhk.updateFirmwares(firmwarePath); const device = uhk.getUhkDevice(); const configBuffer = fs.readFileSync(`${firmwarePath}/devices/uhk60-right/config.bin`); await uhk.writeUca(device, configBuffer); - await uhk.writeHca(device, false); + await uhk.writeHca(device, isIso); await uhk.switchKeymap(device, 'TES'); + console.log('All done!') config.verbose = false; })();