From 49d31f90f777200de27622f83f429a336a9dc167 Mon Sep 17 00:00:00 2001 From: dgyimesi Date: Fri, 23 Aug 2019 22:00:01 +0200 Subject: [PATCH] feat: support more mouse buttons (#936) * feat: support more mouse buttons (#834) * Remove unused style. * Retrigger CI * fix: more button click and texts * fix: the mouse button 4-8 naming * feat: allow extra mouse buttons if userConfig version >= 4.1.1 * fix: version comparison * fix: read correctly the right module informations --- .../config-items/key-action/mouse-action.ts | 7 ++++- .../uhk-common/src/models/hardware-modules.ts | 7 ++--- packages/uhk-common/src/models/index.ts | 3 ++- ...are-module-info.ts => left-module-info.ts} | 2 +- .../src/models/right-module-info.ts | 7 +++++ packages/uhk-usb/src/uhk-operations.ts | 12 ++++++--- .../components/popover/popover.component.html | 1 + .../components/popover/popover.component.ts | 4 ++- .../tab/mouse/mouse-tab.component.html | 23 +++++++++++++++- .../tab/mouse/mouse-tab.component.scss | 26 +++++++++++++++++++ .../popover/tab/mouse/mouse-tab.component.ts | 6 +++++ .../svg/keys/svg-mouse-key/svg-mouse-key.ts | 20 ++++++++++++++ packages/uhk-web/src/app/store/index.ts | 3 +++ 13 files changed, 109 insertions(+), 12 deletions(-) rename packages/uhk-common/src/models/{hardware-module-info.ts => left-module-info.ts} (64%) create mode 100644 packages/uhk-common/src/models/right-module-info.ts diff --git a/packages/uhk-common/src/config-serializer/config-items/key-action/mouse-action.ts b/packages/uhk-common/src/config-serializer/config-items/key-action/mouse-action.ts index a6d34063..6b45c8b4 100644 --- a/packages/uhk-common/src/config-serializer/config-items/key-action/mouse-action.ts +++ b/packages/uhk-common/src/config-serializer/config-items/key-action/mouse-action.ts @@ -15,7 +15,12 @@ export enum MouseActionParam { scrollLeft, scrollRight, accelerate, - decelerate + decelerate, + button4, + button5, + button6, + button7, + button8 } export class MouseAction extends KeyAction { diff --git a/packages/uhk-common/src/models/hardware-modules.ts b/packages/uhk-common/src/models/hardware-modules.ts index 03bd55f7..1a73a5a8 100644 --- a/packages/uhk-common/src/models/hardware-modules.ts +++ b/packages/uhk-common/src/models/hardware-modules.ts @@ -1,6 +1,7 @@ -import { HardwareModuleInfo } from './hardware-module-info'; +import { LeftModuleInfo } from './left-module-info'; +import { RightModuleInfo } from './right-module-info'; export interface HardwareModules { - leftModuleInfo?: HardwareModuleInfo; - rightModuleInfo?: HardwareModuleInfo; + leftModuleInfo?: LeftModuleInfo; + rightModuleInfo?: RightModuleInfo; } diff --git a/packages/uhk-common/src/models/index.ts b/packages/uhk-common/src/models/index.ts index 8248fe95..78f97ba9 100644 --- a/packages/uhk-common/src/models/index.ts +++ b/packages/uhk-common/src/models/index.ts @@ -6,8 +6,9 @@ export * from './app-start-info'; export * from './configuration-reply'; export * from './version-information'; export * from './device-connection-state'; +export * from './left-module-info'; export * from './hardware-modules'; -export * from './hardware-module-info'; +export * from './right-module-info'; export * from './save-user-configuration-data'; export * from './udev-rules-info'; export * from './update-firmware-data'; diff --git a/packages/uhk-common/src/models/hardware-module-info.ts b/packages/uhk-common/src/models/left-module-info.ts similarity index 64% rename from packages/uhk-common/src/models/hardware-module-info.ts rename to packages/uhk-common/src/models/left-module-info.ts index 59fac86c..fdc6205d 100644 --- a/packages/uhk-common/src/models/hardware-module-info.ts +++ b/packages/uhk-common/src/models/left-module-info.ts @@ -1,4 +1,4 @@ -export interface HardwareModuleInfo { +export interface LeftModuleInfo { firmwareVersion?: string; moduleProtocolVersion?: string; } diff --git a/packages/uhk-common/src/models/right-module-info.ts b/packages/uhk-common/src/models/right-module-info.ts new file mode 100644 index 00000000..50818881 --- /dev/null +++ b/packages/uhk-common/src/models/right-module-info.ts @@ -0,0 +1,7 @@ +export interface RightModuleInfo { + deviceProtocolVersion?: string; + hardwareConfigVersion?: string; + firmwareVersion?: string; + moduleProtocolVersion?: string; + userConfigVersion?: string; +} diff --git a/packages/uhk-usb/src/uhk-operations.ts b/packages/uhk-usb/src/uhk-operations.ts index c4dc172e..bfa29145 100644 --- a/packages/uhk-usb/src/uhk-operations.ts +++ b/packages/uhk-usb/src/uhk-operations.ts @@ -1,4 +1,4 @@ -import { HardwareModuleInfo, LogService, UhkBuffer } from 'uhk-common'; +import { LeftModuleInfo, LogService, RightModuleInfo, UhkBuffer } from 'uhk-common'; import { DataOption, KBoot, Properties, UsbPeripheral } from 'kboot'; import { @@ -248,7 +248,7 @@ export class UhkOperations { return false; } - public async getLeftModuleVersionInfo(): Promise { + public async getLeftModuleVersionInfo(): Promise { try { this.logService.debug('[DeviceOperation] USB[T]: Read left module version information'); @@ -277,7 +277,7 @@ export class UhkOperations { }; } - public async getRightModuleVersionInfo(): Promise { + public async getRightModuleVersionInfo(): Promise { this.logService.debug('[DeviceOperation] USB[T]: Read right module version information'); const command = Buffer.from([UsbCommand.GetProperty, DevicePropertyIds.ProtocolVersions]); @@ -287,7 +287,11 @@ export class UhkOperations { uhkBuffer.readUInt8(); return { - firmwareVersion: `${uhkBuffer.readUInt16()}.${uhkBuffer.readUInt16()}.${uhkBuffer.readUInt16()}` + firmwareVersion: `${uhkBuffer.readUInt16()}.${uhkBuffer.readUInt16()}.${uhkBuffer.readUInt16()}`, + deviceProtocolVersion: `${uhkBuffer.readUInt16()}.${uhkBuffer.readUInt16()}.${uhkBuffer.readUInt16()}`, + moduleProtocolVersion: `${uhkBuffer.readUInt16()}.${uhkBuffer.readUInt16()}.${uhkBuffer.readUInt16()}`, + userConfigVersion: `${uhkBuffer.readUInt16()}.${uhkBuffer.readUInt16()}.${uhkBuffer.readUInt16()}`, + hardwareConfigVersion: `${uhkBuffer.readUInt16()}.${uhkBuffer.readUInt16()}.${uhkBuffer.readUInt16()}` }; } 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 9b920258..3b49b1b2 100644 --- a/packages/uhk-web/src/app/components/popover/popover.component.html +++ b/packages/uhk-web/src/app/components/popover/popover.component.html @@ -38,6 +38,7 @@ > ; + extraMouseButtonsSupported$: Observable; private readonly currentKeymap$ = new BehaviorSubject(undefined); @@ -158,6 +159,7 @@ export class PopoverComponent implements OnChanges { keymaps.filter((keymap: Keymap) => currentKeymap.abbreviation !== keymap.abbreviation)) ); this.macroPlaybackSupported$ = store.select(macroPlaybackSupported); + this.extraMouseButtonsSupported$ = store.select(extraMouseButtonsSupported); } ngOnChanges(change: SimpleChanges) { diff --git a/packages/uhk-web/src/app/components/popover/tab/mouse/mouse-tab.component.html b/packages/uhk-web/src/app/components/popover/tab/mouse/mouse-tab.component.html index 6d8e4254..0dc89de8 100644 --- a/packages/uhk-web/src/app/components/popover/tab/mouse/mouse-tab.component.html +++ b/packages/uhk-web/src/app/components/popover/tab/mouse/mouse-tab.component.html @@ -80,6 +80,27 @@ [class.btn-primary]="mouseActionParam === MouseActionParam.rightClick" (click)="setMouseActionParam(MouseActionParam.rightClick)">Right +
+
+ + + +
+
+ + +
+
@@ -104,4 +125,4 @@
-
\ No newline at end of file + diff --git a/packages/uhk-web/src/app/components/popover/tab/mouse/mouse-tab.component.scss b/packages/uhk-web/src/app/components/popover/tab/mouse/mouse-tab.component.scss index e3f4f6e2..9da65257 100644 --- a/packages/uhk-web/src/app/components/popover/tab/mouse/mouse-tab.component.scss +++ b/packages/uhk-web/src/app/components/popover/tab/mouse/mouse-tab.component.scss @@ -54,6 +54,32 @@ } } +.mouse__config--click { + .additional-keys { + display: inline-block; + margin-top: 1rem; + + .btn-group:first-child { + .btn { + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; + } + } + + .btn-group:last-child { + .btn { + border-top: 0; + border-top-left-radius: 0; + border-top-right-radius: 0; + + &:last-child { + right: 1px; + } + } + } + } +} + .mouse__config--speed { .btn-default { font-size: 25px; diff --git a/packages/uhk-web/src/app/components/popover/tab/mouse/mouse-tab.component.ts b/packages/uhk-web/src/app/components/popover/tab/mouse/mouse-tab.component.ts index dec4cf3c..02af4be8 100644 --- a/packages/uhk-web/src/app/components/popover/tab/mouse/mouse-tab.component.ts +++ b/packages/uhk-web/src/app/components/popover/tab/mouse/mouse-tab.component.ts @@ -11,6 +11,7 @@ import { Tab } from '../tab'; }) export class MouseTabComponent extends Tab implements OnChanges { @Input() defaultKeyAction: KeyAction; + @Input() extraMouseButtonsSupported: boolean; /* tslint:disable:variable-name: It is an enum type. So it can start with uppercase. */ MouseActionParam = MouseActionParam; @@ -62,6 +63,11 @@ export class MouseTabComponent extends Tab implements OnChanges { case MouseActionParam.leftClick: case MouseActionParam.middleClick: case MouseActionParam.rightClick: + case MouseActionParam.button4: + case MouseActionParam.button5: + case MouseActionParam.button6: + case MouseActionParam.button7: + case MouseActionParam.button8: this.selectedPageIndex = 2; break; case MouseActionParam.decelerate: diff --git a/packages/uhk-web/src/app/components/svg/keys/svg-mouse-key/svg-mouse-key.ts b/packages/uhk-web/src/app/components/svg/keys/svg-mouse-key/svg-mouse-key.ts index 875782d9..7b3dca12 100644 --- a/packages/uhk-web/src/app/components/svg/keys/svg-mouse-key/svg-mouse-key.ts +++ b/packages/uhk-web/src/app/components/svg/keys/svg-mouse-key/svg-mouse-key.ts @@ -28,6 +28,26 @@ export class SvgMouseKeyComponent implements OnChanges { this.type = 'click'; this.param = 'Middle'; break; + case MouseActionParam.button4: + this.type = 'click'; + this.param = 'Button 4'; + break; + case MouseActionParam.button5: + this.type = 'click'; + this.param = 'Button 5'; + break; + case MouseActionParam.button6: + this.type = 'click'; + this.param = 'Button 6'; + break; + case MouseActionParam.button7: + this.type = 'click'; + this.param = 'Button 7'; + break; + case MouseActionParam.button8: + this.type = 'click'; + this.param = 'Button 8'; + break; case MouseActionParam.scrollDown: this.type = 'scroll'; this.param = 'down'; diff --git a/packages/uhk-web/src/app/store/index.ts b/packages/uhk-web/src/app/store/index.ts index d0704c9e..1491af6a 100644 --- a/packages/uhk-web/src/app/store/index.ts +++ b/packages/uhk-web/src/app/store/index.ts @@ -157,3 +157,6 @@ export const layerDoubleTapSupported = createSelector( return isVersionGte(hardwareModules.rightModuleInfo.firmwareVersion, '8.4.3'); } ); +export const extraMouseButtonsSupported = createSelector(getHardwareModules, (hardwareModules: HardwareModules): boolean => { + return isVersionGte(hardwareModules.rightModuleInfo.userConfigVersion, '4.1.1'); +});