logo

qmk_firmware

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

process_ucis.c (1510B)


  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_ucis.h"
  17. #include "ucis.h"
  18. #include "keycodes.h"
  19. bool process_ucis(uint16_t keycode, keyrecord_t *record) {
  20. if (ucis_active() && record->event.pressed) {
  21. bool special = keycode == KC_SPACE || keycode == KC_ENTER || keycode == KC_ESCAPE || keycode == KC_BACKSPACE;
  22. if (ucis_count() >= UCIS_MAX_INPUT_LENGTH && !special) {
  23. return false;
  24. }
  25. if (!ucis_add(keycode)) {
  26. switch (keycode) {
  27. case KC_BACKSPACE:
  28. return ucis_remove_last();
  29. case KC_ESCAPE:
  30. ucis_cancel();
  31. return false;
  32. case KC_SPACE:
  33. case KC_ENTER:
  34. ucis_finish();
  35. return false;
  36. }
  37. }
  38. }
  39. return true;
  40. }