refactor: Change name of actions (#470)
* style: shorter import in key-macro-action.ts * refactor: rename 'press' macro key action to 'tap' * refactor: rename 'hold' macro key action to 'press' * refactor: rename 'press' macro mouse action to 'click' * style: fix stylelint
This commit is contained in:
committed by
László Monda
parent
133f8be370
commit
6c6e2af047
+3
-3
@@ -1,6 +1,6 @@
|
||||
import { KeyMacroAction } from './key-macro-action';
|
||||
import { binaryDefaultHelper, jsonDefaultHelper } from '../../../../test/serializer-test-helper';
|
||||
import { MacroSubAction } from './macro-action';
|
||||
import { MacroKeySubAction } from './macro-action';
|
||||
import { KeystrokeType } from '../key-action';
|
||||
|
||||
describe('key-macro-action', () => {
|
||||
@@ -12,7 +12,7 @@ describe('key-macro-action', () => {
|
||||
describe('full serialization', () => {
|
||||
it('should json match', () => {
|
||||
const action = new KeyMacroAction();
|
||||
action.action = MacroSubAction.hold;
|
||||
action.action = MacroKeySubAction.press;
|
||||
action.type = KeystrokeType.basic;
|
||||
action.scancode = 100;
|
||||
jsonDefaultHelper(action);
|
||||
@@ -20,7 +20,7 @@ describe('key-macro-action', () => {
|
||||
|
||||
it('should binary match', () => {
|
||||
const action = new KeyMacroAction();
|
||||
action.action = MacroSubAction.hold;
|
||||
action.action = MacroKeySubAction.press;
|
||||
action.type = KeystrokeType.basic;
|
||||
action.scancode = 100;
|
||||
binaryDefaultHelper(action);
|
||||
|
||||
+11
-11
@@ -1,8 +1,8 @@
|
||||
import { assertEnum, assertUInt8 } from '../../assert';
|
||||
import { UhkBuffer } from '../../uhk-buffer';
|
||||
import { KeyModifiers } from '../key-modifiers';
|
||||
import { MacroAction, MacroActionId, MacroSubAction, macroActionType } from './macro-action';
|
||||
import { KeystrokeType } from '../key-action/keystroke-type';
|
||||
import { MacroAction, MacroActionId, MacroKeySubAction, macroActionType } from './macro-action';
|
||||
import { KeystrokeType } from '../key-action';
|
||||
|
||||
interface JsObjectKeyMacroAction {
|
||||
macroActionType: string;
|
||||
@@ -14,8 +14,8 @@ interface JsObjectKeyMacroAction {
|
||||
|
||||
export class KeyMacroAction extends MacroAction {
|
||||
|
||||
@assertEnum(MacroSubAction)
|
||||
action: MacroSubAction;
|
||||
@assertEnum(MacroKeySubAction)
|
||||
action: MacroKeySubAction;
|
||||
|
||||
@assertEnum(KeystrokeType)
|
||||
type: KeystrokeType;
|
||||
@@ -39,7 +39,7 @@ export class KeyMacroAction extends MacroAction {
|
||||
|
||||
fromJsonObject(jsObject: JsObjectKeyMacroAction): KeyMacroAction {
|
||||
this.assertMacroActionType(jsObject);
|
||||
this.action = MacroSubAction[jsObject.action];
|
||||
this.action = MacroKeySubAction[jsObject.action];
|
||||
if (jsObject.type === 'media') {
|
||||
this.type = jsObject.scancode < 256 ? KeystrokeType.shortMedia : KeystrokeType.longMedia;
|
||||
} else {
|
||||
@@ -69,7 +69,7 @@ export class KeyMacroAction extends MacroAction {
|
||||
toJsonObject(): any {
|
||||
const jsObject: JsObjectKeyMacroAction = {
|
||||
macroActionType: macroActionType.KeyMacroAction,
|
||||
action: MacroSubAction[this.action]
|
||||
action: MacroKeySubAction[this.action]
|
||||
};
|
||||
|
||||
if (this.hasScancode()) {
|
||||
@@ -121,16 +121,16 @@ export class KeyMacroAction extends MacroAction {
|
||||
return !!this.modifierMask;
|
||||
}
|
||||
|
||||
isHoldAction(): boolean {
|
||||
return this.action === MacroSubAction.hold;
|
||||
isPressAction(): boolean {
|
||||
return this.action === MacroKeySubAction.press;
|
||||
}
|
||||
|
||||
isPressAction(): boolean {
|
||||
return this.action === MacroSubAction.press;
|
||||
isTapAction(): boolean {
|
||||
return this.action === MacroKeySubAction.tap;
|
||||
}
|
||||
|
||||
isReleaseAction(): boolean {
|
||||
return this.action === MacroSubAction.release;
|
||||
return this.action === MacroKeySubAction.release;
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
|
||||
@@ -23,8 +23,14 @@ export enum MacroActionId {
|
||||
TextMacroAction = 70
|
||||
}
|
||||
|
||||
export enum MacroSubAction {
|
||||
press = 0,
|
||||
export enum MacroKeySubAction {
|
||||
tap = 0,
|
||||
press = 1,
|
||||
release = 2
|
||||
}
|
||||
|
||||
export enum MacroMouseSubAction {
|
||||
click = 0,
|
||||
hold = 1,
|
||||
release = 2
|
||||
}
|
||||
|
||||
+10
-10
@@ -1,6 +1,6 @@
|
||||
import { assertEnum, assertUInt8 } from '../../assert';
|
||||
import { UhkBuffer } from '../../uhk-buffer';
|
||||
import { MacroAction, MacroActionId, MacroSubAction, macroActionType } from './macro-action';
|
||||
import { MacroAction, MacroActionId, MacroMouseSubAction, macroActionType } from './macro-action';
|
||||
|
||||
export enum MouseButtons {
|
||||
Left = 1 << 0,
|
||||
@@ -15,8 +15,8 @@ interface JsObjectMouseButtonMacroAction {
|
||||
}
|
||||
|
||||
export class MouseButtonMacroAction extends MacroAction {
|
||||
@assertEnum(MacroSubAction)
|
||||
action: MacroSubAction;
|
||||
@assertEnum(MacroMouseSubAction)
|
||||
action: MacroMouseSubAction;
|
||||
|
||||
@assertUInt8
|
||||
mouseButtonsMask: number;
|
||||
@@ -32,7 +32,7 @@ export class MouseButtonMacroAction extends MacroAction {
|
||||
|
||||
fromJsonObject(jsObject: JsObjectMouseButtonMacroAction): MouseButtonMacroAction {
|
||||
this.assertMacroActionType(jsObject);
|
||||
this.action = MacroSubAction[jsObject.action];
|
||||
this.action = MacroMouseSubAction[jsObject.action];
|
||||
this.mouseButtonsMask = jsObject.mouseButtonsMask;
|
||||
return this;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ export class MouseButtonMacroAction extends MacroAction {
|
||||
toJsonObject(): any {
|
||||
return {
|
||||
macroActionType: macroActionType.MouseButtonMacroAction,
|
||||
action: MacroSubAction[this.action],
|
||||
action: MacroMouseSubAction[this.action],
|
||||
mouseButtonsMask: this.mouseButtonsMask
|
||||
};
|
||||
}
|
||||
@@ -81,16 +81,16 @@ export class MouseButtonMacroAction extends MacroAction {
|
||||
return this.mouseButtonsMask !== 0;
|
||||
}
|
||||
|
||||
isOnlyHoldAction(): boolean {
|
||||
return this.action === MacroSubAction.hold;
|
||||
isOnlyClickAction(): boolean {
|
||||
return this.action === MacroMouseSubAction.click;
|
||||
}
|
||||
|
||||
isOnlyPressAction(): boolean {
|
||||
return this.action === MacroSubAction.press;
|
||||
isOnlyHoldAction(): boolean {
|
||||
return this.action === MacroMouseSubAction.hold;
|
||||
}
|
||||
|
||||
isOnlyReleaseAction(): boolean {
|
||||
return this.action === MacroSubAction.release;
|
||||
return this.action === MacroMouseSubAction.release;
|
||||
}
|
||||
|
||||
public getName(): string {
|
||||
|
||||
Reference in New Issue
Block a user