diff --git a/package.json b/package.json index 5549b053..e6ab3b90 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "lint:ts:test-serializer": "tslint --type-check --project ./packages/test-serializer/tsconfig.json", "lint:ts:uhk-usb": "tslint --type-check --project ./packages/uhk-usb/tsconfig.json", "lint:style": "stylelint \"packages/uhk-agent/src/**/*.scss\" \"packages/uhk-web/src/**/*.scss\" --syntax scss", - "build": "run-s build:web build:electron build:usb build:common", + "build": "run-s build:common build:usb build:web build:electron", "build:web": "lerna exec --scope uhk-web npm run build", "build:electron": "cross-env AOT_BUILD=true run-s -sn build:electron:renderer build:electron:main", "build:electron:main": "lerna exec --scope uhk-agent npm run build", diff --git a/packages/uhk-common/src/config-serializer/README.md b/packages/uhk-common/src/config-serializer/README.md index 46620bdd..f2a7e973 100644 --- a/packages/uhk-common/src/config-serializer/README.md +++ b/packages/uhk-common/src/config-serializer/README.md @@ -37,7 +37,7 @@ KeyActions.fromJsObject: [{"keyActionType":"none"},{"keyActionType":"keystroke", KeystrokeModifiersAction.fromJsObject: {"keyActionType":"keystrokeModifiers","modifierMask":33} => KeystrokeWithModifiersAction.fromJsObject: {"keyActionType":"keystrokeWithModifiers","scancode":120,"modifierMask":16} => SwitchLayerAction.fromJsObject: {"keyActionType":"switchLayer","layer":"fn","toggle":false} => - DualRoleKeystrokeAction.fromJsObject: {"keyActionType":"dualRoleKeystroke","scancode":111,"longPressAction":"mod"} => + DualRoleKeystrokeAction.fromJsObject: {"keyActionType":"dualRoleKeystroke","scancode":111,"secondaryRoleAction":"mod"} => MouseAction.fromJsObject: {"keyActionType":"mouse","mouseAction":"scrollDown"} => PlayMacroAction.fromJsObject: {"keyActionType":"playMacro","macroId":0} => SwitchKeymapAction.fromJsObject: {"keyActionType":"switchKeymap","keymapId":1} => @@ -47,7 +47,7 @@ KeyActions.toBinary: => ['u8(9)] KeystrokeModifiersAction.toBinary: => ['u8(2), u8(33)] KeystrokeWithModifiersAction.toBinary: => ['u8(3), u8(120), u8(16)] SwitchLayerAction.toBinary: => ['u8(5), u8(1)] - DualRoleKeystrokeAction.toBinary: => ['u8(4), u8(111), u8(8)] + DualRoleKeystrokeAction.toBinary: => ['u8(4), u8(111), u8(8)] MouseAction.toBinary: => ['u8(7), u8(8)] PlayMacroAction.toBinary: => ['u8(8), u8(0)] SwitchKeymapAction.toBinary: => ['u8(6), u8(1)] @@ -57,7 +57,7 @@ KeyActions.fromBinary: [u8(9)] KeystrokeModifiersAction.fromBinary: [u8(2), u8(33)] => KeystrokeWithModifiersAction.fromBinary: [u8(3), u8(120), u8(16)] => SwitchLayerAction.fromBinary: [u8(5), u8(1)] => - DualRoleKeystrokeAction.fromBinary: [u8(4), u8(111), u8(8)] => + DualRoleKeystrokeAction.fromBinary: [u8(4), u8(111), u8(8)] => MouseAction.fromBinary: [u8(7), u8(8)] => PlayMacroAction.fromBinary: [u8(8), u8(0)] => SwitchKeymapAction.fromBinary: [u8(6), u8(1)] => @@ -67,7 +67,7 @@ KeyActions.toJsObject: KeystrokeModifiersAction.toJsObject: => {"keyActionType":"keystrokeModifiers","modifierMask":33} KeystrokeWithModifiersAction.toJsObject: => {"keyActionType":"keystrokeWithModifiers","scancode":120,"modifierMask":16} SwitchLayerAction.toJsObject: => {"keyActionType":"switchLayer","layer":"fn","toggle":false} - DualRoleKeystrokeAction.toJsObject: => {"keyActionType":"dualRoleKeystroke","scancode":111,"longPressAction":"mod"} + DualRoleKeystrokeAction.toJsObject: => {"keyActionType":"dualRoleKeystroke","scancode":111,"secondaryRoleAction":"mod"} MouseAction.toJsObject: => {"keyActionType":"mouse","mouseAction":"scrollDown"} PlayMacroAction.toJsObject: => {"keyActionType":"playMacro","macroId":0} SwitchKeymapAction.toJsObject: => {"keyActionType":"switchKeymap","keymapId":1} diff --git a/packages/uhk-common/src/config-serializer/config-items/index.ts b/packages/uhk-common/src/config-serializer/config-items/index.ts index 0c0c1a77..009ed593 100644 --- a/packages/uhk-common/src/config-serializer/config-items/index.ts +++ b/packages/uhk-common/src/config-serializer/config-items/index.ts @@ -4,7 +4,7 @@ export * from './hardware-configuration'; export * from './key-modifiers'; export * from './keymap'; export * from './layer'; -export * from './long-press-action'; +export * from './secondary-role-action'; export * from './macro'; export * from './module'; export * from './module-configuration'; diff --git a/packages/uhk-common/src/config-serializer/config-items/key-action/key-action.ts b/packages/uhk-common/src/config-serializer/config-items/key-action/key-action.ts index 459b8afd..59f17463 100644 --- a/packages/uhk-common/src/config-serializer/config-items/key-action/key-action.ts +++ b/packages/uhk-common/src/config-serializer/config-items/key-action/key-action.ts @@ -10,7 +10,7 @@ export enum KeyActionId { 5 bits: 1: Do we have scancode? 2: Do we have modifiers? - 3: Do we have longpress? + 3: Do we have secondaryRole? 4-5: What kind of keystroke? (basic, short/long media, system) */ LastKeystrokeAction = 31, // TODO: remove this after refactoring the keyActionId check diff --git a/packages/uhk-common/src/config-serializer/config-items/key-action/keystroke-action.spec.ts b/packages/uhk-common/src/config-serializer/config-items/key-action/keystroke-action.spec.ts index 99f5f546..94ae8f6d 100644 --- a/packages/uhk-common/src/config-serializer/config-items/key-action/keystroke-action.spec.ts +++ b/packages/uhk-common/src/config-serializer/config-items/key-action/keystroke-action.spec.ts @@ -1,6 +1,6 @@ import { KeystrokeAction } from './keystroke-action'; import { KeystrokeType } from './keystroke-type'; -import { LongPressAction } from '../long-press-action'; +import { SecondaryRoleAction } from '../secondary-role-action'; describe('keystroke-action', () => { it('should be instantiate', () => { @@ -13,7 +13,7 @@ describe('keystroke-action', () => { other.type = KeystrokeType.basic; other.scancode = 125; other.modifierMask = 1; - other.longPressAction = LongPressAction.leftAlt; + other.secondaryRoleAction = SecondaryRoleAction.leftAlt; const action = new KeystrokeAction(other); expect(action).toEqual(other); }); @@ -104,12 +104,12 @@ describe('keystroke-action', () => { }); }); - describe('longPressAction', () => { + describe('secondaryRoleAction', () => { it('should store the value without modification', () => { - const value = LongPressAction.leftAlt; + const value = SecondaryRoleAction.leftAlt; const action = new KeystrokeAction(); - action.longPressAction = value; - expect(action.longPressAction).toEqual(value); + action.secondaryRoleAction = value; + expect(action.secondaryRoleAction).toEqual(value); }); }); @@ -182,7 +182,7 @@ describe('keystroke-action', () => { type: 'basic', scancode: 100, modifierMask: 10, - longPressAction: 'leftAlt' + secondaryRoleAction: 'leftAlt' }; const action = new KeystrokeAction(); action.fromJsonObject(jsObject); @@ -191,7 +191,7 @@ describe('keystroke-action', () => { expected.type = KeystrokeType.basic; expected.scancode = 100; expected.modifierMask = 10; - expected.longPressAction = LongPressAction.leftAlt; + expected.secondaryRoleAction = SecondaryRoleAction.leftAlt; expect(action).toEqual(expected); }); @@ -202,7 +202,7 @@ describe('keystroke-action', () => { type: 'system', scancode: 100, modifierMask: 10, - longPressAction: 'leftAlt' + secondaryRoleAction: 'leftAlt' }; const action = new KeystrokeAction(); action.fromJsonObject(jsObject); @@ -211,7 +211,7 @@ describe('keystroke-action', () => { expected.type = KeystrokeType.system; expected.scancode = 100; expected.modifierMask = 10; - expected.longPressAction = LongPressAction.leftAlt; + expected.secondaryRoleAction = SecondaryRoleAction.leftAlt; expect(action).toEqual(expected); }); @@ -222,7 +222,7 @@ describe('keystroke-action', () => { type: 'media', scancode: 100, modifierMask: 10, - longPressAction: 'leftAlt' + secondaryRoleAction: 'leftAlt' }; const action = new KeystrokeAction(); action.fromJsonObject(jsObject); @@ -231,7 +231,7 @@ describe('keystroke-action', () => { expected.type = KeystrokeType.shortMedia; expected.scancode = 100; expected.modifierMask = 10; - expected.longPressAction = LongPressAction.leftAlt; + expected.secondaryRoleAction = SecondaryRoleAction.leftAlt; expect(action).toEqual(expected); }); @@ -242,7 +242,7 @@ describe('keystroke-action', () => { type: 'media', scancode: 256, modifierMask: 10, - longPressAction: 'leftAlt' + secondaryRoleAction: 'leftAlt' }; const action = new KeystrokeAction(); action.fromJsonObject(jsObject); @@ -251,7 +251,7 @@ describe('keystroke-action', () => { expected.type = KeystrokeType.longMedia; expected.scancode = 256; expected.modifierMask = 10; - expected.longPressAction = LongPressAction.leftAlt; + expected.secondaryRoleAction = SecondaryRoleAction.leftAlt; expect(action).toEqual(expected); }); @@ -281,7 +281,7 @@ describe('keystroke-action', () => { }); - describe('hasLongPressAction', () => { + describe('hasSecondaryRoleAction', () => { }); diff --git a/packages/uhk-common/src/config-serializer/config-items/key-action/keystroke-action.ts b/packages/uhk-common/src/config-serializer/config-items/key-action/keystroke-action.ts index 0a43b4a1..757f07fc 100644 --- a/packages/uhk-common/src/config-serializer/config-items/key-action/keystroke-action.ts +++ b/packages/uhk-common/src/config-serializer/config-items/key-action/keystroke-action.ts @@ -1,14 +1,14 @@ import { assertEnum, assertUInt8 } from '../../assert'; import { UhkBuffer } from '../../uhk-buffer'; import { KeyModifiers } from '../key-modifiers'; -import { LongPressAction } from '../long-press-action'; +import { SecondaryRoleAction } from '../secondary-role-action'; import { KeyAction, KeyActionId, keyActionType } from './key-action'; import { KeystrokeType } from './keystroke-type'; export enum KeystrokeActionFlag { scancode = 1 << 0, modifierMask = 1 << 1, - longPressAction = 1 << 2 + secondaryRoleAction = 1 << 2 } const KEYSTROKE_ACTION_FLAG_LENGTH = 3; @@ -17,7 +17,7 @@ interface JsonObjectKeystrokeAction { keyActionType: string; scancode?: number; modifierMask?: number; - longPressAction?: string; + secondaryRoleAction?: string; type?: string; } @@ -40,8 +40,8 @@ export class KeystrokeAction extends KeyAction { @assertUInt8 modifierMask: number; - @assertEnum(LongPressAction) - longPressAction: LongPressAction; + @assertEnum(SecondaryRoleAction) + secondaryRoleAction: SecondaryRoleAction; set type(type: KeystrokeType) { if (type === KeystrokeType.shortMedia || type === KeystrokeType.longMedia) { @@ -67,7 +67,7 @@ export class KeystrokeAction extends KeyAction { this.type = other.type; this._scancode = other._scancode; this.modifierMask = other.modifierMask; - this.longPressAction = other.longPressAction; + this.secondaryRoleAction = other.secondaryRoleAction; } fromJsonObject(jsonObject: JsonObjectKeystrokeAction): KeystrokeAction { @@ -80,7 +80,7 @@ export class KeystrokeAction extends KeyAction { this._scancode = jsonObject.scancode; this.modifierMask = jsonObject.modifierMask; - this.longPressAction = LongPressAction[jsonObject.longPressAction]; + this.secondaryRoleAction = SecondaryRoleAction[jsonObject.secondaryRoleAction]; return this; } @@ -94,8 +94,8 @@ export class KeystrokeAction extends KeyAction { if (flags & KeystrokeActionFlag.modifierMask) { this.modifierMask = buffer.readUInt8(); } - if (flags & KeystrokeActionFlag.longPressAction) { - this.longPressAction = buffer.readUInt8(); + if (flags & KeystrokeActionFlag.secondaryRoleAction) { + this.secondaryRoleAction = buffer.readUInt8(); } return this; } @@ -119,8 +119,8 @@ export class KeystrokeAction extends KeyAction { jsonObject.modifierMask = this.modifierMask; } - if (this.hasLongPressAction()) { - jsonObject.longPressAction = LongPressAction[this.longPressAction]; + if (this.hasSecondaryRoleAction()) { + jsonObject.secondaryRoleAction = SecondaryRoleAction[this.secondaryRoleAction]; } return jsonObject; @@ -143,9 +143,9 @@ export class KeystrokeAction extends KeyAction { toWrite.push({data: this.modifierMask, long: false}); } - if (this.hasLongPressAction()) { - flags |= KeystrokeActionFlag.longPressAction; - toWrite.push({data: this.longPressAction, long: false}); + if (this.hasSecondaryRoleAction()) { + flags |= KeystrokeActionFlag.secondaryRoleAction; + toWrite.push({data: this.secondaryRoleAction, long: false}); } const TYPE_OFFSET = flags + (this.type << KEYSTROKE_ACTION_FLAG_LENGTH); @@ -172,8 +172,8 @@ export class KeystrokeAction extends KeyAction { if (this.hasActiveModifier()) { properties.push(`modifierMask="${this.modifierMask}"`); } - if (this.hasLongPressAction()) { - properties.push(`longPressAction="${this.longPressAction}"`); + if (this.hasSecondaryRoleAction()) { + properties.push(`secondaryRoleAction="${this.secondaryRoleAction}"`); } return ``; @@ -187,8 +187,8 @@ export class KeystrokeAction extends KeyAction { return this.modifierMask > 0; } - hasLongPressAction(): boolean { - return this.longPressAction !== undefined; + hasSecondaryRoleAction(): boolean { + return this.secondaryRoleAction !== undefined && this.secondaryRoleAction !== null; } hasScancode(): boolean { diff --git a/packages/uhk-common/src/config-serializer/config-items/long-press-action.ts b/packages/uhk-common/src/config-serializer/config-items/secondary-role-action.ts similarity index 81% rename from packages/uhk-common/src/config-serializer/config-items/long-press-action.ts rename to packages/uhk-common/src/config-serializer/config-items/secondary-role-action.ts index c348914e..ffb77bd9 100644 --- a/packages/uhk-common/src/config-serializer/config-items/long-press-action.ts +++ b/packages/uhk-common/src/config-serializer/config-items/secondary-role-action.ts @@ -1,4 +1,4 @@ -export enum LongPressAction { +export enum SecondaryRoleAction { leftCtrl, leftShift, leftAlt, diff --git a/packages/uhk-web/src/app/components/device/configuration/device-configuration.component.scss b/packages/uhk-web/src/app/components/device/configuration/device-configuration.component.scss index 2fb5db8a..f9404ba3 100644 --- a/packages/uhk-web/src/app/components/device/configuration/device-configuration.component.scss +++ b/packages/uhk-web/src/app/components/device/configuration/device-configuration.component.scss @@ -4,6 +4,6 @@ height: 100%; p { - margin: 1.5rem 0px 1.5rem; + margin: 1.5rem 0; } } 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 568fbe99..1a1f7f72 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 @@ -26,7 +26,8 @@

Press key

Hold key

Release key

- + - \ No newline at end of file + diff --git a/packages/uhk-web/src/app/components/popover/popover.component.html b/packages/uhk-web/src/app/components/popover/popover.component.html index 5c299214..753a7552 100644 --- a/packages/uhk-web/src/app/components/popover/popover.component.html +++ b/packages/uhk-web/src/app/components/popover/popover.component.html @@ -49,7 +49,7 @@
-
- Long press action: - + Secondary role action: + ; - longPressGroups: Array; + secondaryRoleGroups: Array; options: Select2Options; selectedScancodeOption: Select2OptionData; - selectedLongPressIndex: number; + selectedSecondaryRoleIndex: number; constructor(private mapper: MapperService) { super(); @@ -36,11 +36,11 @@ export class KeypressTabComponent extends Tab implements OnChanges { text: 'None' }]; this.scanCodeGroups = this.scanCodeGroups.concat(require('./scancodes.json')); - this.longPressGroups = require('./longPress.json'); + this.secondaryRoleGroups = require('./secondaryRole.json'); this.leftModifierSelects = Array(this.leftModifiers.length).fill(false); this.rightModifierSelects = Array(this.rightModifiers.length).fill(false); this.selectedScancodeOption = this.scanCodeGroups[0]; - this.selectedLongPressIndex = -1; + this.selectedSecondaryRoleIndex = -1; this.options = { templateResult: this.scanCodeTemplateResult, matcher: (term: string, text: string, data: Select2OptionData) => { @@ -100,9 +100,9 @@ export class KeypressTabComponent extends Tab implements OnChanges { this.rightModifierSelects[index] = ((keystrokeAction.modifierMask >> i) & 1) === 1; } - // Restore longPressAction - if (keystrokeAction.longPressAction !== undefined) { - this.selectedLongPressIndex = this.mapper.modifierMapper(keystrokeAction.longPressAction); + // Restore secondaryRoleAction + if (keystrokeAction.secondaryRoleAction !== undefined) { + this.selectedSecondaryRoleIndex = this.mapper.modifierMapper(keystrokeAction.secondaryRoleAction); } return true; @@ -123,9 +123,9 @@ export class KeypressTabComponent extends Tab implements OnChanges { keystrokeAction.modifierMask |= modifiers[i] << this.mapper.modifierMapper(i); } - keystrokeAction.longPressAction = this.selectedLongPressIndex === -1 + keystrokeAction.secondaryRoleAction = this.selectedSecondaryRoleIndex === -1 ? undefined - : this.mapper.modifierMapper(this.selectedLongPressIndex); + : this.mapper.modifierMapper(this.selectedSecondaryRoleIndex); if (this.keyActionValid(keystrokeAction)) { return keystrokeAction; @@ -158,8 +158,8 @@ export class KeypressTabComponent extends Tab implements OnChanges { this.validAction.emit(this.keyActionValid()); } - onLongpressChange(event: { value: string }) { - this.selectedLongPressIndex = +event.value; + onSecondaryRoleChange(event: { value: string }) { + this.selectedSecondaryRoleIndex = +event.value; } onScancodeChange(event: { value: string }) { diff --git a/packages/uhk-web/src/app/components/popover/tab/keypress/longPress.json b/packages/uhk-web/src/app/components/popover/tab/keypress/secondaryRole.json similarity index 100% rename from packages/uhk-web/src/app/components/popover/tab/keypress/longPress.json rename to packages/uhk-web/src/app/components/popover/tab/keypress/secondaryRole.json diff --git a/packages/uhk-web/src/app/components/side-menu/side-menu.component.scss b/packages/uhk-web/src/app/components/side-menu/side-menu.component.scss index e860574a..41003e8e 100644 --- a/packages/uhk-web/src/app/components/side-menu/side-menu.component.scss +++ b/packages/uhk-web/src/app/components/side-menu/side-menu.component.scss @@ -28,7 +28,7 @@ ul { .sidebar { &__level-0 { - padding: 0.5rem 1rem 0 1rem; + padding: 0.5rem 1rem 0; } &__level-1 { padding: 0.5rem 1rem 0.5rem 2rem; diff --git a/packages/uhk-web/src/app/components/svg/wrap/svg-keyboard-wrap.component.ts b/packages/uhk-web/src/app/components/svg/wrap/svg-keyboard-wrap.component.ts index 2da1e1be..2e20c48e 100644 --- a/packages/uhk-web/src/app/components/svg/wrap/svg-keyboard-wrap.component.ts +++ b/packages/uhk-web/src/app/components/svg/wrap/svg-keyboard-wrap.component.ts @@ -25,7 +25,7 @@ import { KeystrokeAction, Layer, LayerName, - LongPressAction, + SecondaryRoleAction, MouseAction, MouseActionParam, PlayMacroAction, @@ -266,10 +266,10 @@ export class SvgKeyboardWrapComponent implements OnInit, OnChanges { }); } - if (keystrokeAction.hasLongPressAction()) { + if (keystrokeAction.hasSecondaryRoleAction()) { content.push({ - name: 'Long press', - value: LongPressAction[keystrokeAction.longPressAction] + name: 'Secondary role', + value: SecondaryRoleAction[keystrokeAction.secondaryRoleAction] }); } return Observable.of(content);