refactor(agent): Rename 'LongKeypressAction' to 'SecondaryRoleAction' (#462)
* refactor(agent): Rename 'LongKeypressAction' to 'SecondaryRoleAction' * build: Change the build order of the modules * fix(user-config): Fix hasSecondaryRoleAction() calculation * fix(user-config): fix stylelint warnings
This commit is contained in:
committed by
László Monda
parent
641248c9e6
commit
3ffaf918cd
@@ -62,7 +62,7 @@
|
|||||||
"lint:ts:test-serializer": "tslint --type-check --project ./packages/test-serializer/tsconfig.json",
|
"lint:ts:test-serializer": "tslint --type-check --project ./packages/test-serializer/tsconfig.json",
|
||||||
"lint:ts:uhk-usb": "tslint --type-check --project ./packages/uhk-usb/tsconfig.json",
|
"lint:ts:uhk-usb": "tslint --type-check --project ./packages/uhk-usb/tsconfig.json",
|
||||||
"lint:style": "stylelint \"packages/uhk-agent/src/**/*.scss\" \"packages/uhk-web/src/**/*.scss\" --syntax scss",
|
"lint:style": "stylelint \"packages/uhk-agent/src/**/*.scss\" \"packages/uhk-web/src/**/*.scss\" --syntax scss",
|
||||||
"build": "run-s build:web build:electron build:usb build:common",
|
"build": "run-s build:common build:usb build:web build:electron",
|
||||||
"build:web": "lerna exec --scope uhk-web npm run build",
|
"build:web": "lerna exec --scope uhk-web npm run build",
|
||||||
"build:electron": "cross-env AOT_BUILD=true run-s -sn build:electron:renderer build:electron:main",
|
"build:electron": "cross-env AOT_BUILD=true run-s -sn build:electron:renderer build:electron:main",
|
||||||
"build:electron:main": "lerna exec --scope uhk-agent npm run build",
|
"build:electron:main": "lerna exec --scope uhk-agent npm run build",
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ KeyActions.fromJsObject: [{"keyActionType":"none"},{"keyActionType":"keystroke",
|
|||||||
KeystrokeModifiersAction.fromJsObject: {"keyActionType":"keystrokeModifiers","modifierMask":33} => <KeystrokeModifiersAction modifierMask="33">
|
KeystrokeModifiersAction.fromJsObject: {"keyActionType":"keystrokeModifiers","modifierMask":33} => <KeystrokeModifiersAction modifierMask="33">
|
||||||
KeystrokeWithModifiersAction.fromJsObject: {"keyActionType":"keystrokeWithModifiers","scancode":120,"modifierMask":16} => <KeystrokeWithModifiersAction scancode="120" modifierMask="16">
|
KeystrokeWithModifiersAction.fromJsObject: {"keyActionType":"keystrokeWithModifiers","scancode":120,"modifierMask":16} => <KeystrokeWithModifiersAction scancode="120" modifierMask="16">
|
||||||
SwitchLayerAction.fromJsObject: {"keyActionType":"switchLayer","layer":"fn","toggle":false} => <SwitchLayerAction layer="1" toggle="false">
|
SwitchLayerAction.fromJsObject: {"keyActionType":"switchLayer","layer":"fn","toggle":false} => <SwitchLayerAction layer="1" toggle="false">
|
||||||
DualRoleKeystrokeAction.fromJsObject: {"keyActionType":"dualRoleKeystroke","scancode":111,"longPressAction":"mod"} => <DualRoleKeystrokeAction scancode="111" longPressAction="8">
|
DualRoleKeystrokeAction.fromJsObject: {"keyActionType":"dualRoleKeystroke","scancode":111,"secondaryRoleAction":"mod"} => <DualRoleKeystrokeAction scancode="111" secondaryRoleAction="8">
|
||||||
MouseAction.fromJsObject: {"keyActionType":"mouse","mouseAction":"scrollDown"} => <MouseAction mouseAction="8">
|
MouseAction.fromJsObject: {"keyActionType":"mouse","mouseAction":"scrollDown"} => <MouseAction mouseAction="8">
|
||||||
PlayMacroAction.fromJsObject: {"keyActionType":"playMacro","macroId":0} => <PlayMacroAction macroId="0">
|
PlayMacroAction.fromJsObject: {"keyActionType":"playMacro","macroId":0} => <PlayMacroAction macroId="0">
|
||||||
SwitchKeymapAction.fromJsObject: {"keyActionType":"switchKeymap","keymapId":1} => <SwitchKeymapAction keymapId="1">
|
SwitchKeymapAction.fromJsObject: {"keyActionType":"switchKeymap","keymapId":1} => <SwitchKeymapAction keymapId="1">
|
||||||
@@ -47,7 +47,7 @@ KeyActions.toBinary: <KeyActions length="9"> => ['u8(9)]
|
|||||||
KeystrokeModifiersAction.toBinary: <KeystrokeModifiersAction modifierMask="33"> => ['u8(2), u8(33)]
|
KeystrokeModifiersAction.toBinary: <KeystrokeModifiersAction modifierMask="33"> => ['u8(2), u8(33)]
|
||||||
KeystrokeWithModifiersAction.toBinary: <KeystrokeWithModifiersAction scancode="120" modifierMask="16"> => ['u8(3), u8(120), u8(16)]
|
KeystrokeWithModifiersAction.toBinary: <KeystrokeWithModifiersAction scancode="120" modifierMask="16"> => ['u8(3), u8(120), u8(16)]
|
||||||
SwitchLayerAction.toBinary: <SwitchLayerAction layer="1" toggle="false"> => ['u8(5), u8(1)]
|
SwitchLayerAction.toBinary: <SwitchLayerAction layer="1" toggle="false"> => ['u8(5), u8(1)]
|
||||||
DualRoleKeystrokeAction.toBinary: <DualRoleKeystrokeAction scancode="111" longPressAction="8"> => ['u8(4), u8(111), u8(8)]
|
DualRoleKeystrokeAction.toBinary: <DualRoleKeystrokeAction scancode="111" secondaryRoleAction="8"> => ['u8(4), u8(111), u8(8)]
|
||||||
MouseAction.toBinary: <MouseAction mouseAction="8"> => ['u8(7), u8(8)]
|
MouseAction.toBinary: <MouseAction mouseAction="8"> => ['u8(7), u8(8)]
|
||||||
PlayMacroAction.toBinary: <PlayMacroAction macroId="0"> => ['u8(8), u8(0)]
|
PlayMacroAction.toBinary: <PlayMacroAction macroId="0"> => ['u8(8), u8(0)]
|
||||||
SwitchKeymapAction.toBinary: <SwitchKeymapAction keymapId="1"> => ['u8(6), u8(1)]
|
SwitchKeymapAction.toBinary: <SwitchKeymapAction keymapId="1"> => ['u8(6), u8(1)]
|
||||||
@@ -57,7 +57,7 @@ KeyActions.fromBinary: [u8(9)]
|
|||||||
KeystrokeModifiersAction.fromBinary: [u8(2), u8(33)] => <KeystrokeModifiersAction modifierMask="33">
|
KeystrokeModifiersAction.fromBinary: [u8(2), u8(33)] => <KeystrokeModifiersAction modifierMask="33">
|
||||||
KeystrokeWithModifiersAction.fromBinary: [u8(3), u8(120), u8(16)] => <KeystrokeWithModifiersAction scancode="120" modifierMask="16">
|
KeystrokeWithModifiersAction.fromBinary: [u8(3), u8(120), u8(16)] => <KeystrokeWithModifiersAction scancode="120" modifierMask="16">
|
||||||
SwitchLayerAction.fromBinary: [u8(5), u8(1)] => <SwitchLayerAction layer="1" toggle="false">
|
SwitchLayerAction.fromBinary: [u8(5), u8(1)] => <SwitchLayerAction layer="1" toggle="false">
|
||||||
DualRoleKeystrokeAction.fromBinary: [u8(4), u8(111), u8(8)] => <DualRoleKeystrokeAction scancode="111" longPressAction="8">
|
DualRoleKeystrokeAction.fromBinary: [u8(4), u8(111), u8(8)] => <DualRoleKeystrokeAction scancode="111" secondaryRoleAction="8">
|
||||||
MouseAction.fromBinary: [u8(7), u8(8)] => <MouseAction mouseAction="8">
|
MouseAction.fromBinary: [u8(7), u8(8)] => <MouseAction mouseAction="8">
|
||||||
PlayMacroAction.fromBinary: [u8(8), u8(0)] => <PlayMacroAction macroId="0">
|
PlayMacroAction.fromBinary: [u8(8), u8(0)] => <PlayMacroAction macroId="0">
|
||||||
SwitchKeymapAction.fromBinary: [u8(6), u8(1)] => <SwitchKeymapAction keymapId="1">
|
SwitchKeymapAction.fromBinary: [u8(6), u8(1)] => <SwitchKeymapAction keymapId="1">
|
||||||
@@ -67,7 +67,7 @@ KeyActions.toJsObject: <KeyActions length="9">
|
|||||||
KeystrokeModifiersAction.toJsObject: <KeystrokeModifiersAction modifierMask="33"> => {"keyActionType":"keystrokeModifiers","modifierMask":33}
|
KeystrokeModifiersAction.toJsObject: <KeystrokeModifiersAction modifierMask="33"> => {"keyActionType":"keystrokeModifiers","modifierMask":33}
|
||||||
KeystrokeWithModifiersAction.toJsObject: <KeystrokeWithModifiersAction scancode="120" modifierMask="16"> => {"keyActionType":"keystrokeWithModifiers","scancode":120,"modifierMask":16}
|
KeystrokeWithModifiersAction.toJsObject: <KeystrokeWithModifiersAction scancode="120" modifierMask="16"> => {"keyActionType":"keystrokeWithModifiers","scancode":120,"modifierMask":16}
|
||||||
SwitchLayerAction.toJsObject: <SwitchLayerAction layer="1" toggle="false"> => {"keyActionType":"switchLayer","layer":"fn","toggle":false}
|
SwitchLayerAction.toJsObject: <SwitchLayerAction layer="1" toggle="false"> => {"keyActionType":"switchLayer","layer":"fn","toggle":false}
|
||||||
DualRoleKeystrokeAction.toJsObject: <DualRoleKeystrokeAction scancode="111" longPressAction="8"> => {"keyActionType":"dualRoleKeystroke","scancode":111,"longPressAction":"mod"}
|
DualRoleKeystrokeAction.toJsObject: <DualRoleKeystrokeAction scancode="111" secondaryRoleAction="8"> => {"keyActionType":"dualRoleKeystroke","scancode":111,"secondaryRoleAction":"mod"}
|
||||||
MouseAction.toJsObject: <MouseAction mouseAction="8"> => {"keyActionType":"mouse","mouseAction":"scrollDown"}
|
MouseAction.toJsObject: <MouseAction mouseAction="8"> => {"keyActionType":"mouse","mouseAction":"scrollDown"}
|
||||||
PlayMacroAction.toJsObject: <PlayMacroAction macroId="0"> => {"keyActionType":"playMacro","macroId":0}
|
PlayMacroAction.toJsObject: <PlayMacroAction macroId="0"> => {"keyActionType":"playMacro","macroId":0}
|
||||||
SwitchKeymapAction.toJsObject: <SwitchKeymapAction keymapId="1"> => {"keyActionType":"switchKeymap","keymapId":1}
|
SwitchKeymapAction.toJsObject: <SwitchKeymapAction keymapId="1"> => {"keyActionType":"switchKeymap","keymapId":1}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ export * from './hardware-configuration';
|
|||||||
export * from './key-modifiers';
|
export * from './key-modifiers';
|
||||||
export * from './keymap';
|
export * from './keymap';
|
||||||
export * from './layer';
|
export * from './layer';
|
||||||
export * from './long-press-action';
|
export * from './secondary-role-action';
|
||||||
export * from './macro';
|
export * from './macro';
|
||||||
export * from './module';
|
export * from './module';
|
||||||
export * from './module-configuration';
|
export * from './module-configuration';
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export enum KeyActionId {
|
|||||||
5 bits:
|
5 bits:
|
||||||
1: Do we have scancode?
|
1: Do we have scancode?
|
||||||
2: Do we have modifiers?
|
2: Do we have modifiers?
|
||||||
3: Do we have longpress?
|
3: Do we have secondaryRole?
|
||||||
4-5: What kind of keystroke? (basic, short/long media, system)
|
4-5: What kind of keystroke? (basic, short/long media, system)
|
||||||
*/
|
*/
|
||||||
LastKeystrokeAction = 31, // TODO: remove this after refactoring the keyActionId check
|
LastKeystrokeAction = 31, // TODO: remove this after refactoring the keyActionId check
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { KeystrokeAction } from './keystroke-action';
|
import { KeystrokeAction } from './keystroke-action';
|
||||||
import { KeystrokeType } from './keystroke-type';
|
import { KeystrokeType } from './keystroke-type';
|
||||||
import { LongPressAction } from '../long-press-action';
|
import { SecondaryRoleAction } from '../secondary-role-action';
|
||||||
|
|
||||||
describe('keystroke-action', () => {
|
describe('keystroke-action', () => {
|
||||||
it('should be instantiate', () => {
|
it('should be instantiate', () => {
|
||||||
@@ -13,7 +13,7 @@ describe('keystroke-action', () => {
|
|||||||
other.type = KeystrokeType.basic;
|
other.type = KeystrokeType.basic;
|
||||||
other.scancode = 125;
|
other.scancode = 125;
|
||||||
other.modifierMask = 1;
|
other.modifierMask = 1;
|
||||||
other.longPressAction = LongPressAction.leftAlt;
|
other.secondaryRoleAction = SecondaryRoleAction.leftAlt;
|
||||||
const action = new KeystrokeAction(other);
|
const action = new KeystrokeAction(other);
|
||||||
expect(action).toEqual(other);
|
expect(action).toEqual(other);
|
||||||
});
|
});
|
||||||
@@ -104,12 +104,12 @@ describe('keystroke-action', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('longPressAction', () => {
|
describe('secondaryRoleAction', () => {
|
||||||
it('should store the value without modification', () => {
|
it('should store the value without modification', () => {
|
||||||
const value = LongPressAction.leftAlt;
|
const value = SecondaryRoleAction.leftAlt;
|
||||||
const action = new KeystrokeAction();
|
const action = new KeystrokeAction();
|
||||||
action.longPressAction = value;
|
action.secondaryRoleAction = value;
|
||||||
expect(action.longPressAction).toEqual(value);
|
expect(action.secondaryRoleAction).toEqual(value);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ describe('keystroke-action', () => {
|
|||||||
type: 'basic',
|
type: 'basic',
|
||||||
scancode: 100,
|
scancode: 100,
|
||||||
modifierMask: 10,
|
modifierMask: 10,
|
||||||
longPressAction: 'leftAlt'
|
secondaryRoleAction: 'leftAlt'
|
||||||
};
|
};
|
||||||
const action = new KeystrokeAction();
|
const action = new KeystrokeAction();
|
||||||
action.fromJsonObject(jsObject);
|
action.fromJsonObject(jsObject);
|
||||||
@@ -191,7 +191,7 @@ describe('keystroke-action', () => {
|
|||||||
expected.type = KeystrokeType.basic;
|
expected.type = KeystrokeType.basic;
|
||||||
expected.scancode = 100;
|
expected.scancode = 100;
|
||||||
expected.modifierMask = 10;
|
expected.modifierMask = 10;
|
||||||
expected.longPressAction = LongPressAction.leftAlt;
|
expected.secondaryRoleAction = SecondaryRoleAction.leftAlt;
|
||||||
|
|
||||||
expect(action).toEqual(expected);
|
expect(action).toEqual(expected);
|
||||||
});
|
});
|
||||||
@@ -202,7 +202,7 @@ describe('keystroke-action', () => {
|
|||||||
type: 'system',
|
type: 'system',
|
||||||
scancode: 100,
|
scancode: 100,
|
||||||
modifierMask: 10,
|
modifierMask: 10,
|
||||||
longPressAction: 'leftAlt'
|
secondaryRoleAction: 'leftAlt'
|
||||||
};
|
};
|
||||||
const action = new KeystrokeAction();
|
const action = new KeystrokeAction();
|
||||||
action.fromJsonObject(jsObject);
|
action.fromJsonObject(jsObject);
|
||||||
@@ -211,7 +211,7 @@ describe('keystroke-action', () => {
|
|||||||
expected.type = KeystrokeType.system;
|
expected.type = KeystrokeType.system;
|
||||||
expected.scancode = 100;
|
expected.scancode = 100;
|
||||||
expected.modifierMask = 10;
|
expected.modifierMask = 10;
|
||||||
expected.longPressAction = LongPressAction.leftAlt;
|
expected.secondaryRoleAction = SecondaryRoleAction.leftAlt;
|
||||||
|
|
||||||
expect(action).toEqual(expected);
|
expect(action).toEqual(expected);
|
||||||
});
|
});
|
||||||
@@ -222,7 +222,7 @@ describe('keystroke-action', () => {
|
|||||||
type: 'media',
|
type: 'media',
|
||||||
scancode: 100,
|
scancode: 100,
|
||||||
modifierMask: 10,
|
modifierMask: 10,
|
||||||
longPressAction: 'leftAlt'
|
secondaryRoleAction: 'leftAlt'
|
||||||
};
|
};
|
||||||
const action = new KeystrokeAction();
|
const action = new KeystrokeAction();
|
||||||
action.fromJsonObject(jsObject);
|
action.fromJsonObject(jsObject);
|
||||||
@@ -231,7 +231,7 @@ describe('keystroke-action', () => {
|
|||||||
expected.type = KeystrokeType.shortMedia;
|
expected.type = KeystrokeType.shortMedia;
|
||||||
expected.scancode = 100;
|
expected.scancode = 100;
|
||||||
expected.modifierMask = 10;
|
expected.modifierMask = 10;
|
||||||
expected.longPressAction = LongPressAction.leftAlt;
|
expected.secondaryRoleAction = SecondaryRoleAction.leftAlt;
|
||||||
|
|
||||||
expect(action).toEqual(expected);
|
expect(action).toEqual(expected);
|
||||||
});
|
});
|
||||||
@@ -242,7 +242,7 @@ describe('keystroke-action', () => {
|
|||||||
type: 'media',
|
type: 'media',
|
||||||
scancode: 256,
|
scancode: 256,
|
||||||
modifierMask: 10,
|
modifierMask: 10,
|
||||||
longPressAction: 'leftAlt'
|
secondaryRoleAction: 'leftAlt'
|
||||||
};
|
};
|
||||||
const action = new KeystrokeAction();
|
const action = new KeystrokeAction();
|
||||||
action.fromJsonObject(jsObject);
|
action.fromJsonObject(jsObject);
|
||||||
@@ -251,7 +251,7 @@ describe('keystroke-action', () => {
|
|||||||
expected.type = KeystrokeType.longMedia;
|
expected.type = KeystrokeType.longMedia;
|
||||||
expected.scancode = 256;
|
expected.scancode = 256;
|
||||||
expected.modifierMask = 10;
|
expected.modifierMask = 10;
|
||||||
expected.longPressAction = LongPressAction.leftAlt;
|
expected.secondaryRoleAction = SecondaryRoleAction.leftAlt;
|
||||||
|
|
||||||
expect(action).toEqual(expected);
|
expect(action).toEqual(expected);
|
||||||
});
|
});
|
||||||
@@ -281,7 +281,7 @@ describe('keystroke-action', () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('hasLongPressAction', () => {
|
describe('hasSecondaryRoleAction', () => {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import { assertEnum, assertUInt8 } from '../../assert';
|
import { assertEnum, assertUInt8 } from '../../assert';
|
||||||
import { UhkBuffer } from '../../uhk-buffer';
|
import { UhkBuffer } from '../../uhk-buffer';
|
||||||
import { KeyModifiers } from '../key-modifiers';
|
import { KeyModifiers } from '../key-modifiers';
|
||||||
import { LongPressAction } from '../long-press-action';
|
import { SecondaryRoleAction } from '../secondary-role-action';
|
||||||
import { KeyAction, KeyActionId, keyActionType } from './key-action';
|
import { KeyAction, KeyActionId, keyActionType } from './key-action';
|
||||||
import { KeystrokeType } from './keystroke-type';
|
import { KeystrokeType } from './keystroke-type';
|
||||||
|
|
||||||
export enum KeystrokeActionFlag {
|
export enum KeystrokeActionFlag {
|
||||||
scancode = 1 << 0,
|
scancode = 1 << 0,
|
||||||
modifierMask = 1 << 1,
|
modifierMask = 1 << 1,
|
||||||
longPressAction = 1 << 2
|
secondaryRoleAction = 1 << 2
|
||||||
}
|
}
|
||||||
|
|
||||||
const KEYSTROKE_ACTION_FLAG_LENGTH = 3;
|
const KEYSTROKE_ACTION_FLAG_LENGTH = 3;
|
||||||
@@ -17,7 +17,7 @@ interface JsonObjectKeystrokeAction {
|
|||||||
keyActionType: string;
|
keyActionType: string;
|
||||||
scancode?: number;
|
scancode?: number;
|
||||||
modifierMask?: number;
|
modifierMask?: number;
|
||||||
longPressAction?: string;
|
secondaryRoleAction?: string;
|
||||||
type?: string;
|
type?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,8 +40,8 @@ export class KeystrokeAction extends KeyAction {
|
|||||||
@assertUInt8
|
@assertUInt8
|
||||||
modifierMask: number;
|
modifierMask: number;
|
||||||
|
|
||||||
@assertEnum(LongPressAction)
|
@assertEnum(SecondaryRoleAction)
|
||||||
longPressAction: LongPressAction;
|
secondaryRoleAction: SecondaryRoleAction;
|
||||||
|
|
||||||
set type(type: KeystrokeType) {
|
set type(type: KeystrokeType) {
|
||||||
if (type === KeystrokeType.shortMedia || type === KeystrokeType.longMedia) {
|
if (type === KeystrokeType.shortMedia || type === KeystrokeType.longMedia) {
|
||||||
@@ -67,7 +67,7 @@ export class KeystrokeAction extends KeyAction {
|
|||||||
this.type = other.type;
|
this.type = other.type;
|
||||||
this._scancode = other._scancode;
|
this._scancode = other._scancode;
|
||||||
this.modifierMask = other.modifierMask;
|
this.modifierMask = other.modifierMask;
|
||||||
this.longPressAction = other.longPressAction;
|
this.secondaryRoleAction = other.secondaryRoleAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
fromJsonObject(jsonObject: JsonObjectKeystrokeAction): KeystrokeAction {
|
fromJsonObject(jsonObject: JsonObjectKeystrokeAction): KeystrokeAction {
|
||||||
@@ -80,7 +80,7 @@ export class KeystrokeAction extends KeyAction {
|
|||||||
|
|
||||||
this._scancode = jsonObject.scancode;
|
this._scancode = jsonObject.scancode;
|
||||||
this.modifierMask = jsonObject.modifierMask;
|
this.modifierMask = jsonObject.modifierMask;
|
||||||
this.longPressAction = LongPressAction[jsonObject.longPressAction];
|
this.secondaryRoleAction = SecondaryRoleAction[jsonObject.secondaryRoleAction];
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,8 +94,8 @@ export class KeystrokeAction extends KeyAction {
|
|||||||
if (flags & KeystrokeActionFlag.modifierMask) {
|
if (flags & KeystrokeActionFlag.modifierMask) {
|
||||||
this.modifierMask = buffer.readUInt8();
|
this.modifierMask = buffer.readUInt8();
|
||||||
}
|
}
|
||||||
if (flags & KeystrokeActionFlag.longPressAction) {
|
if (flags & KeystrokeActionFlag.secondaryRoleAction) {
|
||||||
this.longPressAction = buffer.readUInt8();
|
this.secondaryRoleAction = buffer.readUInt8();
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -119,8 +119,8 @@ export class KeystrokeAction extends KeyAction {
|
|||||||
jsonObject.modifierMask = this.modifierMask;
|
jsonObject.modifierMask = this.modifierMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasLongPressAction()) {
|
if (this.hasSecondaryRoleAction()) {
|
||||||
jsonObject.longPressAction = LongPressAction[this.longPressAction];
|
jsonObject.secondaryRoleAction = SecondaryRoleAction[this.secondaryRoleAction];
|
||||||
}
|
}
|
||||||
|
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
@@ -143,9 +143,9 @@ export class KeystrokeAction extends KeyAction {
|
|||||||
toWrite.push({data: this.modifierMask, long: false});
|
toWrite.push({data: this.modifierMask, long: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasLongPressAction()) {
|
if (this.hasSecondaryRoleAction()) {
|
||||||
flags |= KeystrokeActionFlag.longPressAction;
|
flags |= KeystrokeActionFlag.secondaryRoleAction;
|
||||||
toWrite.push({data: this.longPressAction, long: false});
|
toWrite.push({data: this.secondaryRoleAction, long: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
const TYPE_OFFSET = flags + (this.type << KEYSTROKE_ACTION_FLAG_LENGTH);
|
const TYPE_OFFSET = flags + (this.type << KEYSTROKE_ACTION_FLAG_LENGTH);
|
||||||
@@ -172,8 +172,8 @@ export class KeystrokeAction extends KeyAction {
|
|||||||
if (this.hasActiveModifier()) {
|
if (this.hasActiveModifier()) {
|
||||||
properties.push(`modifierMask="${this.modifierMask}"`);
|
properties.push(`modifierMask="${this.modifierMask}"`);
|
||||||
}
|
}
|
||||||
if (this.hasLongPressAction()) {
|
if (this.hasSecondaryRoleAction()) {
|
||||||
properties.push(`longPressAction="${this.longPressAction}"`);
|
properties.push(`secondaryRoleAction="${this.secondaryRoleAction}"`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return `<KeystrokeAction ${properties.join(' ')}>`;
|
return `<KeystrokeAction ${properties.join(' ')}>`;
|
||||||
@@ -187,8 +187,8 @@ export class KeystrokeAction extends KeyAction {
|
|||||||
return this.modifierMask > 0;
|
return this.modifierMask > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasLongPressAction(): boolean {
|
hasSecondaryRoleAction(): boolean {
|
||||||
return this.longPressAction !== undefined;
|
return this.secondaryRoleAction !== undefined && this.secondaryRoleAction !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
hasScancode(): boolean {
|
hasScancode(): boolean {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export enum LongPressAction {
|
export enum SecondaryRoleAction {
|
||||||
leftCtrl,
|
leftCtrl,
|
||||||
leftShift,
|
leftShift,
|
||||||
leftAlt,
|
leftAlt,
|
||||||
@@ -4,6 +4,6 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
p {
|
p {
|
||||||
margin: 1.5rem 0px 1.5rem;
|
margin: 1.5rem 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,8 @@
|
|||||||
<h4 *ngIf="activeTab === TabName.Keypress">Press key</h4>
|
<h4 *ngIf="activeTab === TabName.Keypress">Press key</h4>
|
||||||
<h4 *ngIf="activeTab === TabName.Hold">Hold key</h4>
|
<h4 *ngIf="activeTab === TabName.Hold">Hold key</h4>
|
||||||
<h4 *ngIf="activeTab === TabName.Release">Release key</h4>
|
<h4 *ngIf="activeTab === TabName.Release">Release key</h4>
|
||||||
<keypress-tab #keypressTab [defaultKeyAction]="defaultKeyAction" [longPressEnabled]="false" (validAction)="validate()"></keypress-tab>
|
<keypress-tab #keypressTab [defaultKeyAction]="defaultKeyAction" [secondaryRoleEnabled]="false"
|
||||||
|
(validAction)="validate()"></keypress-tab>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
<div [ngSwitch]="activeTab">
|
<div [ngSwitch]="activeTab">
|
||||||
<keypress-tab #tab *ngSwitchCase="tabName.Keypress" class="popover-content"
|
<keypress-tab #tab *ngSwitchCase="tabName.Keypress" class="popover-content"
|
||||||
[defaultKeyAction]="defaultKeyAction"
|
[defaultKeyAction]="defaultKeyAction"
|
||||||
[longPressEnabled]="true"
|
[secondaryRoleEnabled]="true"
|
||||||
(validAction)="keyActionValid=$event"
|
(validAction)="keyActionValid=$event"
|
||||||
></keypress-tab>
|
></keypress-tab>
|
||||||
<layer-tab #tab *ngSwitchCase="tabName.Layer" class="popover-content"
|
<layer-tab #tab *ngSwitchCase="tabName.Layer" class="popover-content"
|
||||||
|
|||||||
@@ -32,12 +32,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="long-press-container" *ngIf="longPressEnabled">
|
<div class="long-press-container" *ngIf="secondaryRoleEnabled">
|
||||||
<b class="setting-label">Long press action:</b>
|
<b class="setting-label">Secondary role action:</b>
|
||||||
<select2 #longPressSelect
|
<select2 #secondaryRoleSelect
|
||||||
[data]="longPressGroups"
|
[data]="secondaryRoleGroups"
|
||||||
[value]="selectedLongPressIndex.toString()"
|
[value]="selectedSecondaryRoleIndex.toString()"
|
||||||
(valueChanged)="onLongpressChange($event)"
|
(valueChanged)="onSecondaryRoleChange($event)"
|
||||||
[width]="140"
|
[width]="140"
|
||||||
></select2>
|
></select2>
|
||||||
<icon name="question-circle"
|
<icon name="question-circle"
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { MapperService } from '../../../../services/mapper.service';
|
|||||||
})
|
})
|
||||||
export class KeypressTabComponent extends Tab implements OnChanges {
|
export class KeypressTabComponent extends Tab implements OnChanges {
|
||||||
@Input() defaultKeyAction: KeyAction;
|
@Input() defaultKeyAction: KeyAction;
|
||||||
@Input() longPressEnabled: boolean;
|
@Input() secondaryRoleEnabled: boolean;
|
||||||
|
|
||||||
leftModifiers: string[];
|
leftModifiers: string[];
|
||||||
rightModifiers: string[];
|
rightModifiers: string[];
|
||||||
@@ -21,11 +21,11 @@ export class KeypressTabComponent extends Tab implements OnChanges {
|
|||||||
rightModifierSelects: boolean[];
|
rightModifierSelects: boolean[];
|
||||||
|
|
||||||
scanCodeGroups: Array<Select2OptionData>;
|
scanCodeGroups: Array<Select2OptionData>;
|
||||||
longPressGroups: Array<Select2OptionData>;
|
secondaryRoleGroups: Array<Select2OptionData>;
|
||||||
options: Select2Options;
|
options: Select2Options;
|
||||||
|
|
||||||
selectedScancodeOption: Select2OptionData;
|
selectedScancodeOption: Select2OptionData;
|
||||||
selectedLongPressIndex: number;
|
selectedSecondaryRoleIndex: number;
|
||||||
|
|
||||||
constructor(private mapper: MapperService) {
|
constructor(private mapper: MapperService) {
|
||||||
super();
|
super();
|
||||||
@@ -36,11 +36,11 @@ export class KeypressTabComponent extends Tab implements OnChanges {
|
|||||||
text: 'None'
|
text: 'None'
|
||||||
}];
|
}];
|
||||||
this.scanCodeGroups = this.scanCodeGroups.concat(require('./scancodes.json'));
|
this.scanCodeGroups = this.scanCodeGroups.concat(require('./scancodes.json'));
|
||||||
this.longPressGroups = require('./longPress.json');
|
this.secondaryRoleGroups = require('./secondaryRole.json');
|
||||||
this.leftModifierSelects = Array(this.leftModifiers.length).fill(false);
|
this.leftModifierSelects = Array(this.leftModifiers.length).fill(false);
|
||||||
this.rightModifierSelects = Array(this.rightModifiers.length).fill(false);
|
this.rightModifierSelects = Array(this.rightModifiers.length).fill(false);
|
||||||
this.selectedScancodeOption = this.scanCodeGroups[0];
|
this.selectedScancodeOption = this.scanCodeGroups[0];
|
||||||
this.selectedLongPressIndex = -1;
|
this.selectedSecondaryRoleIndex = -1;
|
||||||
this.options = {
|
this.options = {
|
||||||
templateResult: this.scanCodeTemplateResult,
|
templateResult: this.scanCodeTemplateResult,
|
||||||
matcher: (term: string, text: string, data: Select2OptionData) => {
|
matcher: (term: string, text: string, data: Select2OptionData) => {
|
||||||
@@ -100,9 +100,9 @@ export class KeypressTabComponent extends Tab implements OnChanges {
|
|||||||
this.rightModifierSelects[index] = ((keystrokeAction.modifierMask >> i) & 1) === 1;
|
this.rightModifierSelects[index] = ((keystrokeAction.modifierMask >> i) & 1) === 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore longPressAction
|
// Restore secondaryRoleAction
|
||||||
if (keystrokeAction.longPressAction !== undefined) {
|
if (keystrokeAction.secondaryRoleAction !== undefined) {
|
||||||
this.selectedLongPressIndex = this.mapper.modifierMapper(keystrokeAction.longPressAction);
|
this.selectedSecondaryRoleIndex = this.mapper.modifierMapper(keystrokeAction.secondaryRoleAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -123,9 +123,9 @@ export class KeypressTabComponent extends Tab implements OnChanges {
|
|||||||
keystrokeAction.modifierMask |= modifiers[i] << this.mapper.modifierMapper(i);
|
keystrokeAction.modifierMask |= modifiers[i] << this.mapper.modifierMapper(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
keystrokeAction.longPressAction = this.selectedLongPressIndex === -1
|
keystrokeAction.secondaryRoleAction = this.selectedSecondaryRoleIndex === -1
|
||||||
? undefined
|
? undefined
|
||||||
: this.mapper.modifierMapper(this.selectedLongPressIndex);
|
: this.mapper.modifierMapper(this.selectedSecondaryRoleIndex);
|
||||||
|
|
||||||
if (this.keyActionValid(keystrokeAction)) {
|
if (this.keyActionValid(keystrokeAction)) {
|
||||||
return keystrokeAction;
|
return keystrokeAction;
|
||||||
@@ -158,8 +158,8 @@ export class KeypressTabComponent extends Tab implements OnChanges {
|
|||||||
this.validAction.emit(this.keyActionValid());
|
this.validAction.emit(this.keyActionValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
onLongpressChange(event: { value: string }) {
|
onSecondaryRoleChange(event: { value: string }) {
|
||||||
this.selectedLongPressIndex = +event.value;
|
this.selectedSecondaryRoleIndex = +event.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
onScancodeChange(event: { value: string }) {
|
onScancodeChange(event: { value: string }) {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ ul {
|
|||||||
|
|
||||||
.sidebar {
|
.sidebar {
|
||||||
&__level-0 {
|
&__level-0 {
|
||||||
padding: 0.5rem 1rem 0 1rem;
|
padding: 0.5rem 1rem 0;
|
||||||
}
|
}
|
||||||
&__level-1 {
|
&__level-1 {
|
||||||
padding: 0.5rem 1rem 0.5rem 2rem;
|
padding: 0.5rem 1rem 0.5rem 2rem;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import {
|
|||||||
KeystrokeAction,
|
KeystrokeAction,
|
||||||
Layer,
|
Layer,
|
||||||
LayerName,
|
LayerName,
|
||||||
LongPressAction,
|
SecondaryRoleAction,
|
||||||
MouseAction,
|
MouseAction,
|
||||||
MouseActionParam,
|
MouseActionParam,
|
||||||
PlayMacroAction,
|
PlayMacroAction,
|
||||||
@@ -266,10 +266,10 @@ export class SvgKeyboardWrapComponent implements OnInit, OnChanges {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keystrokeAction.hasLongPressAction()) {
|
if (keystrokeAction.hasSecondaryRoleAction()) {
|
||||||
content.push({
|
content.push({
|
||||||
name: 'Long press',
|
name: 'Secondary role',
|
||||||
value: LongPressAction[keystrokeAction.longPressAction]
|
value: SecondaryRoleAction[keystrokeAction.secondaryRoleAction]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return Observable.of(content);
|
return Observable.of(content);
|
||||||
|
|||||||
Reference in New Issue
Block a user