Fix config size user config offsets. Restore getConfigSizeFromKeyboard() size if the read user config size is larger than it. Move pointerRole from keymaps to module configurations as pointerMode. Add angularShift, modLayerPointerFunction, fnLayerPointerFunction, and mouseLayerPointerFunction to module configurations. Reference firmware 5.0.0
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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[<string>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 `<Module id="${this.id}" pointerRole="${this.pointerRole}">`;
|
||||
return `<Module id="${this.id}">`;
|
||||
}
|
||||
|
||||
renameKeymap(oldAbbr: string, newAbbr: string): Module {
|
||||
|
||||
Reference in New Issue
Block a user