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

26
package-lock.json generated
View File

@@ -1049,7 +1049,7 @@
},
"readable-stream": {
"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==",
"dev": true,
"requires": {
@@ -2200,6 +2200,12 @@
"@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": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@types/usb/-/usb-1.1.3.tgz",
@@ -5988,7 +5994,7 @@
},
"readable-stream": {
"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==",
"dev": true,
"requires": {
@@ -7575,7 +7581,7 @@
},
"readable-stream": {
"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==",
"dev": true,
"requires": {
@@ -7687,7 +7693,7 @@
},
"readable-stream": {
"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==",
"dev": true,
"requires": {
@@ -7822,14 +7828,12 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -7849,8 +7853,7 @@
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"console-control-strings": {
"version": "1.1.0",
@@ -7998,7 +8001,6 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@@ -11381,7 +11383,7 @@
},
"readable-stream": {
"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==",
"dev": true,
"requires": {
@@ -12617,7 +12619,7 @@
},
"readable-stream": {
"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==",
"dev": true,
"requires": {

View File

@@ -29,6 +29,7 @@
"@types/node": "8.0.53",
"@types/node-hid": "0.7.0",
"@types/request": "2.0.8",
"@types/semver": "5.5.0",
"@types/usb": "1.1.3",
"autoprefixer": "6.5.3",
"buffer": "5.0.6",

View File

@@ -22,9 +22,7 @@ import { setMenu } from './electron-menu';
const optionDefinitions = [
{name: 'addons', type: Boolean},
{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}
{name: 'spe', type: Boolean} // simulate privilege escalation error
];
const options: CommandLineArgs = commandLineArgs(optionDefinitions);

View File

@@ -26,8 +26,7 @@ export class AppService extends MainServiceBase {
const deviceConnectionState = this.uhkHidDeviceService.getDeviceConnectionState();
const response: AppStartInfo = {
commandLineArgs: {
addons: this.options.addons || false,
layerDoubleTap: this.options['layer-double-tap'] || false
addons: this.options.addons || false
},
deviceConnected: deviceConnectionState.connected,
hasPermission: deviceConnectionState.hasPermission,

View File

@@ -7,9 +7,4 @@ export interface CommandLineArgs {
* simulate privilege escalation error
*/
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;
}

View File

@@ -9540,9 +9540,9 @@
}
},
"semver": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz",
"integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==",
"version": "5.6.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz",
"integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==",
"dev": true
},
"semver-dsl": {

View File

@@ -70,6 +70,7 @@
"reselect": "3.0.1",
"rxjs": "5.5.8",
"typescript": "2.6.2",
"semver": "5.6.0",
"uhk-common": "1.0.0",
"xml-loader": "1.2.1",
"zone.js": "0.8.26",

View File

@@ -14,7 +14,7 @@ import 'rxjs/add/operator/combineLatest';
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 { KeyboardLayout } from '../../../keyboard/keyboard-layout.enum';
import { KeymapActions } from '../../../store/actions';
@@ -51,7 +51,7 @@ export class KeymapEditComponent {
.map((keymaps: Keymap[]) => keymaps.length > 1);
this.keyboardLayout$ = store.select(getKeyboardLayout);
this.allowLayerDoubleTap$ = store.select(allowLayerDoubleTap);
this.allowLayerDoubleTap$ = store.select(layerDoubleTapSupported);
}
downloadKeymap() {

View File

@@ -5,6 +5,7 @@
></macro-header>
<macro-list
[macro]="macro"
[macroPlaybackSupported]="macroPlaybackSupported$ | async"
(add)="addAction($event.macroId, $event.action)"
(edit)="editAction($event.macroId, $event.index, $event.action)"
(delete)="deleteAction($event.macroId, $event.index, $event.action)"

View File

@@ -3,11 +3,12 @@ import { ActivatedRoute } from '@angular/router';
import { Store } from '@ngrx/store';
import { Macro, MacroAction } from 'uhk-common';
import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';
import 'rxjs/add/operator/pluck';
import { MacroActions } from '../../../store/actions';
import { AppState } from '../../../store';
import { AppState, macroPlaybackSupported } from '../../../store';
import { getMacro } from '../../../store/reducers/user-configuration';
@Component({
@@ -22,6 +23,7 @@ export class MacroEditComponent implements OnDestroy {
macro: Macro;
isNew: boolean;
macroId: number;
macroPlaybackSupported$: Observable<boolean>;
private subscription: Subscription;
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.macroPlaybackSupported$ = this.store.select(macroPlaybackSupported);
}
ngOnDestroy() {

View File

@@ -1,6 +1,6 @@
<div class="row list-container">
<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">
<macro-item *ngFor="let macroAction of macro.macroActions; let macroActionIndex = index"
[macroAction]="macroAction"

View File

@@ -35,6 +35,7 @@ import { MacroItemComponent } from '../item';
})
export class MacroListComponent {
@Input() macro: Macro;
@Input() macroPlaybackSupported: boolean;
@ViewChildren(forwardRef(() => MacroItemComponent)) macroItems: QueryList<MacroItemComponent>;
@Output() add = new EventEmitter();

View File

@@ -42,6 +42,7 @@
></mouse-tab>
<macro-tab #tab *ngSwitchCase="tabName.Macro" class="popover-content"
[defaultKeyAction]="defaultKeyAction"
[macroPlaybackSupported]="macroPlaybackSupported$ | async"
(validAction)="setKeyActionValidState($event)"
></macro-tab>
<keymap-tab #tab *ngSwitchCase="tabName.Keymap" class="popover-content"

View File

@@ -32,7 +32,7 @@ import {
import { Tab } from './tab';
import { AppState } from '../../store';
import { AppState, macroPlaybackSupported } from '../../store';
import { getKeymaps } from '../../store/reducers/user-configuration';
import { KeyActionRemap } from '../../models/key-action-remap';
import { RemapInfo } from '../../models/remap-info';
@@ -147,6 +147,7 @@ export class PopoverComponent implements OnChanges {
text: 'None'
}
];
macroPlaybackSupported$: Observable<boolean>;
private readonly currentKeymap$ = new BehaviorSubject<Keymap>(undefined);
@@ -158,6 +159,7 @@ export class PopoverComponent implements OnChanges {
.map(([keymaps, currentKeymap]: [Keymap[], Keymap]) =>
keymaps.filter((keymap: Keymap) => currentKeymap.abbreviation !== keymap.abbreviation)
);
this.macroPlaybackSupported$ = store.select(macroPlaybackSupported);
}
ngOnChanges(change: SimpleChanges) {

View File

@@ -2,7 +2,7 @@
<span> No macros are available to choose from. Create a macro first! </span>
</ng-template>
<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">
<b> Play macro: </b>
<ngx-select [items]="macroOptions"

View File

@@ -17,6 +17,7 @@ import { SelectOptionData } from '../../../../models/select-option-data';
})
export class MacroTabComponent extends Tab implements OnInit, OnChanges, OnDestroy {
@Input() defaultKeyAction: KeyAction;
@Input() macroPlaybackSupported: boolean;
macros: Macro[];
macroOptions: Array<SelectOptionData>;

View File

@@ -2,7 +2,7 @@ import { createSelector } from 'reselect';
import { ActionReducerMap, MetaReducer } from '@ngrx/store';
import { RouterReducerState, routerReducer } from '@ngrx/router-store';
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 fromPreset from './reducers/preset';
@@ -14,6 +14,7 @@ import * as fromSelectors from './reducers/selectors';
import { initProgressButtonState } from './reducers/progress-button-state';
import { environment } from '../../environments/environment';
import { RouterStateUrl } from './router-util';
import { isVersionGte } from '../util';
// State interface for the application
export interface AppState {
@@ -45,7 +46,6 @@ export const getUserConfiguration = (state: AppState) => state.userConfiguration
export const appState = (state: AppState) => state.app;
export const showAddonMenu = createSelector(appState, fromApp.showAddonMenu);
export const allowLayerDoubleTap = createSelector(appState, fromApp.allowLayerDoubleTap);
export const getUndoableNotification = createSelector(appState, fromApp.getUndoableNotification);
export const getPrevUserConfiguration = createSelector(appState, fromApp.getPrevUserConfiguration);
export const runningInElectron = createSelector(appState, fromApp.runningInElectron);
@@ -113,3 +113,13 @@ export const getSideMenuPageState = createSelector(
);
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');
}
);

View File

@@ -171,7 +171,6 @@ export function reducer(state = initialState, action: Action & { payload: any })
}
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 getPrevUserConfiguration = (state: State) => state.prevUserConfig;
export const runningInElectron = (state: State) => state.runningInElectron;

View File

@@ -1,3 +1,4 @@
import * as semver from 'semver';
import { VersionInformation } from 'uhk-common';
const collectVersions = (): VersionInformation => {
@@ -20,3 +21,11 @@ export const getVersions = (): VersionInformation => {
}
return versions;
};
export const isVersionGte = (v1: string, v2: string): boolean => {
if (!v1) {
return false;
}
return semver.gte(v1, v2);
};