You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

445 lines
15 KiB

[Keymap] Cleanup and updating of drashna keymap code (#11516) * Update other keyboards for rgb matrix changes * Remove customized bootmagic code * Fix corne layout compilation error * Fix compiler errors with all keymaps * Add Simple Visualizer for ergodox infinity * Fix compile issue with Corne * Fix keymap stuff * Add alias for mouse layer * Add Halmak Keyboard layout * Updates for Kyria * Add support for oled interval * Change RGB stuff [CHANGE] Fix coexistence issues * Fix rgb_stuff * Add custom ploopyco mouse keymap * Decrease default dwell time * Updates based on last breaking changes update * Disable command on dactyl * Update ergodox to use proper commands for rgb matrix indicators * Update all rgb matrix indicator functions * Update rules for dactyl-manuform * Reduce wait time for mouse layer off event * Add more info to logger * Add wrappers for get_tapping term * Move version.h include into only file that actually needs it * Update rgb sleep stuff * Update key print function * Change DM keymap settings * Change pin for DM Manuform * Add Proton C stuff for Corne keymap * more arm corne tinkering * Even more arm stuff for corne * Cleanup corne stuff * redirect default keymap to drashna because I am a very bad man * change corne rgb priority * Update tractyl manuform to not conflict * Add more secret stuff * more dactyl tweaks * Add more options to split transport * Changes of oled support * Change split settings * Improve keylogger formatting more * tweak oled stuff * Oled and such tweaks * Reduce brightness due to leds * Decrease brightness more * Only run layer code if master
3 years ago
[Keymap] Cleanup and updating of drashna keymap code (#11516) * Update other keyboards for rgb matrix changes * Remove customized bootmagic code * Fix corne layout compilation error * Fix compiler errors with all keymaps * Add Simple Visualizer for ergodox infinity * Fix compile issue with Corne * Fix keymap stuff * Add alias for mouse layer * Add Halmak Keyboard layout * Updates for Kyria * Add support for oled interval * Change RGB stuff [CHANGE] Fix coexistence issues * Fix rgb_stuff * Add custom ploopyco mouse keymap * Decrease default dwell time * Updates based on last breaking changes update * Disable command on dactyl * Update ergodox to use proper commands for rgb matrix indicators * Update all rgb matrix indicator functions * Update rules for dactyl-manuform * Reduce wait time for mouse layer off event * Add more info to logger * Add wrappers for get_tapping term * Move version.h include into only file that actually needs it * Update rgb sleep stuff * Update key print function * Change DM keymap settings * Change pin for DM Manuform * Add Proton C stuff for Corne keymap * more arm corne tinkering * Even more arm stuff for corne * Cleanup corne stuff * redirect default keymap to drashna because I am a very bad man * change corne rgb priority * Update tractyl manuform to not conflict * Add more secret stuff * more dactyl tweaks * Add more options to split transport * Changes of oled support * Change split settings * Improve keylogger formatting more * tweak oled stuff * Oled and such tweaks * Reduce brightness due to leds * Decrease brightness more * Only run layer code if master
3 years ago
[Keymap] Cleanup and updating of drashna keymap code (#11516) * Update other keyboards for rgb matrix changes * Remove customized bootmagic code * Fix corne layout compilation error * Fix compiler errors with all keymaps * Add Simple Visualizer for ergodox infinity * Fix compile issue with Corne * Fix keymap stuff * Add alias for mouse layer * Add Halmak Keyboard layout * Updates for Kyria * Add support for oled interval * Change RGB stuff [CHANGE] Fix coexistence issues * Fix rgb_stuff * Add custom ploopyco mouse keymap * Decrease default dwell time * Updates based on last breaking changes update * Disable command on dactyl * Update ergodox to use proper commands for rgb matrix indicators * Update all rgb matrix indicator functions * Update rules for dactyl-manuform * Reduce wait time for mouse layer off event * Add more info to logger * Add wrappers for get_tapping term * Move version.h include into only file that actually needs it * Update rgb sleep stuff * Update key print function * Change DM keymap settings * Change pin for DM Manuform * Add Proton C stuff for Corne keymap * more arm corne tinkering * Even more arm stuff for corne * Cleanup corne stuff * redirect default keymap to drashna because I am a very bad man * change corne rgb priority * Update tractyl manuform to not conflict * Add more secret stuff * more dactyl tweaks * Add more options to split transport * Changes of oled support * Change split settings * Improve keylogger formatting more * tweak oled stuff * Oled and such tweaks * Reduce brightness due to leds * Decrease brightness more * Only run layer code if master
3 years ago
[Keymap] Cleanup and updating of drashna keymap code (#11516) * Update other keyboards for rgb matrix changes * Remove customized bootmagic code * Fix corne layout compilation error * Fix compiler errors with all keymaps * Add Simple Visualizer for ergodox infinity * Fix compile issue with Corne * Fix keymap stuff * Add alias for mouse layer * Add Halmak Keyboard layout * Updates for Kyria * Add support for oled interval * Change RGB stuff [CHANGE] Fix coexistence issues * Fix rgb_stuff * Add custom ploopyco mouse keymap * Decrease default dwell time * Updates based on last breaking changes update * Disable command on dactyl * Update ergodox to use proper commands for rgb matrix indicators * Update all rgb matrix indicator functions * Update rules for dactyl-manuform * Reduce wait time for mouse layer off event * Add more info to logger * Add wrappers for get_tapping term * Move version.h include into only file that actually needs it * Update rgb sleep stuff * Update key print function * Change DM keymap settings * Change pin for DM Manuform * Add Proton C stuff for Corne keymap * more arm corne tinkering * Even more arm stuff for corne * Cleanup corne stuff * redirect default keymap to drashna because I am a very bad man * change corne rgb priority * Update tractyl manuform to not conflict * Add more secret stuff * more dactyl tweaks * Add more options to split transport * Changes of oled support * Change split settings * Improve keylogger formatting more * tweak oled stuff * Oled and such tweaks * Reduce brightness due to leds * Decrease brightness more * Only run layer code if master
3 years ago
[Keymap] Cleanup and updating of drashna keymap code (#11516) * Update other keyboards for rgb matrix changes * Remove customized bootmagic code * Fix corne layout compilation error * Fix compiler errors with all keymaps * Add Simple Visualizer for ergodox infinity * Fix compile issue with Corne * Fix keymap stuff * Add alias for mouse layer * Add Halmak Keyboard layout * Updates for Kyria * Add support for oled interval * Change RGB stuff [CHANGE] Fix coexistence issues * Fix rgb_stuff * Add custom ploopyco mouse keymap * Decrease default dwell time * Updates based on last breaking changes update * Disable command on dactyl * Update ergodox to use proper commands for rgb matrix indicators * Update all rgb matrix indicator functions * Update rules for dactyl-manuform * Reduce wait time for mouse layer off event * Add more info to logger * Add wrappers for get_tapping term * Move version.h include into only file that actually needs it * Update rgb sleep stuff * Update key print function * Change DM keymap settings * Change pin for DM Manuform * Add Proton C stuff for Corne keymap * more arm corne tinkering * Even more arm stuff for corne * Cleanup corne stuff * redirect default keymap to drashna because I am a very bad man * change corne rgb priority * Update tractyl manuform to not conflict * Add more secret stuff * more dactyl tweaks * Add more options to split transport * Changes of oled support * Change split settings * Improve keylogger formatting more * tweak oled stuff * Oled and such tweaks * Reduce brightness due to leds * Decrease brightness more * Only run layer code if master
3 years ago
[Keymap] Cleanup and updating of drashna keymap code (#11516) * Update other keyboards for rgb matrix changes * Remove customized bootmagic code * Fix corne layout compilation error * Fix compiler errors with all keymaps * Add Simple Visualizer for ergodox infinity * Fix compile issue with Corne * Fix keymap stuff * Add alias for mouse layer * Add Halmak Keyboard layout * Updates for Kyria * Add support for oled interval * Change RGB stuff [CHANGE] Fix coexistence issues * Fix rgb_stuff * Add custom ploopyco mouse keymap * Decrease default dwell time * Updates based on last breaking changes update * Disable command on dactyl * Update ergodox to use proper commands for rgb matrix indicators * Update all rgb matrix indicator functions * Update rules for dactyl-manuform * Reduce wait time for mouse layer off event * Add more info to logger * Add wrappers for get_tapping term * Move version.h include into only file that actually needs it * Update rgb sleep stuff * Update key print function * Change DM keymap settings * Change pin for DM Manuform * Add Proton C stuff for Corne keymap * more arm corne tinkering * Even more arm stuff for corne * Cleanup corne stuff * redirect default keymap to drashna because I am a very bad man * change corne rgb priority * Update tractyl manuform to not conflict * Add more secret stuff * more dactyl tweaks * Add more options to split transport * Changes of oled support * Change split settings * Improve keylogger formatting more * tweak oled stuff * Oled and such tweaks * Reduce brightness due to leds * Decrease brightness more * Only run layer code if master
3 years ago
  1. /* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "drashna.h"
  17. extern bool host_driver_disabled;
  18. #ifndef KEYLOGGER_LENGTH
  19. // # ifdef OLED_DISPLAY_128X64
  20. # define KEYLOGGER_LENGTH ((uint8_t)(OLED_DISPLAY_HEIGHT / OLED_FONT_WIDTH))
  21. // # else
  22. // # define KEYLOGGER_LENGTH (uint8_t *(OLED_DISPLAY_WIDTH / OLED_FONT_HEIGHT))
  23. // # endif
  24. #endif
  25. uint32_t oled_timer = 0;
  26. static char keylog_str[KEYLOGGER_LENGTH + 1] = {0};
  27. static uint16_t log_timer = 0;
  28. // clang-format off
  29. static const char PROGMEM code_to_name[256] = {
  30. // 0 1 2 3 4 5 6 7 8 9 A B c D E F
  31. ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', // 0x
  32. 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', // 1x
  33. '3', '4', '5', '6', '7', '8', '9', '0', 20, 19, 27, 26, 22, '-', '=', '[', // 2x
  34. ']','\\', '#', ';','\'', '`', ',', '.', '/', 128, '1', '2', '3', '4', '5', '6', // 3x
  35. '7', '8', '9', '0', '1', '2', 'P', 'S', 19, ' ', 17, 30, 16, 16, 31, 26, // 4x
  36. 27, 25, 24, 'N', '/', '*', '-', '+', 23, '1', '2', '3', '4', '5', '6', '7', // 5x
  37. '8', '9', '0', '.','\\', 'A', 0, '=', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 6x
  38. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 7x
  39. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 8x
  40. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 9x
  41. ' ', ' ', ' ', ' ', ' ', 0, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ax
  42. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Bx
  43. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Cx
  44. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Dx
  45. 'C', 'S', 'A', 'C', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 24, 26, 24, // Ex
  46. 25,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D,0x9D, 24, 25, 27, 26, ' ', ' ', ' ' // Fx
  47. };
  48. // clang-format on
  49. void add_keylog(uint16_t keycode, keyrecord_t *record) {
  50. 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)) {
  51. if (((keycode & 0xFF) == KC_BSPC) && mod_config(get_mods() | get_oneshot_mods()) & MOD_MASK_CTRL) {
  52. memset(keylog_str, ' ', sizeof(keylog_str) - 1);
  53. return;
  54. }
  55. if (record->tap.count) {
  56. keycode = keycode & 0xFF;
  57. } else if (keycode > 0xFF) {
  58. return;
  59. }
  60. }
  61. if (keycode > 0xFF) {
  62. return;
  63. }
  64. for (uint8_t i = 1; i < KEYLOGGER_LENGTH; i++) {
  65. keylog_str[i - 1] = keylog_str[i];
  66. }
  67. if (keycode < (sizeof(code_to_name) / sizeof(char))) {
  68. keylog_str[(KEYLOGGER_LENGTH - 1)] = pgm_read_byte(&code_to_name[keycode]);
  69. }
  70. log_timer = timer_read();
  71. }
  72. bool process_record_user_oled(uint16_t keycode, keyrecord_t *record) {
  73. if (record->event.pressed) {
  74. #ifdef OLED_ENABLE
  75. oled_timer = timer_read32();
  76. add_keylog(keycode, record);
  77. #endif
  78. }
  79. return true;
  80. }
  81. void update_log(void) {
  82. if (timer_elapsed(log_timer) > 750) {
  83. // add_keylog(0);
  84. }
  85. }
  86. void render_keylogger_status(void) {
  87. oled_write_P(PSTR(OLED_RENDER_KEYLOGGER), false);
  88. oled_write(keylog_str, false);
  89. }
  90. void render_default_layer_state(void) {
  91. oled_write_P(PSTR(OLED_RENDER_LAYOUT_NAME), false);
  92. switch (get_highest_layer(default_layer_state)) {
  93. case _QWERTY:
  94. oled_write_P(PSTR(OLED_RENDER_LAYOUT_QWERTY), false);
  95. break;
  96. case _COLEMAK_DH:
  97. oled_write_P(PSTR(OLED_RENDER_LAYOUT_COLEMAK_DH), false);
  98. break;
  99. case _COLEMAK:
  100. oled_write_P(PSTR(OLED_RENDER_LAYOUT_COLEMAK), false);
  101. break;
  102. case _DVORAK:
  103. oled_write_P(PSTR(OLED_RENDER_LAYOUT_DVORAK), false);
  104. break;
  105. }
  106. #ifdef OLED_DISPLAY_128X64
  107. oled_advance_page(true);
  108. #endif
  109. }
  110. void render_layer_state(void) {
  111. oled_write_P(PSTR(OLED_RENDER_LAYER_NAME), false);
  112. #ifdef OLED_DISPLAY_128X64
  113. oled_write_P(PSTR(" "), false);
  114. #endif
  115. oled_write_P(PSTR(OLED_RENDER_LAYER_LOWER), layer_state_is(_LOWER));
  116. #ifdef OLED_DISPLAY_128X64
  117. oled_write_P(PSTR(" "), false);
  118. #endif
  119. oled_write_P(PSTR(OLED_RENDER_LAYER_RAISE), layer_state_is(_RAISE));
  120. #ifdef OLED_DISPLAY_128X64
  121. oled_advance_page(true);
  122. oled_write_P(PSTR(" "), false);
  123. oled_write_P(PSTR("GamePad"), layer_state_is(_GAMEPAD));
  124. oled_write_P(PSTR(" "), false);
  125. oled_write_P(PSTR("Diablo"), layer_state_is(_DIABLO));
  126. oled_write_P(PSTR(" "), false);
  127. oled_write_P(PSTR("Mouse"), layer_state_is(_MOUSE));
  128. #endif
  129. }
  130. void render_keylock_status(uint8_t led_usb_state) {
  131. oled_write_P(PSTR(OLED_RENDER_LOCK_NAME), false);
  132. #if !defined(OLED_DISPLAY_128X64)
  133. oled_write_P(PSTR(" "), false);
  134. #endif
  135. oled_write_P(PSTR(OLED_RENDER_LOCK_NUML), led_usb_state & (1 << USB_LED_NUM_LOCK));
  136. oled_write_P(PSTR(" "), false);
  137. oled_write_P(PSTR(OLED_RENDER_LOCK_CAPS), led_usb_state & (1 << USB_LED_CAPS_LOCK));
  138. // oled_write_P(PSTR(" "), false);
  139. // oled_write_P(PSTR(OLED_RENDER_LOCK_SCLK), led_usb_state & (1 << USB_LED_SCROLL_LOCK));
  140. }
  141. void render_matrix_scan_rate(void) {
  142. #ifdef DEBUG_MATRIX_SCAN_RATE
  143. char matrix_rate[5];
  144. uint16_t n = get_matrix_scan_rate();
  145. matrix_rate[4] = '\0';
  146. matrix_rate[3] = '0' + n % 10;
  147. matrix_rate[2] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
  148. matrix_rate[1] = n / 10 ? '0' + n / 10 : ' ';
  149. matrix_rate[0] = ' ';
  150. oled_write_P(PSTR("MS:"), false);
  151. oled_write(matrix_rate, false);
  152. #endif
  153. }
  154. void render_mod_status(uint8_t modifiers) {
  155. static const char PROGMEM mod_status[5][3] = {{0xE8, 0xE9, 0}, {0xE4, 0xE5, 0}, {0xE6, 0xE7, 0}, {0xEA, 0xEB, 0}, {0xEC, 0xED, 0}};
  156. oled_write_P(PSTR(OLED_RENDER_MODS_NAME), false);
  157. #if defined(OLED_DISPLAY_128X64)
  158. oled_write_P(mod_status[0], (modifiers & MOD_BIT(KC_LSHIFT)));
  159. oled_write_P(mod_status[!keymap_config.swap_lctl_lgui ? 3 : 4], (modifiers & MOD_BIT(KC_LGUI)));
  160. oled_write_P(mod_status[2], (modifiers & MOD_BIT(KC_LALT)));
  161. oled_write_P(mod_status[1], (modifiers & MOD_BIT(KC_LCTL)));
  162. oled_write_P(mod_status[1], (modifiers & MOD_BIT(KC_RCTL)));
  163. oled_write_P(mod_status[2], (modifiers & MOD_BIT(KC_RALT)));
  164. oled_write_P(mod_status[!keymap_config.swap_lctl_lgui ? 3 : 4], (modifiers & MOD_BIT(KC_RGUI)));
  165. oled_write_P(mod_status[0], (modifiers & MOD_BIT(KC_RSHIFT)));
  166. #else
  167. oled_write_P(mod_status[0], (modifiers & MOD_MASK_SHIFT));
  168. oled_write_P(mod_status[!keymap_config.swap_lctl_lgui ? 3 : 4], (modifiers & MOD_MASK_GUI));
  169. oled_write_P(PSTR(" "), false);
  170. oled_write_P(mod_status[2], (modifiers & MOD_MASK_ALT));
  171. oled_write_P(mod_status[1], (modifiers & MOD_MASK_CTRL));
  172. #endif
  173. }
  174. #ifdef SWAP_HANDS_ENABLE
  175. extern bool swap_hands;
  176. #endif
  177. void render_bootmagic_status(void) {
  178. /* Show Ctrl-Gui Swap options */
  179. static const char PROGMEM logo[][2][3] = {
  180. {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}},
  181. {{0x95, 0x96, 0}, {0xb5, 0xb6, 0}},
  182. };
  183. bool is_bootmagic_on;
  184. #ifdef OLED_DISPLAY_128X64
  185. is_bootmagic_on = !keymap_config.swap_lctl_lgui;
  186. #else
  187. is_bootmagic_on = keymap_config.swap_lctl_lgui;
  188. #endif
  189. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NAME), false);
  190. #ifdef OLED_DISPLAY_128X64
  191. if (keymap_config.swap_lctl_lgui)
  192. #else
  193. oled_write_P(PSTR(" "), false);
  194. #endif
  195. {
  196. oled_write_P(logo[1][0], is_bootmagic_on);
  197. #ifdef OLED_DISPLAY_128X64
  198. } else {
  199. #endif
  200. oled_write_P(logo[0][0], !is_bootmagic_on);
  201. }
  202. #ifndef OLED_DISPLAY_128X64
  203. oled_write_P(PSTR(" "), false);
  204. oled_write_P(logo[1][1], is_bootmagic_on);
  205. oled_write_P(logo[0][1], !is_bootmagic_on);
  206. #endif
  207. oled_write_P(PSTR(" "), false);
  208. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NKRO), keymap_config.nkro);
  209. oled_write_P(PSTR(" "), false);
  210. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NOGUI), keymap_config.no_gui);
  211. #ifdef OLED_DISPLAY_128X64
  212. oled_advance_page(true);
  213. oled_write_P(PSTR("Magic"), false);
  214. oled_write_P(PSTR(" "), false);
  215. if (keymap_config.swap_lctl_lgui) {
  216. oled_write_P(logo[1][1], is_bootmagic_on);
  217. } else {
  218. oled_write_P(logo[0][1], !is_bootmagic_on);
  219. }
  220. #endif
  221. oled_write_P(PSTR(" "), false);
  222. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_ONESHOT), !is_oneshot_enabled());
  223. #ifdef SWAP_HANDS_ENABLE
  224. oled_write_P(PSTR(" "), false);
  225. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_SWAP), swap_hands);
  226. #endif
  227. #ifdef OLED_DISPLAY_128X64
  228. oled_advance_page(true);
  229. #endif
  230. }
  231. #if defined(POINTING_DEVICE_ENABLE)
  232. extern bool tap_toggling;
  233. #endif
  234. void render_user_status(void) {
  235. #ifdef AUDIO_ENABLE
  236. bool is_audio_on = false, is_clicky_on = false;
  237. # ifdef SPLIT_KEYBOARD
  238. is_audio_on = user_state.audio_enable;
  239. is_clicky_on = user_state.audio_clicky_enable;
  240. # else
  241. is_audio_on = is_audio_on();
  242. is_clicky_on = is_clicky_on();
  243. # endif
  244. #endif
  245. oled_write_P(PSTR(OLED_RENDER_USER_NAME), false);
  246. #if !defined(OLED_DISPLAY_128X64)
  247. oled_write_P(PSTR(" "), false);
  248. #endif
  249. #if defined(RGB_MATRIX_ENABLE)
  250. oled_write_P(PSTR(OLED_RENDER_USER_ANIM), userspace_config.rgb_matrix_idle_anim);
  251. # if !defined(OLED_DISPLAY_128X64)
  252. oled_write_P(PSTR(" "), false);
  253. # endif
  254. #elif defined(POINTING_DEVICE_ENABLE)
  255. static const char PROGMEM mouse_lock[3] = {0xF2, 0xF3, 0};
  256. oled_write_P(mouse_lock, tap_toggling);
  257. #endif
  258. #ifdef AUDIO_ENABLE
  259. static const char PROGMEM audio_status[2][3] = {{0xE0, 0xE1, 0}, {0xE2, 0xE3, 0}};
  260. oled_write_P(audio_status[is_audio_on], false);
  261. # ifdef AUDIO_CLICKY
  262. static const char PROGMEM audio_clicky_status[2][3] = {{0xF4, 0xF5, 0}, {0xF6, 0xF7, 0}};
  263. oled_write_P(audio_clicky_status[is_clicky_on && is_audio_on], false);
  264. # if !defined(OLED_DISPLAY_128X64)
  265. oled_write_P(PSTR(" "), false);
  266. # endif
  267. # endif
  268. #endif
  269. static const char PROGMEM rgb_layer_status[2][3] = {{0xEE, 0xEF, 0}, {0xF0, 0xF1, 0}};
  270. oled_write_P(rgb_layer_status[userspace_config.rgb_layer_change], false);
  271. static const char PROGMEM cat_mode[2][3] = {{0xF8, 0xF9, 0}, {0xF6, 0xF7, 0}};
  272. oled_write_P(cat_mode[0], host_driver_disabled);
  273. #if defined(UNICODE_ENABLE)
  274. static const char PROGMEM uc_mod_status[5][3] = {{0xEA, 0xEB, 0}, {0xEC, 0xED, 0}};
  275. oled_write_P(uc_mod_status[get_unicode_input_mode() == UC_MAC], false);
  276. #endif
  277. if (userspace_config.nuke_switch) {
  278. #if !defined(OLED_DISPLAY_128X64)
  279. oled_write_P(PSTR(" "), false);
  280. #endif
  281. static const char PROGMEM nukem_good[2] = {0xFA, 0};
  282. oled_write_P(nukem_good, false);
  283. #if !defined(OLED_DISPLAY_128X64)
  284. oled_advance_page(true);
  285. #endif
  286. }
  287. #if defined(OLED_DISPLAY_128X64)
  288. oled_advance_page(true);
  289. #endif
  290. }
  291. void oled_driver_render_logo(void) {
  292. // clang-format off
  293. static const char PROGMEM qmk_logo[] = {
  294. 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
  295. 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
  296. 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0};
  297. // clang-format on
  298. oled_write_P(qmk_logo, false);
  299. }
  300. void render_wpm(uint8_t padding) {
  301. #ifdef WPM_ENABLE
  302. uint8_t n = get_current_wpm();
  303. char wpm_counter[4];
  304. wpm_counter[3] = '\0';
  305. wpm_counter[2] = '0' + n % 10;
  306. wpm_counter[1] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
  307. wpm_counter[0] = n / 10 ? '0' + n / 10 : ' ';
  308. oled_write_P(PSTR(OLED_RENDER_WPM_COUNTER), false);
  309. if (padding) {
  310. for (uint8_t n = padding; n > 0; n--) {
  311. oled_write_P(PSTR(" "), false);
  312. }
  313. }
  314. oled_write(wpm_counter, false);
  315. #endif
  316. }
  317. #if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right)
  318. extern kb_config_data_t kb_config;
  319. void render_pointing_dpi_status(uint8_t padding) {
  320. char dpi_status[5];
  321. uint16_t n = kb_config.device_cpi;
  322. dpi_status[4] = '\0';
  323. dpi_status[3] = '0' + n % 10;
  324. dpi_status[2] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
  325. dpi_status[1] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
  326. dpi_status[0] = n / 10 ? '0' + n / 10 : ' ';
  327. oled_write_P(PSTR("DPI: "), false);
  328. if (padding) {
  329. for (uint8_t n = padding; n > 0; n--) {
  330. oled_write_P(PSTR(" "), false);
  331. }
  332. }
  333. oled_write(dpi_status, false);
  334. }
  335. #endif
  336. __attribute__((weak)) void oled_driver_render_logo_right(void) {
  337. #if defined(OLED_DISPLAY_128X64)
  338. oled_driver_render_logo();
  339. render_default_layer_state();
  340. oled_set_cursor(0, 4);
  341. #else
  342. render_default_layer_state();
  343. #endif
  344. }
  345. __attribute__((weak)) void oled_driver_render_logo_left(void) {
  346. #if defined(OLED_DISPLAY_128X64)
  347. oled_driver_render_logo();
  348. # ifdef DEBUG_MATRIX_SCAN_RATE
  349. render_matrix_scan_rate();
  350. # elif defined(WPM_ENABLE)
  351. render_wpm(0);
  352. # endif
  353. oled_write_P(PSTR(" "), false);
  354. # if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right)
  355. render_pointing_dpi_status(1);
  356. # endif
  357. oled_set_cursor(0, 4);
  358. #else
  359. render_default_layer_state();
  360. #endif
  361. }
  362. void render_status_secondary(void) {
  363. oled_driver_render_logo_right();
  364. /* Show Keyboard Layout */
  365. render_layer_state();
  366. render_mod_status(get_mods() | get_oneshot_mods());
  367. #if !defined(OLED_DISPLAY_128X64) && defined(WPM_ENABLE) && !defined(CONVERT_TO_PROTON_C)
  368. render_wpm(2);
  369. #endif
  370. // render_keylock_status(host_keyboard_leds());
  371. }
  372. void render_status_main(void) {
  373. oled_driver_render_logo_left();
  374. /* Show Keyboard Layout */
  375. // render_keylock_status(host_keyboard_leds());
  376. render_bootmagic_status();
  377. render_user_status();
  378. // render_keylogger_status();
  379. }
  380. __attribute__((weak)) oled_rotation_t oled_init_keymap(oled_rotation_t rotation) { return rotation; }
  381. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  382. memset(keylog_str, ' ', sizeof(keylog_str) - 1);
  383. return oled_init_keymap(rotation);
  384. }
  385. void oled_task_user(void) {
  386. update_log();
  387. if (is_keyboard_master()) {
  388. if (timer_elapsed32(oled_timer) > 30000) {
  389. oled_off();
  390. return;
  391. } else {
  392. oled_on();
  393. }
  394. }
  395. if (is_keyboard_left()) {
  396. render_status_main(); // Renders the current keyboard state (layer, lock, caps, scroll, etc)
  397. } else {
  398. render_status_secondary();
  399. }
  400. if (is_keyboard_master()) {
  401. render_keylogger_status();
  402. } else {
  403. render_keylock_status(host_keyboard_leds());
  404. }
  405. }