Add SwitchKeymapAction
This commit is contained in:
44
config-serializer/config-items/SwitchKeymapAction.ts
Normal file
44
config-serializer/config-items/SwitchKeymapAction.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
class SwitchKeymapAction extends KeyAction implements Serializable<SwitchKeymapAction> {
|
||||
|
||||
static keyActionTypeString = 'switchKeymap';
|
||||
static keyActionId = 246;
|
||||
|
||||
private _keymapId: number;
|
||||
|
||||
get keymapId(): number {
|
||||
return this._keymapId;
|
||||
}
|
||||
|
||||
set keymapId(value) {
|
||||
if (!SwitchKeymapAction.isKeymapIdValid(value)) {
|
||||
throw 'Invalid SwitchKeymapAction.keymapId: ${value}';
|
||||
}
|
||||
this._keymapId = value;
|
||||
}
|
||||
|
||||
static isKeymapIdValid(keymapId) {
|
||||
return 0 <= keymapId && keymapId <= 255;
|
||||
}
|
||||
|
||||
fromJsObject(jsObject: any): SwitchKeymapAction {
|
||||
this.keymapId = jsObject.keymapId;
|
||||
return this;
|
||||
}
|
||||
|
||||
fromBinary(buffer: UhkBuffer): SwitchKeymapAction {
|
||||
this.keymapId = buffer.readUInt8();
|
||||
return this;
|
||||
}
|
||||
|
||||
toJsObject(): any {
|
||||
return {
|
||||
keyActionType: SwitchKeymapAction.keyActionTypeString,
|
||||
keymapId: this.keymapId
|
||||
};
|
||||
}
|
||||
|
||||
toBinary(buffer: UhkBuffer) {
|
||||
buffer.writeUInt8(SwitchKeymapAction.keyActionId);
|
||||
buffer.writeUInt8(this.keymapId);
|
||||
}
|
||||
}
|
||||
@@ -2,4 +2,5 @@
|
||||
/// <reference path="KeystrokeAction.ts" />
|
||||
/// <reference path="MouseAction.ts" />
|
||||
/// <reference path="PlayMacroAction.ts" />
|
||||
/// <reference path="SwitchKeymapAction.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_SWITCH_KEYMAP = 246;
|
||||
let KEY_ACTION_ID_NONE = 255;
|
||||
|
||||
let SWITCH_LAYER_MOD = 0;
|
||||
@@ -45,9 +44,6 @@ function serializeKeyAction(keyAction) {
|
||||
case 'dualRoleKeystroke':
|
||||
serializeDualRoleKeyAction(keyAction);
|
||||
break;
|
||||
case 'switchKeymap':
|
||||
serializeSwitchKeymapAction(keyAction);
|
||||
break;
|
||||
case 'switchLayer':
|
||||
serializeSwitchLayerAction(keyAction);
|
||||
break;
|
||||
@@ -73,11 +69,6 @@ function serializeDualRoleKeyAction(dualRoleKeyAction) {
|
||||
writer.writeUInt8(dualRoleKeyAction.scancode);
|
||||
}
|
||||
|
||||
function serializeSwitchKeymapAction(switchKeymapAction) {
|
||||
writer.writeUInt8(KEY_ACTION_ID_SWITCH_KEYMAP);
|
||||
writer.writeUInt8(switchKeymapAction.keymapId);
|
||||
}
|
||||
|
||||
function serializeSwitchLayerAction(switchLayerAction) {
|
||||
writer.writeUInt8(KEY_ACTION_ID_SWITCH_LAYER);
|
||||
writer.writeUInt8({
|
||||
|
||||
Reference in New Issue
Block a user