X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=quantum%2Fprocess_keycode%2Fprocess_unicode_common.h;h=7340800e567fec744a277d0ca24c3bbfcaed2f3b;hb=b12b26946d19830a64d9643ddf2944303ac1f6d0;hp=1f25eae7dd25e62c212d462a7738718ba0179f42;hpb=e34c3936b7db8f9d39f1eb0d0f4734fc37d7ebe3;p=qmk_firmware.git diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index 1f25eae7d..7340800e5 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -1,28 +1,89 @@ -#ifndef PROCESS_UNICODE_COMMON_H -#define PROCESS_UNICODE_COMMON_H +/* 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 . + */ + +#pragma once #include "quantum.h" -#ifndef UNICODE_TYPE_DELAY -#define UNICODE_TYPE_DELAY 10 +#if defined(UNICODE_ENABLE) + defined(UNICODEMAP_ENABLE) + defined(UCIS_ENABLE) > 1 + #error "Cannot enable more than one Unicode method (UNICODE, UNICODEMAP, UCIS) at the same time" +#endif + +// Keycodes used for starting Unicode input on different platforms +#ifndef UNICODE_KEY_OSX + #define UNICODE_KEY_OSX KC_LALT +#endif +#ifndef UNICODE_KEY_LNX + #define UNICODE_KEY_LNX LCTL(LSFT(KC_U)) +#endif +#ifndef UNICODE_KEY_WINC + #define UNICODE_KEY_WINC KC_RALT +#endif + +// 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 -static uint8_t input_mode; +// Whether input mode changes in cycle should be written to EEPROM +#ifndef UNICODE_CYCLE_PERSIST + #define UNICODE_CYCLE_PERSIST true +#endif -void set_unicode_input_mode(uint8_t os_target); +// Delay between starting Unicode input and sending a sequence, in ms +#ifndef UNICODE_TYPE_DELAY + #define UNICODE_TYPE_DELAY 10 +#endif + +enum unicode_input_modes { + UC_OSX, // Mac OS X using Unicode Hex Input + UC_LNX, // Linux using IBus + UC_WIN, // Windows using EnableHexNumpad + UC_BSD, // BSD (not implemented) + UC_WINC, // Windows using WinCompose (https://github.com/samhocevar/wincompose) + UC__COUNT // Number of available input modes (always leave at the end) +}; + +typedef union { + uint32_t raw; + struct { + uint8_t input_mode : 8; + }; +} unicode_config_t; + +extern unicode_config_t unicode_config; +extern uint8_t unicode_saved_mods; + +void unicode_input_mode_init(void); uint8_t get_unicode_input_mode(void); +void set_unicode_input_mode(uint8_t mode); +void cycle_unicode_input_mode(uint8_t offset); +void persist_unicode_input_mode(void); + void unicode_input_start(void); void unicode_input_finish(void); +void unicode_input_cancel(void); + void register_hex(uint16_t hex); +void send_unicode_hex_string(const char *str); -#define UC_OSX 0 // Mac OS X -#define UC_LNX 1 // Linux -#define UC_WIN 2 // Windows 'HexNumpad' -#define UC_BSD 3 // BSD (not implemented) -#define UC_WINC 4 // WinCompose https://github.com/samhocevar/wincompose +bool process_unicode_common(uint16_t keycode, keyrecord_t *record); #define UC_BSPC UC(0x0008) - #define UC_SPC UC(0x0020) #define UC_EXLM UC(0x0021) @@ -127,5 +188,3 @@ void register_hex(uint16_t hex); #define UC_RCBR UC(0x007D) #define UC_TILD UC(0x007E) #define UC_DEL UC(0x007F) - -#endif \ No newline at end of file