mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-06-27 11:32:08 +00:00
Add cycle_unicode_input_mode and UNICODE_SELECTED_MODES macro
This commit is contained in:
parent
cd544e10a9
commit
b01d34e1dd
@ -20,6 +20,11 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
static uint8_t input_mode;
|
static uint8_t input_mode;
|
||||||
|
#if UNICODE_SELECTED_MODES != -1
|
||||||
|
static uint8_t selected[] = { UNICODE_SELECTED_MODES };
|
||||||
|
static uint8_t selected_count = sizeof selected / sizeof *selected;
|
||||||
|
static uint8_t selected_index;
|
||||||
|
#endif
|
||||||
uint8_t mods;
|
uint8_t mods;
|
||||||
|
|
||||||
void set_unicode_input_mode(uint8_t os_target) {
|
void set_unicode_input_mode(uint8_t os_target) {
|
||||||
@ -35,10 +40,34 @@ void unicode_input_mode_init(void) {
|
|||||||
static bool first_flag = false;
|
static bool first_flag = false;
|
||||||
if (!first_flag) {
|
if (!first_flag) {
|
||||||
input_mode = eeprom_read_byte(EECONFIG_UNICODEMODE);
|
input_mode = eeprom_read_byte(EECONFIG_UNICODEMODE);
|
||||||
|
|
||||||
|
#if UNICODE_SELECTED_MODES != -1
|
||||||
|
// Find input_mode in selected modes
|
||||||
|
uint8_t i;
|
||||||
|
for (i = 0; i < selected_count; i++) {
|
||||||
|
if (selected[i] == input_mode) {
|
||||||
|
selected_index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i == selected_count) {
|
||||||
|
// input_mode isn't selected, change to one that is
|
||||||
|
input_mode = selected[selected_index = 0];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
first_flag = true;
|
first_flag = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cycle_unicode_input_mode(void) {
|
||||||
|
#if UNICODE_SELECTED_MODES != -1
|
||||||
|
unicode_input_mode_init(); // Init selected_index
|
||||||
|
selected_index = (selected_index + 1) % selected_count;
|
||||||
|
input_mode = selected[selected_index];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
__attribute__((weak))
|
__attribute__((weak))
|
||||||
void unicode_input_start (void) {
|
void unicode_input_start (void) {
|
||||||
// save current mods
|
// save current mods
|
||||||
|
@ -19,6 +19,12 @@
|
|||||||
|
|
||||||
#include "quantum.h"
|
#include "quantum.h"
|
||||||
|
|
||||||
|
// Comma-delimited, ordered list of input modes selected for use (e.g. in cycle)
|
||||||
|
// Example: #define UNICODE_SELECTED_MODES UC_WINC, UC_LNX
|
||||||
|
#ifndef UNICODE_SELECTED_MODES
|
||||||
|
#define UNICODE_SELECTED_MODES -1
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef UNICODE_TYPE_DELAY
|
#ifndef UNICODE_TYPE_DELAY
|
||||||
#define UNICODE_TYPE_DELAY 10
|
#define UNICODE_TYPE_DELAY 10
|
||||||
#endif
|
#endif
|
||||||
@ -29,6 +35,8 @@ static uint8_t input_mode;
|
|||||||
void set_unicode_input_mode(uint8_t os_target);
|
void set_unicode_input_mode(uint8_t os_target);
|
||||||
uint8_t get_unicode_input_mode(void);
|
uint8_t get_unicode_input_mode(void);
|
||||||
void unicode_input_mode_init(void);
|
void unicode_input_mode_init(void);
|
||||||
|
void cycle_unicode_input_mode(void);
|
||||||
|
|
||||||
void unicode_input_start(void);
|
void unicode_input_start(void);
|
||||||
void unicode_input_finish(void);
|
void unicode_input_finish(void);
|
||||||
void register_hex(uint16_t hex);
|
void register_hex(uint16_t hex);
|
||||||
|
Loading…
Reference in New Issue
Block a user