process_repeat_key.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2022-2023 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // https://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include "quantum.h"
  16. /**
  17. * @brief Process handler for remembering the last key.
  18. *
  19. * @param keycode Keycode registered by matrix press, per keymap
  20. * @param record keyrecord_t structure
  21. * @return true Continue processing keycodes, and send to host
  22. * @return false Stop processing keycodes, and don't send to host
  23. */
  24. bool process_last_key(uint16_t keycode, keyrecord_t* record);
  25. /**
  26. * @brief Optional callback defining which keys are remembered.
  27. *
  28. * @param keycode Keycode that was just pressed
  29. * @param record keyrecord_t structure
  30. * @param remembered_mods Mods that will be remembered with this key
  31. * @return true Key is remembered
  32. * @return false Key is ignored
  33. *
  34. * Modifier and layer switch keys are always ignored. For all other keys, this
  35. * callback is called on every key press. Returning true means that the key is
  36. * remembered, false means it is ignored. By default, all non-modifier,
  37. * non-layer switch keys are remembered.
  38. *
  39. * The `remembered_mods` arg represents the mods that will be remembered with
  40. * this key. It can be modified to forget certain mods, for instance to forget
  41. * capitalization when repeating shifted letters:
  42. *
  43. * // Forget Shift on letter keys.
  44. * if (KC_A <= keycode && keycode <= KC_Z && (*remembered_mods & ~MOD_MASK_SHIFT) == 0) {
  45. * *remembered_mods = 0;
  46. * }
  47. */
  48. bool remember_last_key_user(uint16_t keycode, keyrecord_t* record, uint8_t* remembered_mods);
  49. /**
  50. * @brief Process handler for Repeat Key feature.
  51. *
  52. * @param keycode Keycode registered by matrix press, per keymap
  53. * @param record keyrecord_t structure
  54. * @return true Continue processing keycodes, and send to host
  55. * @return false Stop processing keycodes, and don't send to host
  56. */
  57. bool process_repeat_key(uint16_t keycode, keyrecord_t* record);