Add DualRoleKeystrokeAction.
This commit is contained in:
61
config-serializer/config-items/DualRoleKeystrokeAction.ts
Normal file
61
config-serializer/config-items/DualRoleKeystrokeAction.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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" />
|
||||
|
||||
Reference in New Issue
Block a user