From 9ec70b832ad273890e28e36dce43da241b504a98 Mon Sep 17 00:00:00 2001 From: John Barbero Unenge Date: Thu, 9 Nov 2023 23:17:46 +0100 Subject: [PATCH 1/3] [Keyboard] Change default implementation for get_layer_name_user Will now show the layer number instead of "Unknown", since this is what will be shown if QMK Configurator is used to compile the firmware. --- keyboards/snes_macropad/snes_macropad.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/keyboards/snes_macropad/snes_macropad.c b/keyboards/snes_macropad/snes_macropad.c index a8e04c8c32af..6a2930d57731 100644 --- a/keyboards/snes_macropad/snes_macropad.c +++ b/keyboards/snes_macropad/snes_macropad.c @@ -9,6 +9,8 @@ char key_name = ' '; uint16_t last_keycode; uint8_t last_row; uint8_t last_col; +char layer_str[3] = ""; // 2 digits + null terminator +_Static_assert(MAX_LAYER < 100, "layer_str is too small"); static const char PROGMEM code_to_name[60] = {' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'R', 'E', 'B', 'T', '_', '-', '=', '[', ']', '\\', '#', ';', '\'', '`', ',', '.', '/', ' ', ' ', ' '}; @@ -58,7 +60,8 @@ static void oled_render_keylog(void) { } __attribute__((weak)) const char * get_layer_name_user(int layer) { - return "Unknown"; + snprintf(layer_str, sizeof(layer_str), "%d", layer); + return layer_str; } static void oled_render_layer(void) { From 117c4b669283ed3afe64e983dd3c8241fce8ba4a Mon Sep 17 00:00:00 2001 From: John Barbero Unenge Date: Thu, 9 Nov 2023 23:21:08 +0100 Subject: [PATCH 2/3] [Keyboard] Update the layout info This makes it look sort of like a macropad + gamepad rather than an 4x6 ortholinear keyboard. --- keyboards/snes_macropad/info.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/keyboards/snes_macropad/info.json b/keyboards/snes_macropad/info.json index c54e9bb0b266..15e3c9ee6784 100644 --- a/keyboards/snes_macropad/info.json +++ b/keyboards/snes_macropad/info.json @@ -45,18 +45,18 @@ {"matrix": [2, 2], "x": 2, "y": 2}, {"matrix": [2, 3], "x": 3, "y": 2}, - {"matrix": [3, 0], "x": 0, "y": 3}, - {"matrix": [3, 1], "x": 1, "y": 3}, - {"matrix": [3, 2], "x": 2, "y": 3}, - {"matrix": [3, 3], "x": 3, "y": 3}, - {"matrix": [4, 0], "x": 0, "y": 4}, - {"matrix": [4, 1], "x": 1, "y": 4}, - {"matrix": [4, 2], "x": 2, "y": 4}, - {"matrix": [4, 3], "x": 3, "y": 4}, - {"matrix": [5, 0], "x": 0, "y": 5}, - {"matrix": [5, 1], "x": 1, "y": 5}, - {"matrix": [5, 2], "x": 2, "y": 5}, - {"matrix": [5, 3], "x": 3, "y": 5} + {"matrix": [3, 0], "x": 5.2, "y": 0, "w": 2, "h": 0.75}, + {"matrix": [3, 1], "x": 10.65, "y": 0, "w": 2, "h": 0.75}, + {"matrix": [3, 2], "x": 7.9, "y": 2.5, "w": 1, "h": 0.75}, + {"matrix": [3, 3], "x": 8.9, "y": 2.5, "w": 1, "h": 0.75}, + {"matrix": [4, 0], "x": 6, "y": 1, "w": 0.85, "h": 0.85}, + {"matrix": [4, 1], "x": 6, "y": 3, "w": 0.85, "h": 0.85}, + {"matrix": [4, 2], "x": 5.2, "y": 2, "w": 0.85, "h": 0.85}, + {"matrix": [4, 3], "x": 6.8, "y": 2, "w": 0.85, "h": 0.85}, + {"matrix": [5, 0], "x": 11.8, "y": 2, "w": 0.85, "h": 0.85}, + {"matrix": [5, 1], "x": 11, "y": 3, "w": 0.85, "h": 0.85}, + {"matrix": [5, 2], "x": 11, "y": 1, "w": 0.85, "h": 0.85}, + {"matrix": [5, 3], "x": 10.2, "y": 2, "w": 0.85, "h": 0.85} ] } }, From 1b44a62040931e645693e94ff976a41458a153a9 Mon Sep 17 00:00:00 2001 From: John Barbero Unenge Date: Sat, 11 Nov 2023 20:33:58 +0100 Subject: [PATCH 3/3] [Keyboard] Fix default implementation of get_layer_name_user Based on feedback from code review the implementation was swapped in favor of using get_u8_str. This implied a change to the argument type from int to uint8_t, which cascaded into the existing keymaps. (This made sense in general, since the return type of get_highest_layer is also a uint8_t.) --- keyboards/snes_macropad/keymaps/default/keymap.c | 2 +- keyboards/snes_macropad/keymaps/jbarberu/keymap.c | 2 +- keyboards/snes_macropad/keymaps/test/keymap.c | 2 +- keyboards/snes_macropad/snes_macropad.c | 7 ++----- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/keyboards/snes_macropad/keymaps/default/keymap.c b/keyboards/snes_macropad/keymaps/default/keymap.c index 34f4f6248a07..c4896b1f49b8 100644 --- a/keyboards/snes_macropad/keymaps/default/keymap.c +++ b/keyboards/snes_macropad/keymaps/default/keymap.c @@ -61,7 +61,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { }; // clang-format on -const char* get_layer_name_user(int layer) { +const char* get_layer_name_user(uint8_t layer) { switch (layer) { case L_Numpad: return "Numpad"; diff --git a/keyboards/snes_macropad/keymaps/jbarberu/keymap.c b/keyboards/snes_macropad/keymaps/jbarberu/keymap.c index 0fbe0fa6266e..478d1461e257 100644 --- a/keyboards/snes_macropad/keymaps/jbarberu/keymap.c +++ b/keyboards/snes_macropad/keymaps/jbarberu/keymap.c @@ -81,7 +81,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { }; // clang-format on -const char * get_layer_name_user(int layer) { +const char * get_layer_name_user(uint8_t layer) { switch (layer) { case L_Numpad: return "Numpad"; diff --git a/keyboards/snes_macropad/keymaps/test/keymap.c b/keyboards/snes_macropad/keymaps/test/keymap.c index 86dd66996574..72be941694cf 100644 --- a/keyboards/snes_macropad/keymaps/test/keymap.c +++ b/keyboards/snes_macropad/keymaps/test/keymap.c @@ -61,7 +61,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { }; // clang-format on -const char * get_layer_name_user(int layer) { +const char * get_layer_name_user(uint8_t layer) { switch (layer) { case L_Numpad: return "Numpad"; diff --git a/keyboards/snes_macropad/snes_macropad.c b/keyboards/snes_macropad/snes_macropad.c index 6a2930d57731..ba4ce44bd1e0 100644 --- a/keyboards/snes_macropad/snes_macropad.c +++ b/keyboards/snes_macropad/snes_macropad.c @@ -9,8 +9,6 @@ char key_name = ' '; uint16_t last_keycode; uint8_t last_row; uint8_t last_col; -char layer_str[3] = ""; // 2 digits + null terminator -_Static_assert(MAX_LAYER < 100, "layer_str is too small"); static const char PROGMEM code_to_name[60] = {' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'R', 'E', 'B', 'T', '_', '-', '=', '[', ']', '\\', '#', ';', '\'', '`', ',', '.', '/', ' ', ' ', ' '}; @@ -59,9 +57,8 @@ static void oled_render_keylog(void) { oled_write_char(key_name, false); } -__attribute__((weak)) const char * get_layer_name_user(int layer) { - snprintf(layer_str, sizeof(layer_str), "%d", layer); - return layer_str; +__attribute__((weak)) const char * get_layer_name_user(uint8_t layer) { + return get_u8_str(layer, ' '); } static void oled_render_layer(void) {