Add PlayMacroAction.
This commit is contained in:
@@ -4,7 +4,7 @@ class KeystrokeAction extends KeyAction implements Serializable<KeystrokeAction>
|
||||
static firstValidScancode = 1;
|
||||
static lastValidScancode = 231;
|
||||
|
||||
_scancode: number;
|
||||
private _scancode: number;
|
||||
modifierMask: number;
|
||||
|
||||
get scancode(): number {
|
||||
|
||||
@@ -18,7 +18,7 @@ class MouseAction extends KeyAction implements Serializable<MouseAction> {
|
||||
static keyActionTypeString = 'mouse';
|
||||
static keyActionId = 244;
|
||||
|
||||
_mouseAction: MouseActionParam;
|
||||
private _mouseAction: MouseActionParam;
|
||||
|
||||
get mouseAction(): number {
|
||||
return this._mouseAction;
|
||||
|
||||
44
config-serializer/config-items/PlayMacroAction.ts
Normal file
44
config-serializer/config-items/PlayMacroAction.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
class PlayMacroAction extends KeyAction implements Serializable<PlayMacroAction> {
|
||||
|
||||
static keyActionTypeString = 'playMacro';
|
||||
static keyActionId = 245;
|
||||
|
||||
private _macroId: number;
|
||||
|
||||
get macroId(): number {
|
||||
return this._macroId;
|
||||
}
|
||||
|
||||
set macroId(value) {
|
||||
if (!PlayMacroAction.isScancodeValid(value)) {
|
||||
throw 'Invalid PlayMacroAction.macroId: ${value}';
|
||||
}
|
||||
this._macroId = value;
|
||||
}
|
||||
|
||||
static isScancodeValid(scancode) {
|
||||
return 0 <= scancode && scancode <= 255;
|
||||
}
|
||||
|
||||
fromJsObject(jsObject: any): PlayMacroAction {
|
||||
this.macroId = jsObject.macroId;
|
||||
return this;
|
||||
}
|
||||
|
||||
fromBinary(buffer: UhkBuffer): PlayMacroAction {
|
||||
this.macroId = buffer.readUInt8();
|
||||
return this;
|
||||
}
|
||||
|
||||
toJsObject(): any {
|
||||
return {
|
||||
keyActionType: PlayMacroAction.keyActionTypeString,
|
||||
macroId: this.macroId
|
||||
};
|
||||
}
|
||||
|
||||
toBinary(buffer: UhkBuffer) {
|
||||
buffer.writeUInt8(PlayMacroAction.keyActionId);
|
||||
buffer.writeUInt8(this.macroId);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
/// <reference path="KeyAction.ts" />
|
||||
/// <reference path="KeystrokeAction.ts" />
|
||||
/// <reference path="MouseAction.ts" />
|
||||
/// <reference path="PlayMacroAction.ts" />
|
||||
/// <reference path="NoneAction.ts" />
|
||||
|
||||
@@ -22,7 +22,6 @@ let KEY_ACTION_ID_DUAL_ROLE_KEYSTROKE_RIGHT_CTRL = 240;
|
||||
let KEY_ACTION_ID_DUAL_ROLE_KEYSTROKE_RIGHT_SHIFT = 241;
|
||||
let KEY_ACTION_ID_DUAL_ROLE_KEYSTROKE_RIGHT_ALT = 242;
|
||||
let KEY_ACTION_ID_DUAL_ROLE_KEYSTROKE_RIGHT_SUPER = 243;
|
||||
let KEY_ACTION_ID_PLAY_MACRO = 245;
|
||||
let KEY_ACTION_ID_SWITCH_KEYMAP = 246;
|
||||
let KEY_ACTION_ID_NONE = 255;
|
||||
|
||||
@@ -46,9 +45,6 @@ function serializeKeyAction(keyAction) {
|
||||
case 'dualRoleKeystroke':
|
||||
serializeDualRoleKeyAction(keyAction);
|
||||
break;
|
||||
case 'playMacro':
|
||||
serializeMacroAction(keyAction);
|
||||
break;
|
||||
case 'switchKeymap':
|
||||
serializeSwitchKeymapAction(keyAction);
|
||||
break;
|
||||
@@ -77,11 +73,6 @@ function serializeDualRoleKeyAction(dualRoleKeyAction) {
|
||||
writer.writeUInt8(dualRoleKeyAction.scancode);
|
||||
}
|
||||
|
||||
function serializeMacroAction(macroAction) {
|
||||
writer.writeUInt8(KEY_ACTION_ID_PLAY_MACRO);
|
||||
writer.writeUInt8(macroAction.macroId);
|
||||
}
|
||||
|
||||
function serializeSwitchKeymapAction(switchKeymapAction) {
|
||||
writer.writeUInt8(KEY_ACTION_ID_SWITCH_KEYMAP);
|
||||
writer.writeUInt8(switchKeymapAction.keymapId);
|
||||
|
||||
Reference in New Issue
Block a user