Files
agent/packages/uhk-common/src/config-serializer/config-items/key-action/mouse-action.ts
T
Róbert Kiss 9294bede50 feat(config): Read / write hardware configuration area (#423)
* add write-hca.js

* refactor: Move config serializer into the uhk-common package

* refactor: Move getTransferBuffers into the uhk-usb package

* refactor: delete obsoleted classes

* build: add uhk-usb build command

* refactor: move eeprom transfer to uhk-usb package

* fix: Fix write-hca.js

* feat: load hardware config from the device and

* style: fix ts lint errors

* build: fix rxjs dependency resolve

* test: Add jasmine unit test framework to the tet serializer

* fix(user-config): A "type": "basic", properties to the "keystroke" action types

* feat(usb): set chmod+x on write-hca.js

* feat(usb): Create USB logger

* style: Fix type

* build: Add chalk to dependencies.

Chalk will colorize the output
2017-09-26 16:57:27 +00:00

66 lines
1.5 KiB
TypeScript

import { assertEnum } from '../../assert';
import { UhkBuffer } from '../../uhk-buffer';
import { KeyAction, KeyActionId, keyActionType } from './key-action';
export enum MouseActionParam {
leftClick,
middleClick,
rightClick,
moveUp,
moveDown,
moveLeft,
moveRight,
scrollUp,
scrollDown,
scrollLeft,
scrollRight,
accelerate,
decelerate
}
export class MouseAction extends KeyAction {
@assertEnum(MouseActionParam)
mouseAction: MouseActionParam;
constructor(other?: MouseAction) {
super();
if (!other) {
return;
}
this.mouseAction = other.mouseAction;
}
fromJsonObject(jsObject: any): MouseAction {
this.assertKeyActionType(jsObject);
this.mouseAction = MouseActionParam[<string>jsObject.mouseAction];
return this;
}
fromBinary(buffer: UhkBuffer): MouseAction {
this.readAndAssertKeyActionId(buffer);
this.mouseAction = buffer.readUInt8();
return this;
}
toJsonObject(): any {
return {
keyActionType: keyActionType.MouseAction,
mouseAction: MouseActionParam[this.mouseAction]
};
}
toBinary(buffer: UhkBuffer) {
buffer.writeUInt8(KeyActionId.MouseAction);
buffer.writeUInt8(this.mouseAction);
}
toString(): string {
return `<MouseAction mouseAction="${this.mouseAction}">`;
}
public getName(): string {
return 'MouseAction';
}
}