diff --git a/packages/uhk-agent/src/package.json b/packages/uhk-agent/src/package.json index f3fb067a..1bff5d6c 100644 --- a/packages/uhk-agent/src/package.json +++ b/packages/uhk-agent/src/package.json @@ -16,8 +16,8 @@ "dependencies": { "node-hid": "0.5.7" }, - "firmwareVersion": "4.0.0", - "dataModelVersion": "3.0.0", + "firmwareVersion": "5.0.0", + "dataModelVersion": "4.0.0", "usbProtocolVersion": "2.0.0", "slaveProtocolVersion": "3.0.0" } diff --git a/packages/uhk-agent/src/services/device.service.ts b/packages/uhk-agent/src/services/device.service.ts index fa7f390f..b75f323f 100644 --- a/packages/uhk-agent/src/services/device.service.ts +++ b/packages/uhk-agent/src/services/device.service.ts @@ -103,6 +103,8 @@ export class DeviceService { try { this.logService.debug(`[DeviceService] USB[T]: Read ${configName} size from keyboard`); let configSize = await this.getConfigSizeFromKeyboard(property); + const originalConfigSize = configSize; + this.logService.debug(`[DeviceService] getConfigSize() configSize: ${configSize}`); const chunkSize = 63; let offset = 0; let configBuffer = new Buffer(0); @@ -118,7 +120,13 @@ export class DeviceService { if (firstRead && config === UsbCommand.ReadUserConfig) { firstRead = false; - configSize = readBuffer[6] + (readBuffer[7] << 8); + configSize = readBuffer[7] + (readBuffer[8] << 8); + this.logService.debug(`[DeviceService] userConfigSize: ${configSize}`); + if (originalConfigSize < configSize) { + this.logService.debug(`[DeviceService] userConfigSize should never be larger than getConfigSize()! ` + + `Overriding configSize with getConfigSize()`); + configSize = originalConfigSize; + } } } response = convertBufferToIntArray(configBuffer); diff --git a/packages/uhk-common/src/config-serializer/config-items/module-configuration.ts b/packages/uhk-common/src/config-serializer/config-items/module-configuration.ts index c76a59e1..552a5d14 100644 --- a/packages/uhk-common/src/config-serializer/config-items/module-configuration.ts +++ b/packages/uhk-common/src/config-serializer/config-items/module-configuration.ts @@ -1,4 +1,4 @@ -import { assertUInt8 } from '../assert'; +import { assertUInt8, assertUInt16 } from '../assert'; import { UhkBuffer } from '../uhk-buffer'; export class ModuleConfiguration { @@ -10,6 +10,9 @@ export class ModuleConfiguration { @assertUInt8 id: number; + @assertUInt8 + pointerMode: number; + @assertUInt8 deceleratedPointerSpeedMultiplier: number; @@ -19,36 +22,69 @@ export class ModuleConfiguration { @assertUInt8 acceleratedPointerSpeedMultiplier: number; + @assertUInt16 + angularShift: number; + + @assertUInt8 + modLayerPointerFunction: number; + + @assertUInt8 + fnLayerPointerFunction: number; + + @assertUInt8 + mouseLayerPointerFunction: number; + fromJsonObject(jsonObject: any): ModuleConfiguration { this.id = jsonObject.id; + this.pointerMode = jsonObject.pointerMode; this.deceleratedPointerSpeedMultiplier = jsonObject.deceleratedPointerSpeedMultiplier; this.basePointerSpeedMultiplier = jsonObject.basePointerSpeedMultiplier; this.acceleratedPointerSpeedMultiplier = jsonObject.acceleratedPointerSpeedMultiplier; + this.angularShift = jsonObject.angularShift; + this.modLayerPointerFunction = jsonObject.modLayerPointerFunction; + this.fnLayerPointerFunction = jsonObject.fnLayerPointerFunction; + this.mouseLayerPointerFunction = jsonObject.mouseLayerPointerFunction; + return this; } fromBinary(buffer: UhkBuffer): ModuleConfiguration { this.id = buffer.readUInt8(); + this.pointerMode = buffer.readInt8(); this.deceleratedPointerSpeedMultiplier = buffer.readUInt8(); this.basePointerSpeedMultiplier = buffer.readUInt8(); this.acceleratedPointerSpeedMultiplier = buffer.readUInt8(); + this.angularShift = buffer.readUInt16(); + this.modLayerPointerFunction = buffer.readUInt8(); + this.fnLayerPointerFunction = buffer.readUInt8(); + this.mouseLayerPointerFunction = buffer.readUInt8(); return this; } toJsonObject(): any { return { id: this.id, + pointerMode: this.pointerMode, deceleratedPointerSpeedMultiplier: this.deceleratedPointerSpeedMultiplier, basePointerSpeedMultiplier: this.basePointerSpeedMultiplier, - acceleratedPointerSpeedMultiplier: this.acceleratedPointerSpeedMultiplier + acceleratedPointerSpeedMultiplier: this.acceleratedPointerSpeedMultiplier, + angularShift: this.angularShift, + modeLayerPointerFunction: this.modLayerPointerFunction, + fnLayerPointerFunction: this.fnLayerPointerFunction, + mouseLayerPointerFunction: this.mouseLayerPointerFunction }; } toBinary(buffer: UhkBuffer): void { buffer.writeUInt8(this.id); + buffer.writeUInt8(this.pointerMode); buffer.writeUInt8(this.deceleratedPointerSpeedMultiplier); buffer.writeUInt8(this.basePointerSpeedMultiplier); buffer.writeUInt8(this.acceleratedPointerSpeedMultiplier); + buffer.writeUInt16(this.angularShift); + buffer.writeUInt8(this.modLayerPointerFunction); + buffer.writeUInt8(this.fnLayerPointerFunction); + buffer.writeUInt8(this.mouseLayerPointerFunction); } toString(): string { diff --git a/packages/uhk-common/src/config-serializer/config-items/module.ts b/packages/uhk-common/src/config-serializer/config-items/module.ts index a7edf199..45a350be 100644 --- a/packages/uhk-common/src/config-serializer/config-items/module.ts +++ b/packages/uhk-common/src/config-serializer/config-items/module.ts @@ -4,12 +4,6 @@ import { KeyActionHelper, KeyAction, NoneAction, PlayMacroAction, SwitchKeymapAc import { Macro } from './macro'; import { UserConfiguration } from './user-configuration'; -enum PointerRole { - none, - move, - scroll -} - export class Module { @assertUInt8 @@ -17,21 +11,16 @@ export class Module { keyActions: KeyAction[]; - @assertEnum(PointerRole) - pointerRole: PointerRole; - constructor(other?: Module) { if (!other) { return; } this.id = other.id; this.keyActions = other.keyActions.map(keyAction => KeyActionHelper.createKeyAction(keyAction)); - this.pointerRole = other.pointerRole; } fromJsonObject(jsonObject: any, macros?: Macro[]): Module { this.id = jsonObject.id; - this.pointerRole = PointerRole[jsonObject.pointerRole]; this.keyActions = jsonObject.keyActions.map((keyAction: any) => { return KeyActionHelper.createKeyAction(keyAction, macros); }); @@ -40,7 +29,6 @@ export class Module { fromBinary(buffer: UhkBuffer, macros?: Macro[]): Module { this.id = buffer.readUInt8(); - this.pointerRole = buffer.readUInt8(); const keyActionsLength: number = buffer.readCompactLength(); this.keyActions = []; for (let i = 0; i < keyActionsLength; ++i) { @@ -52,7 +40,6 @@ export class Module { toJsonObject(macros?: Macro[]): any { return { id: this.id, - pointerRole: PointerRole[this.pointerRole], keyActions: this.keyActions.map(keyAction => { if (keyAction && (macros || !(keyAction instanceof PlayMacroAction || keyAction instanceof SwitchKeymapAction))) { return keyAction.toJsonObject(macros); @@ -64,7 +51,6 @@ export class Module { toBinary(buffer: UhkBuffer, userConfiguration: UserConfiguration): void { buffer.writeUInt8(this.id); - buffer.writeUInt8(this.pointerRole); const noneAction = new NoneAction(); @@ -81,7 +67,7 @@ export class Module { } toString(): string { - return ``; + return ``; } renameKeymap(oldAbbr: string, newAbbr: string): Module { diff --git a/packages/uhk-web/src/app/services/user-config.json b/packages/uhk-web/src/app/services/user-config.json index e4de8dfb..bf16a17d 100644 --- a/packages/uhk-web/src/app/services/user-config.json +++ b/packages/uhk-web/src/app/services/user-config.json @@ -3,7 +3,9 @@ "dataModelMinorVersion": 0, "dataModelPatchVersion": 0, "deviceName": "My UHK", - "doubleTapSwitchLayerTimeout": 300, + "doubleTapSwitchLayerTimeout": 250, + "iconsAndLayerTextsBrightness": 255, + "alphanumericSegmentsBrightness": 255, "keyBacklightBrightness": 255, "mouseMoveInitialSpeed": 5, "mouseMoveAcceleration": 35, @@ -15,14 +17,7 @@ "mouseScrollDeceleratedSpeed": 20, "mouseScrollBaseSpeed": 20, "mouseScrollAcceleratedSpeed": 50, - "moduleConfigurations": [ - { - "id": 1, - "initialPointerSpeed": 1, - "pointerAcceleration": 5, - "maxPointerSpeed": 200 - } - ], + "moduleConfigurations": [], "keymaps": [ { "isDefault": true, @@ -34,7 +29,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ { "keyActionType": "keystroke", @@ -211,7 +205,6 @@ }, { "id": 1, - "pointerRole": "move", "keyActions": [ { "keyActionType": "keystroke", @@ -380,7 +373,6 @@ }, { "id": 2, - "pointerRole": "scroll", "keyActions": [] } ] @@ -389,7 +381,6 @@ "modules": [ { "id": 0, - "pointerRole": "none", "keyActions": [ { "keyActionType": "keystroke", @@ -538,7 +529,6 @@ }, { "id": 1, - "pointerRole": "none", "keyActions": [ { "keyActionType": "keystroke", @@ -685,7 +675,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ null, null, @@ -788,7 +777,6 @@ }, { "id": 1, - "pointerRole": "scroll", "keyActions": [ null, { @@ -883,7 +871,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ null, null, @@ -954,7 +941,6 @@ }, { "id": 1, - "pointerRole": "move", "keyActions": [ null, null, @@ -1035,7 +1021,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ { "keyActionType": "keystroke", @@ -1212,7 +1197,6 @@ }, { "id": 1, - "pointerRole": "move", "keyActions": [ { "keyActionType": "keystroke", @@ -1381,7 +1365,6 @@ }, { "id": 2, - "pointerRole": "scroll", "keyActions": [] } ] @@ -1390,7 +1373,6 @@ "modules": [ { "id": 0, - "pointerRole": "none", "keyActions": [ { "keyActionType": "keystroke", @@ -1539,7 +1521,6 @@ }, { "id": 1, - "pointerRole": "none", "keyActions": [ { "keyActionType": "keystroke", @@ -1686,7 +1667,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ null, null, @@ -1797,7 +1777,6 @@ }, { "id": 1, - "pointerRole": "scroll", "keyActions": [ { "keyActionType": "switchKeymap", @@ -1892,7 +1871,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ null, null, @@ -1963,7 +1941,6 @@ }, { "id": 1, - "pointerRole": "move", "keyActions": [ null, null, @@ -2044,7 +2021,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ { "keyActionType": "keystroke", @@ -2221,7 +2197,6 @@ }, { "id": 1, - "pointerRole": "move", "keyActions": [ { "keyActionType": "keystroke", @@ -2390,7 +2365,6 @@ }, { "id": 2, - "pointerRole": "scroll", "keyActions": [] } ] @@ -2399,7 +2373,6 @@ "modules": [ { "id": 0, - "pointerRole": "none", "keyActions": [ { "keyActionType": "keystroke", @@ -2548,7 +2521,6 @@ }, { "id": 1, - "pointerRole": "none", "keyActions": [ { "keyActionType": "keystroke", @@ -2695,7 +2667,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ null, null, @@ -2806,7 +2777,6 @@ }, { "id": 1, - "pointerRole": "scroll", "keyActions": [ { "keyActionType": "switchKeymap", @@ -2901,7 +2871,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ null, null, @@ -2972,7 +2941,6 @@ }, { "id": 1, - "pointerRole": "move", "keyActions": [ null, null, @@ -3053,7 +3021,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ { "keyActionType": "keystroke", @@ -3230,7 +3197,6 @@ }, { "id": 1, - "pointerRole": "move", "keyActions": [ { "keyActionType": "keystroke", @@ -3399,7 +3365,6 @@ }, { "id": 2, - "pointerRole": "scroll", "keyActions": [] } ] @@ -3408,7 +3373,6 @@ "modules": [ { "id": 0, - "pointerRole": "none", "keyActions": [ { "keyActionType": "keystroke", @@ -3557,7 +3521,6 @@ }, { "id": 1, - "pointerRole": "none", "keyActions": [ { "keyActionType": "keystroke", @@ -3704,7 +3667,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ null, null, @@ -3807,7 +3769,6 @@ }, { "id": 1, - "pointerRole": "scroll", "keyActions": [ { "keyActionType": "switchKeymap", @@ -3902,7 +3863,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ null, null, @@ -3973,7 +3933,6 @@ }, { "id": 1, - "pointerRole": "move", "keyActions": [ null, null, @@ -4054,7 +4013,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ { "keyActionType": "keystroke", @@ -4231,7 +4189,6 @@ }, { "id": 1, - "pointerRole": "move", "keyActions": [ { "keyActionType": "keystroke", @@ -4400,7 +4357,6 @@ }, { "id": 2, - "pointerRole": "scroll", "keyActions": [] } ] @@ -4409,7 +4365,6 @@ "modules": [ { "id": 0, - "pointerRole": "none", "keyActions": [ { "keyActionType": "keystroke", @@ -4566,7 +4521,6 @@ }, { "id": 1, - "pointerRole": "none", "keyActions": [ { "keyActionType": "keystroke", @@ -4727,7 +4681,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ null, null, @@ -4838,7 +4791,6 @@ }, { "id": 1, - "pointerRole": "scroll", "keyActions": [ { "keyActionType": "switchKeymap", @@ -4973,7 +4925,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ null, null, @@ -5063,7 +5014,6 @@ }, { "id": 1, - "pointerRole": "move", "keyActions": [ null, null, @@ -5165,7 +5115,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ null, null, @@ -5267,7 +5216,6 @@ }, { "id": 1, - "pointerRole": "move", "keyActions": [ { "keyActionType": "keystroke", @@ -5436,7 +5384,6 @@ }, { "id": 2, - "pointerRole": "scroll", "keyActions": [] } ] @@ -5445,7 +5392,6 @@ "modules": [ { "id": 0, - "pointerRole": "none", "keyActions": [ { "keyActionType": "keystroke", @@ -5602,7 +5548,6 @@ }, { "id": 1, - "pointerRole": "none", "keyActions": [ { "keyActionType": "keystroke", @@ -5759,7 +5704,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ null, null, @@ -5874,7 +5818,6 @@ }, { "id": 1, - "pointerRole": "scroll", "keyActions": [ { "keyActionType": "switchKeymap", @@ -6009,7 +5952,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ null, null, @@ -6050,7 +5992,6 @@ }, { "id": 1, - "pointerRole": "move", "keyActions": [ null, null, @@ -6103,7 +6044,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ { "keyActionType": "keystroke", @@ -6280,7 +6220,6 @@ }, { "id": 1, - "pointerRole": "move", "keyActions": [ { "keyActionType": "keystroke", @@ -6449,7 +6388,6 @@ }, { "id": 2, - "pointerRole": "scroll", "keyActions": [] } ] @@ -6458,7 +6396,6 @@ "modules": [ { "id": 0, - "pointerRole": "none", "keyActions": [ { "keyActionType": "keystroke", @@ -6607,7 +6544,6 @@ }, { "id": 1, - "pointerRole": "none", "keyActions": [ { "keyActionType": "keystroke", @@ -6751,7 +6687,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ null, null, @@ -6862,7 +6797,6 @@ }, { "id": 1, - "pointerRole": "scroll", "keyActions": [ { "keyActionType": "switchKeymap", @@ -6957,7 +6891,6 @@ "modules": [ { "id": 0, - "pointerRole": "move", "keyActions": [ null, null, @@ -7028,7 +6961,6 @@ }, { "id": 1, - "pointerRole": "move", "keyActions": [ null, null,