Make factory-update.js allow the layout to be set.

This commit is contained in:
László Monda
2018-04-03 21:04:47 +02:00
parent 0ca922d24a
commit a7d07dbf4c

View File

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