Add KeyActionNone
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
/// <reference path="KeyActionNone.ts" />
|
||||
/// <reference path="KeystrokeAction.ts" />
|
||||
|
||||
class KeyAction {
|
||||
|
||||
static fromJsObject(jsObject: any): KeyAction {
|
||||
switch (jsObject.actionType) {
|
||||
case 'none':
|
||||
let keyActionNone = new KeyActionNone();
|
||||
keyActionNone.fromJsObject(jsObject);
|
||||
return keyActionNone;
|
||||
case 'keyStroke':
|
||||
let keystrokeAction = new KeystrokeAction();
|
||||
keystrokeAction.fromJsObject(jsObject);
|
||||
@@ -17,12 +22,14 @@ class KeyAction {
|
||||
let keyActionFirstByte = buffer.readUInt8();
|
||||
buffer.backtrack();
|
||||
|
||||
if (KeystrokeAction.firstValidScancode <= keyActionFirstByte &&
|
||||
keyActionFirstByte <= KeystrokeAction.lastValidScancode)
|
||||
{
|
||||
if (KeystrokeAction.isScancodeValid(keyActionFirstByte)) {
|
||||
let keystrokeAction = new KeystrokeAction();
|
||||
keystrokeAction.fromBinary(buffer);
|
||||
return keystrokeAction;
|
||||
} else if (keyActionFirstByte === KeyActionNone.keyActionNoneId) {
|
||||
let keyActionNone = new KeyActionNone();
|
||||
keyActionNone.fromBinary(buffer);
|
||||
return keyActionNone;
|
||||
} else {
|
||||
throw 'Unknown KeyAction first byte "${keyActionFirstByte}"';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user