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:
László Monda
2017-12-04 00:51:50 +01:00
parent 7537e5b823
commit fdef5ed580
5 changed files with 54 additions and 92 deletions

View File

@@ -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 {