unicode.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 "unicode_keycodes.h"
  19. typedef union {
  20. uint8_t raw;
  21. struct {
  22. uint8_t input_mode : 8;
  23. };
  24. } unicode_config_t;
  25. _Static_assert(sizeof(unicode_config_t) == sizeof(uint8_t), "Unicode EECONFIG out of spec.");
  26. extern unicode_config_t unicode_config;
  27. enum unicode_input_modes {
  28. UNICODE_MODE_MACOS, // macOS using Unicode Hex Input
  29. UNICODE_MODE_LINUX, // Linux using IBus
  30. UNICODE_MODE_WINDOWS, // Windows using EnableHexNumpad
  31. UNICODE_MODE_BSD, // BSD (not implemented)
  32. UNICODE_MODE_WINCOMPOSE, // Windows using WinCompose (https://github.com/samhocevar/wincompose)
  33. UNICODE_MODE_EMACS, // Emacs is an operating system in search of a good text editor
  34. UNICODE_MODE_COUNT // Number of available input modes (always leave at the end)
  35. };
  36. void unicode_input_mode_init(void);
  37. uint8_t get_unicode_input_mode(void);
  38. void set_unicode_input_mode(uint8_t mode);
  39. void cycle_unicode_input_mode(int8_t offset);
  40. void persist_unicode_input_mode(void);
  41. void unicode_input_mode_set_user(uint8_t input_mode);
  42. void unicode_input_mode_set_kb(uint8_t input_mode);
  43. void unicode_input_start(void);
  44. void unicode_input_finish(void);
  45. void unicode_input_cancel(void);
  46. void register_hex(uint16_t hex);
  47. void register_hex32(uint32_t hex);
  48. void register_unicode(uint32_t code_point);
  49. void send_unicode_string(const char *str);