From 163bd6905d999c45e1bc33da11903ccc4f1778f7 Mon Sep 17 00:00:00 2001 From: Sascha Hagedorn Date: Wed, 9 Oct 2019 13:37:27 +0200 Subject: [PATCH] Use drashnas latest OLED changes See #6920 --- keyboards/crkbd/keymaps/saesh/keymap.c | 34 ++++++++++++++++++-------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/keyboards/crkbd/keymaps/saesh/keymap.c b/keyboards/crkbd/keymaps/saesh/keymap.c index d3e7d0dbf526..ceb7afb1900f 100644 --- a/keyboards/crkbd/keymaps/saesh/keymap.c +++ b/keyboards/crkbd/keymaps/saesh/keymap.c @@ -52,24 +52,38 @@ qk_tap_dance_action_t tap_dance_actions[] = { #ifdef OLED_DRIVER_ENABLE static bool oled_should_be_off = false; static uint32_t oled_timer = 0; -const char 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', ' ', ' ', ' ', ' ', ' ', ' ', - ' ', ';', '\'', ' ', ',', '.', '/', ' ', ' ', ' '}; +static const char PROGMEM code_to_name[0xFF] = { +// 0 1 2 3 4 5 6 7 8 9 A B c D E F + ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', // 0x + 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', // 1x + '3', '4', '5', '6', '7', '8', '9', '0', 20, 19, 27, 26, 22, '-', '=', '[', // 2x + ']','\\', '#', ';','\'', '`', ',', '.', '/', 128, ' ', ' ', ' ', ' ', ' ', ' ', // 3x + ' ', ' ', ' ', ' ', ' ', ' ', 'P', 'S', ' ', ' ', ' ', ' ', 16, ' ', ' ', ' ', // 4x + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 5x + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 6x + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 7x + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 8x + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 9x + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ax + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Bx + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Cx + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Dx + 'C', 'S', 'A', 'C', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ex + ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' // Fx +}; char codelog_str[6] = {' ', 'c', 'o', 'd', 'e'}; char keylog_str[6] = {' ', 'k', 'e', 'y', ' '}; void add_to_keylog(uint16_t keycode) { - if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) { + if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) || (keycode >= QK_MODS && keycode <= QK_MODS_MAX)) { keycode = keycode & 0xFF; + } else if (keycode > 0xFF) { + keycode = 0; } char name = ' '; - if (keycode < 60) { - name = code_to_name[keycode]; + if (keycode < (sizeof(code_to_name) / sizeof(char))) { + name = pgm_read_byte(&code_to_name[keycode]); } snprintf(codelog_str, sizeof(codelog_str), "%5d", keycode);