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; })();