Add KeystrokeModifiersAction.
This commit is contained in:
@@ -41,9 +41,9 @@ class UhkBuffer {
|
||||
}
|
||||
|
||||
writeUInt8(value: number): void {
|
||||
this.dump(`u8(${value})`);
|
||||
this.buffer.writeUInt8(value, this.offset);
|
||||
this.offset += 1;
|
||||
this.dump(`u8(${value})`);
|
||||
}
|
||||
|
||||
readInt16(): number {
|
||||
|
||||
@@ -4,17 +4,19 @@
|
||||
enum KeyActionId {
|
||||
NoneAction = 0,
|
||||
KeystrokeAction = 1,
|
||||
KeystrokeWithModifiersAction = 2,
|
||||
DualRoleKeystrokeAction = 3,
|
||||
SwitchLayerAction = 4,
|
||||
SwitchKeymapAction = 5,
|
||||
MouseAction = 6,
|
||||
PlayMacroAction = 7
|
||||
KeystrokeModifiersAction = 2,
|
||||
KeystrokeWithModifiersAction = 3,
|
||||
DualRoleKeystrokeAction = 4,
|
||||
SwitchLayerAction = 5,
|
||||
SwitchKeymapAction = 6,
|
||||
MouseAction = 7,
|
||||
PlayMacroAction = 8
|
||||
}
|
||||
|
||||
let KeyActionType = {
|
||||
NoneAction : 'none',
|
||||
KeystrokeAction : 'keystroke',
|
||||
KeystrokeModifiersAction : 'keystrokeModifiers',
|
||||
KeystrokeWithModifiersAction : 'keystrokeWithModifiers',
|
||||
DualRoleKeystrokeAction : 'dualRoleKeystroke',
|
||||
SwitchLayerAction : 'switchLayer',
|
||||
|
||||
@@ -6,6 +6,8 @@ class KeyActions extends ClassArray<KeyAction> {
|
||||
return new NoneAction().fromJsObject(jsObject);
|
||||
case KeyActionType.KeystrokeAction:
|
||||
return new KeystrokeAction().fromJsObject(jsObject);
|
||||
case KeyActionType.KeystrokeModifiersAction:
|
||||
return new KeystrokeModifiersAction().fromJsObject(jsObject);
|
||||
case KeyActionType.KeystrokeWithModifiersAction:
|
||||
return new KeystrokeWithModifiersAction().fromJsObject(jsObject);
|
||||
case KeyActionType.DualRoleKeystrokeAction:
|
||||
@@ -27,11 +29,18 @@ class KeyActions extends ClassArray<KeyAction> {
|
||||
let keyActionFirstByte = buffer.readUInt8();
|
||||
buffer.backtrack();
|
||||
|
||||
if (buffer.enableDump) {
|
||||
process.stdout.write(']\n');
|
||||
buffer.enableDump = false;
|
||||
}
|
||||
|
||||
switch (keyActionFirstByte) {
|
||||
case KeyActionId.NoneAction:
|
||||
return new NoneAction().fromBinary(buffer);
|
||||
case KeyActionId.KeystrokeAction:
|
||||
return new KeystrokeAction().fromBinary(buffer);
|
||||
case KeyActionId.KeystrokeModifiersAction:
|
||||
return new KeystrokeModifiersAction().fromBinary(buffer);
|
||||
case KeyActionId.KeystrokeWithModifiersAction:
|
||||
return new KeystrokeWithModifiersAction().fromBinary(buffer);
|
||||
case KeyActionId.DualRoleKeystrokeAction:
|
||||
|
||||
33
config-serializer/config-items/KeystrokeModifiersAction.ts
Normal file
33
config-serializer/config-items/KeystrokeModifiersAction.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
class KeystrokeModifiersAction extends KeyAction {
|
||||
|
||||
modifierMask: number;
|
||||
|
||||
_fromJsObject(jsObject: any): KeystrokeModifiersAction {
|
||||
this.assertKeyActionType(
|
||||
jsObject, KeyActionType.KeystrokeModifiersAction, 'KeystrokeModifiersAction');
|
||||
this.modifierMask = jsObject.modifierMask;
|
||||
return this;
|
||||
}
|
||||
|
||||
_fromBinary(buffer: UhkBuffer): KeystrokeModifiersAction {
|
||||
this.readAndAssertKeyActionId(buffer, KeyActionId.KeystrokeModifiersAction, 'KeystrokeModifiersAction');
|
||||
this.modifierMask = buffer.readUInt8();
|
||||
return this;
|
||||
}
|
||||
|
||||
_toJsObject(): any {
|
||||
return {
|
||||
keyActionType: KeyActionType.KeystrokeModifiersAction,
|
||||
modifierMask: this.modifierMask
|
||||
};
|
||||
}
|
||||
|
||||
_toBinary(buffer: UhkBuffer) {
|
||||
buffer.writeUInt8(KeyActionId.KeystrokeModifiersAction);
|
||||
buffer.writeUInt8(this.modifierMask);
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return `<KeystrokeModifiersAction modifierMask="${this.modifierMask}">`;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
class KeystrokeWithModifiersAction extends KeyAction {
|
||||
|
||||
static keyActionTypeString = 'keystrokeWithModifiers';
|
||||
|
||||
modifierMask: number;
|
||||
|
||||
private _scancode: number;
|
||||
@@ -19,7 +17,7 @@ class KeystrokeWithModifiersAction extends KeyAction {
|
||||
|
||||
_fromJsObject(jsObject: any): KeystrokeWithModifiersAction {
|
||||
this.assertKeyActionType(
|
||||
jsObject, KeystrokeWithModifiersAction.keyActionTypeString, 'KeystrokeWithModifiersAction');
|
||||
jsObject, KeyActionType.KeystrokeWithModifiersAction, 'KeystrokeWithModifiersAction');
|
||||
this.scancode = jsObject.scancode;
|
||||
this.modifierMask = jsObject.modifierMask;
|
||||
return this;
|
||||
@@ -34,7 +32,7 @@ class KeystrokeWithModifiersAction extends KeyAction {
|
||||
|
||||
_toJsObject(): any {
|
||||
return {
|
||||
keyActionType: KeystrokeWithModifiersAction.keyActionTypeString,
|
||||
keyActionType: KeyActionType.KeystrokeWithModifiersAction,
|
||||
scancode: this.scancode,
|
||||
modifierMask: this.modifierMask
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
/// <reference path="KeyActions.ts" />
|
||||
/// <reference path="KeystrokeAction.ts" />
|
||||
/// <reference path="KeystrokeWithModifiersAction.ts" />
|
||||
/// <reference path="KeystrokeModifiersAction.ts" />
|
||||
/// <reference path="DualRoleKeystrokeAction.ts" />
|
||||
/// <reference path="MouseAction.ts" />
|
||||
/// <reference path="PlayMacroAction.ts" />
|
||||
|
||||
@@ -34,6 +34,10 @@
|
||||
"keyActionType": "keystroke",
|
||||
"scancode": 110
|
||||
},
|
||||
{
|
||||
"keyActionType": "keystrokeModifiers",
|
||||
"modifierMask":33
|
||||
},
|
||||
{
|
||||
"keyActionType": "keystrokeWithModifiers",
|
||||
"scancode": 120,
|
||||
|
||||
Reference in New Issue
Block a user