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.

209 lines
5.6 KiB

Migrated most code from keymaps to userspace (#1980) * Add woodpad * Cleanup * Remove misc layouts for woodpad * Move woodpad to handwired * Updated RGB Underglow info * Cleanup macros * Tweaked RGB lighting stuff * Start to merge orthodox/ergodox keymaps (persistant layers) * Add woodpad * Add forced NKRO * Added default layer (qwerty/colemak/dvorak) detection to RGB Underglow * Updated macros and added workman keymaps * Fixed RGB lighting for Workman layout * Add leader keys * Remove force NKRO * Add Viterbi one handed layout and minor tweaks to others * Finishing up Viterbi keyboard layout, and NKRO tweaks to other layouts * Made "make" keystroke universal * Clean up and updates of drashna keymaps * Add workman layer to planck * Update to keymaps * Fix makefile toggle code in ez keymap Finish adding RGB code to orthodox * Updated RGB Underglow layer indication code due to discovery of the layer_state_set_kb function * Remove unnecessary planck layout * Fixed Workman song * update make command and added lit reset * Fixed formatting to fall in line with official standards * Minor tweaks * Removed Leader Keys from Ergodox EZ Keymap Added KC_RESET that resets board and sets underglow to red * Tweak reset code * Cleanup * Remove misc layouts for woodpad * Move woodpad to handwired * Updated RGB Underglow info * Cleanup macros * Tweaked RGB lighting stuff * Start to merge orthodox/ergodox keymaps (persistant layers) * Add forced NKRO * Added default layer (qwerty/colemak/dvorak) detection to RGB Underglow * Updated macros and added workman keymaps * Fixed RGB lighting for Workman layout * Add leader keys * Remove force NKRO * Add Viterbi one handed layout and minor tweaks to others * Finishing up Viterbi keyboard layout, and NKRO tweaks to other layouts * Made "make" keystroke universal * Clean up and updates of drashna keymaps * Add workman layer to planck * Update to keymaps * Fix makefile toggle code in ez keymap Finish adding RGB code to orthodox * Updated RGB Underglow layer indication code due to discovery of the layer_state_set_kb function * Remove unnecessary planck layout * Fixed Workman song * update make command and added lit reset * Fixed formatting to fall in line with official standards * Minor tweaks * Removed Leader Keys from Ergodox EZ Keymap Added KC_RESET that resets board and sets underglow to red * Tweak reset code * Fix rebasing issues * remove head files * Fix "macro" issue * Rename ez keymaps for userspace * Revert "Rename ez keymaps for userspace" This reverts commit c25425911852e41711a5f0273b5741adb16e5bd4. * Renamed Ergodox EZ layouts so that all of my personal layouts are on the same name, in prep for using userspaces * Fix ergodox code * Remove "drashna-ez" keymap as it's no longer needed * Migrate majority of code to Userspace
6 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
Update to drashna userspace and keymaps (#3172) * Use string with delay * Add skipped region to ergodox * Add send string config * Use default_layer_state instead of function * Fully generalize keyboards * old iris cleanup * Fix Drashna keymap compile issues By checking to see if secret.c exists before actually trying to add it * Remove unnecessary references * Add 4x12 ortho board * Update userspace readme for secrets * Make RGB more modular * Fix iris keymap, since we don't need the lower left (Function keys) * Fix includes * Add Blanks * Fix Ergodox lower layer * Add suspend commands * Add Maltron Layout * Add additional layouts * Finish adding gamepad to Iris * Tweaks to iris gamepag layer * make gaming layers more friendly * minor gaming layer tweak * Add Carplax * Add modded key timer function * Cleanup and macro documentation * Add QMK DFU info * Add 'old' keymap for 12 LED spare * Update Pro Micro documentation * Disable twinkling so it fits in firmware space * Switch to QMK DFU bootloader, since it's better anyhow * Write default layer state colors to EEPROM Since we are writing to EEPROM anyways, and this way, it sticks on reboot * Fix QMK DFU bootloader options * More updates for QMK DFU support * Use matrix scanning hack for startup_user until #3113 gets merged * Fix indicator light consistency issue * Add/readd ifdefs to indicators * Add/readd alt indicator * Remove RGB Twinkling from Viterbi macro pad * Fix default layer color detection * Fix rebase and detection issues * Cleanup code so it will compile if RGBLIGHT is disabled * Revert vsode settings * Use Pragma Once instead of boilerplate code
5 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
Update to drashna userspace and keymaps (#3172) * Use string with delay * Add skipped region to ergodox * Add send string config * Use default_layer_state instead of function * Fully generalize keyboards * old iris cleanup * Fix Drashna keymap compile issues By checking to see if secret.c exists before actually trying to add it * Remove unnecessary references * Add 4x12 ortho board * Update userspace readme for secrets * Make RGB more modular * Fix iris keymap, since we don't need the lower left (Function keys) * Fix includes * Add Blanks * Fix Ergodox lower layer * Add suspend commands * Add Maltron Layout * Add additional layouts * Finish adding gamepad to Iris * Tweaks to iris gamepag layer * make gaming layers more friendly * minor gaming layer tweak * Add Carplax * Add modded key timer function * Cleanup and macro documentation * Add QMK DFU info * Add 'old' keymap for 12 LED spare * Update Pro Micro documentation * Disable twinkling so it fits in firmware space * Switch to QMK DFU bootloader, since it's better anyhow * Write default layer state colors to EEPROM Since we are writing to EEPROM anyways, and this way, it sticks on reboot * Fix QMK DFU bootloader options * More updates for QMK DFU support * Use matrix scanning hack for startup_user until #3113 gets merged * Fix indicator light consistency issue * Add/readd ifdefs to indicators * Add/readd alt indicator * Remove RGB Twinkling from Viterbi macro pad * Fix default layer color detection * Fix rebase and detection issues * Cleanup code so it will compile if RGBLIGHT is disabled * Revert vsode settings * Use Pragma Once instead of boilerplate code
5 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. userspace_config_t userspace_config;
  5. /**
  6. * @brief Handle registering a keycode, with optional modifer based on timed event
  7. *
  8. * @param code keycode to send to host
  9. * @param mod_code modifier to send with code, if held for tapping term or longer
  10. * @param pressed the press/release event (can use "record->event.pressed" for this)
  11. * @return true exits function
  12. * @return false exits function
  13. */
  14. bool mod_key_press_timer(uint16_t code, uint16_t mod_code, bool pressed) {
  15. static uint16_t this_timer;
  16. mod_key_press(code, mod_code, pressed, this_timer);
  17. return false;
  18. }
  19. /**
  20. * @brief Handle registation of keycode, with optional modifier based on custom timer
  21. *
  22. * @param code keycode to send to host
  23. * @param mod_code modifier keycode to send with code, if held for tapping term or longer
  24. * @param pressed the press/release event
  25. * @param this_timer custom timer to use
  26. * @return true
  27. * @return false
  28. */
  29. bool mod_key_press(uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer) {
  30. if (pressed) {
  31. this_timer = timer_read();
  32. } else {
  33. if (timer_elapsed(this_timer) < TAPPING_TERM) {
  34. tap_code(code);
  35. } else {
  36. register_code(mod_code);
  37. tap_code(code);
  38. unregister_code(mod_code);
  39. }
  40. }
  41. return false;
  42. }
  43. /**
  44. * @brief Performs exact match for modifier values
  45. *
  46. * @param value the modifer varible (get_mods/get_oneshot_mods/get_weak_mods)
  47. * @param mask the modifier mask to check for
  48. * @return true Has the exact modifiers specifed
  49. * @return false Does not have the exact modifiers specified
  50. */
  51. bool hasAllBitsInMask(uint8_t value, uint8_t mask) {
  52. value &= 0xF;
  53. mask &= 0xF;
  54. return (value & mask) == mask;
  55. }
  56. /**
  57. * @brief Tap keycode, with no mods
  58. *
  59. * @param kc keycode to use
  60. */
  61. void tap_code16_nomods(uint16_t kc) {
  62. uint8_t temp_mod = get_mods();
  63. clear_mods();
  64. clear_oneshot_mods();
  65. tap_code16(kc);
  66. set_mods(temp_mod);
  67. }
  68. #ifdef I2C_SCANNER_ENABLE
  69. # include "i2c_master.h"
  70. # include "debug.h"
  71. # ifndef I2C_SCANNER_TIMEOUT
  72. # define I2C_SCANNER_TIMEOUT 50
  73. # endif
  74. i2c_status_t i2c_start_bodge(uint8_t address, uint16_t timeout) {
  75. i2c_start(address);
  76. // except on ChibiOS where the only way is do do "something"
  77. uint8_t data = 0;
  78. return i2c_readReg(address, 0, &data, sizeof(data), I2C_SCANNER_TIMEOUT);
  79. }
  80. # define i2c_start i2c_start_bodge
  81. void do_scan(void) {
  82. uint8_t nDevices = 0;
  83. dprintf("Scanning...\n");
  84. for (uint8_t address = 1; address < 127; address++) {
  85. // The i2c_scanner uses the return value of
  86. // i2c_start to see if a device did acknowledge to the address.
  87. i2c_status_t error = i2c_start(address << 1, I2C_SCANNER_TIMEOUT);
  88. if (error == I2C_STATUS_SUCCESS) {
  89. i2c_stop();
  90. xprintf(" I2C device found at address 0x%02X\n", I2C_SCANNER_TIMEOUT);
  91. nDevices++;
  92. } else {
  93. // dprintf(" Unknown error (%u) at address 0x%02X\n", error, address);
  94. }
  95. }
  96. if (nDevices == 0)
  97. xprintf("No I2C devices found\n");
  98. else
  99. xprintf("done\n");
  100. }
  101. uint16_t scan_timer = 0;
  102. void housekeeping_task_i2c_scanner(void) {
  103. if (timer_elapsed(scan_timer) > 5000) {
  104. do_scan();
  105. scan_timer = timer_read();
  106. }
  107. }
  108. void keyboard_post_init_i2c(void) {
  109. i2c_init();
  110. scan_timer = timer_read();
  111. }
  112. #endif
  113. #if defined(AUTOCORRECT_ENABLE)
  114. # if defined(AUDIO_ENABLE)
  115. # ifdef USER_SONG_LIST
  116. float autocorrect_song[][2] = SONG(MARIO_GAMEOVER);
  117. # else
  118. float autocorrect_song[][2] = SONG(PLOVER_GOODBYE_SOUND);
  119. # endif
  120. # endif
  121. bool apply_autocorrect(uint8_t backspaces, const char* str) {
  122. if (layer_state_is(_GAMEPAD)) {
  123. return false;
  124. }
  125. // TO-DO use unicode stuff for this. Will probably have to reverse engineer
  126. // send string to get working properly, to send char string.
  127. # if defined(AUDIO_ENABLE)
  128. PLAY_SONG(autocorrect_song);
  129. # endif
  130. return true;
  131. }
  132. #endif
  133. #if defined(CAPS_WORD_ENABLE)
  134. bool caps_word_press_user(uint16_t keycode) {
  135. switch (keycode) {
  136. // Keycodes that continue Caps Word, with shift applied.
  137. case KC_MINS:
  138. if (!keymap_config.swap_lctl_lgui) {
  139. return true;
  140. }
  141. case KC_A ... KC_Z:
  142. add_weak_mods(MOD_BIT(KC_LSFT)); // Apply shift to next key.
  143. return true;
  144. // Keycodes that continue Caps Word, without shifting.
  145. case KC_1 ... KC_0:
  146. case KC_BSPC:
  147. case KC_DEL:
  148. case KC_UNDS:
  149. return true;
  150. default:
  151. return false; // Deactivate Caps Word.
  152. }
  153. }
  154. # if !defined(NO_ACTION_ONESHOT)
  155. void oneshot_locked_mods_changed_user(uint8_t mods) {
  156. if (mods & MOD_MASK_SHIFT) {
  157. del_mods(MOD_MASK_SHIFT);
  158. set_oneshot_locked_mods(~MOD_MASK_SHIFT & get_oneshot_locked_mods());
  159. caps_word_on();
  160. }
  161. }
  162. # endif
  163. #endif
  164. void format_layer_bitmap_string(char* buffer, layer_state_t state, layer_state_t default_state) {
  165. for (int i = 0; i < 16; i++) {
  166. if (i == 0 || i == 4 || i == 8 || i == 12) {
  167. *buffer = ' ';
  168. ++buffer;
  169. }
  170. uint8_t layer = i;
  171. if ((default_state & ((layer_state_t)1 << layer)) != 0) {
  172. *buffer = 'D';
  173. } else if ((state & ((layer_state_t)1 << layer)) != 0) {
  174. *buffer = '1';
  175. } else {
  176. *buffer = '_';
  177. }
  178. ++buffer;
  179. }
  180. *buffer = 0;
  181. }