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.

399 lines
14 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. #ifndef KEYLOGGER_LENGTH
  18. // # ifdef OLED_DISPLAY_128X64
  19. # define KEYLOGGER_LENGTH ((int)(OLED_DISPLAY_HEIGHT / OLED_FONT_WIDTH))
  20. // # else
  21. // # define KEYLOGGER_LENGTH (uint8_t *(OLED_DISPLAY_WIDTH / OLED_FONT_HEIGHT))
  22. // # endif
  23. #endif
  24. uint32_t oled_timer = 0;
  25. static char keylog_str[KEYLOGGER_LENGTH + 1] = {0};
  26. static uint16_t log_timer = 0;
  27. // clang-format off
  28. static const char PROGMEM code_to_name[0xFF] = {
  29. // 0 1 2 3 4 5 6 7 8 9 A B c D E F
  30. ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', // 0x
  31. 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', // 1x
  32. '3', '4', '5', '6', '7', '8', '9', '0', 20, 19, 27, 26, 22, '-', '=', '[', // 2x
  33. ']','\\', '#', ';','\'', '`', ',', '.', '/', 128, ' ', ' ', ' ', ' ', ' ', ' ', // 3x
  34. ' ', ' ', ' ', ' ', ' ', ' ', 'P', 'S', ' ', ' ', ' ', ' ', 16, ' ', ' ', ' ', // 4x
  35. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 5x
  36. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 6x
  37. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 7x
  38. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 8x
  39. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 9x
  40. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ax
  41. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Bx
  42. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Cx
  43. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Dx
  44. 'C', 'S', 'A', 'C', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // Ex
  45. ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' // Fx
  46. };
  47. // clang-format on
  48. void add_keylog(uint16_t keycode) {
  49. 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)) {
  50. keycode = keycode & 0xFF;
  51. } else if (keycode > 0xFF) {
  52. keycode = 0;
  53. }
  54. for (uint8_t i = 1; i < KEYLOGGER_LENGTH; i++) {
  55. keylog_str[i - 1] = keylog_str[i];
  56. }
  57. if (keycode < (sizeof(code_to_name) / sizeof(char))) {
  58. keylog_str[(KEYLOGGER_LENGTH - 1)] = pgm_read_byte(&code_to_name[keycode]);
  59. }
  60. log_timer = timer_read();
  61. }
  62. bool process_record_user_oled(uint16_t keycode, keyrecord_t *record) {
  63. if (record->event.pressed) {
  64. #ifdef OLED_DRIVER_ENABLE
  65. oled_timer = timer_read32();
  66. add_keylog(keycode);
  67. #endif
  68. }
  69. return true;
  70. }
  71. void update_log(void) {
  72. if (timer_elapsed(log_timer) > 750) {
  73. // add_keylog(0);
  74. }
  75. }
  76. void render_keylogger_status(void) {
  77. oled_write_P(PSTR(OLED_RENDER_KEYLOGGER), false);
  78. oled_write(keylog_str, false);
  79. }
  80. void render_default_layer_state(void) {
  81. oled_write_P(PSTR(OLED_RENDER_LAYOUT_NAME), false);
  82. switch (get_highest_layer(default_layer_state)) {
  83. case _QWERTY:
  84. oled_write_P(PSTR(OLED_RENDER_LAYOUT_QWERTY), false);
  85. break;
  86. case _COLEMAK_DH:
  87. oled_write_P(PSTR(OLED_RENDER_LAYOUT_COLEMAK_DH), false);
  88. break;
  89. case _COLEMAK:
  90. oled_write_P(PSTR(OLED_RENDER_LAYOUT_COLEMAK), false);
  91. break;
  92. case _DVORAK:
  93. oled_write_P(PSTR(OLED_RENDER_LAYOUT_DVORAK), false);
  94. break;
  95. }
  96. #ifdef OLED_DISPLAY_128X64
  97. oled_advance_page(true);
  98. #endif
  99. }
  100. void render_layer_state(void) {
  101. oled_write_P(PSTR(OLED_RENDER_LAYER_NAME), false);
  102. #ifdef OLED_DISPLAY_128X64
  103. oled_write_P(PSTR(" "), false);
  104. #endif
  105. oled_write_P(PSTR(OLED_RENDER_LAYER_LOWER), layer_state_is(_LOWER));
  106. #ifdef OLED_DISPLAY_128X64
  107. oled_write_P(PSTR(" "), false);
  108. #endif
  109. oled_write_P(PSTR(OLED_RENDER_LAYER_RAISE), layer_state_is(_RAISE));
  110. #ifdef OLED_DISPLAY_128X64
  111. oled_advance_page(true);
  112. oled_write_P(PSTR(" "), false);
  113. oled_write_P(PSTR("GamePad"), layer_state_is(_GAMEPAD));
  114. oled_write_P(PSTR(" "), false);
  115. oled_write_P(PSTR("Diablo"), layer_state_is(_DIABLO));
  116. oled_write_P(PSTR(" "), false);
  117. oled_write_P(PSTR("Mouse"), layer_state_is(_MOUSE));
  118. #endif
  119. }
  120. void render_keylock_status(uint8_t led_usb_state) {
  121. oled_write_P(PSTR(OLED_RENDER_LOCK_NAME), false);
  122. #if !defined(OLED_DISPLAY_128X64)
  123. oled_write_P(PSTR(" "), false);
  124. #endif
  125. oled_write_P(PSTR(OLED_RENDER_LOCK_NUML), led_usb_state & (1 << USB_LED_NUM_LOCK));
  126. oled_write_P(PSTR(" "), false);
  127. oled_write_P(PSTR(OLED_RENDER_LOCK_CAPS), led_usb_state & (1 << USB_LED_CAPS_LOCK));
  128. oled_write_P(PSTR(" "), false);
  129. oled_write_P(PSTR(OLED_RENDER_LOCK_SCLK), led_usb_state & (1 << USB_LED_SCROLL_LOCK));
  130. }
  131. void render_matrix_scan_rate(void) {
  132. #ifdef DEBUG_MATRIX_SCAN_RATE
  133. char matrix_rate[5];
  134. uint16_t n = get_matrix_scan_rate();
  135. matrix_rate[4] = '\0';
  136. matrix_rate[3] = '0' + n % 10;
  137. matrix_rate[2] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
  138. matrix_rate[1] = n / 10 ? '0' + n / 10 : ' ';
  139. matrix_rate[0] = ' ';
  140. oled_write_P(PSTR("MS:"), false);
  141. oled_write(matrix_rate, false);
  142. #endif
  143. }
  144. void render_mod_status(uint8_t modifiers) {
  145. static const char PROGMEM mod_status[5][3] = {{0xE8, 0xE9, 0}, {0xE4, 0xE5, 0}, {0xE6, 0xE7, 0}, {0xEA, 0xEB, 0}, {0xEC, 0xED, 0}};
  146. oled_write_P(PSTR(OLED_RENDER_MODS_NAME), false);
  147. oled_write_P(mod_status[0], (modifiers & MOD_MASK_SHIFT));
  148. oled_write_P(mod_status[!keymap_config.swap_lctl_lgui ? 3 : 4], (modifiers & MOD_MASK_GUI));
  149. #if !defined(OLED_DISPLAY_128X64)
  150. oled_write_P(PSTR(" "), false);
  151. #endif
  152. oled_write_P(mod_status[2], (modifiers & MOD_MASK_ALT));
  153. oled_write_P(mod_status[1], (modifiers & MOD_MASK_CTRL));
  154. render_matrix_scan_rate();
  155. #if defined(OLED_DISPLAY_128X64)
  156. oled_advance_page(true);
  157. #endif
  158. }
  159. #ifdef SWAP_HANDS_ENABLE
  160. extern bool swap_hands;
  161. #endif
  162. void render_bootmagic_status(void) {
  163. /* Show Ctrl-Gui Swap options */
  164. static const char PROGMEM logo[][2][3] = {
  165. {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}},
  166. {{0x95, 0x96, 0}, {0xb5, 0xb6, 0}},
  167. };
  168. bool is_bootmagic_on;
  169. #ifdef OLED_DISPLAY_128X64
  170. is_bootmagic_on = !keymap_config.swap_lctl_lgui;
  171. #else
  172. is_bootmagic_on = keymap_config.swap_lctl_lgui;
  173. #endif
  174. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NAME), false);
  175. #ifdef OLED_DISPLAY_128X64
  176. if (keymap_config.swap_lctl_lgui)
  177. #else
  178. oled_write_P(PSTR(" "), false);
  179. #endif
  180. {
  181. oled_write_P(logo[1][0], is_bootmagic_on);
  182. #ifdef OLED_DISPLAY_128X64
  183. } else {
  184. #endif
  185. oled_write_P(logo[0][0], !is_bootmagic_on);
  186. }
  187. #ifndef OLED_DISPLAY_128X64
  188. oled_write_P(PSTR(" "), false);
  189. oled_write_P(logo[1][1], is_bootmagic_on);
  190. oled_write_P(logo[0][1], !is_bootmagic_on);
  191. #endif
  192. oled_write_P(PSTR(" "), false);
  193. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NKRO), keymap_config.nkro);
  194. oled_write_P(PSTR(" "), false);
  195. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_NOGUI), keymap_config.no_gui);
  196. #ifdef OLED_DISPLAY_128X64
  197. oled_advance_page(true);
  198. oled_write_P(PSTR("Magic"), false);
  199. oled_write_P(PSTR(" "), false);
  200. if (keymap_config.swap_lctl_lgui) {
  201. oled_write_P(logo[1][1], is_bootmagic_on);
  202. } else {
  203. oled_write_P(logo[0][1], !is_bootmagic_on);
  204. }
  205. #endif
  206. oled_write_P(PSTR(" "), false);
  207. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_ONESHOT), !is_oneshot_enabled());
  208. #ifdef SWAP_HANDS_ENABLE
  209. oled_write_P(PSTR(" "), false);
  210. oled_write_P(PSTR(OLED_RENDER_BOOTMAGIC_SWAP), swap_hands);
  211. #endif
  212. #ifdef OLED_DISPLAY_128X64
  213. oled_advance_page(true);
  214. #endif
  215. }
  216. #if defined(POINTING_DEVICE_ENABLE)
  217. extern bool tap_toggling;
  218. #endif
  219. void render_user_status(void) {
  220. oled_write_P(PSTR(OLED_RENDER_USER_NAME), false);
  221. #if !defined(OLED_DISPLAY_128X64)
  222. oled_write_P(PSTR(" "), false);
  223. #endif
  224. #if defined(RGB_MATRIX_ENABLE)
  225. oled_write_P(PSTR(OLED_RENDER_USER_ANIM), userspace_config.rgb_matrix_idle_anim);
  226. # if !defined(OLED_DISPLAY_128X64)
  227. oled_write_P(PSTR(" "), false);
  228. # endif
  229. #elif defined(POINTING_DEVICE_ENABLE)
  230. static const char PROGMEM mouse_lock[3] = {0xF2, 0xF3, 0};
  231. oled_write_P(mouse_lock, tap_toggling);
  232. #endif
  233. #ifdef AUDIO_ENABLE
  234. static const char PROGMEM audio_status[2][3] = {{0xE0, 0xE1, 0}, {0xE2, 0xE3, 0}};
  235. oled_write_P(audio_status[is_audio_on()], false);
  236. # ifdef AUDIO_CLICKY
  237. static const char PROGMEM audio_clicky_status[2][3] = {{0xF4, 0xF5, 0}, {0xF6, 0xF7, 0}};
  238. oled_write_P(audio_clicky_status[is_clicky_on() && is_audio_on()], false);
  239. # if !defined(OLED_DISPLAY_128X64)
  240. oled_write_P(PSTR(" "), false);
  241. # endif
  242. # endif
  243. #endif
  244. static const char PROGMEM rgb_layer_status[2][3] = {{0xEE, 0xEF, 0}, {0xF0, 0xF1, 0}};
  245. oled_write_P(rgb_layer_status[userspace_config.rgb_layer_change], false);
  246. static const char PROGMEM nukem_good[2][3] = {{0xF8, 0xF9, 0}, {0xF6, 0xF7, 0}};
  247. oled_write_P(nukem_good[0], userspace_config.nuke_switch);
  248. #if defined(UNICODE_ENABLE)
  249. static const char PROGMEM uc_mod_status[5][3] = {{0xEA, 0xEB, 0}, {0xEC, 0xED, 0}};
  250. oled_write_P(uc_mod_status[get_unicode_input_mode() == UC_MAC], false);
  251. #endif
  252. #if defined(OLED_DISPLAY_128X64)
  253. oled_advance_page(true);
  254. #endif
  255. }
  256. __attribute__((weak)) void oled_driver_render_logo(void) {
  257. // clang-format off
  258. static const char PROGMEM qmk_logo[] = {
  259. 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
  260. 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
  261. 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0};
  262. // clang-format on
  263. oled_write_P(qmk_logo, false);
  264. }
  265. void render_wpm(void) {
  266. #ifdef WPM_ENABLE
  267. uint8_t n = get_current_wpm();
  268. # ifdef OLED_DISPLAY_128X64
  269. char wpm_counter[4];
  270. wpm_counter[3] = '\0';
  271. wpm_counter[2] = '0' + n % 10;
  272. wpm_counter[1] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
  273. wpm_counter[0] = n / 10 ? '0' + n / 10 : ' ';
  274. # else
  275. char wpm_counter[6];
  276. wpm_counter[5] = '\0';
  277. wpm_counter[4] = '0' + n % 10;
  278. wpm_counter[3] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
  279. wpm_counter[2] = n / 10 ? '0' + n / 10 : ' ';
  280. wpm_counter[1] = ' ';
  281. wpm_counter[0] = ' ';
  282. # endif
  283. oled_write_P(PSTR(OLED_RENDER_WPM_COUNTER), false);
  284. oled_write(wpm_counter, false);
  285. #endif
  286. }
  287. #if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right)
  288. extern kb_runtime_config_t kb_state;
  289. void render_pointing_dpi_status(void) {
  290. char dpi_status[6];
  291. uint16_t n = kb_state.device_cpi;
  292. dpi_status[5] = '\0';
  293. dpi_status[4] = '0' + n % 10;
  294. dpi_status[3] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
  295. dpi_status[2] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
  296. dpi_status[1] = n / 10 ? '0' + n / 10 : ' ';
  297. dpi_status[0] = ' ';
  298. oled_write_P(PSTR(" DPI: "), false);
  299. oled_write(dpi_status, false);
  300. }
  301. #endif
  302. void render_status_secondary(void) {
  303. #if defined(OLED_DISPLAY_128X64)
  304. oled_driver_render_logo();
  305. #endif
  306. /* Show Keyboard Layout */
  307. render_default_layer_state();
  308. render_layer_state();
  309. render_mod_status(get_mods() | get_oneshot_mods());
  310. #if !defined(OLED_DISPLAY_128X64) && defined(WPM_ENABLE)
  311. render_wpm();
  312. #endif
  313. // render_keylock_status(host_keyboard_leds());
  314. }
  315. void render_status_main(void) {
  316. #if defined(OLED_DISPLAY_128X64)
  317. oled_driver_render_logo();
  318. # ifdef DEBUG_MATRIX_SCAN_RATE
  319. render_matrix_scan_rate();
  320. # elif defined(WPM_ENABLE)
  321. render_wpm();
  322. # endif
  323. # if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right)
  324. render_pointing_dpi_status();
  325. # endif
  326. oled_write_P(PSTR("\n"), false);
  327. #else
  328. render_default_layer_state();
  329. #endif
  330. /* Show Keyboard Layout */
  331. // render_keylock_status(host_keyboard_leds());
  332. render_bootmagic_status();
  333. render_user_status();
  334. // render_keylogger_status();
  335. }
  336. __attribute__((weak)) oled_rotation_t oled_init_keymap(oled_rotation_t rotation) { return rotation; }
  337. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  338. for (uint8_t i = 0; i < (KEYLOGGER_LENGTH - 1); i++) {
  339. add_keylog(0);
  340. }
  341. return oled_init_keymap(rotation);
  342. }
  343. void oled_task_user(void) {
  344. update_log();
  345. if (is_keyboard_master()) {
  346. if (timer_elapsed32(oled_timer) > 30000) {
  347. oled_off();
  348. return;
  349. } else {
  350. oled_on();
  351. }
  352. }
  353. if (is_keyboard_left()) {
  354. render_status_main(); // Renders the current keyboard state (layer, lock, caps, scroll, etc)
  355. } else {
  356. render_status_secondary();
  357. }
  358. if (is_keyboard_master()) {
  359. render_keylogger_status();
  360. } else {
  361. render_keylock_status(host_keyboard_leds());
  362. }
  363. }