You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.4 KiB

  1. /*
  2. Copyright 2020 rupa <rupa@lrrr.us> @rupa
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include "rupa.h"
  15. font_t *translator = NULL;
  16. __attribute__((weak))
  17. bool process_record_keymap(uint16_t keycode, keyrecord_t *record) {
  18. return true;
  19. }
  20. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  21. bool is_shifted = get_mods()&MOD_MASK_SHIFT;
  22. bool is_pressed = record->event.pressed;
  23. switch(keycode) {
  24. case VRSN:
  25. if (is_pressed) {
  26. send_string_with_delay_P(PSTR(
  27. "# " QMK_KEYBOARD "/" QMK_KEYMAP ":" QMK_VERSION " " QMK_BUILDDATE "\n"
  28. ), TAP_CODE_DELAY);
  29. }
  30. return false;
  31. case LOD:
  32. case RUPA:
  33. if (is_pressed) {
  34. if (keycode == LOD) {
  35. send_unicode_string((is_shifted ? "¯\\_(ツ)_/¯" : "ಠ_ಠ"));
  36. } else if (keycode == RUPA) {
  37. send_unicode_string((is_shifted ? "Śrīrūpa" : "rūpa"));
  38. }
  39. }
  40. return false;
  41. // script modes
  42. case U_FRACT:
  43. case U_MONOS:
  44. case U_SCRPT:
  45. if (is_pressed) {
  46. if (keycode == U_SCRPT) {
  47. translator = (translator == &script_bold ? NULL : &script_bold);
  48. } else if (keycode == U_FRACT) {
  49. translator = (translator == &fraktu_bold ? NULL : &fraktu_bold);
  50. } else if (keycode == U_MONOS) {
  51. translator = (translator == &monosp_bold ? NULL : &monosp_bold);
  52. }
  53. }
  54. return true;
  55. default:
  56. if (is_pressed && translator != NULL) {
  57. return script_mode_translate(translator, is_shifted, keycode);
  58. }
  59. }
  60. return process_record_keymap(keycode, record);
  61. }