diff --git a/config-serializer/config-items/MacroActions.ts b/config-serializer/config-items/MacroActions.ts index 315035db..5d9209f0 100644 --- a/config-serializer/config-items/MacroActions.ts +++ b/config-serializer/config-items/MacroActions.ts @@ -20,6 +20,10 @@ class MacroActions extends ClassArray { return new HoldMouseButtonsAction().fromJsObject(jsObject); case macroActionType.ReleaseMouseButtonsAction: return new ReleaseMouseButtonsAction().fromJsObject(jsObject); + case macroActionType.MoveMouseAction: + return new MoveMouseAction().fromJsObject(jsObject); + case macroActionType.ScrollMouseAction: + return new ScrollMouseAction().fromJsObject(jsObject); default: throw `Invalid MacroAction.macroActionType: "${jsObject.macroActionType}"`; } @@ -53,6 +57,10 @@ class MacroActions extends ClassArray { return new HoldMouseButtonsAction().fromBinary(buffer); case MacroActionId.ReleaseMouseButtonsAction: return new ReleaseMouseButtonsAction().fromBinary(buffer); + case MacroActionId.MoveMouseAction: + return new MoveMouseAction().fromBinary(buffer); + case MacroActionId.ScrollMouseAction: + return new ScrollMouseAction().fromBinary(buffer); default: throw `Invalid MacroAction first byte: ${macroActionFirstByte}`; } diff --git a/config-serializer/config-items/MoveMouseAction.ts b/config-serializer/config-items/MoveMouseAction.ts new file mode 100644 index 00000000..197e494f --- /dev/null +++ b/config-serializer/config-items/MoveMouseAction.ts @@ -0,0 +1,40 @@ +class MoveMouseAction extends MacroAction { + + // @assertInt16 + x: number; + + // @assertInt16 + y: number; + + _fromJsObject(jsObject: any): MoveMouseAction { + this.assertMacroActionType(jsObject); + this.x = jsObject.x; + this.y = jsObject.y; + return this; + } + + _fromBinary(buffer: UhkBuffer): MoveMouseAction { + this.readAndAssertMacroActionId(buffer); + this.x = buffer.readInt16(); + this.y = buffer.readInt16(); + return this; + } + + _toJsObject(): any { + return { + macroActionType: macroActionType.MoveMouseAction, + x: this.x, + y: this.y + }; + } + + _toBinary(buffer: UhkBuffer) { + buffer.writeUInt8(MacroActionId.MoveMouseAction); + buffer.writeInt16(this.x); + buffer.writeInt16(this.y); + } + + toString(): string { + return ``; + } +} diff --git a/config-serializer/config-items/ScrollMouseAction.ts b/config-serializer/config-items/ScrollMouseAction.ts new file mode 100644 index 00000000..d2e78d9a --- /dev/null +++ b/config-serializer/config-items/ScrollMouseAction.ts @@ -0,0 +1,40 @@ +class ScrollMouseAction extends MacroAction { + + // @assertInt16 + x: number; + + // @assertInt16 + y: number; + + _fromJsObject(jsObject: any): ScrollMouseAction { + this.assertMacroActionType(jsObject); + this.x = jsObject.x; + this.y = jsObject.y; + return this; + } + + _fromBinary(buffer: UhkBuffer): ScrollMouseAction { + this.readAndAssertMacroActionId(buffer); + this.x = buffer.readInt16(); + this.y = buffer.readInt16(); + return this; + } + + _toJsObject(): any { + return { + macroActionType: macroActionType.ScrollMouseAction, + x: this.x, + y: this.y + }; + } + + _toBinary(buffer: UhkBuffer) { + buffer.writeUInt8(MacroActionId.ScrollMouseAction); + buffer.writeInt16(this.x); + buffer.writeInt16(this.y); + } + + toString(): string { + return ``; + } +} diff --git a/config-serializer/config-items/config-items.ts b/config-serializer/config-items/config-items.ts index 9415eb66..9aa3a9e9 100644 --- a/config-serializer/config-items/config-items.ts +++ b/config-serializer/config-items/config-items.ts @@ -26,3 +26,5 @@ /// /// /// +/// +/// diff --git a/config-serializer/uhk-config.json b/config-serializer/uhk-config.json index fd13d498..922b1a8a 100644 --- a/config-serializer/uhk-config.json +++ b/config-serializer/uhk-config.json @@ -234,6 +234,16 @@ { "macroActionType": "releaseMouseButtons", "mouseButtonsMask": 104 + }, + { + "macroActionType": "moveMouse", + "x": 123, + "y": 123 + }, + { + "macroActionType": "scrollMouse", + "x": 123, + "y": 123 } ] }