feat: allow 8.4.3 firmware features (#845)

* feat: allow 8.4.3 firmware features

* feat: remove "layer-double-tap" command line argument
This commit is contained in:
Róbert Kiss
2018-11-05 19:51:39 +01:00
committed by László Monda
parent 84b6c33c54
commit 10cd06c70b
19 changed files with 57 additions and 34 deletions
+14 -12
View File
@@ -1049,7 +1049,7 @@
}, },
"readable-stream": { "readable-stream": {
"version": "2.3.6", "version": "2.3.6",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"dev": true, "dev": true,
"requires": { "requires": {
@@ -2200,6 +2200,12 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"@types/semver": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/@types/semver/-/semver-5.5.0.tgz",
"integrity": "sha512-41qEJgBH/TWgo5NFSvBCJ1qkoi3Q6ONSF2avrHq1LVEZfYpdHmj0y9SuTK+u9ZhG1sYQKBL1AWXKyLWP4RaUoQ==",
"dev": true
},
"@types/usb": { "@types/usb": {
"version": "1.1.3", "version": "1.1.3",
"resolved": "https://registry.npmjs.org/@types/usb/-/usb-1.1.3.tgz", "resolved": "https://registry.npmjs.org/@types/usb/-/usb-1.1.3.tgz",
@@ -5988,7 +5994,7 @@
}, },
"readable-stream": { "readable-stream": {
"version": "2.3.6", "version": "2.3.6",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"dev": true, "dev": true,
"requires": { "requires": {
@@ -7575,7 +7581,7 @@
}, },
"readable-stream": { "readable-stream": {
"version": "2.3.6", "version": "2.3.6",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"dev": true, "dev": true,
"requires": { "requires": {
@@ -7687,7 +7693,7 @@
}, },
"readable-stream": { "readable-stream": {
"version": "2.3.6", "version": "2.3.6",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"dev": true, "dev": true,
"requires": { "requires": {
@@ -7822,14 +7828,12 @@
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@@ -7849,8 +7853,7 @@
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
@@ -7998,7 +8001,6 @@
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
@@ -11381,7 +11383,7 @@
}, },
"readable-stream": { "readable-stream": {
"version": "2.3.6", "version": "2.3.6",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"dev": true, "dev": true,
"requires": { "requires": {
@@ -12617,7 +12619,7 @@
}, },
"readable-stream": { "readable-stream": {
"version": "2.3.6", "version": "2.3.6",
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"dev": true, "dev": true,
"requires": { "requires": {
+1
View File
@@ -29,6 +29,7 @@
"@types/node": "8.0.53", "@types/node": "8.0.53",
"@types/node-hid": "0.7.0", "@types/node-hid": "0.7.0",
"@types/request": "2.0.8", "@types/request": "2.0.8",
"@types/semver": "5.5.0",
"@types/usb": "1.1.3", "@types/usb": "1.1.3",
"autoprefixer": "6.5.3", "autoprefixer": "6.5.3",
"buffer": "5.0.6", "buffer": "5.0.6",
+1 -3
View File
@@ -22,9 +22,7 @@ import { setMenu } from './electron-menu';
const optionDefinitions = [ const optionDefinitions = [
{name: 'addons', type: Boolean}, {name: 'addons', type: Boolean},
{name: 'spe', type: Boolean}, // simulate privilege escalation error {name: 'spe', type: Boolean} // simulate privilege escalation error
// show 'Lock layer when double tapping this key' checkbox on 'Layer' tab of the config popover
{name: 'layer-double-tap', type: Boolean}
]; ];
const options: CommandLineArgs = commandLineArgs(optionDefinitions); const options: CommandLineArgs = commandLineArgs(optionDefinitions);
@@ -26,8 +26,7 @@ export class AppService extends MainServiceBase {
const deviceConnectionState = this.uhkHidDeviceService.getDeviceConnectionState(); const deviceConnectionState = this.uhkHidDeviceService.getDeviceConnectionState();
const response: AppStartInfo = { const response: AppStartInfo = {
commandLineArgs: { commandLineArgs: {
addons: this.options.addons || false, addons: this.options.addons || false
layerDoubleTap: this.options['layer-double-tap'] || false
}, },
deviceConnected: deviceConnectionState.connected, deviceConnected: deviceConnectionState.connected,
hasPermission: deviceConnectionState.hasPermission, hasPermission: deviceConnectionState.hasPermission,
@@ -7,9 +7,4 @@ export interface CommandLineArgs {
* simulate privilege escalation error * simulate privilege escalation error
*/ */
spe?: boolean; spe?: boolean;
/**
* show 'Lock layer when double tapping this key' checkbox on 'Layer' tab of the config popover
* if it false the checkbox invisible and the value of the checkbox = true
*/
layerDoubleTap?: boolean;
} }
+3 -3
View File
@@ -9540,9 +9540,9 @@
} }
}, },
"semver": { "semver": {
"version": "5.5.0", "version": "5.6.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz",
"integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==",
"dev": true "dev": true
}, },
"semver-dsl": { "semver-dsl": {
+1
View File
@@ -70,6 +70,7 @@
"reselect": "3.0.1", "reselect": "3.0.1",
"rxjs": "5.5.8", "rxjs": "5.5.8",
"typescript": "2.6.2", "typescript": "2.6.2",
"semver": "5.6.0",
"uhk-common": "1.0.0", "uhk-common": "1.0.0",
"xml-loader": "1.2.1", "xml-loader": "1.2.1",
"zone.js": "0.8.26", "zone.js": "0.8.26",
@@ -14,7 +14,7 @@ import 'rxjs/add/operator/combineLatest';
import { saveAs } from 'file-saver'; import { saveAs } from 'file-saver';
import { allowLayerDoubleTap, AppState, getKeyboardLayout } from '../../../store'; import { layerDoubleTapSupported, AppState, getKeyboardLayout } from '../../../store';
import { getKeymap, getKeymaps, getUserConfiguration } from '../../../store/reducers/user-configuration'; import { getKeymap, getKeymaps, getUserConfiguration } from '../../../store/reducers/user-configuration';
import { KeyboardLayout } from '../../../keyboard/keyboard-layout.enum'; import { KeyboardLayout } from '../../../keyboard/keyboard-layout.enum';
import { KeymapActions } from '../../../store/actions'; import { KeymapActions } from '../../../store/actions';
@@ -51,7 +51,7 @@ export class KeymapEditComponent {
.map((keymaps: Keymap[]) => keymaps.length > 1); .map((keymaps: Keymap[]) => keymaps.length > 1);
this.keyboardLayout$ = store.select(getKeyboardLayout); this.keyboardLayout$ = store.select(getKeyboardLayout);
this.allowLayerDoubleTap$ = store.select(allowLayerDoubleTap); this.allowLayerDoubleTap$ = store.select(layerDoubleTapSupported);
} }
downloadKeymap() { downloadKeymap() {
@@ -5,6 +5,7 @@
></macro-header> ></macro-header>
<macro-list <macro-list
[macro]="macro" [macro]="macro"
[macroPlaybackSupported]="macroPlaybackSupported$ | async"
(add)="addAction($event.macroId, $event.action)" (add)="addAction($event.macroId, $event.action)"
(edit)="editAction($event.macroId, $event.index, $event.action)" (edit)="editAction($event.macroId, $event.index, $event.action)"
(delete)="deleteAction($event.macroId, $event.index, $event.action)" (delete)="deleteAction($event.macroId, $event.index, $event.action)"
@@ -3,11 +3,12 @@ import { ActivatedRoute } from '@angular/router';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { Macro, MacroAction } from 'uhk-common'; import { Macro, MacroAction } from 'uhk-common';
import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription'; import { Subscription } from 'rxjs/Subscription';
import 'rxjs/add/operator/pluck'; import 'rxjs/add/operator/pluck';
import { MacroActions } from '../../../store/actions'; import { MacroActions } from '../../../store/actions';
import { AppState } from '../../../store'; import { AppState, macroPlaybackSupported } from '../../../store';
import { getMacro } from '../../../store/reducers/user-configuration'; import { getMacro } from '../../../store/reducers/user-configuration';
@Component({ @Component({
@@ -22,6 +23,7 @@ export class MacroEditComponent implements OnDestroy {
macro: Macro; macro: Macro;
isNew: boolean; isNew: boolean;
macroId: number; macroId: number;
macroPlaybackSupported$: Observable<boolean>;
private subscription: Subscription; private subscription: Subscription;
constructor(private store: Store<AppState>, public route: ActivatedRoute) { constructor(private store: Store<AppState>, public route: ActivatedRoute) {
@@ -37,6 +39,7 @@ export class MacroEditComponent implements OnDestroy {
}); });
this.isNew = this.route.snapshot.params['empty'] === 'new'; this.isNew = this.route.snapshot.params['empty'] === 'new';
this.macroPlaybackSupported$ = this.store.select(macroPlaybackSupported);
} }
ngOnDestroy() { ngOnDestroy() {
@@ -1,6 +1,6 @@
<div class="row list-container"> <div class="row list-container">
<div class="col-xs-10 col-xs-offset-1 list-group"> <div class="col-xs-10 col-xs-offset-1 list-group">
<p><i>Please note that macro playback is not implemented yet. You can create macros, but they won't have any effect until firmware support is implemented. We're working on this.</i></p> <p *ngIf="!macroPlaybackSupported"><i>Please note that macro playback is not implemented yet. You can create macros, but they won't have any effect until firmware support is implemented. We're working on this.</i></p>
<div class="macro-actions-container" [dragula]="'macroActions'" [dragulaModel]="macro.macroActions"> <div class="macro-actions-container" [dragula]="'macroActions'" [dragulaModel]="macro.macroActions">
<macro-item *ngFor="let macroAction of macro.macroActions; let macroActionIndex = index" <macro-item *ngFor="let macroAction of macro.macroActions; let macroActionIndex = index"
[macroAction]="macroAction" [macroAction]="macroAction"
@@ -35,6 +35,7 @@ import { MacroItemComponent } from '../item';
}) })
export class MacroListComponent { export class MacroListComponent {
@Input() macro: Macro; @Input() macro: Macro;
@Input() macroPlaybackSupported: boolean;
@ViewChildren(forwardRef(() => MacroItemComponent)) macroItems: QueryList<MacroItemComponent>; @ViewChildren(forwardRef(() => MacroItemComponent)) macroItems: QueryList<MacroItemComponent>;
@Output() add = new EventEmitter(); @Output() add = new EventEmitter();
@@ -42,6 +42,7 @@
></mouse-tab> ></mouse-tab>
<macro-tab #tab *ngSwitchCase="tabName.Macro" class="popover-content" <macro-tab #tab *ngSwitchCase="tabName.Macro" class="popover-content"
[defaultKeyAction]="defaultKeyAction" [defaultKeyAction]="defaultKeyAction"
[macroPlaybackSupported]="macroPlaybackSupported$ | async"
(validAction)="setKeyActionValidState($event)" (validAction)="setKeyActionValidState($event)"
></macro-tab> ></macro-tab>
<keymap-tab #tab *ngSwitchCase="tabName.Keymap" class="popover-content" <keymap-tab #tab *ngSwitchCase="tabName.Keymap" class="popover-content"
@@ -32,7 +32,7 @@ import {
import { Tab } from './tab'; import { Tab } from './tab';
import { AppState } from '../../store'; import { AppState, macroPlaybackSupported } from '../../store';
import { getKeymaps } from '../../store/reducers/user-configuration'; import { getKeymaps } from '../../store/reducers/user-configuration';
import { KeyActionRemap } from '../../models/key-action-remap'; import { KeyActionRemap } from '../../models/key-action-remap';
import { RemapInfo } from '../../models/remap-info'; import { RemapInfo } from '../../models/remap-info';
@@ -147,6 +147,7 @@ export class PopoverComponent implements OnChanges {
text: 'None' text: 'None'
} }
]; ];
macroPlaybackSupported$: Observable<boolean>;
private readonly currentKeymap$ = new BehaviorSubject<Keymap>(undefined); private readonly currentKeymap$ = new BehaviorSubject<Keymap>(undefined);
@@ -158,6 +159,7 @@ export class PopoverComponent implements OnChanges {
.map(([keymaps, currentKeymap]: [Keymap[], Keymap]) => .map(([keymaps, currentKeymap]: [Keymap[], Keymap]) =>
keymaps.filter((keymap: Keymap) => currentKeymap.abbreviation !== keymap.abbreviation) keymaps.filter((keymap: Keymap) => currentKeymap.abbreviation !== keymap.abbreviation)
); );
this.macroPlaybackSupported$ = store.select(macroPlaybackSupported);
} }
ngOnChanges(change: SimpleChanges) { ngOnChanges(change: SimpleChanges) {
@@ -2,7 +2,7 @@
<span> No macros are available to choose from. Create a macro first! </span> <span> No macros are available to choose from. Create a macro first! </span>
</ng-template> </ng-template>
<ng-template [ngIf]="macroOptions.length > 0"> <ng-template [ngIf]="macroOptions.length > 0">
<p><i>Please note that macro playback is not implemented yet. You can bind macros, but they won't have any effect until firmware support is implemented. We're working on this.</i></p> <p *ngIf="!macroPlaybackSupported"><i>Please note that macro playback is not implemented yet. You can bind macros, but they won't have any effect until firmware support is implemented. We're working on this.</i></p>
<div class="macro-selector"> <div class="macro-selector">
<b> Play macro: </b> <b> Play macro: </b>
<ngx-select [items]="macroOptions" <ngx-select [items]="macroOptions"
@@ -17,6 +17,7 @@ import { SelectOptionData } from '../../../../models/select-option-data';
}) })
export class MacroTabComponent extends Tab implements OnInit, OnChanges, OnDestroy { export class MacroTabComponent extends Tab implements OnInit, OnChanges, OnDestroy {
@Input() defaultKeyAction: KeyAction; @Input() defaultKeyAction: KeyAction;
@Input() macroPlaybackSupported: boolean;
macros: Macro[]; macros: Macro[];
macroOptions: Array<SelectOptionData>; macroOptions: Array<SelectOptionData>;
+12 -2
View File
@@ -2,7 +2,7 @@ import { createSelector } from 'reselect';
import { ActionReducerMap, MetaReducer } from '@ngrx/store'; import { ActionReducerMap, MetaReducer } from '@ngrx/store';
import { RouterReducerState, routerReducer } from '@ngrx/router-store'; import { RouterReducerState, routerReducer } from '@ngrx/router-store';
import { storeFreeze } from 'ngrx-store-freeze'; import { storeFreeze } from 'ngrx-store-freeze';
import { Keymap, UserConfiguration } from 'uhk-common'; import { HardwareModules, Keymap, UserConfiguration } from 'uhk-common';
import * as fromUserConfig from './reducers/user-configuration'; import * as fromUserConfig from './reducers/user-configuration';
import * as fromPreset from './reducers/preset'; import * as fromPreset from './reducers/preset';
@@ -14,6 +14,7 @@ import * as fromSelectors from './reducers/selectors';
import { initProgressButtonState } from './reducers/progress-button-state'; import { initProgressButtonState } from './reducers/progress-button-state';
import { environment } from '../../environments/environment'; import { environment } from '../../environments/environment';
import { RouterStateUrl } from './router-util'; import { RouterStateUrl } from './router-util';
import { isVersionGte } from '../util';
// State interface for the application // State interface for the application
export interface AppState { export interface AppState {
@@ -45,7 +46,6 @@ export const getUserConfiguration = (state: AppState) => state.userConfiguration
export const appState = (state: AppState) => state.app; export const appState = (state: AppState) => state.app;
export const showAddonMenu = createSelector(appState, fromApp.showAddonMenu); export const showAddonMenu = createSelector(appState, fromApp.showAddonMenu);
export const allowLayerDoubleTap = createSelector(appState, fromApp.allowLayerDoubleTap);
export const getUndoableNotification = createSelector(appState, fromApp.getUndoableNotification); export const getUndoableNotification = createSelector(appState, fromApp.getUndoableNotification);
export const getPrevUserConfiguration = createSelector(appState, fromApp.getPrevUserConfiguration); export const getPrevUserConfiguration = createSelector(appState, fromApp.getPrevUserConfiguration);
export const runningInElectron = createSelector(appState, fromApp.runningInElectron); export const runningInElectron = createSelector(appState, fromApp.runningInElectron);
@@ -113,3 +113,13 @@ export const getSideMenuPageState = createSelector(
); );
export const getRouterState = (state: AppState) => state.router; export const getRouterState = (state: AppState) => state.router;
export const macroPlaybackSupported = createSelector(getHardwareModules, (hardwareModules: HardwareModules): boolean => {
return isVersionGte(hardwareModules.rightModuleInfo.firmwareVersion, '8.4.3');
});
export const layerDoubleTapSupported = createSelector(
getHardwareModules,
(hardwareModules: HardwareModules): boolean => {
return isVersionGte(hardwareModules.rightModuleInfo.firmwareVersion, '8.4.3');
}
);
@@ -171,7 +171,6 @@ export function reducer(state = initialState, action: Action & { payload: any })
} }
export const showAddonMenu = (state: State) => state.commandLineArgs.addons; export const showAddonMenu = (state: State) => state.commandLineArgs.addons;
export const allowLayerDoubleTap = (state: State) => state.commandLineArgs.layerDoubleTap;
export const getUndoableNotification = (state: State) => state.undoableNotification; export const getUndoableNotification = (state: State) => state.undoableNotification;
export const getPrevUserConfiguration = (state: State) => state.prevUserConfig; export const getPrevUserConfiguration = (state: State) => state.prevUserConfig;
export const runningInElectron = (state: State) => state.runningInElectron; export const runningInElectron = (state: State) => state.runningInElectron;
@@ -1,3 +1,4 @@
import * as semver from 'semver';
import { VersionInformation } from 'uhk-common'; import { VersionInformation } from 'uhk-common';
const collectVersions = (): VersionInformation => { const collectVersions = (): VersionInformation => {
@@ -20,3 +21,11 @@ export const getVersions = (): VersionInformation => {
} }
return versions; return versions;
}; };
export const isVersionGte = (v1: string, v2: string): boolean => {
if (!v1) {
return false;
}
return semver.gte(v1, v2);
};