From 2aaef66d8595fa77c02e433ae60cbd9f59b9f1d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Thu, 2 Nov 2017 21:48:30 +0100 Subject: [PATCH] Convert LAYER_ID_* macros to LayerId_* enum values. --- right/src/config_parser/parse_config.c | 2 ++ right/src/keymaps.c | 20 ++++++++++---------- right/src/layer.h | 14 +++++++++----- right/src/led_display.c | 2 +- right/src/usb_report_updater.c | 8 ++++---- 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/right/src/config_parser/parse_config.c b/right/src/config_parser/parse_config.c index 3bc825e..65556e2 100644 --- a/right/src/config_parser/parse_config.c +++ b/right/src/config_parser/parse_config.c @@ -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); diff --git a/right/src/keymaps.c b/right/src/keymaps.c index 6d3595f..41f5714 100644 --- a/right/src/keymaps.c +++ b/right/src/keymaps.c @@ -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 }}, diff --git a/right/src/layer.h b/right/src/layer.h index 34b9099..0528c6a 100644 --- a/right/src/layer.h +++ b/right/src/layer.h @@ -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 diff --git a/right/src/led_display.c b/right/src/led_display.c index e87f187..3678d59 100644 --- a/right/src/led_display.c +++ b/right/src/led_display.c @@ -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; } } diff --git a/right/src/usb_report_updater.c b/right/src/usb_report_updater.c index 2f4078f..6669fbf 100644 --- a/right/src/usb_report_updater.c +++ b/right/src/usb_report_updater.c @@ -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; slotIdmodifiers |= previousModifiers; }