Merge branch 'master' into auto-write-config

This commit is contained in:
Róbert Kiss
2017-12-14 22:01:12 +01:00
14 changed files with 68 additions and 66 deletions

5
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{ {
"name": "uhk-agent", "name": "uhk-agent",
"version": "1.4.1", "version": "1.0.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@@ -4085,8 +4085,7 @@
"jsbn": { "jsbn": {
"version": "0.1.1", "version": "0.1.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true
"optional": true
}, },
"json-schema": { "json-schema": {
"version": "0.2.3", "version": "0.2.3",

View File

@@ -3,7 +3,7 @@
"private": true, "private": true,
"author": "Ultimate Gadget Laboratories", "author": "Ultimate Gadget Laboratories",
"main": "electron/dist/electron-main.js", "main": "electron/dist/electron-main.js",
"version": "1.4.3", "version": "1.0.0",
"description": "Agent is the configuration application of the Ultimate Hacking Keyboard.", "description": "Agent is the configuration application of the Ultimate Hacking Keyboard.",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@@ -16,8 +16,9 @@
"dependencies": { "dependencies": {
"node-hid": "0.5.7" "node-hid": "0.5.7"
}, },
"firmwareVersion": "6.0.0", "firmwareVersion": "7.0.0",
"dataModelVersion": "4.0.0", "deviceProtocolVersion": "4.0.0",
"usbProtocolVersion": "3.0.0", "moduleProtocolVersion": "3.0.0",
"slaveProtocolVersion": "3.0.0" "userConfigVersion": "4.0.0",
"hardwareConfigVersion": "1.0.0"
} }

View File

@@ -34,10 +34,11 @@ export class AppService extends MainServiceBase {
hasPermission: this.uhkHidDeviceService.hasPermission(), hasPermission: this.uhkHidDeviceService.hasPermission(),
agentVersionInfo: { agentVersionInfo: {
version: packageJson.version, version: packageJson.version,
dataModelVersion: packageJson.dataModelVersion, firmwareVersion: packageJson.firmwareVersion,
usbProtocolVersion: packageJson.usbProtocolVersion, deviceProtocolVersion: packageJson.deviceProtocolVersion,
slaveProtocolVersion: packageJson.slaveProtocolVersion, moduleProtocolVersion: packageJson.moduleProtocolVersion,
firmwareVersion: packageJson.firmwareVersion userConfigVersion: packageJson.userConfigVersion,
hardwareConfigVersion: packageJson.hardwareConfigVersion
} }
}; };
this.logService.info('[AppService] getAppStartInfo response:', response); this.logService.info('[AppService] getAppStartInfo response:', response);

View File

@@ -3,9 +3,9 @@ import { UserConfiguration } from '../user-configuration';
describe('keymap', () => { describe('keymap', () => {
it('should normalize SwitchLayerAction if non base layer action is not SwitchLayerAction', () => { it('should normalize SwitchLayerAction if non base layer action is not SwitchLayerAction', () => {
const inputJsonConfig = { const inputJsonConfig = {
dataModelMajorVersion: 3, userConfigMajorVersion: 3,
dataModelMinorVersion: 0, userConfigMinorVersion: 0,
dataModelPatchVersion: 0, userConfigPatchVersion: 0,
deviceName: 'My UHK', deviceName: 'My UHK',
doubleTapSwitchLayerTimeout: 250, doubleTapSwitchLayerTimeout: 250,
iconsAndLayerTextsBrightness: 255, iconsAndLayerTextsBrightness: 255,
@@ -75,9 +75,9 @@ describe('keymap', () => {
] ]
}; };
const expectedJsonConfig = { const expectedJsonConfig = {
dataModelMajorVersion: 3, userConfigMajorVersion: 3,
dataModelMinorVersion: 0, userConfigMinorVersion: 0,
dataModelPatchVersion: 0, userConfigPatchVersion: 0,
deviceName: 'My UHK', deviceName: 'My UHK',
doubleTapSwitchLayerTimeout: 250, doubleTapSwitchLayerTimeout: 250,
iconsAndLayerTextsBrightness: 255, iconsAndLayerTextsBrightness: 255,
@@ -156,9 +156,9 @@ describe('keymap', () => {
it('should normalize SwitchLayerAction if non base layer action is other SwitchLayerAction', () => { it('should normalize SwitchLayerAction if non base layer action is other SwitchLayerAction', () => {
const inputJsonConfig = { const inputJsonConfig = {
dataModelMajorVersion: 3, userConfigMajorVersion: 3,
dataModelMinorVersion: 0, userConfigMinorVersion: 0,
dataModelPatchVersion: 0, userConfigPatchVersion: 0,
deviceName: 'My UHK', deviceName: 'My UHK',
doubleTapSwitchLayerTimeout: 250, doubleTapSwitchLayerTimeout: 250,
iconsAndLayerTextsBrightness: 255, iconsAndLayerTextsBrightness: 255,
@@ -228,9 +228,9 @@ describe('keymap', () => {
] ]
}; };
const expectedJsonConfig = { const expectedJsonConfig = {
dataModelMajorVersion: 3, userConfigMajorVersion: 3,
dataModelMinorVersion: 0, userConfigMinorVersion: 0,
dataModelPatchVersion: 0, userConfigPatchVersion: 0,
deviceName: 'My UHK', deviceName: 'My UHK',
doubleTapSwitchLayerTimeout: 250, doubleTapSwitchLayerTimeout: 250,
iconsAndLayerTextsBrightness: 255, iconsAndLayerTextsBrightness: 255,

View File

@@ -8,9 +8,9 @@ describe('user-configuration', () => {
it('should transform an empty config', () => { it('should transform an empty config', () => {
jsonTester({ jsonTester({
dataModelMajorVersion: 3, userConfigMajorVersion: 3,
dataModelMinorVersion: 0, userConfigMinorVersion: 0,
dataModelPatchVersion: 0, userConfigPatchVersion: 0,
deviceName: 'My UHK', deviceName: 'My UHK',
doubleTapSwitchLayerTimeout: 250, doubleTapSwitchLayerTimeout: 250,
iconsAndLayerTextsBrightness: 255, iconsAndLayerTextsBrightness: 255,
@@ -34,9 +34,9 @@ describe('user-configuration', () => {
it('should transform a null keyActionType ', () => { it('should transform a null keyActionType ', () => {
jsonTester({ jsonTester({
dataModelMajorVersion: 3, userConfigMajorVersion: 3,
dataModelMinorVersion: 0, userConfigMinorVersion: 0,
dataModelPatchVersion: 0, userConfigPatchVersion: 0,
deviceName: 'My UHK', deviceName: 'My UHK',
doubleTapSwitchLayerTimeout: 250, doubleTapSwitchLayerTimeout: 250,
iconsAndLayerTextsBrightness: 255, iconsAndLayerTextsBrightness: 255,
@@ -75,7 +75,7 @@ describe('user-configuration', () => {
it('Should set the device name to "My UHK" if not exists in the config', () => { it('Should set the device name to "My UHK" if not exists in the config', () => {
const original = { const original = {
dataModelVersion: 1, userConfigVersion: 1,
moduleConfigurations: [], moduleConfigurations: [],
macros: [], macros: [],
keymaps: [] keymaps: []

View File

@@ -8,13 +8,13 @@ import { ConfigSerializer } from '../config-serializer';
export class UserConfiguration { export class UserConfiguration {
@assertUInt16 @assertUInt16
dataModelMajorVersion: number; userConfigMajorVersion: number;
@assertUInt16 @assertUInt16
dataModelMinorVersion: number; userConfigMinorVersion: number;
@assertUInt16 @assertUInt16
dataModelPatchVersion: number; userConfigPatchVersion: number;
@assertUInt16 @assertUInt16
userConfigurationLength: number; userConfigurationLength: number;
@@ -74,9 +74,9 @@ export class UserConfiguration {
} }
fromJsonObject(jsonObject: any): UserConfiguration { fromJsonObject(jsonObject: any): UserConfiguration {
this.dataModelMajorVersion = jsonObject.dataModelMajorVersion; this.userConfigMajorVersion = jsonObject.userConfigMajorVersion;
this.dataModelMinorVersion = jsonObject.dataModelMinorVersion; this.userConfigMinorVersion = jsonObject.userConfigMinorVersion;
this.dataModelPatchVersion = jsonObject.dataModelPatchVersion; this.userConfigPatchVersion = jsonObject.userConfigPatchVersion;
this.deviceName = jsonObject.deviceName; this.deviceName = jsonObject.deviceName;
this.setDefaultDeviceName(); this.setDefaultDeviceName();
this.doubleTapSwitchLayerTimeout = jsonObject.doubleTapSwitchLayerTimeout; this.doubleTapSwitchLayerTimeout = jsonObject.doubleTapSwitchLayerTimeout;
@@ -107,9 +107,9 @@ export class UserConfiguration {
} }
fromBinary(buffer: UhkBuffer): UserConfiguration { fromBinary(buffer: UhkBuffer): UserConfiguration {
this.dataModelMajorVersion = buffer.readUInt16(); this.userConfigMajorVersion = buffer.readUInt16();
this.dataModelMinorVersion = buffer.readUInt16(); this.userConfigMinorVersion = buffer.readUInt16();
this.dataModelPatchVersion = buffer.readUInt16(); this.userConfigPatchVersion = buffer.readUInt16();
this.userConfigurationLength = buffer.readUInt16(); this.userConfigurationLength = buffer.readUInt16();
this.deviceName = buffer.readString(); this.deviceName = buffer.readString();
this.setDefaultDeviceName(); this.setDefaultDeviceName();
@@ -147,9 +147,9 @@ export class UserConfiguration {
toJsonObject(): any { toJsonObject(): any {
return { return {
dataModelMajorVersion: this.dataModelMajorVersion, userConfigMajorVersion: this.userConfigMajorVersion,
dataModelMinorVersion: this.dataModelMinorVersion, userConfigMinorVersion: this.userConfigMinorVersion,
dataModelPatchVersion: this.dataModelPatchVersion, userConfigPatchVersion: this.userConfigPatchVersion,
deviceName: this.deviceName, deviceName: this.deviceName,
doubleTapSwitchLayerTimeout: this.doubleTapSwitchLayerTimeout, doubleTapSwitchLayerTimeout: this.doubleTapSwitchLayerTimeout,
iconsAndLayerTextsBrightness: this.iconsAndLayerTextsBrightness, iconsAndLayerTextsBrightness: this.iconsAndLayerTextsBrightness,
@@ -172,9 +172,9 @@ export class UserConfiguration {
} }
toBinary(buffer: UhkBuffer): void { toBinary(buffer: UhkBuffer): void {
buffer.writeUInt16(this.dataModelMajorVersion); buffer.writeUInt16(this.userConfigMajorVersion);
buffer.writeUInt16(this.dataModelMinorVersion); buffer.writeUInt16(this.userConfigMinorVersion);
buffer.writeUInt16(this.dataModelPatchVersion); buffer.writeUInt16(this.userConfigPatchVersion);
buffer.writeUInt16(this.userConfigurationLength); buffer.writeUInt16(this.userConfigurationLength);
buffer.writeString(this.deviceName); buffer.writeString(this.deviceName);
buffer.writeUInt16(this.doubleTapSwitchLayerTimeout); buffer.writeUInt16(this.doubleTapSwitchLayerTimeout);
@@ -199,8 +199,8 @@ export class UserConfiguration {
} }
toString(): string { toString(): string {
return `<UserConfiguration dataModelVersion="${this.dataModelMajorVersion}.\ return `<UserConfiguration userConfigVersion="${this.userConfigMajorVersion}.\
${this.dataModelMinorVersion}.${this.dataModelPatchVersion}">`; ${this.userConfigMinorVersion}.${this.userConfigPatchVersion}">`;
} }
getKeymap(keymapAbbreviation: string): Keymap { getKeymap(keymapAbbreviation: string): Keymap {

View File

@@ -1,7 +1,8 @@
export interface VersionInformation { export interface VersionInformation {
version: string; version: string;
dataModelVersion: string;
usbProtocolVersion: string;
slaveProtocolVersion: string;
firmwareVersion: string; firmwareVersion: string;
deviceProtocolVersion: string;
moduleProtocolVersion: string;
userConfigVersion: string;
hardwareConfigVersion: string;
} }

View File

@@ -82,9 +82,9 @@ export class KeymapEditComponent {
site: 'https://ultimatehackingkeyboard.com', site: 'https://ultimatehackingkeyboard.com',
description: 'Ultimate Hacking Keyboard keymap', description: 'Ultimate Hacking Keyboard keymap',
keyboardModel: 'UHK60', keyboardModel: 'UHK60',
dataModelMajorVersion: userConfiguration.dataModelMajorVersion, userConfigMajorVersion: userConfiguration.userConfigMajorVersion,
dataModelMinorVersion: userConfiguration.dataModelMinorVersion, userConfigMinorVersion: userConfiguration.userConfigMinorVersion,
dataModelPatchVersion: userConfiguration.dataModelPatchVersion, userConfigPatchVersion: userConfiguration.userConfigPatchVersion,
objectType: 'keymap', objectType: 'keymap',
objectValue: keymap.toJsonObject() objectValue: keymap.toJsonObject()
}; };

View File

@@ -1,6 +1,6 @@
{ {
"signature": "UHK", "signature": "UHK",
"dataModelVersion": 0, "hardwareConfigVersion": 0,
"hardwareId": 0, "hardwareId": 0,
"brandId": 0, "brandId": 0,
"isIso": false, "isIso": false,

View File

@@ -1,7 +1,7 @@
{ {
"dataModelMajorVersion": 3, "userConfigMajorVersion": 4,
"dataModelMinorVersion": 0, "userConfigMinorVersion": 0,
"dataModelPatchVersion": 0, "userConfigPatchVersion": 0,
"deviceName": "My UHK", "deviceName": "My UHK",
"doubleTapSwitchLayerTimeout": 250, "doubleTapSwitchLayerTimeout": 250,
"iconsAndLayerTextsBrightness": 255, "iconsAndLayerTextsBrightness": 255,

View File

@@ -44,7 +44,7 @@ export class UserConfigEffects {
const userConfig = new UserConfiguration(); const userConfig = new UserConfiguration();
userConfig.fromBinary(UhkBuffer.fromArray(data)); userConfig.fromBinary(UhkBuffer.fromArray(data));
if (userConfig.dataModelMajorVersion > 0) { if (userConfig.userConfigMajorVersion > 0) {
return userConfig; return userConfig;
} }
@@ -211,8 +211,8 @@ export class UserConfigEffects {
let config: UserConfiguration; let config: UserConfiguration;
if (configJsonObject) { if (configJsonObject) {
if (configJsonObject.dataModelMajorVersion === if (configJsonObject.userConfigMajorVersion ===
this.defaultUserConfigurationService.getDefault().dataModelMajorVersion) { this.defaultUserConfigurationService.getDefault().userConfigMajorVersion) {
config = new UserConfiguration().fromJsonObject(configJsonObject); config = new UserConfiguration().fromJsonObject(configJsonObject);
} }
} }

View File

@@ -56,7 +56,7 @@ describe('user-configuration reducer', () => {
const result = reducer(state, saveKeyAction); const result = reducer(state, saveKeyAction);
expect(result).not.toBe(defaultUserConfig); expect(result).not.toBe(defaultUserConfig);
expect(result.toJsonObject()).toEqual({ expect(result.toJsonObject()).toEqual({
dataModelVersion: 4, userConfigVersion: 4,
moduleConfigurations: [ moduleConfigurations: [
{ {
id: 1, id: 1,
@@ -233,7 +233,7 @@ describe('user-configuration reducer', () => {
const result = reducer(state, saveKeyAction); const result = reducer(state, saveKeyAction);
expect(result).not.toBe(defaultUserConfig); expect(result).not.toBe(defaultUserConfig);
expect(result.toJsonObject()).toEqual({ expect(result.toJsonObject()).toEqual({
dataModelVersion: 4, userConfigVersion: 4,
moduleConfigurations: [ moduleConfigurations: [
{ {
id: 1, id: 1,

View File

@@ -1,9 +1,9 @@
import { cloneDeep } from 'lodash'; import { cloneDeep } from 'lodash';
const defaultUserConfig = { const defaultUserConfig = {
dataModelMajorVersion: 3, userConfigMajorVersion: 3,
dataModelMinorVersion: 0, userConfigMinorVersion: 0,
dataModelPatchVersion: 0, userConfigPatchVersion: 0,
deviceName: 'My UHK', deviceName: 'My UHK',
doubleTapSwitchLayerTimeout: 250, doubleTapSwitchLayerTimeout: 250,
iconsAndLayerTextsBrightness: 255, iconsAndLayerTextsBrightness: 255,