Add missing keyboard-key labels

This commit is contained in:
József Farkas
2016-04-29 21:19:50 +02:00
parent a03588cc02
commit e2eb46b0de
5 changed files with 102 additions and 23 deletions
@@ -48,4 +48,8 @@ export class KeystrokeModifiersAction extends KeyAction {
isModifierActive(modifier: KeyModifiers): boolean {
return (this.modifierMask & modifier) > 0;
}
isOnlyOneModifierActive(): boolean {
return this.modifierMask !== 0 && !(this.modifierMask & this.modifierMask - 1);
}
}
@@ -1,7 +1,7 @@
import {keyActionType, KeyActionId, KeyAction} from './KeyAction';
import {UhkBuffer} from '../UhkBuffer';
enum LayerName {
export enum LayerName {
mod,
fn,
mouse
@@ -12,18 +12,18 @@ export class SwitchLayerAction extends KeyAction {
isLayerToggleable: boolean;
// @assertEnum(LayerName)
private layer: LayerName;
private _layer: LayerName;
_fromJsObject(jsObject: any): SwitchLayerAction {
this.assertKeyActionType(jsObject);
this.layer = LayerName[<string> jsObject.layer];
this._layer = LayerName[<string> jsObject.layer];
this.isLayerToggleable = jsObject.toggle;
return this;
}
_fromBinary(buffer: UhkBuffer): SwitchLayerAction {
this.readAndAssertKeyActionId(buffer);
this.layer = buffer.readUInt8();
this._layer = buffer.readUInt8();
this.isLayerToggleable = buffer.readBoolean();
return this;
}
@@ -45,4 +45,8 @@ export class SwitchLayerAction extends KeyAction {
toString(): string {
return `<SwitchLayerAction layer="${this.layer}" toggle="${this.isLayerToggleable}">`;
}
get layer() {
return this._layer;
}
}
+30
View File
@@ -132,6 +132,36 @@
{
"keyActionType": "keystroke",
"scancode": 56
},
{
"keyActionType": "keystrokeModifiers",
"modifierMask": 32
},
{
"keyActionType": "keystroke",
"scancode": 44
},
{
"keyActionType": "switchLayer",
"layer": "fn",
"toggle": false
},
{
"keyActionType": "keystrokeModifiers",
"modifierMask": 64
},
{
"keyActionType": "keystrokeModifiers",
"modifierMask": 128
},
{
"keyActionType": "keystrokeModifiers",
"modifierMask": 16
},
{
"keyActionType": "switchLayer",
"layer": "mod",
"toggle": false
}
]
},