logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

repeat_key.h (3094B)


  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 <stdint.h>
  16. #include <stdbool.h>
  17. #include "action.h"
  18. #include "keyboard.h"
  19. uint16_t get_last_keycode(void); /**< Keycode of the last key. */
  20. uint8_t get_last_mods(void); /**< Mods active with the last key. */
  21. void set_last_keycode(uint16_t keycode); /**< Sets the last key. */
  22. void set_last_mods(uint8_t mods); /**< Sets the last mods. */
  23. /** @brief Gets the record for the last key. */
  24. keyrecord_t* get_last_record(void);
  25. /** @brief Sets keycode and record info for the last key. */
  26. void set_last_record(uint16_t keycode, keyrecord_t* record);
  27. /**
  28. * @brief Signed count of times the key has been repeated or alternate repeated.
  29. *
  30. * @note The count is nonzero only while a repeated or alternate-repeated key is
  31. * being processed.
  32. *
  33. * When a key is pressed normally, the count is 0. When the Repeat Key is used
  34. * to repeat a key, the count is 1 on the first repeat, 2 on the second repeat,
  35. * and continuing up to 127.
  36. *
  37. * Negative counts are used similarly for alternate repeating. When the
  38. * Alternate Repeat Key is used, the count is -1 on the first alternate repeat,
  39. * -2 on the second, continuing down to -127.
  40. */
  41. int8_t get_repeat_key_count(void);
  42. /**
  43. * @brief Calls `process_record()` on a generated record repeating the last key.
  44. * @param event Event information in the generated record.
  45. */
  46. void repeat_key_invoke(const keyevent_t* event);
  47. #ifndef NO_ALT_REPEAT_KEY
  48. /**
  49. * @brief Keycode to be used for alternate repeating.
  50. *
  51. * Alternate Repeat performs this keycode based on the last eligible pressed key
  52. * and mods, get_last_keycode() and get_last_mods(). For example, when the last
  53. * key was KC_UP, this function returns KC_DOWN. The function returns KC_NO if
  54. * the last key doesn't have a defined alternate.
  55. */
  56. uint16_t get_alt_repeat_key_keycode(void);
  57. /**
  58. * @brief Calls `process_record()` to alternate repeat the last key.
  59. * @param event Event information in the generated record.
  60. */
  61. void alt_repeat_key_invoke(const keyevent_t* event);
  62. /**
  63. * @brief Optional user callback to define additional alternate keys.
  64. *
  65. * When `get_alt_repeat_key_keycode()` is called, it first calls this callback.
  66. * It should return a keycode representing the "alternate" of the given keycode
  67. * and mods. Returning KC_NO defers to the default definitions in
  68. * `get_alt_repeat_key_keycode()`.
  69. */
  70. uint16_t get_alt_repeat_key_keycode_user(uint16_t keycode, uint8_t mods);
  71. #endif // NO_ALT_REPEAT_KEY