process_ucis.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* Copyright 2017 Jack Humbert
  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. #pragma once
  17. #include "quantum.h"
  18. #include "process_unicode_common.h"
  19. #ifndef UCIS_MAX_SYMBOL_LENGTH
  20. # define UCIS_MAX_SYMBOL_LENGTH 32
  21. #endif
  22. #ifndef UCIS_MAX_CODE_POINTS
  23. # define UCIS_MAX_CODE_POINTS 3
  24. #endif
  25. typedef struct {
  26. char * symbol;
  27. uint32_t code_points[UCIS_MAX_CODE_POINTS];
  28. } qk_ucis_symbol_t;
  29. typedef struct {
  30. uint8_t count;
  31. uint16_t codes[UCIS_MAX_SYMBOL_LENGTH];
  32. bool in_progress : 1;
  33. } qk_ucis_state_t;
  34. extern qk_ucis_state_t qk_ucis_state;
  35. // clang-format off
  36. #define UCIS_TABLE(...) \
  37. { \
  38. __VA_ARGS__, \
  39. { NULL, {} } \
  40. }
  41. #define UCIS_SYM(name, ...) \
  42. { name, {__VA_ARGS__} }
  43. // clang-format on
  44. extern const qk_ucis_symbol_t ucis_symbol_table[];
  45. void qk_ucis_start(void);
  46. void qk_ucis_start_user(void);
  47. void qk_ucis_symbol_fallback(void);
  48. void qk_ucis_success(uint8_t symbol_index);
  49. void register_ucis(const uint32_t *code_points);
  50. bool process_ucis(uint16_t keycode, keyrecord_t *record);