Move the classes of the config items into the newly created config-items directory.
This commit is contained in:
26
config-serializer/config-items/KeyAction.ts
Normal file
26
config-serializer/config-items/KeyAction.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
class KeyAction {
|
||||
|
||||
static fromJsObject(jsObject: any): KeyAction {
|
||||
switch (jsObject.keyActionType) {
|
||||
case KeystrokeAction.actionTypeString:
|
||||
return new KeystrokeAction().fromJsObject(jsObject);
|
||||
case KeyActionNone.actionTypeString:
|
||||
return new KeyActionNone().fromJsObject(jsObject);
|
||||
default:
|
||||
throw 'Invalid KeyAction.keyActionType: "${jsObject.actionType}"';
|
||||
}
|
||||
}
|
||||
|
||||
static fromBinary(buffer: UhkBuffer): KeyAction {
|
||||
let keyActionFirstByte = buffer.readUInt8();
|
||||
buffer.backtrack();
|
||||
|
||||
if (KeystrokeAction.isScancodeValid(keyActionFirstByte)) {
|
||||
return new KeystrokeAction().fromBinary(buffer);
|
||||
} else if (keyActionFirstByte === KeyActionNone.keyActionNoneId) {
|
||||
return new KeyActionNone().fromBinary(buffer);
|
||||
} else {
|
||||
throw 'Invalid KeyAction first byte "${keyActionFirstByte}"';
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user