Add DualRoleKeystrokeAction.

This commit is contained in:
László Monda
2016-03-30 01:48:08 +02:00
parent 7660bdb729
commit 94e5d55d8f
4 changed files with 64 additions and 49 deletions

View File

@@ -0,0 +1,61 @@
enum LongPressActionId {
leftCtrl = 233,
leftShift,
leftAlt,
leftSuper,
rightCtrl,
rightShift,
rightAlt,
rightSuper,
mod,
fn,
mouse,
}
class DualRoleKeystrokeAction extends KeyAction implements Serializable<DualRoleKeystrokeAction> {
static keyActionTypeString = 'dualRoleKeystroke';
public scancode;
private _longPressAction: LongPressActionId;
get longPressAction(): number {
return this._longPressAction;
}
set longPressAction(value) {
if (!DualRoleKeystrokeAction.isDualRoleKeystrokeActionValid(value)) {
throw 'Invalid DualRoleKeystrokeAction.longPressAction: ${value}';
}
this._longPressAction = value;
}
static isDualRoleKeystrokeActionValid(keyActionId): boolean {
return LongPressActionId[keyActionId] !== undefined;
}
fromJsObject(jsObject: any): DualRoleKeystrokeAction {
this.longPressAction = jsObject.longPressAction;
this.scancode = jsObject.scancode;
return this;
}
fromBinary(buffer: UhkBuffer): DualRoleKeystrokeAction {
this.longPressAction = buffer.readUInt8();
this.scancode = buffer.readUInt8();
return this;
}
toJsObject(): any {
return {
keyActionType: DualRoleKeystrokeAction.keyActionTypeString,
longPressAction: LongPressActionId[this.longPressAction],
scancode: this.scancode
};
}
toBinary(buffer: UhkBuffer) {
buffer.writeUInt8(this.longPressAction);
buffer.writeUInt8(this.scancode);
}
}

View File

@@ -4,9 +4,10 @@ class KeystrokeAction extends KeyAction implements Serializable<KeystrokeAction>
static firstValidScancode = 1;
static lastValidScancode = 231;
private _scancode: number;
modifierMask: number;
private _scancode: number;
get scancode(): number {
return this._scancode;
}

View File

@@ -1,5 +1,6 @@
/// <reference path="KeyAction.ts" />
/// <reference path="KeystrokeAction.ts" />
/// <reference path="DualRoleKeystrokeAction.ts" />
/// <reference path="MouseAction.ts" />
/// <reference path="PlayMacroAction.ts" />
/// <reference path="SwitchKeymapAction.ts" />