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.

47 lines
1.2 KiB

  1. // This is a hack to place <question mark> on <shift-comma> and <exclamation
  2. // mark> on <shift-period>, when using an operating system configured for a
  3. // US/qwerty layout.
  4. //
  5. // cdeq = "comma dot exclamation question"
  6. #include QMK_KEYBOARD_H
  7. bool comm_shifted = false;
  8. bool ques_shifted = false;
  9. bool process_record_cdeq(uint16_t keycode, keyrecord_t *record) {
  10. uint8_t shifted;
  11. uint16_t s_keycode;
  12. bool *k_shifted;
  13. switch (keycode) {
  14. case KC_COMM:
  15. s_keycode = KC_SLSH;
  16. k_shifted = &comm_shifted;
  17. break;
  18. case KC_DOT:
  19. s_keycode = KC_1;
  20. k_shifted = &ques_shifted;
  21. break;
  22. default:
  23. return true;
  24. }
  25. shifted = get_mods() & (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT));
  26. // Keydown. If shift is currently pressed, register its alternate keycode.
  27. if (record->event.pressed && shifted) {
  28. *k_shifted = true;
  29. register_code(s_keycode);
  30. return false;
  31. // Keyup. If shift was pressed back when the key was pressed, unregister
  32. // its alternate keycode.
  33. } else if (!(record->event.pressed) && *k_shifted) {
  34. *k_shifted = false;
  35. unregister_code(s_keycode);
  36. return false;
  37. // Otherwise, behave as normal.
  38. } else {
  39. return true;
  40. }
  41. }