logo

qmk_firmware

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

unicode.h (3557B)


  1. /* Copyright 2022
  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 <stdint.h>
  18. #include "compiler_support.h"
  19. #include "unicode_keycodes.h"
  20. /**
  21. * \file
  22. *
  23. * \defgroup unicode Unicode
  24. * \{
  25. */
  26. typedef union unicode_config_t {
  27. uint8_t raw;
  28. struct {
  29. uint8_t input_mode : 8;
  30. };
  31. } unicode_config_t;
  32. STATIC_ASSERT(sizeof(unicode_config_t) == sizeof(uint8_t), "Unicode EECONFIG out of spec.");
  33. extern unicode_config_t unicode_config;
  34. enum unicode_input_modes {
  35. UNICODE_MODE_MACOS, // macOS using Unicode Hex Input
  36. UNICODE_MODE_LINUX, // Linux using IBus
  37. UNICODE_MODE_WINDOWS, // Windows using EnableHexNumpad
  38. UNICODE_MODE_BSD, // BSD (not implemented)
  39. UNICODE_MODE_WINCOMPOSE, // Windows using WinCompose (https://github.com/samhocevar/wincompose)
  40. UNICODE_MODE_EMACS, // Emacs is an operating system in search of a good text editor
  41. UNICODE_MODE_COUNT // Number of available input modes (always leave at the end)
  42. };
  43. void unicode_input_mode_init(void);
  44. /**
  45. * \brief Get the current Unicode input mode.
  46. *
  47. * \return The currently active Unicode input mode.
  48. */
  49. uint8_t get_unicode_input_mode(void);
  50. /**
  51. * \brief Set the Unicode input mode.
  52. *
  53. * \param mode The input mode to set.
  54. */
  55. void set_unicode_input_mode(uint8_t mode);
  56. /**
  57. * \brief Change to the next Unicode input mode.
  58. */
  59. void unicode_input_mode_step(void);
  60. /**
  61. * \brief Change to the previous Unicode input mode.
  62. */
  63. void unicode_input_mode_step_reverse(void);
  64. /**
  65. * \brief User-level callback, invoked when the input mode is changed.
  66. *
  67. * \param input_mode The new input mode.
  68. */
  69. void unicode_input_mode_set_user(uint8_t input_mode);
  70. /**
  71. * \brief Keyboard-level callback, invoked when the input mode is changed.
  72. *
  73. * \param input_mode The new input mode.
  74. */
  75. void unicode_input_mode_set_kb(uint8_t input_mode);
  76. /**
  77. * \brief Begin the Unicode input sequence. The exact behavior depends on the currently selected input mode.
  78. */
  79. void unicode_input_start(void);
  80. /**
  81. * \brief Complete the Unicode input sequence. The exact behavior depends on the currently selected input mode.
  82. */
  83. void unicode_input_finish(void);
  84. /**
  85. * \brief Cancel the Unicode input sequence. The exact behavior depends on the currently selected input mode.
  86. */
  87. void unicode_input_cancel(void);
  88. /**
  89. * \brief Send a 16-bit hex number.
  90. *
  91. * \param hex The number to send.
  92. */
  93. void register_hex(uint16_t hex);
  94. /**
  95. * \brief Send a 32-bit hex number.
  96. *
  97. * \param hex The number to send.
  98. */
  99. void register_hex32(uint32_t hex);
  100. /**
  101. * \brief Input a single Unicode character. A surrogate pair will be sent if required by the input mode.
  102. *
  103. * \param code_point The code point of the character to send.
  104. */
  105. void register_unicode(uint32_t code_point);
  106. /**
  107. * \brief Send a string containing Unicode characters.
  108. *
  109. * \param str The string to send.
  110. */
  111. void send_unicode_string(const char *str);
  112. /** \} */