Add Serializable.ts and KeystrokeAction.ts
This commit is contained in:
26
model/KeystrokeAction.ts
Normal file
26
model/KeystrokeAction.ts
Normal 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
8
model/Serializable.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
/// <reference path="UhkBuffer.ts" />
|
||||
|
||||
interface Serializable {
|
||||
fromJsObject(jsObject: any);
|
||||
toJsObject(): any;
|
||||
fromBinary(buffer: UhkBuffer);
|
||||
toBinary(buffer: UhkBuffer);
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user