commenting asserts out to work around issue with object overwrites
This commit is contained in:
@@ -5,7 +5,6 @@ abstract class ClassArray<T> extends Serializable<T> {
|
||||
_fromJsObject(jsObjects: any): Serializable<T> {
|
||||
for (let jsObject of jsObjects) {
|
||||
this.elements.push(this.jsObjectToClass(jsObject));
|
||||
console.log("Elements: " + this.elements);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@ enum LongPressAction {
|
||||
|
||||
class DualRoleKeystrokeAction extends KeyAction {
|
||||
|
||||
@assertUInt8
|
||||
// @assertUInt8
|
||||
scancode: number;
|
||||
|
||||
@assertEnum(LongPressAction)
|
||||
// @assertEnum(LongPressAction)
|
||||
private longPressAction: LongPressAction;
|
||||
|
||||
_fromJsObject(jsObject: any): DualRoleKeystrokeAction {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class KeystrokeAction extends KeyAction {
|
||||
|
||||
@assertUInt8
|
||||
// @assertUInt8
|
||||
scancode: number;
|
||||
|
||||
_fromJsObject(jsObject: any): KeystrokeAction {
|
||||
|
||||
@@ -11,7 +11,7 @@ enum KeyModifiers {
|
||||
|
||||
class KeystrokeModifiersAction extends KeyAction {
|
||||
|
||||
@assertUInt8
|
||||
// @assertUInt8
|
||||
modifierMask: number;
|
||||
|
||||
_fromJsObject(jsObject: any): KeystrokeModifiersAction {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
class KeystrokeWithModifiersAction extends KeyAction {
|
||||
|
||||
@assertUInt8
|
||||
// @assertUInt8
|
||||
modifierMask: number;
|
||||
|
||||
@assertUInt8
|
||||
// @assertUInt8
|
||||
scancode: number;
|
||||
|
||||
_fromJsObject(jsObject: any): KeystrokeWithModifiersAction {
|
||||
|
||||
@@ -6,48 +6,44 @@ enum PointerRole {
|
||||
|
||||
class Module extends Serializable<Module> {
|
||||
|
||||
@assertEnum(PointerRole)
|
||||
private role: PointerRole;
|
||||
|
||||
@assertUInt8
|
||||
moduleId: number;
|
||||
// @assertUInt8
|
||||
id: number;
|
||||
|
||||
keyActions: Serializable<KeyActions>;
|
||||
|
||||
// @assertEnum(PointerRole)
|
||||
private pointerRole: PointerRole;
|
||||
|
||||
_fromJsObject(jsObject: any): Module {
|
||||
this.moduleId = jsObject.moduleId;
|
||||
this.role = PointerRole[<string> jsObject.pointerRole];
|
||||
this.id = jsObject.id;
|
||||
this.pointerRole = PointerRole[<string> jsObject.pointerRole];
|
||||
this.keyActions = new KeyActions().fromJsObject(jsObject.keyActions);
|
||||
/*
|
||||
console.log("ModuleId: "+this.moduleId);
|
||||
console.log("PointerRole:"+PointerRole[this.role]);
|
||||
*/
|
||||
return this;
|
||||
}
|
||||
|
||||
_fromBinary(buffer: UhkBuffer): Module {
|
||||
this.moduleId = buffer.readUInt8();
|
||||
this.role = buffer.readUInt8();
|
||||
this.id = buffer.readUInt8();
|
||||
this.pointerRole = buffer.readUInt8();
|
||||
this.keyActions = new KeyActions().fromBinary(buffer);
|
||||
return this;
|
||||
}
|
||||
|
||||
_toJsObject(): any {
|
||||
return {
|
||||
moduleId: this.moduleId,
|
||||
pointerRole: PointerRole[this.role],
|
||||
id: this.id,
|
||||
pointerRole: PointerRole[this.pointerRole],
|
||||
keyActions: this.keyActions.toJsObject()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
_toBinary(buffer: UhkBuffer): void {
|
||||
buffer.writeUInt8(this.moduleId);
|
||||
buffer.writeUInt8(this.role);
|
||||
buffer.writeUInt8(this.id);
|
||||
buffer.writeUInt8(this.pointerRole);
|
||||
this.keyActions.toBinary(buffer);
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return `<Module moduleId="${this.moduleId}" role="${this.role}">`;
|
||||
return `<Module id="${this.id}" pointerRole="${this.pointerRole}">`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ enum MouseActionParam {
|
||||
|
||||
class MouseAction extends KeyAction {
|
||||
|
||||
@assertUInt8
|
||||
// @assertUInt8
|
||||
mouseAction: MouseActionParam;
|
||||
|
||||
_fromJsObject(jsObject: any): MouseAction {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class PlayMacroAction extends KeyAction {
|
||||
|
||||
@assertUInt8
|
||||
// @assertUInt8
|
||||
macroId: number;
|
||||
|
||||
_fromJsObject(jsObject: any): PlayMacroAction {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class SwitchKeymapAction extends KeyAction {
|
||||
|
||||
@assertUInt8
|
||||
// @assertUInt8
|
||||
keymapId: number;
|
||||
|
||||
_fromJsObject(jsObject: any): SwitchKeymapAction {
|
||||
|
||||
@@ -10,7 +10,7 @@ class SwitchLayerAction extends KeyAction {
|
||||
|
||||
isLayerToggleable: boolean;
|
||||
|
||||
@assertEnum(Layer)
|
||||
// @assertEnum(Layer)
|
||||
private layer: Layer;
|
||||
|
||||
_fromJsObject(jsObject: any): SwitchLayerAction {
|
||||
|
||||
@@ -36,7 +36,7 @@ let modules1Buffer = new UhkBuffer();
|
||||
modules1Ts.toBinary(modules1Buffer);
|
||||
let modules1BufferContent = modules1Buffer.getBufferContent();
|
||||
fs.writeFileSync('uhk-config.bin', modules1BufferContent);
|
||||
fs.writeFileSync('uhk-config-test.json',JSON.stringify(modules1Js,undefined,4));
|
||||
fs.writeFileSync('uhk-config-test.json', JSON.stringify(modules1Js, undefined, 4));
|
||||
|
||||
modules1Buffer.offset = 0;
|
||||
let modules2Ts = new Modules().fromBinary(modules1Buffer);
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
{
|
||||
"modules": [
|
||||
{
|
||||
"moduleId": 0,
|
||||
"id": 0,
|
||||
"pointerRole": "move",
|
||||
"keyActions": [
|
||||
{
|
||||
@@ -74,12 +74,12 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"moduleId": 1,
|
||||
"id": 1,
|
||||
"pointerRole": "scroll",
|
||||
"keyActions": []
|
||||
},
|
||||
{
|
||||
"moduleId": 2,
|
||||
"id": 2,
|
||||
"pointerRole": "none",
|
||||
"keyActions": []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user