process_unicode_common.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. #include "process_unicode_common.h"
  17. #include "unicode.h"
  18. #include "action_util.h"
  19. #include "keycode.h"
  20. #if defined(UNICODE_ENABLE)
  21. # include "process_unicode.h"
  22. #elif defined(UNICODEMAP_ENABLE)
  23. # include "process_unicodemap.h"
  24. #elif defined(UCIS_ENABLE)
  25. # include "process_ucis.h"
  26. #endif
  27. bool process_unicode_common(uint16_t keycode, keyrecord_t *record) {
  28. if (record->event.pressed) {
  29. bool shifted = get_mods() & MOD_MASK_SHIFT;
  30. switch (keycode) {
  31. case UNICODE_MODE_FORWARD:
  32. cycle_unicode_input_mode(shifted ? -1 : +1);
  33. break;
  34. case UNICODE_MODE_REVERSE:
  35. cycle_unicode_input_mode(shifted ? +1 : -1);
  36. break;
  37. case UNICODE_MODE_MAC:
  38. set_unicode_input_mode(UC_MAC);
  39. break;
  40. case UNICODE_MODE_LNX:
  41. set_unicode_input_mode(UC_LNX);
  42. break;
  43. case UNICODE_MODE_WIN:
  44. set_unicode_input_mode(UC_WIN);
  45. break;
  46. case UNICODE_MODE_BSD:
  47. set_unicode_input_mode(UC_BSD);
  48. break;
  49. case UNICODE_MODE_WINC:
  50. set_unicode_input_mode(UC_WINC);
  51. break;
  52. case UNICODE_MODE_EMACS:
  53. set_unicode_input_mode(UC_EMACS);
  54. break;
  55. }
  56. }
  57. #if defined(UNICODE_ENABLE)
  58. return process_unicode(keycode, record);
  59. #elif defined(UNICODEMAP_ENABLE)
  60. return process_unicodemap(keycode, record);
  61. #elif defined(UCIS_ENABLE)
  62. return process_ucis(keycode, record);
  63. #else
  64. return true;
  65. #endif
  66. }