Convert LAYER_ID_* macros to LayerId_* enum values.
This commit is contained in:
@@ -27,6 +27,8 @@ parser_error_t ParseConfig(config_buffer_t *buffer)
|
||||
parser_error_t errorCode;
|
||||
|
||||
uint16_t dataModelVersion = readUInt16(buffer);
|
||||
// uint16_t userConfigLength = readUInt16(buffer);
|
||||
// (void)userConfigLength;
|
||||
readString(buffer, &len); // Ignore device name
|
||||
uint16_t moduleConfigurationCount = readCompactLength(buffer);
|
||||
|
||||
|
||||
@@ -65,8 +65,8 @@ key_action_t CurrentKeymap[LAYER_COUNT][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] =
|
||||
|
||||
// Row 5
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_SPACE }},
|
||||
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LAYER_ID_MOD }},
|
||||
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LAYER_ID_FN }},
|
||||
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Mod }},
|
||||
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Fn }},
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_ALT }},
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_CONTROL }},
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_GUI }},
|
||||
@@ -93,7 +93,7 @@ key_action_t CurrentKeymap[LAYER_COUNT][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] =
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_T }},
|
||||
|
||||
// Row 3
|
||||
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LAYER_ID_MOUSE }},
|
||||
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Mouse }},
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_A }},
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_S }},
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_D }},
|
||||
@@ -114,9 +114,9 @@ key_action_t CurrentKeymap[LAYER_COUNT][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] =
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_GUI }},
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_CONTROL }},
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_ALT }},
|
||||
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LAYER_ID_FN }},
|
||||
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Fn }},
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_SPACE }},
|
||||
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LAYER_ID_MOD }},
|
||||
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Mod }},
|
||||
{ .type = KeyActionType_None },
|
||||
}
|
||||
},
|
||||
@@ -164,7 +164,7 @@ key_action_t CurrentKeymap[LAYER_COUNT][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] =
|
||||
|
||||
// Row 5
|
||||
{ .type = KeyActionType_None },
|
||||
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LAYER_ID_MOD }},
|
||||
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Mod }},
|
||||
{ .type = KeyActionType_None },
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_ALT }},
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_CONTROL }},
|
||||
@@ -215,7 +215,7 @@ key_action_t CurrentKeymap[LAYER_COUNT][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] =
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_ALT }},
|
||||
{ .type = KeyActionType_None },
|
||||
{ .type = KeyActionType_None },
|
||||
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LAYER_ID_MOD }},
|
||||
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Mod }},
|
||||
{ .type = KeyActionType_None },
|
||||
}
|
||||
},
|
||||
@@ -264,7 +264,7 @@ key_action_t CurrentKeymap[LAYER_COUNT][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] =
|
||||
// Row 5
|
||||
{ .type = KeyActionType_None },
|
||||
{ .type = KeyActionType_None },
|
||||
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LAYER_ID_FN }},
|
||||
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Fn }},
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_ALT }},
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_CONTROL }},
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_RIGHT_GUI }},
|
||||
@@ -312,7 +312,7 @@ key_action_t CurrentKeymap[LAYER_COUNT][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] =
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_GUI }},
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_CONTROL }},
|
||||
{ .type = KeyActionType_Keystroke, .keystroke = { .scancode = HID_KEYBOARD_SC_LEFT_ALT }},
|
||||
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LAYER_ID_FN }},
|
||||
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Fn }},
|
||||
{ .type = KeyActionType_None },
|
||||
{ .type = KeyActionType_None },
|
||||
{ .type = KeyActionType_None },
|
||||
@@ -390,7 +390,7 @@ key_action_t CurrentKeymap[LAYER_COUNT][SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE] =
|
||||
{ .type = KeyActionType_None },
|
||||
|
||||
// Row 3
|
||||
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LAYER_ID_MOUSE }},
|
||||
{ .type = KeyActionType_SwitchLayer, .switchLayer = { .layer = LayerId_Mouse }},
|
||||
{ .type = KeyActionType_None },
|
||||
{ .type = KeyActionType_Mouse, .mouse = { .buttonActions = MouseButton_Right }},
|
||||
{ .type = KeyActionType_Mouse, .mouse = { .buttonActions = MouseButton_Middle }},
|
||||
|
||||
@@ -3,11 +3,15 @@
|
||||
|
||||
// Macros:
|
||||
|
||||
#define LAYER_ID_BASE 0
|
||||
#define LAYER_ID_MOD 1
|
||||
#define LAYER_ID_FN 2
|
||||
#define LAYER_ID_MOUSE 3
|
||||
|
||||
#define LAYER_COUNT 4
|
||||
|
||||
// Typedefs:
|
||||
|
||||
typedef enum {
|
||||
LayerId_Base,
|
||||
LayerId_Mod,
|
||||
LayerId_Fn,
|
||||
LayerId_Mouse,
|
||||
} layer_id_t;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -83,7 +83,7 @@ void LedDisplay_SetLayer(uint8_t layerId) {
|
||||
LedDriverValues[LedDriverId_Left][i] = 0;
|
||||
}
|
||||
|
||||
if (layerId >= LAYER_ID_MOD && layerId <= LAYER_ID_MOUSE) {
|
||||
if (layerId >= LayerId_Mod && layerId <= LayerId_Mouse) {
|
||||
LedDriverValues[LedDriverId_Left][16 * layerId - 3] = LED_BRIGHTNESS_LEVEL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,11 +74,11 @@ void processMouseAction(key_action_t action)
|
||||
|
||||
uint8_t getActiveLayer(void)
|
||||
{
|
||||
uint8_t activeLayer = LAYER_ID_BASE;
|
||||
uint8_t activeLayer = LayerId_Base;
|
||||
for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) {
|
||||
for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) {
|
||||
if (CurrentKeyStates[slotId][keyId]) {
|
||||
key_action_t action = CurrentKeymap[LAYER_ID_BASE][slotId][keyId];
|
||||
key_action_t action = CurrentKeymap[LayerId_Base][slotId][keyId];
|
||||
if (action.type == KeyActionType_SwitchLayer) {
|
||||
activeLayer = action.switchLayer.layer;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ void UpdateActiveUsbReports(void)
|
||||
uint8_t basicScancodeIndex = 0;
|
||||
uint8_t mediaScancodeIndex = 0;
|
||||
uint8_t systemScancodeIndex = 0;
|
||||
static uint8_t previousLayer = LAYER_ID_BASE;
|
||||
static uint8_t previousLayer = LayerId_Base;
|
||||
static uint8_t previousModifiers = 0;
|
||||
uint8_t activeLayer;
|
||||
|
||||
@@ -153,7 +153,7 @@ void UpdateActiveUsbReports(void)
|
||||
// When a layer switcher key gets pressed along with another key that produces some modifiers
|
||||
// and the accomanying key gets released then keep the related modifiers active a long as the
|
||||
// layer switcher key stays pressed. Useful for Alt+Tab keymappings and the like.
|
||||
if (activeLayer != LAYER_ID_BASE && activeLayer == previousLayer && basicScancodeIndex == 0) {
|
||||
if (activeLayer != LayerId_Base && activeLayer == previousLayer && basicScancodeIndex == 0) {
|
||||
ActiveUsbBasicKeyboardReport->modifiers |= previousModifiers;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user