feat(config): Read / write hardware configuration area (#423)
* add write-hca.js * refactor: Move config serializer into the uhk-common package * refactor: Move getTransferBuffers into the uhk-usb package * refactor: delete obsoleted classes * build: add uhk-usb build command * refactor: move eeprom transfer to uhk-usb package * fix: Fix write-hca.js * feat: load hardware config from the device and * style: fix ts lint errors * build: fix rxjs dependency resolve * test: Add jasmine unit test framework to the tet serializer * fix(user-config): A "type": "basic", properties to the "keystroke" action types * feat(usb): set chmod+x on write-hca.js * feat(usb): Create USB logger * style: Fix type * build: Add chalk to dependencies. Chalk will colorize the output
This commit is contained in:
committed by
László Monda
parent
1122784bdb
commit
9294bede50
@@ -1,10 +1,10 @@
|
||||
import { routerActions } from '@ngrx/router-store';
|
||||
import { Action } from '@ngrx/store';
|
||||
|
||||
import { runInElectron, Notification, NotificationType } from 'uhk-common';
|
||||
import { HardwareConfiguration, runInElectron, Notification, NotificationType, UserConfiguration } from 'uhk-common';
|
||||
import { ActionTypes, ShowNotificationAction } from '../actions/app';
|
||||
import { ActionTypes as UserConfigActionTypes } from '../actions/user-config';
|
||||
import { UserConfiguration } from '../../config-serializer/config-items/user-configuration';
|
||||
import { KeyboardLayout } from '../../keyboard/keyboard-layout.enum';
|
||||
|
||||
export interface State {
|
||||
started: boolean;
|
||||
@@ -13,7 +13,8 @@ export interface State {
|
||||
navigationCountAfterNotification: number;
|
||||
prevUserConfig?: UserConfiguration;
|
||||
runningInElectron: boolean;
|
||||
userConfigLoading: boolean;
|
||||
configLoading: boolean;
|
||||
hardwareConfig?: HardwareConfiguration;
|
||||
}
|
||||
|
||||
const initialState: State = {
|
||||
@@ -21,7 +22,7 @@ const initialState: State = {
|
||||
showAddonMenu: false,
|
||||
navigationCountAfterNotification: 0,
|
||||
runningInElectron: runInElectron(),
|
||||
userConfigLoading: true
|
||||
configLoading: true
|
||||
};
|
||||
|
||||
export function reducer(state = initialState, action: Action) {
|
||||
@@ -56,7 +57,7 @@ export function reducer(state = initialState, action: Action) {
|
||||
// When deleted a keymap or macro the app automaticaly navigate to other keymap, or macro, so
|
||||
// so we have to count the navigations and when reach the 2nd then remove the dialog.
|
||||
case routerActions.UPDATE_LOCATION: {
|
||||
const newState = { ...state };
|
||||
const newState = {...state};
|
||||
newState.navigationCountAfterNotification++;
|
||||
|
||||
if (newState.navigationCountAfterNotification > 1) {
|
||||
@@ -79,18 +80,24 @@ export function reducer(state = initialState, action: Action) {
|
||||
return {
|
||||
...state,
|
||||
prevUserConfig: action.payload,
|
||||
userConfigLoading: false
|
||||
configLoading: false
|
||||
};
|
||||
}
|
||||
|
||||
case UserConfigActionTypes.LOAD_USER_CONFIG_FROM_DEVICE:
|
||||
case UserConfigActionTypes.LOAD_CONFIG_FROM_DEVICE:
|
||||
case UserConfigActionTypes.LOAD_USER_CONFIG: {
|
||||
return {
|
||||
...state,
|
||||
userConfigLoading: true
|
||||
configLoading: true
|
||||
};
|
||||
}
|
||||
|
||||
case ActionTypes.LOAD_HARDWARE_CONFIGURATION_SUCCESS:
|
||||
return {
|
||||
...state,
|
||||
hardwareConfig: action.payload
|
||||
};
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
@@ -100,3 +107,11 @@ export const showAddonMenu = (state: State) => state.showAddonMenu;
|
||||
export const getUndoableNotification = (state: State) => state.undoableNotification;
|
||||
export const getPrevUserConfiguration = (state: State) => state.prevUserConfig;
|
||||
export const runningInElectron = (state: State) => state.runningInElectron;
|
||||
export const getHardwareConfiguration = (state: State) => state.hardwareConfig;
|
||||
export const getKeyboardLayout = (state: State): KeyboardLayout => {
|
||||
if (state.hardwareConfig && state.hardwareConfig.isIso) {
|
||||
return KeyboardLayout.ISO;
|
||||
}
|
||||
|
||||
return KeyboardLayout.ANSI;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Action } from '@ngrx/store';
|
||||
import { Keymap } from 'uhk-common';
|
||||
|
||||
import { Keymap } from '../../config-serializer/config-items/keymap';
|
||||
import { KeymapActions } from '../actions/keymap';
|
||||
|
||||
const initialState: Keymap[] = [];
|
||||
|
||||
@@ -5,12 +5,7 @@ import { Observable } from 'rxjs/Observable';
|
||||
import 'rxjs/add/observable/of';
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
import { Helper as KeyActionHelper } from '../../config-serializer/config-items/key-action';
|
||||
import { Keymap } from '../../config-serializer/config-items/keymap';
|
||||
import { Macro } from '../../config-serializer/config-items/macro';
|
||||
import { UserConfiguration } from '../../config-serializer/config-items/user-configuration';
|
||||
import { Layer } from '../../config-serializer/config-items/layer';
|
||||
import { Module } from '../../config-serializer/config-items/module';
|
||||
import { Keymap, KeyActionHelper, Layer, Macro, Module, UserConfiguration } from 'uhk-common';
|
||||
import { KeymapActions, MacroActions } from '../actions';
|
||||
import { AppState } from '../index';
|
||||
import { ActionTypes } from '../actions/user-config';
|
||||
|
||||
Reference in New Issue
Block a user