1
0
Fork 0
forked from forks/qmk_firmware

UCIS: remove qk_ prefix (#19302)

This commit is contained in:
Ryan 2022-12-14 13:44:36 +11:00 committed by GitHub
parent 515dd18c28
commit 9e4cfcd181
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 41 deletions

View file

@ -83,7 +83,7 @@ UCIS_ENABLE = yes
Then define a table like this in your keymap file:
```c
const qk_ucis_symbol_t ucis_symbol_table[] = UCIS_TABLE(
const ucis_symbol_t ucis_symbol_table[] = UCIS_TABLE(
UCIS_SYM("poop", 0x1F4A9), // 💩
UCIS_SYM("rofl", 0x1F923), // 🤣
UCIS_SYM("cuba", 0x1F1E8, 0x1F1FA), // 🇨🇺
@ -93,15 +93,15 @@ const qk_ucis_symbol_t ucis_symbol_table[] = UCIS_TABLE(
By default, each table entry may be up to 3 code points long. This number can be changed by adding `#define UCIS_MAX_CODE_POINTS n` to your `config.h` file.
To use UCIS input, call `qk_ucis_start()`. Then, type the mnemonic for the character (such as "rofl") and hit Space, Enter or Esc. QMK should erase the "rofl" text and insert the laughing emoji.
To use UCIS input, call `ucis_start()`. Then, type the mnemonic for the character (such as "rofl") and hit Space, Enter or Esc. QMK should erase the "rofl" text and insert the laughing emoji.
#### Customization
There are several functions that you can define in your keymap to customize the functionality of this feature.
* `void qk_ucis_start_user(void)` This runs when you call the "start" function, and can be used to provide feedback. By default, it types out a keyboard emoji.
* `void qk_ucis_success(uint8_t symbol_index)` This runs when the input has matched something and has completed. By default, it doesn't do anything.
* `void qk_ucis_symbol_fallback (void)` This runs when the input doesn't match anything. By default, it falls back to trying that input as a Unicode code.
* `void ucis_start_user(void)` This runs when you call the "start" function, and can be used to provide feedback. By default, it types out a keyboard emoji.
* `void ucis_success(uint8_t symbol_index)` This runs when the input has matched something and has completed. By default, it doesn't do anything.
* `void ucis_symbol_fallback (void)` This runs when the input doesn't match anything. By default, it falls back to trying that input as a Unicode code.
You can find the default implementations of these functions in [`process_ucis.c`](https://github.com/qmk/qmk_firmware/blob/master/quantum/process_keycode/process_ucis.c).

View file

@ -19,20 +19,20 @@
#include "keycode.h"
#include "wait.h"
qk_ucis_state_t qk_ucis_state;
ucis_state_t ucis_state;
void qk_ucis_start(void) {
qk_ucis_state.count = 0;
qk_ucis_state.in_progress = true;
void ucis_start(void) {
ucis_state.count = 0;
ucis_state.in_progress = true;
qk_ucis_start_user();
ucis_start_user();
}
__attribute__((weak)) void qk_ucis_start_user(void) {
__attribute__((weak)) void ucis_start_user(void) {
register_unicode(0x2328); // ⌨
}
__attribute__((weak)) void qk_ucis_success(uint8_t symbol_index) {}
__attribute__((weak)) void ucis_success(uint8_t symbol_index) {}
static bool is_uni_seq(char *seq) {
uint8_t i;
@ -43,20 +43,20 @@ static bool is_uni_seq(char *seq) {
} else {
keycode = seq[i] - 'a' + KC_A;
}
if (i > qk_ucis_state.count || qk_ucis_state.codes[i] != keycode) {
if (i > ucis_state.count || ucis_state.codes[i] != keycode) {
return false;
}
}
return qk_ucis_state.codes[i] == KC_ENTER || qk_ucis_state.codes[i] == KC_SPACE;
return ucis_state.codes[i] == KC_ENTER || ucis_state.codes[i] == KC_SPACE;
}
__attribute__((weak)) void qk_ucis_symbol_fallback(void) {
for (uint8_t i = 0; i < qk_ucis_state.count - 1; i++) {
tap_code(qk_ucis_state.codes[i]);
__attribute__((weak)) void ucis_symbol_fallback(void) {
for (uint8_t i = 0; i < ucis_state.count - 1; i++) {
tap_code(ucis_state.codes[i]);
}
}
__attribute__((weak)) void qk_ucis_cancel(void) {}
__attribute__((weak)) void ucis_cancel(void) {}
void register_ucis(const uint32_t *code_points) {
for (int i = 0; i < UCIS_MAX_CODE_POINTS && code_points[i]; i++) {
@ -65,38 +65,38 @@ void register_ucis(const uint32_t *code_points) {
}
bool process_ucis(uint16_t keycode, keyrecord_t *record) {
if (!qk_ucis_state.in_progress || !record->event.pressed) {
if (!ucis_state.in_progress || !record->event.pressed) {
return true;
}
bool special = keycode == KC_SPACE || keycode == KC_ENTER || keycode == KC_ESCAPE || keycode == KC_BACKSPACE;
if (qk_ucis_state.count >= UCIS_MAX_SYMBOL_LENGTH && !special) {
if (ucis_state.count >= UCIS_MAX_SYMBOL_LENGTH && !special) {
return false;
}
qk_ucis_state.codes[qk_ucis_state.count] = keycode;
qk_ucis_state.count++;
ucis_state.codes[ucis_state.count] = keycode;
ucis_state.count++;
switch (keycode) {
case KC_BACKSPACE:
if (qk_ucis_state.count >= 2) {
qk_ucis_state.count -= 2;
if (ucis_state.count >= 2) {
ucis_state.count -= 2;
return true;
} else {
qk_ucis_state.count--;
ucis_state.count--;
return false;
}
case KC_SPACE:
case KC_ENTER:
case KC_ESCAPE:
for (uint8_t i = 0; i < qk_ucis_state.count; i++) {
for (uint8_t i = 0; i < ucis_state.count; i++) {
tap_code(KC_BACKSPACE);
}
if (keycode == KC_ESCAPE) {
qk_ucis_state.in_progress = false;
qk_ucis_cancel();
ucis_state.in_progress = false;
ucis_cancel();
return false;
}
@ -110,12 +110,12 @@ bool process_ucis(uint16_t keycode, keyrecord_t *record) {
}
}
if (symbol_found) {
qk_ucis_success(i);
ucis_success(i);
} else {
qk_ucis_symbol_fallback();
ucis_symbol_fallback();
}
qk_ucis_state.in_progress = false;
ucis_state.in_progress = false;
return false;
default:

View file

@ -31,15 +31,15 @@
typedef struct {
char * symbol;
uint32_t code_points[UCIS_MAX_CODE_POINTS];
} qk_ucis_symbol_t;
} ucis_symbol_t;
typedef struct {
uint8_t count;
uint16_t codes[UCIS_MAX_SYMBOL_LENGTH];
bool in_progress : 1;
} qk_ucis_state_t;
} ucis_state_t;
extern qk_ucis_state_t qk_ucis_state;
extern ucis_state_t ucis_state;
// clang-format off
@ -53,12 +53,12 @@ extern qk_ucis_state_t qk_ucis_state;
// clang-format on
extern const qk_ucis_symbol_t ucis_symbol_table[];
extern const ucis_symbol_t ucis_symbol_table[];
void qk_ucis_start(void);
void qk_ucis_start_user(void);
void qk_ucis_symbol_fallback(void);
void qk_ucis_success(uint8_t symbol_index);
void ucis_start(void);
void ucis_start_user(void);
void ucis_symbol_fallback(void);
void ucis_success(uint8_t symbol_index);
void register_ucis(const uint32_t *code_points);

View file

@ -543,7 +543,7 @@ void matrix_scan_user(void) {
#ifdef UCIS_ENABLE
SEQ_ONE_KEY(KC_U) {
qk_ucis_start();
ucis_start();
}
#endif
SEQ_ONE_KEY(KC_H) {
@ -576,7 +576,7 @@ void matrix_scan_user(void) {
#ifdef UCIS_ENABLE
// 3 codepoints at most, otherwise increase UCIS_MAX_CODE_POINTS
const qk_ucis_symbol_t ucis_symbol_table[] = UCIS_TABLE(
const ucis_symbol_t ucis_symbol_table[] = UCIS_TABLE(
UCIS_SYM("poop", 0x1F4A9), // 💩
UCIS_SYM("rofl", 0x1F923), // 🤣
UCIS_SYM("look", 0x0CA0, 0x005F, 0x0CA0) // ಠ_ಠ