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.

200 lines
7.5 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] Drashna's Feature madness (#6128) * Fix my Tap Dance issues after I broke them * Cleanup and organization of userspace documentation As well as some additional cleanup of functions due to review of documentation. * Enable Tapdance on Glow and remove more animations * Revert to Eager PR debouncing * Add better check for startup animation * Move where RGB Matrix defines are listed * Limit RGB Matrix max val * Update keyboard for Iris Rev 3 conflicts * Enable encoder support on planck ez * Remove is_master check from corne\'s OLED code * Overhaul OLED screens for my Corne * One last removal * Show RGB valu On both sides * Updates for OLED display info * Fix compile issues for rgb config * Disabled Space Cadet for all drashna keymaps * Fix OLED Screen configs * Minor OLED Tweaks * Revert some Iris changes * Fix song include * Handle MAKE macro for the Corne boards better * Add super hacky-hack for eeconfig initialization * Add audio support for Fractal since Elite Cs support it * Add defines for keycode steps * Add White layout * Update Corne RGB info * Add fun effects to layer indication for RGB Matrix enabled boards * Use proper define for product name detection * Update formatting * Use custom timeout mechanism for OLED timeout * Fix up OLED screen HSV code for new HSV structure * Better handle turning off RGB Matrix when sleeping * Disable MultiSplash Animation * Change Iris back to using serial * Why was RGB disabled?!?!?! * Limit val in rgb_matrix_layer_helper function * Remove EECONFIG setting for RGB matrix
4 years ago
[Keymap] Drashna's Feature madness (#6128) * Fix my Tap Dance issues after I broke them * Cleanup and organization of userspace documentation As well as some additional cleanup of functions due to review of documentation. * Enable Tapdance on Glow and remove more animations * Revert to Eager PR debouncing * Add better check for startup animation * Move where RGB Matrix defines are listed * Limit RGB Matrix max val * Update keyboard for Iris Rev 3 conflicts * Enable encoder support on planck ez * Remove is_master check from corne\'s OLED code * Overhaul OLED screens for my Corne * One last removal * Show RGB valu On both sides * Updates for OLED display info * Fix compile issues for rgb config * Disabled Space Cadet for all drashna keymaps * Fix OLED Screen configs * Minor OLED Tweaks * Revert some Iris changes * Fix song include * Handle MAKE macro for the Corne boards better * Add super hacky-hack for eeconfig initialization * Add audio support for Fractal since Elite Cs support it * Add defines for keycode steps * Add White layout * Update Corne RGB info * Add fun effects to layer indication for RGB Matrix enabled boards * Use proper define for product name detection * Update formatting * Use custom timeout mechanism for OLED timeout * Fix up OLED screen HSV code for new HSV structure * Better handle turning off RGB Matrix when sleeping * Disable MultiSplash Animation * Change Iris back to using serial * Why was RGB disabled?!?!?! * Limit val in rgb_matrix_layer_helper function * Remove EECONFIG setting for RGB matrix
4 years ago
  1. // Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "drashna.h"
  4. #include "version.h"
  5. #ifdef OS_DETECTION_ENABLE
  6. # include "os_detection.h"
  7. #endif
  8. #ifdef CUSTOM_DYNAMIC_MACROS_ENABLE
  9. # include "keyrecords/dynamic_macros.h"
  10. #endif
  11. uint16_t copy_paste_timer;
  12. // Defines actions tor my global custom keycodes. Defined in drashna.h file
  13. // Then runs the _keymap's record handier if not processed here
  14. /**
  15. * @brief Keycode handler for keymaps
  16. *
  17. * This handles the keycodes at the keymap level, useful for keyboard specific customization
  18. */
  19. __attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
  20. return true;
  21. }
  22. __attribute__((weak)) bool process_record_secrets(uint16_t keycode, keyrecord_t *record) {
  23. return true;
  24. }
  25. /**
  26. * @brief Main user keycode handler
  27. *
  28. * This handles all of the keycodes for the user, including calling feature handlers.
  29. *
  30. * @param keycode Keycode from matrix
  31. * @param record keyrecord_t data structure
  32. * @return true Continue processing keycode and send to host
  33. * @return false Stop process keycode and do not send to host
  34. */
  35. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  36. // If console is enabled, it will print the matrix position and status of each key pressed
  37. #ifdef KEYLOGGER_ENABLE
  38. uprintf("KL: kc: 0x%04X, col: %2u, row: %2u, pressed: %1d, time: %5u, int: %1d, count: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed, record->event.time, record->tap.interrupted, record->tap.count);
  39. #endif // KEYLOGGER_ENABLE
  40. #if defined(OLED_ENABLE) && defined(CUSTOM_OLED_DRIVER)
  41. process_record_user_oled(keycode, record);
  42. #endif // OLED
  43. if (!(process_record_keymap(keycode, record) && process_record_secrets(keycode, record)
  44. #ifdef CUSTOM_RGB_MATRIX
  45. && process_record_user_rgb_matrix(keycode, record)
  46. #endif
  47. #ifdef CUSTOM_RGBLIGHT
  48. && process_record_user_rgb_light(keycode, record)
  49. #endif
  50. #ifdef CUSTOM_UNICODE_ENABLE
  51. && process_record_unicode(keycode, record)
  52. #endif
  53. #if defined(CUSTOM_POINTING_DEVICE)
  54. && process_record_pointing(keycode, record)
  55. #endif
  56. #ifdef CUSTOM_DYNAMIC_MACROS_ENABLE
  57. && process_record_dynamic_macro(keycode, record)
  58. #endif
  59. && true)) {
  60. return false;
  61. }
  62. switch (keycode) {
  63. case VRSN: // Prints firmware version
  64. if (record->event.pressed) {
  65. send_string_with_delay_P(PSTR(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION ", Built on: " QMK_BUILDDATE), TAP_CODE_DELAY);
  66. }
  67. break;
  68. case KC_DIABLO_CLEAR: // reset all Diablo timers, disabling them
  69. #ifdef TAP_DANCE_ENABLE
  70. if (record->event.pressed) {
  71. for (uint8_t index = 0; index < 4; index++) {
  72. diablo_timer[index].key_interval = 0;
  73. }
  74. }
  75. #endif // TAP_DANCE_ENABLE
  76. break;
  77. case KC_CCCV: // One key copy/paste
  78. if (record->event.pressed) {
  79. copy_paste_timer = timer_read();
  80. } else {
  81. if (timer_elapsed(copy_paste_timer) > TAPPING_TERM) { // Hold, copy
  82. tap_code16(LCTL(KC_C));
  83. } else { // Tap, paste
  84. tap_code16(LCTL(KC_V));
  85. }
  86. }
  87. break;
  88. case KC_RGB_T: // This allows me to use underglow as layer indication, or as normal
  89. #if defined(CUSTOM_RGBLIGHT) || defined(CUSTOM_RGB_MATRIX)
  90. if (record->event.pressed) {
  91. userspace_config.rgb_layer_change ^= 1;
  92. dprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change);
  93. eeconfig_update_user_config(&userspace_config.raw);
  94. if (userspace_config.rgb_layer_change) {
  95. # if defined(CUSTOM_RGB_MATRIX)
  96. rgb_matrix_set_flags(LED_FLAG_UNDERGLOW | LED_FLAG_KEYLIGHT | LED_FLAG_INDICATOR);
  97. # if defined(CUSTOM_RGBLIGHT)
  98. rgblight_enable_noeeprom();
  99. # endif
  100. # endif
  101. layer_state_set(layer_state); // This is needed to immediately set the layer color (looks better)
  102. # if defined(CUSTOM_RGB_MATRIX)
  103. } else {
  104. rgb_matrix_set_flags(LED_FLAG_ALL);
  105. # if defined(CUSTOM_RGBLIGHT)
  106. rgblight_disable_noeeprom();
  107. # endif
  108. # endif
  109. }
  110. }
  111. #endif // CUSTOM_RGBLIGHT
  112. break;
  113. #if defined(CUSTOM_RGBLIGHT) || defined(CUSTOM_RGB_MATRIX)
  114. case RGB_TOG:
  115. // Split keyboards need to trigger on key-up for edge-case issue
  116. # ifndef SPLIT_KEYBOARD
  117. if (record->event.pressed) {
  118. # else
  119. if (!record->event.pressed) {
  120. # endif
  121. # if defined(CUSTOM_RGBLIGHT) && !defined(RGBLIGHT_DISABLE_KEYCODES)
  122. rgblight_toggle();
  123. # endif
  124. # if defined(CUSTOM_RGB_MATRIX) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
  125. rgb_matrix_toggle();
  126. # endif
  127. }
  128. return false;
  129. break;
  130. case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // quantum_keycodes.h L400 for definitions
  131. if (record->event.pressed) {
  132. bool is_eeprom_updated;
  133. # if defined(CUSTOM_RGBLIGHT) && !defined(RGBLIGHT_DISABLE_KEYCODES)
  134. // This disables layer indication, as it's assumed that if you're changing this ... you want that disabled
  135. if (userspace_config.rgb_layer_change) {
  136. userspace_config.rgb_layer_change = false;
  137. dprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change);
  138. is_eeprom_updated = true;
  139. }
  140. # endif
  141. # if defined(CUSTOM_RGB_MATRIX) && defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
  142. if (userspace_config.rgb_matrix_idle_anim) {
  143. userspace_config.rgb_matrix_idle_anim = false;
  144. dprintf("RGB Matrix Idle Animation [EEPROM]: %u\n", userspace_config.rgb_matrix_idle_anim);
  145. is_eeprom_updated = true;
  146. }
  147. # endif
  148. if (is_eeprom_updated) {
  149. eeconfig_update_user_config(&userspace_config.raw);
  150. }
  151. }
  152. break;
  153. #endif
  154. case KEYLOCK:
  155. if (record->event.pressed) {
  156. toggle_keyboard_lock();
  157. }
  158. break;
  159. #if defined(OS_DETECTION_ENABLE) && defined(OS_DETECTION_DEBUG_ENABLE)
  160. case STORE_SETUPS:
  161. if (record->event.pressed) {
  162. store_setups_in_eeprom();
  163. }
  164. return false;
  165. case PRINT_SETUPS:
  166. if (record->event.pressed) {
  167. print_stored_setups();
  168. }
  169. return false;
  170. #endif
  171. }
  172. return true;
  173. }
  174. __attribute__((weak)) void post_process_record_keymap(uint16_t keycode, keyrecord_t *record) {}
  175. void post_process_record_user(uint16_t keycode, keyrecord_t *record) {
  176. #if defined(OS_DETECTION_ENABLE) && defined(UNICODE_COMMON_ENABLE)
  177. switch (keycode) {
  178. case QK_MAGIC_SWAP_LCTL_LGUI:
  179. case QK_MAGIC_SWAP_RCTL_RGUI:
  180. case QK_MAGIC_SWAP_CTL_GUI:
  181. case QK_MAGIC_UNSWAP_LCTL_LGUI:
  182. case QK_MAGIC_UNSWAP_RCTL_RGUI:
  183. case QK_MAGIC_UNSWAP_CTL_GUI:
  184. case QK_MAGIC_TOGGLE_CTL_GUI:
  185. set_unicode_input_mode_soft(keymap_config.swap_lctl_lgui ? UNICODE_MODE_MACOS : UNICODE_MODE_WINCOMPOSE);
  186. break;
  187. }
  188. #endif
  189. post_process_record_keymap(keycode, record);
  190. }