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