keycodes.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* Copyright 2020 Casey Webster <casey@e1337.dev>
  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 "keycodes.h"
  17. __attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; }
  18. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  19. static uint16_t my_colon_timer;
  20. switch (keycode) {
  21. case KC_LCCL:
  22. if (record->event.pressed) {
  23. my_colon_timer = timer_read();
  24. register_code(KC_LCTL);
  25. } else {
  26. unregister_code(KC_LCTL);
  27. if (timer_elapsed(my_colon_timer) < TAPPING_TERM) {
  28. SEND_STRING(":");
  29. }
  30. }
  31. return false;
  32. }
  33. return process_record_keymap(keycode, record);
  34. }
  35. uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) {
  36. switch (keycode) {
  37. case LGUI_T(KC_A):
  38. case LALT_T(KC_S):
  39. case LCTL_T(KC_D):
  40. case LSFT_T(KC_F):
  41. case RSFT_T(KC_J):
  42. case RCTL_T(KC_K):
  43. case RALT_T(KC_L):
  44. case RGUI_T(KC_SCLN):
  45. return TAPPING_TERM + 150;
  46. default:
  47. return TAPPING_TERM;
  48. }
  49. }