logo

qmk_firmware

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

ucis.h (1785B)


  1. // Copyright 2023 QMK
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <stdbool.h>
  5. #include <stdint.h>
  6. /**
  7. * \file
  8. *
  9. * \defgroup ucis UCIS
  10. * \{
  11. */
  12. #ifndef UCIS_MAX_INPUT_LENGTH
  13. # define UCIS_MAX_INPUT_LENGTH 32
  14. #endif
  15. #ifndef UCIS_MAX_CODE_POINTS
  16. # define UCIS_MAX_CODE_POINTS 3
  17. #endif
  18. typedef struct {
  19. char* mnemonic;
  20. uint32_t code_points[UCIS_MAX_CODE_POINTS];
  21. } ucis_symbol_t;
  22. // clang-format off
  23. #define UCIS_TABLE(...) { \
  24. __VA_ARGS__, \
  25. { NULL, {} } \
  26. }
  27. #define UCIS_SYM(name, ...) { \
  28. .mnemonic = name, \
  29. .code_points = {__VA_ARGS__} \
  30. }
  31. // clang-format on
  32. extern const ucis_symbol_t ucis_symbol_table[];
  33. /**
  34. * \brief Begin the input sequence.
  35. */
  36. void ucis_start(void);
  37. /**
  38. * \brief Whether UCIS is currently active.
  39. *
  40. * \return `true` if UCIS is active.
  41. */
  42. bool ucis_active(void);
  43. /**
  44. * \brief Get the number of characters in the input sequence buffer.
  45. *
  46. * \return The current input sequence buffer length.
  47. */
  48. uint8_t ucis_count(void);
  49. /**
  50. * \brief Add the given keycode to the input sequence buffer.
  51. *
  52. * \param keycode The keycode to add. Must be between `KC_A` and `KC_Z`, or `KC_1` and `KC_0`.
  53. *
  54. * \return `true` if the keycode was added.
  55. */
  56. bool ucis_add(uint16_t keycode);
  57. /**
  58. * \brief Remove the last character from the input sequence.
  59. *
  60. * \return `true` if the sequence was not empty.
  61. */
  62. bool ucis_remove_last(void);
  63. /**
  64. * Mark the input sequence as complete, and attempt to match.
  65. */
  66. void ucis_finish(void);
  67. /**
  68. * \brief Cancel the input sequence.
  69. */
  70. void ucis_cancel(void);
  71. /**
  72. * Send the code point(s) for the given UCIS index.
  73. *
  74. * \param index The index into the UCIS symbol table.
  75. */
  76. void register_ucis(uint8_t index);
  77. /** \} */