From 27e65b36e50f70d79c47b465bcaec41c94a4e6f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Sun, 20 Mar 2016 11:33:17 +0100 Subject: [PATCH] Put module bindings inside of layers, not the other way around. Use IDs instead of strings for identifying modules. Update script. --- model/serializeConfig.js | 22 +++++++++++---- model/uhk-config.json | 60 +++++++++++++++++----------------------- 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/model/serializeConfig.js b/model/serializeConfig.js index 2900b1a6..2537106c 100755 --- a/model/serializeConfig.js +++ b/model/serializeConfig.js @@ -8,8 +8,8 @@ buffer.fill(0); var writer = BufferWriter(buffer); var uhkConfig = JSON.parse(fs.readFileSync('uhk-config.json')); -var keyActions = uhkConfig.keymaps[0].modules[0].layers[0].keyActions; - +var keyActions = uhkConfig.keymaps[0].layers[0].modules[0].keyActions; +console.log(keyActions) var ARRAY_LAST_ELEMENT_ID = 0; var KEY_ACTION_ID_KEYSTROKE_SCANCODE_FIRST = 1; @@ -61,10 +61,10 @@ function serializeKeyAction(keyAction) { case 'none': serializeNoneAction(); break; - case 'key': + case 'keystroke': serializeKeystrokeAction(keyAction); break; - case 'dualRoleKey': + case 'dualRoleKeystroke': serializeDualRoleKeyAction(keyAction); break; case 'mouse': @@ -76,8 +76,11 @@ function serializeKeyAction(keyAction) { case 'switchKeymap': serializeSwitchKeymapAction(keyAction); break; + case 'switchLayer': + serializeSwitchLayerAction(keyAction); + break; default: - throw "KeyAction doesn't have a valid actionType property!"; + throw "KeyAction doesn't have a valid actionType property: " + keyAction.actionType; } } @@ -137,5 +140,14 @@ function serializeSwitchKeymapAction(switchKeymapAction) { writer.uint8(switchKeymapAction.keymapId); } +function serializeSwitchLayerAction(switchLayerAction) { + writer.uint8({ + mod : KEY_ACTION_ID_SWITCH_LAYER_MOD, + fn : KEY_ACTION_ID_SWITCH_LAYER_FN, + mouse: KEY_ACTION_ID_SWITCH_LAYER_MOUSE + }[switchLayerAction]); + writer.uint8(0); +} + serializeKeyActions(keyActions); fs.writeFileSync('uhk-config.bin', buffer); diff --git a/model/uhk-config.json b/model/uhk-config.json index f5064840..f16aacf0 100644 --- a/model/uhk-config.json +++ b/model/uhk-config.json @@ -14,12 +14,14 @@ "name": "QWERTY", "isDefault": true, "abbreviation": "QTY", - "modules": [ + "layers": [ { - "name": "uhkLeft", - "layers": [ + "modules": [ { - "pointerRole": "move", + "id": 0, + "pointerRoles": [ + "move" + ], "keyActions": [ { "actionType": "none" @@ -52,38 +54,28 @@ } ] }, - {}, - {}, - {} + { + "id": 1 + }, + { + "id": 2, + "pointerRoles": [ + "scroll" + ], + "keyActions": [] + }, + { + "id": 3, + "pointerRoles": [ + "move" + ], + "keyActions": [] + } ] }, - { - "name": "uhkRight" - }, - { - "name": "keyClusterLeft", - "layers": [ - { - "pointerRole": "scroll", - "keyActions": [] - } - ], - "modLayer": {}, - "fnLayer": {}, - "mouseLayer": {} - }, - { - "name": "trackballRight", - "layers": [ - { - "pointerRole": "move", - "keyActions": [] - } - ], - "modLayer": {}, - "fnLayer": {}, - "mouseLayer": {} - } + {}, + {}, + {} ] }, {