2017-03-29 00:20:36 +02:00
|
|
|
/* 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/>.
|
|
|
|
*/
|
|
|
|
|
2018-12-19 17:39:24 +01:00
|
|
|
#pragma once
|
2017-02-15 22:36:31 +01:00
|
|
|
|
2022-09-12 17:49:04 +02:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "action.h"
|
2017-02-15 22:36:31 +01:00
|
|
|
|
|
|
|
#ifndef UCIS_MAX_SYMBOL_LENGTH
|
2019-08-30 20:19:03 +02:00
|
|
|
# define UCIS_MAX_SYMBOL_LENGTH 32
|
2017-02-15 22:36:31 +01:00
|
|
|
#endif
|
2020-06-18 09:07:34 +02:00
|
|
|
#ifndef UCIS_MAX_CODE_POINTS
|
|
|
|
# define UCIS_MAX_CODE_POINTS 3
|
|
|
|
#endif
|
2017-02-15 22:36:31 +01:00
|
|
|
|
|
|
|
typedef struct {
|
2020-06-18 09:07:34 +02:00
|
|
|
char * symbol;
|
|
|
|
uint32_t code_points[UCIS_MAX_CODE_POINTS];
|
2022-12-14 03:44:36 +01:00
|
|
|
} ucis_symbol_t;
|
2017-02-15 22:36:31 +01:00
|
|
|
|
|
|
|
typedef struct {
|
2019-08-30 20:19:03 +02:00
|
|
|
uint8_t count;
|
|
|
|
uint16_t codes[UCIS_MAX_SYMBOL_LENGTH];
|
|
|
|
bool in_progress : 1;
|
2022-12-14 03:44:36 +01:00
|
|
|
} ucis_state_t;
|
2017-02-15 22:36:31 +01:00
|
|
|
|
2022-12-14 03:44:36 +01:00
|
|
|
extern ucis_state_t ucis_state;
|
2017-02-15 22:36:31 +01:00
|
|
|
|
2020-06-18 09:07:34 +02:00
|
|
|
// clang-format off
|
|
|
|
|
|
|
|
#define UCIS_TABLE(...) \
|
|
|
|
{ \
|
|
|
|
__VA_ARGS__, \
|
|
|
|
{ NULL, {} } \
|
2019-08-30 20:19:03 +02:00
|
|
|
}
|
2020-06-18 09:07:34 +02:00
|
|
|
#define UCIS_SYM(name, ...) \
|
|
|
|
{ name, {__VA_ARGS__} }
|
|
|
|
|
|
|
|
// clang-format on
|
2017-02-15 22:36:31 +01:00
|
|
|
|
2022-12-14 03:44:36 +01:00
|
|
|
extern const ucis_symbol_t ucis_symbol_table[];
|
2017-02-15 22:36:31 +01:00
|
|
|
|
2022-12-14 03:44:36 +01:00
|
|
|
void ucis_start(void);
|
|
|
|
void ucis_start_user(void);
|
|
|
|
void ucis_symbol_fallback(void);
|
|
|
|
void ucis_success(uint8_t symbol_index);
|
2020-06-18 09:07:34 +02:00
|
|
|
|
|
|
|
void register_ucis(const uint32_t *code_points);
|
|
|
|
|
2019-08-30 20:19:03 +02:00
|
|
|
bool process_ucis(uint16_t keycode, keyrecord_t *record);
|