Add Serializable.ts and KeystrokeAction.ts

This commit is contained in:
László Monda
2016-03-24 20:56:27 +01:00
parent 25b7cad4ab
commit 483053a991
3 changed files with 36 additions and 0 deletions

26
model/KeystrokeAction.ts Normal file
View File

@@ -0,0 +1,26 @@
/// <reference path="Serializable.ts" />
class KeystrokeAction implements Serializable {
scancode: number;
modifierMask: number;
fromJsObject(jsObject: any) {
this.scancode = jsObject.scancode;
this.modifierMask = jsObject.modifierMask;
}
toJsObject(): any {
return {
scancode: this.scancode,
modifierMask: this.modifierMask
};
}
fromBinary(buffer: UhkBuffer) {
}
toBinary(buffer: UhkBuffer) {
buffer.uint8(this.scancode);
buffer.uint8(this.modifierMask);
}
}

8
model/Serializable.ts Normal file
View File

@@ -0,0 +1,8 @@
/// <reference path="UhkBuffer.ts" />
interface Serializable {
fromJsObject(jsObject: any);
toJsObject(): any;
fromBinary(buffer: UhkBuffer);
toBinary(buffer: UhkBuffer);
}

View File

@@ -1,4 +1,5 @@
/// <reference path="UhkBuffer.ts" />
/// <reference path="KeystrokeAction.ts" />
var fs = require('fs');
var buffer = new Buffer(1000);
@@ -150,5 +151,6 @@ function serializeSwitchLayerAction(switchLayerAction) {
}[switchLayerAction] | switchLayerAction.toggle ? SWITCH_LAYER_TOGGLE : 0);
}
new KeystrokeAction();
serializeKeyActions(keyActions);
fs.writeFileSync('uhk-config.bin', buffer);