diff --git a/packages/uhk-common/src/config-serializer/config-items/macro-action/key-macro-action.spec.ts b/packages/uhk-common/src/config-serializer/config-items/macro-action/key-macro-action.spec.ts index 80cf8e8d..a663b40d 100644 --- a/packages/uhk-common/src/config-serializer/config-items/macro-action/key-macro-action.spec.ts +++ b/packages/uhk-common/src/config-serializer/config-items/macro-action/key-macro-action.spec.ts @@ -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); diff --git a/packages/uhk-common/src/config-serializer/config-items/macro-action/key-macro-action.ts b/packages/uhk-common/src/config-serializer/config-items/macro-action/key-macro-action.ts index 7ca5e2e1..afb65e2b 100644 --- a/packages/uhk-common/src/config-serializer/config-items/macro-action/key-macro-action.ts +++ b/packages/uhk-common/src/config-serializer/config-items/macro-action/key-macro-action.ts @@ -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 { diff --git a/packages/uhk-common/src/config-serializer/config-items/macro-action/macro-action.ts b/packages/uhk-common/src/config-serializer/config-items/macro-action/macro-action.ts index 7e0f655e..342fae47 100644 --- a/packages/uhk-common/src/config-serializer/config-items/macro-action/macro-action.ts +++ b/packages/uhk-common/src/config-serializer/config-items/macro-action/macro-action.ts @@ -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 } diff --git a/packages/uhk-common/src/config-serializer/config-items/macro-action/mouse-button-macro-action.ts b/packages/uhk-common/src/config-serializer/config-items/macro-action/mouse-button-macro-action.ts index 09b5f0a2..d500ac2b 100644 --- a/packages/uhk-common/src/config-serializer/config-items/macro-action/mouse-button-macro-action.ts +++ b/packages/uhk-common/src/config-serializer/config-items/macro-action/mouse-button-macro-action.ts @@ -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 { diff --git a/packages/uhk-web/src/app/components/macro/action-editor/tab/key/macro-key.component.html b/packages/uhk-web/src/app/components/macro/action-editor/tab/key/macro-key.component.html index 1a1f7f72..ef0b009e 100644 --- a/packages/uhk-web/src/app/components/macro/action-editor/tab/key/macro-key.component.html +++ b/packages/uhk-web/src/app/components/macro/action-editor/tab/key/macro-key.component.html @@ -1,16 +1,16 @@