Merge (Hold|Press|Release)(Key|Modifiers) into KeyMacroAction (#99)
This commit is contained in:
@@ -5,15 +5,15 @@ import { Component, Input, OnChanges, OnInit } from '@angular/core';
|
||||
import {KeyModifiers} from '../../../../config-serializer/config-items/KeyModifiers';
|
||||
import {
|
||||
DelayMacroAction,
|
||||
HoldModifiersMacroAction,
|
||||
KeyMacroAction,
|
||||
MacroAction,
|
||||
MoveMouseMacroAction,
|
||||
PressModifiersMacroAction,
|
||||
ReleaseModifiersMacroAction,
|
||||
ScrollMouseMacroAction,
|
||||
TextMacroAction
|
||||
} from '../../../../config-serializer/config-items/macro-action';
|
||||
|
||||
import {MapperService} from '../../../../services/mapper.service';
|
||||
|
||||
@Component({
|
||||
selector: 'macro-item',
|
||||
template: require('./macro-item.component.html'),
|
||||
@@ -29,7 +29,7 @@ export class MacroItemComponent implements OnInit, OnChanges {
|
||||
private iconName: string;
|
||||
private title: string;
|
||||
|
||||
constructor() { }
|
||||
constructor(private mapper: MapperService) { }
|
||||
|
||||
ngOnInit() {
|
||||
this.updateView();
|
||||
@@ -75,42 +75,23 @@ export class MacroItemComponent implements OnInit, OnChanges {
|
||||
if (Math.abs(action.y) > 0) {
|
||||
this.title += ` ${needAnd ? 'and' : 'by'} ${Math.abs(action.y)}px ${action.y > 0 ? 'down' : 'up'}ward`;
|
||||
}
|
||||
} else if (this.macroAction instanceof PressModifiersMacroAction) {
|
||||
} else if (this.macroAction instanceof KeyMacroAction) {
|
||||
const keyMacroAction: KeyMacroAction = <KeyMacroAction>this.macroAction;
|
||||
this.title += 'KeyMacroAction: ';
|
||||
if (keyMacroAction.isPressAction()) {
|
||||
this.title = 'Press';
|
||||
} else if (keyMacroAction.isHoldAction()) {
|
||||
this.title = 'Hold';
|
||||
} else {
|
||||
this.title = 'Release';
|
||||
}
|
||||
if (keyMacroAction.hasScancode()) {
|
||||
this.title += ' ' + this.mapper.scanCodeToText(keyMacroAction.scancode).join(' ');
|
||||
}
|
||||
this.iconName = 'square';
|
||||
let action: PressModifiersMacroAction = this.macroAction as PressModifiersMacroAction;
|
||||
if (action.modifierMask === 0) {
|
||||
this.title = 'Invalid PressModifiersMacroAction!';
|
||||
return;
|
||||
}
|
||||
this.title = 'Press: ';
|
||||
|
||||
for (let i = KeyModifiers.leftCtrl; i !== KeyModifiers.rightCtrl; i <<= 1) {
|
||||
if (action.isModifierActive(i)) {
|
||||
this.title += ' ' + KeyModifiers[i];
|
||||
}
|
||||
}
|
||||
} else if (this.macroAction instanceof HoldModifiersMacroAction) {
|
||||
this.iconName = 'square';
|
||||
let action: HoldModifiersMacroAction = this.macroAction as HoldModifiersMacroAction;
|
||||
if (action.modifierMask === 0) {
|
||||
this.title = 'Invalid HoldModifiersMacroAction!';
|
||||
return;
|
||||
}
|
||||
this.title = 'Hold: ';
|
||||
for (let i = KeyModifiers.leftCtrl; i !== KeyModifiers.rightCtrl; i <<= 1) {
|
||||
if (action.isModifierActive(i)) {
|
||||
this.title += ' ' + KeyModifiers[i];
|
||||
}
|
||||
}
|
||||
} else if (this.macroAction instanceof ReleaseModifiersMacroAction) {
|
||||
this.iconName = 'square';
|
||||
let action: ReleaseModifiersMacroAction = this.macroAction as ReleaseModifiersMacroAction;
|
||||
if (action.modifierMask === 0) {
|
||||
this.title = 'Invalid ReleaseModifiersMacroAction!';
|
||||
return;
|
||||
}
|
||||
this.title = 'Release: ';
|
||||
for (let i = KeyModifiers.leftCtrl; i !== KeyModifiers.rightCtrl; i <<= 1) {
|
||||
if (action.isModifierActive(i)) {
|
||||
if (keyMacroAction.isModifierActive(i)) {
|
||||
this.title += ' ' + KeyModifiers[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
import {assertUInt8} from '../../assert';
|
||||
import {UhkBuffer} from '../../UhkBuffer';
|
||||
import {MacroAction, MacroActionId, macroActionType} from './MacroAction';
|
||||
|
||||
export class HoldKeyMacroAction extends MacroAction {
|
||||
|
||||
@assertUInt8
|
||||
scancode: number;
|
||||
|
||||
_fromJsObject(jsObject: any): HoldKeyMacroAction {
|
||||
this.assertMacroActionType(jsObject);
|
||||
this.scancode = jsObject.scancode;
|
||||
return this;
|
||||
}
|
||||
|
||||
_fromBinary(buffer: UhkBuffer): HoldKeyMacroAction {
|
||||
this.readAndAssertMacroActionId(buffer);
|
||||
this.scancode = buffer.readUInt8();
|
||||
return this;
|
||||
}
|
||||
|
||||
_toJsObject(): any {
|
||||
return {
|
||||
macroActionType: macroActionType.HoldKeyMacroAction,
|
||||
scancode: this.scancode
|
||||
};
|
||||
}
|
||||
|
||||
_toBinary(buffer: UhkBuffer) {
|
||||
buffer.writeUInt8(MacroActionId.HoldKeyMacroAction);
|
||||
buffer.writeUInt8(this.scancode);
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return `<HoldKeyMacroAction scancode="${this.scancode}">`;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
import {assertUInt8} from '../../assert';
|
||||
import {UhkBuffer} from '../../UhkBuffer';
|
||||
import {KeyModifiers} from '../KeyModifiers';
|
||||
import {MacroAction, MacroActionId, macroActionType} from './MacroAction';
|
||||
|
||||
export class HoldModifiersMacroAction extends MacroAction {
|
||||
|
||||
@assertUInt8
|
||||
modifierMask: number;
|
||||
|
||||
_fromJsObject(jsObject: any): HoldModifiersMacroAction {
|
||||
this.assertMacroActionType(jsObject);
|
||||
this.modifierMask = jsObject.modifierMask;
|
||||
return this;
|
||||
}
|
||||
|
||||
_fromBinary(buffer: UhkBuffer): HoldModifiersMacroAction {
|
||||
this.readAndAssertMacroActionId(buffer);
|
||||
this.modifierMask = buffer.readUInt8();
|
||||
return this;
|
||||
}
|
||||
|
||||
_toJsObject(): any {
|
||||
return {
|
||||
macroActionType: macroActionType.HoldModifiersMacroAction,
|
||||
modifierMask: this.modifierMask
|
||||
};
|
||||
}
|
||||
|
||||
_toBinary(buffer: UhkBuffer) {
|
||||
buffer.writeUInt8(MacroActionId.HoldModifiersMacroAction);
|
||||
buffer.writeUInt8(this.modifierMask);
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return `<HoldModifiersMacroAction modifierMask="${this.modifierMask}">`;
|
||||
}
|
||||
|
||||
isModifierActive(modifier: KeyModifiers): boolean {
|
||||
return (this.modifierMask & modifier) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
import { assertEnum, assertUInt8 } from '../../assert';
|
||||
import { UhkBuffer} from '../../UhkBuffer';
|
||||
import { KeyModifiers } from '../KeyModifiers';
|
||||
import { MacroAction, MacroActionId, macroActionType } from './MacroAction';
|
||||
|
||||
const NUM_OF_COMBINATIONS = 3; // Cases: scancode, modifer, both
|
||||
|
||||
enum Action {
|
||||
press = 0,
|
||||
hold = 1,
|
||||
release = 2
|
||||
}
|
||||
|
||||
interface JsObjectKeyMacroAction {
|
||||
macroActionType: string;
|
||||
action: string;
|
||||
scancode?: number;
|
||||
modifierMask?: number;
|
||||
}
|
||||
|
||||
export class KeyMacroAction extends MacroAction {
|
||||
|
||||
@assertEnum(Action)
|
||||
action: Action;
|
||||
|
||||
@assertUInt8
|
||||
scancode: number;
|
||||
|
||||
@assertUInt8
|
||||
modifierMask: number;
|
||||
|
||||
_fromJsObject(jsObject: JsObjectKeyMacroAction): KeyMacroAction {
|
||||
this.assertMacroActionType(jsObject);
|
||||
this.action = Action[jsObject.action];
|
||||
this.scancode = jsObject.scancode;
|
||||
this.modifierMask = jsObject.modifierMask;
|
||||
return this;
|
||||
}
|
||||
|
||||
_fromBinary(buffer: UhkBuffer): KeyMacroAction {
|
||||
let macroActionId: MacroActionId = this.readAndAssertMacroActionId(buffer);
|
||||
let keyMacroType: number = macroActionId - MacroActionId.KeyMacroAction;
|
||||
this.action = Math.floor(keyMacroType / NUM_OF_COMBINATIONS);
|
||||
keyMacroType %= NUM_OF_COMBINATIONS;
|
||||
if (keyMacroType % 2 === 0) {
|
||||
this.scancode = buffer.readUInt8();
|
||||
}
|
||||
if (keyMacroType !== 0) {
|
||||
this.modifierMask = buffer.readUInt8();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
_toJsObject(): any {
|
||||
let jsObject: JsObjectKeyMacroAction = {
|
||||
macroActionType: macroActionType.KeyMacroAction,
|
||||
action: Action[this.action]
|
||||
};
|
||||
|
||||
if (this.hasScancode()) {
|
||||
jsObject.scancode = this.scancode;
|
||||
}
|
||||
|
||||
if (this.hasModifiers()) {
|
||||
jsObject.modifierMask = this.modifierMask;
|
||||
}
|
||||
|
||||
return jsObject;
|
||||
}
|
||||
|
||||
_toBinary(buffer: UhkBuffer) {
|
||||
let keyMacroType: number = MacroActionId.KeyMacroAction;
|
||||
keyMacroType += NUM_OF_COMBINATIONS * this.action;
|
||||
|
||||
if (this.hasModifiers()) {
|
||||
++keyMacroType;
|
||||
if (this.hasScancode()) {
|
||||
++keyMacroType;
|
||||
}
|
||||
}
|
||||
buffer.writeUInt8(keyMacroType);
|
||||
if (this.hasScancode()) {
|
||||
buffer.writeUInt8(this.scancode);
|
||||
}
|
||||
if (this.hasModifiers()) {
|
||||
buffer.writeUInt8(this.modifierMask);
|
||||
}
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return `<KeyMacroAction action="${this.action}" scancode="${this.scancode}" modifierMask="${this.modifierMask}">`;
|
||||
}
|
||||
|
||||
isModifierActive(modifier: KeyModifiers): boolean {
|
||||
return (this.modifierMask & modifier) > 0;
|
||||
}
|
||||
|
||||
hasScancode(): boolean {
|
||||
return !!this.scancode;
|
||||
}
|
||||
|
||||
hasModifiers(): boolean {
|
||||
return !!this.modifierMask;
|
||||
}
|
||||
|
||||
isHoldAction(): boolean {
|
||||
return this.action === Action.hold;
|
||||
}
|
||||
|
||||
isPressAction(): boolean {
|
||||
return this.action === Action.press;
|
||||
}
|
||||
|
||||
isReleaseAction(): boolean {
|
||||
return this.action === Action.release;
|
||||
}
|
||||
}
|
||||
@@ -2,35 +2,38 @@ import {Serializable} from '../../Serializable';
|
||||
import {UhkBuffer} from '../../UhkBuffer';
|
||||
|
||||
export enum MacroActionId {
|
||||
PressKeyMacroAction = 0,
|
||||
HoldKeyMacroAction = 1,
|
||||
ReleaseKeyMacroAction = 2,
|
||||
PressModifiersMacroAction = 3,
|
||||
HoldModifiersMacroAction = 4,
|
||||
ReleaseModifiersMacroAction = 5,
|
||||
PressMouseButtonsMacroAction = 6,
|
||||
HoldMouseButtonsMacroAction = 7,
|
||||
ReleaseMouseButtonsMacroAction = 8,
|
||||
MoveMouseMacroAction = 9,
|
||||
ScrollMouseMacroAction = 10,
|
||||
DelayMacroAction = 11,
|
||||
TextMacroAction = 12
|
||||
KeyMacroAction = 0,
|
||||
/*
|
||||
0 - 8 are reserved for KeyMacroAction
|
||||
PressKeyMacroAction with scancode: 0
|
||||
PressKeyMacroAction with modifiers: 1
|
||||
PressKeyMacroAction with scancode and modifiers 2
|
||||
HoldKeyMacroAction with scancode: 3
|
||||
HoldKeyMacroAction with modifiers: 4
|
||||
HoldKeyMacroAction with scancode and modifiers 5
|
||||
ReleaseKeyMacroAction with scancode: 6
|
||||
ReleaseKeyMacroAction with modifiers: 7
|
||||
ReleaseKeyMacroAction with scancode and modifiers 8
|
||||
*/
|
||||
LastKeyMacroAction = 8,
|
||||
PressMouseButtonsMacroAction = 9,
|
||||
HoldMouseButtonsMacroAction = 10,
|
||||
ReleaseMouseButtonsMacroAction = 11,
|
||||
MoveMouseMacroAction = 12,
|
||||
ScrollMouseMacroAction = 13,
|
||||
DelayMacroAction = 14,
|
||||
TextMacroAction = 15
|
||||
}
|
||||
|
||||
export let macroActionType = {
|
||||
PressKeyMacroAction : 'pressKey',
|
||||
HoldKeyMacroAction : 'holdKey',
|
||||
ReleaseKeyMacroAction : 'releaseKey',
|
||||
PressModifiersMacroAction : 'pressModifiers',
|
||||
HoldModifiersMacroAction : 'holdModifiers',
|
||||
ReleaseModifiersMacroAction : 'releaseModifiers',
|
||||
PressMouseButtonsMacroAction : 'pressMouseButtons',
|
||||
HoldMouseButtonsMacroAction : 'holdMouseButtons',
|
||||
ReleaseMouseButtonsMacroAction : 'releaseMouseButtons',
|
||||
MoveMouseMacroAction : 'moveMouse',
|
||||
ScrollMouseMacroAction : 'scrollMouse',
|
||||
DelayMacroAction : 'delay',
|
||||
TextMacroAction : 'text'
|
||||
KeyMacroAction : 'key',
|
||||
PressMouseButtonsMacroAction : 'pressMouseButtons',
|
||||
HoldMouseButtonsMacroAction : 'holdMouseButtons',
|
||||
ReleaseMouseButtonsMacroAction : 'releaseMouseButtons',
|
||||
MoveMouseMacroAction : 'moveMouse',
|
||||
ScrollMouseMacroAction : 'scrollMouse',
|
||||
DelayMacroAction : 'delay',
|
||||
TextMacroAction : 'text'
|
||||
};
|
||||
|
||||
export abstract class MacroAction extends Serializable<MacroAction> {
|
||||
@@ -42,13 +45,19 @@ export abstract class MacroAction extends Serializable<MacroAction> {
|
||||
}
|
||||
}
|
||||
|
||||
readAndAssertMacroActionId(buffer: UhkBuffer) {
|
||||
let classname = this.constructor.name;
|
||||
let readMacroActionId = buffer.readUInt8();
|
||||
let macroActionId = MacroActionId[<string> classname];
|
||||
if (readMacroActionId !== macroActionId) {
|
||||
readAndAssertMacroActionId(buffer: UhkBuffer): MacroActionId {
|
||||
let classname: string = this.constructor.name;
|
||||
let readMacroActionId: MacroActionId = buffer.readUInt8();
|
||||
let macroActionId: MacroActionId = MacroActionId[classname];
|
||||
if (macroActionId === MacroActionId.KeyMacroAction) {
|
||||
if (readMacroActionId < MacroActionId.KeyMacroAction || readMacroActionId > MacroActionId.LastKeyMacroAction) {
|
||||
throw `Invalid ${classname} first byte: ${readMacroActionId}`;
|
||||
}
|
||||
}
|
||||
else if (readMacroActionId !== macroActionId) {
|
||||
throw `Invalid ${classname} first byte: ${readMacroActionId}`;
|
||||
}
|
||||
return readMacroActionId;
|
||||
}
|
||||
|
||||
abstract _fromJsObject(jsObject: any): MacroAction;
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
import {ClassArray} from '../../ClassArray';
|
||||
import {UhkBuffer} from '../../UhkBuffer';
|
||||
import {DelayMacroAction} from './DelayMacroAction';
|
||||
import {HoldKeyMacroAction} from './HoldKeyMacroAction';
|
||||
import {HoldModifiersMacroAction} from './HoldModifiersMacroAction';
|
||||
import {HoldMouseButtonsMacroAction} from './HoldMouseButtonsMacroAction';
|
||||
import {KeyMacroAction} from './KeyMacroAction';
|
||||
import {MacroAction, MacroActionId, macroActionType} from './MacroAction';
|
||||
import {MoveMouseMacroAction} from './MoveMouseMacroAction';
|
||||
import {PressKeyMacroAction} from './PressKeyMacroAction';
|
||||
import {PressModifiersMacroAction} from './PressModifiersMacroAction';
|
||||
import {PressMouseButtonsMacroAction} from './PressMouseButtonsMacroAction';
|
||||
import {ReleaseKeyMacroAction} from './ReleaseKeyMacroAction';
|
||||
import {ReleaseModifiersMacroAction} from './ReleaseModifiersMacroAction';
|
||||
import {ReleaseMouseButtonsMacroAction} from './ReleaseMouseButtonsMacroAction';
|
||||
import {ScrollMouseMacroAction} from './ScrollMouseMacroAction';
|
||||
import {TextMacroAction} from './TextMacroAction';
|
||||
@@ -19,18 +14,8 @@ export class MacroActions extends ClassArray<MacroAction> {
|
||||
|
||||
jsObjectToClass(jsObject: any): MacroAction {
|
||||
switch (jsObject.macroActionType) {
|
||||
case macroActionType.PressKeyMacroAction:
|
||||
return new PressKeyMacroAction().fromJsObject(jsObject);
|
||||
case macroActionType.HoldKeyMacroAction:
|
||||
return new HoldKeyMacroAction().fromJsObject(jsObject);
|
||||
case macroActionType.ReleaseKeyMacroAction:
|
||||
return new ReleaseKeyMacroAction().fromJsObject(jsObject);
|
||||
case macroActionType.PressModifiersMacroAction:
|
||||
return new PressModifiersMacroAction().fromJsObject(jsObject);
|
||||
case macroActionType.HoldModifiersMacroAction:
|
||||
return new HoldModifiersMacroAction().fromJsObject(jsObject);
|
||||
case macroActionType.ReleaseModifiersMacroAction:
|
||||
return new ReleaseModifiersMacroAction().fromJsObject(jsObject);
|
||||
case macroActionType.KeyMacroAction:
|
||||
return new KeyMacroAction().fromJsObject(jsObject);
|
||||
case macroActionType.PressMouseButtonsMacroAction:
|
||||
return new PressMouseButtonsMacroAction().fromJsObject(jsObject);
|
||||
case macroActionType.HoldMouseButtonsMacroAction:
|
||||
@@ -59,19 +44,10 @@ export class MacroActions extends ClassArray<MacroAction> {
|
||||
buffer.enableDump = false;
|
||||
}
|
||||
|
||||
if (macroActionFirstByte >= MacroActionId.KeyMacroAction && macroActionFirstByte <= MacroActionId.LastKeyMacroAction) {
|
||||
return new KeyMacroAction().fromBinary(buffer);
|
||||
}
|
||||
switch (macroActionFirstByte) {
|
||||
case MacroActionId.PressKeyMacroAction:
|
||||
return new PressKeyMacroAction().fromBinary(buffer);
|
||||
case MacroActionId.HoldKeyMacroAction:
|
||||
return new HoldKeyMacroAction().fromBinary(buffer);
|
||||
case MacroActionId.ReleaseKeyMacroAction:
|
||||
return new ReleaseKeyMacroAction().fromBinary(buffer);
|
||||
case MacroActionId.PressModifiersMacroAction:
|
||||
return new PressModifiersMacroAction().fromBinary(buffer);
|
||||
case MacroActionId.HoldModifiersMacroAction:
|
||||
return new HoldModifiersMacroAction().fromBinary(buffer);
|
||||
case MacroActionId.ReleaseModifiersMacroAction:
|
||||
return new ReleaseModifiersMacroAction().fromBinary(buffer);
|
||||
case MacroActionId.PressMouseButtonsMacroAction:
|
||||
return new PressMouseButtonsMacroAction().fromBinary(buffer);
|
||||
case MacroActionId.HoldMouseButtonsMacroAction:
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
import {assertUInt8} from '../../assert';
|
||||
import {UhkBuffer} from '../../UhkBuffer';
|
||||
import {MacroAction, MacroActionId, macroActionType} from './MacroAction';
|
||||
|
||||
export class PressKeyMacroAction extends MacroAction {
|
||||
|
||||
@assertUInt8
|
||||
scancode: number;
|
||||
|
||||
_fromJsObject(jsObject: any): PressKeyMacroAction {
|
||||
this.assertMacroActionType(jsObject);
|
||||
this.scancode = jsObject.scancode;
|
||||
return this;
|
||||
}
|
||||
|
||||
_fromBinary(buffer: UhkBuffer): PressKeyMacroAction {
|
||||
this.readAndAssertMacroActionId(buffer);
|
||||
this.scancode = buffer.readUInt8();
|
||||
return this;
|
||||
}
|
||||
|
||||
_toJsObject(): any {
|
||||
return {
|
||||
macroActionType: macroActionType.PressKeyMacroAction,
|
||||
scancode: this.scancode
|
||||
};
|
||||
}
|
||||
|
||||
_toBinary(buffer: UhkBuffer) {
|
||||
buffer.writeUInt8(MacroActionId.PressKeyMacroAction);
|
||||
buffer.writeUInt8(this.scancode);
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return `<PressKeyMacroAction scancode="${this.scancode}">`;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
import {assertUInt8} from '../../assert';
|
||||
import {UhkBuffer} from '../../UhkBuffer';
|
||||
import {KeyModifiers} from '../KeyModifiers';
|
||||
import {MacroAction, MacroActionId, macroActionType} from './MacroAction';
|
||||
|
||||
export class PressModifiersMacroAction extends MacroAction {
|
||||
|
||||
@assertUInt8
|
||||
modifierMask: number;
|
||||
|
||||
_fromJsObject(jsObject: any): PressModifiersMacroAction {
|
||||
this.assertMacroActionType(jsObject);
|
||||
this.modifierMask = jsObject.modifierMask;
|
||||
return this;
|
||||
}
|
||||
|
||||
_fromBinary(buffer: UhkBuffer): PressModifiersMacroAction {
|
||||
this.readAndAssertMacroActionId(buffer);
|
||||
this.modifierMask = buffer.readUInt8();
|
||||
return this;
|
||||
}
|
||||
|
||||
_toJsObject(): any {
|
||||
return {
|
||||
macroActionType: macroActionType.PressModifiersMacroAction,
|
||||
modifierMask: this.modifierMask
|
||||
};
|
||||
}
|
||||
|
||||
_toBinary(buffer: UhkBuffer) {
|
||||
buffer.writeUInt8(MacroActionId.PressModifiersMacroAction);
|
||||
buffer.writeUInt8(this.modifierMask);
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return `<PressModifiersMacroAction modifierMask="${this.modifierMask}">`;
|
||||
}
|
||||
|
||||
isModifierActive(modifier: KeyModifiers): boolean {
|
||||
return (this.modifierMask & modifier) > 0;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
import {assertUInt8} from '../../assert';
|
||||
import {UhkBuffer} from '../../UhkBuffer';
|
||||
import {MacroAction, MacroActionId, macroActionType} from './MacroAction';
|
||||
|
||||
export class ReleaseKeyMacroAction extends MacroAction {
|
||||
|
||||
@assertUInt8
|
||||
scancode: number;
|
||||
|
||||
_fromJsObject(jsObject: any): ReleaseKeyMacroAction {
|
||||
this.assertMacroActionType(jsObject);
|
||||
this.scancode = jsObject.scancode;
|
||||
return this;
|
||||
}
|
||||
|
||||
_fromBinary(buffer: UhkBuffer): ReleaseKeyMacroAction {
|
||||
this.readAndAssertMacroActionId(buffer);
|
||||
this.scancode = buffer.readUInt8();
|
||||
return this;
|
||||
}
|
||||
|
||||
_toJsObject(): any {
|
||||
return {
|
||||
macroActionType: macroActionType.ReleaseKeyMacroAction,
|
||||
scancode: this.scancode
|
||||
};
|
||||
}
|
||||
|
||||
_toBinary(buffer: UhkBuffer) {
|
||||
buffer.writeUInt8(MacroActionId.ReleaseKeyMacroAction);
|
||||
buffer.writeUInt8(this.scancode);
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return `<ReleaseKeyMacroAction scancode="${this.scancode}">`;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
import {assertUInt8} from '../../assert';
|
||||
import {UhkBuffer} from '../../UhkBuffer';
|
||||
import {KeyModifiers} from '../KeyModifiers';
|
||||
import {MacroAction, MacroActionId, macroActionType} from './MacroAction';
|
||||
|
||||
export class ReleaseModifiersMacroAction extends MacroAction {
|
||||
|
||||
@assertUInt8
|
||||
modifierMask: number;
|
||||
|
||||
_fromJsObject(jsObject: any): ReleaseModifiersMacroAction {
|
||||
this.assertMacroActionType(jsObject);
|
||||
this.modifierMask = jsObject.modifierMask;
|
||||
return this;
|
||||
}
|
||||
|
||||
_fromBinary(buffer: UhkBuffer): ReleaseModifiersMacroAction {
|
||||
this.readAndAssertMacroActionId(buffer);
|
||||
this.modifierMask = buffer.readUInt8();
|
||||
return this;
|
||||
}
|
||||
|
||||
_toJsObject(): any {
|
||||
return {
|
||||
macroActionType: macroActionType.ReleaseModifiersMacroAction,
|
||||
modifierMask: this.modifierMask
|
||||
};
|
||||
}
|
||||
|
||||
_toBinary(buffer: UhkBuffer) {
|
||||
buffer.writeUInt8(MacroActionId.ReleaseModifiersMacroAction);
|
||||
buffer.writeUInt8(this.modifierMask);
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return `<ReleaseModifiersMacroAction modifierMask="${this.modifierMask}">`;
|
||||
}
|
||||
|
||||
isModifierActive(modifier: KeyModifiers): boolean {
|
||||
return (this.modifierMask & modifier) > 0;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,10 @@
|
||||
export * from './DelayMacroAction';
|
||||
export * from './HoldKeyMacroAction';
|
||||
export * from './HoldModifiersMacroAction';
|
||||
export * from './HoldMouseButtonsMacroAction';
|
||||
export * from './KeyMacroAction';
|
||||
export * from './MacroAction';
|
||||
export * from './MacroActions';
|
||||
export * from './MoveMouseMacroAction';
|
||||
export * from './PressKeyMacroAction';
|
||||
export * from './PressModifiersMacroAction';
|
||||
export * from './PressMouseButtonsMacroAction';
|
||||
export * from './ReleaseKeyMacroAction';
|
||||
export * from './ReleaseModifiersMacroAction';
|
||||
export * from './ReleaseMouseButtonsMacroAction';
|
||||
export * from './ScrollMouseMacroAction';
|
||||
export * from './TextMacroAction';
|
||||
|
||||
@@ -985,27 +985,33 @@
|
||||
"name": "My address",
|
||||
"macroActions": [
|
||||
{
|
||||
"macroActionType": "pressKey",
|
||||
"macroActionType": "key",
|
||||
"action": "press",
|
||||
"scancode": 111
|
||||
},
|
||||
{
|
||||
"macroActionType": "holdKey",
|
||||
"macroActionType": "key",
|
||||
"action": "hold",
|
||||
"scancode": 83
|
||||
},
|
||||
{
|
||||
"macroActionType": "releaseKey",
|
||||
"macroActionType": "key",
|
||||
"action": "release",
|
||||
"scancode": 112
|
||||
},
|
||||
{
|
||||
"macroActionType": "pressModifiers",
|
||||
"macroActionType": "key",
|
||||
"action": "press",
|
||||
"modifierMask": 93
|
||||
},
|
||||
{
|
||||
"macroActionType": "holdModifiers",
|
||||
"macroActionType": "key",
|
||||
"action": "hold",
|
||||
"modifierMask": 101
|
||||
},
|
||||
{
|
||||
"macroActionType": "releaseModifiers",
|
||||
"macroActionType": "key",
|
||||
"action": "release",
|
||||
"modifierMask": 133
|
||||
},
|
||||
{
|
||||
@@ -1047,7 +1053,8 @@
|
||||
"name": "Blah Blah blah",
|
||||
"macroActions": [
|
||||
{
|
||||
"macroActionType": "pressKey",
|
||||
"macroActionType": "key",
|
||||
"action": "press",
|
||||
"scancode": 111
|
||||
},
|
||||
{
|
||||
|
||||
@@ -99,7 +99,7 @@ export class MapperService {
|
||||
}
|
||||
|
||||
public scanCodeToText(scanCode: number): string[] {
|
||||
return this.scanCodeTextMap[scanCode];
|
||||
return this.scanCodeTextMap[scanCode] || [ 'Unkown' ];
|
||||
}
|
||||
|
||||
public scanCodeToSvgImagePath(scanCode: number): string {
|
||||
|
||||
Reference in New Issue
Block a user