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