]> git.donarmstrong.com Git - qmk_firmware.git/blobdiff - quantum/process_keycode/process_ucis.c
Add user-overridable callback for cancelling UCIS input (#5564)
[qmk_firmware.git] / quantum / process_keycode / process_ucis.c
index 4ad2533b089ffbe640dfd2e43f77e231a42d9904..fd4508b53547860032022e18374f03222fca7877 100644 (file)
@@ -1,3 +1,19 @@
+/* Copyright 2017 Jack Humbert
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
 #include "process_ucis.h"
 
 qk_ucis_state_t qk_ucis_state;
@@ -16,6 +32,10 @@ void qk_ucis_start_user(void) {
   unicode_input_finish();
 }
 
+__attribute__((weak))
+void qk_ucis_success(uint8_t symbol_index) {
+}
+
 static bool is_uni_seq(char *seq) {
   uint8_t i;
 
@@ -44,6 +64,10 @@ void qk_ucis_symbol_fallback (void) {
   }
 }
 
+__attribute__((weak))
+void qk_ucis_cancel(void) {
+}
+
 void register_ucis(const char *hex) {
   for(int i = 0; hex[i]; i++) {
     uint8_t kc = 0;
@@ -110,6 +134,7 @@ bool process_ucis (uint16_t keycode, keyrecord_t *record) {
 
     if (keycode == KC_ESC) {
       qk_ucis_state.in_progress = false;
+      qk_ucis_cancel();
       return false;
     }
 
@@ -126,8 +151,12 @@ bool process_ucis (uint16_t keycode, keyrecord_t *record) {
     }
     unicode_input_finish();
 
+    if (symbol_found) {
+      qk_ucis_success(i);
+    }
+
     qk_ucis_state.in_progress = false;
     return false;
   }
   return true;
-}
\ No newline at end of file
+}