Let's not duplicate part of the KeyActionId enum as LongPressActionId because duplication should only cause troubles down the road.
This commit is contained in:
@@ -1,23 +1,9 @@
|
|||||||
enum LongPressActionId {
|
|
||||||
leftCtrl = 236, // KeyActionId.DualRoleActionLeftCtrl
|
|
||||||
leftShift,
|
|
||||||
leftAlt,
|
|
||||||
leftSuper,
|
|
||||||
rightCtrl,
|
|
||||||
rightShift,
|
|
||||||
rightAlt,
|
|
||||||
rightSuper,
|
|
||||||
mod,
|
|
||||||
fn,
|
|
||||||
mouse,
|
|
||||||
}
|
|
||||||
|
|
||||||
class DualRoleKeystrokeAction extends KeyAction implements Serializable<DualRoleKeystrokeAction> {
|
class DualRoleKeystrokeAction extends KeyAction implements Serializable<DualRoleKeystrokeAction> {
|
||||||
static keyActionTypeString = 'dualRoleKeystroke';
|
static keyActionTypeString = 'dualRoleKeystroke';
|
||||||
|
|
||||||
public scancode;
|
public scancode;
|
||||||
|
|
||||||
private _longPressAction: LongPressActionId;
|
private _longPressAction: KeyActionId;
|
||||||
|
|
||||||
get longPressAction(): number {
|
get longPressAction(): number {
|
||||||
return this._longPressAction;
|
return this._longPressAction;
|
||||||
@@ -30,8 +16,9 @@ class DualRoleKeystrokeAction extends KeyAction implements Serializable<DualRole
|
|||||||
this._longPressAction = value;
|
this._longPressAction = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static isDualRoleKeystrokeActionValid(keyActionId): boolean {
|
static isDualRoleKeystrokeActionValid(keyActionIdParam): boolean {
|
||||||
return LongPressActionId[keyActionId] !== undefined;
|
return KeyActionId.DualRoleActionLeftCtrlLongPressAction <= keyActionIdParam &&
|
||||||
|
keyActionIdParam <= KeyActionId.DualRoleActionMouseLongPressAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
fromJsObject(jsObject: any): DualRoleKeystrokeAction {
|
fromJsObject(jsObject: any): DualRoleKeystrokeAction {
|
||||||
@@ -49,7 +36,7 @@ class DualRoleKeystrokeAction extends KeyAction implements Serializable<DualRole
|
|||||||
toJsObject(): any {
|
toJsObject(): any {
|
||||||
return {
|
return {
|
||||||
keyActionType: DualRoleKeystrokeAction.keyActionTypeString,
|
keyActionType: DualRoleKeystrokeAction.keyActionTypeString,
|
||||||
longPressAction: LongPressActionId[this.longPressAction],
|
longPressAction: KeyActionId[this.longPressAction],
|
||||||
scancode: this.scancode
|
scancode: this.scancode
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,25 +2,25 @@
|
|||||||
// Id denotes the subclass of the KeyAction and param is subclass-specific.
|
// Id denotes the subclass of the KeyAction and param is subclass-specific.
|
||||||
|
|
||||||
enum KeyActionId {
|
enum KeyActionId {
|
||||||
NoneAction = 0,
|
NoneAction = 0,
|
||||||
KeyStrokeActionFirst = TypeChecker.firstValidScancode, // 1
|
KeyStrokeActionFirst = TypeChecker.firstValidScancode, // 1
|
||||||
// Intermediary scancodes = 2 to 230
|
// Intermediary scancodes = 2 to 230
|
||||||
KeyStrokeActionLast = TypeChecker.lastValidScancode, // 231
|
KeyStrokeActionLast = TypeChecker.lastValidScancode, // 231
|
||||||
SwitchLayerAction = 232,
|
SwitchLayerAction = 232,
|
||||||
SwitchKeymapAction = 233,
|
SwitchKeymapAction = 233,
|
||||||
MouseAction = 234,
|
MouseAction = 234,
|
||||||
PlayMacroAction = 235,
|
PlayMacroAction = 235,
|
||||||
DualRoleActionLeftCtrl = 236,
|
DualRoleActionLeftCtrlLongPressAction = 236,
|
||||||
DualRoleActionLeftShift = 237,
|
DualRoleActionLeftShiftLongPressAction = 237,
|
||||||
DualRoleActionLeftAlt = 238,
|
DualRoleActionLeftAltLongPressAction = 238,
|
||||||
DualRoleActionLeftSuper = 239,
|
DualRoleActionLeftSuperLongPressAction = 239,
|
||||||
DualRoleActionRightCtrl = 240,
|
DualRoleActionRightCtrlLongPressAction = 240,
|
||||||
DualRoleActionRightShift = 241,
|
DualRoleActionRightShiftLongPressAction = 241,
|
||||||
DualRoleActionRightAlt = 242,
|
DualRoleActionRightAltLongPressAction = 242,
|
||||||
DualRoleActionRightSuper = 243,
|
DualRoleActionRightSuperLongPressAction = 243,
|
||||||
DualRoleActionMod = 244,
|
DualRoleActionModLongPressAction = 244,
|
||||||
DualRoleActionFn = 245,
|
DualRoleActionFnLongPressAction = 245,
|
||||||
DualRoleActionMouse = 246
|
DualRoleActionMouseLongPressAction = 246
|
||||||
// Let's leave space for further layers - additional actions should descend from 255
|
// Let's leave space for further layers - additional actions should descend from 255
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user