diff options
| author | Stick <nstickney@gmail.com> | 2017-04-03 16:59:27 -0500 |
|---|---|---|
| committer | Stick <nstickney@gmail.com> | 2017-04-03 16:59:27 -0500 |
| commit | bee9183e7fae7c739b9c42dd4dc759783ac80e46 (patch) | |
| tree | 690f17486c2e57175bbd36152d685ebedc7c9439 /quantum/process_keycode/process_unicode_common.c | |
| parent | b6280d0cac59c741db62a63072efd5de4887fc01 (diff) | |
| parent | 3ac9259742bfd428f71c31dbf2bfedace2a7f91b (diff) | |
| download | qmk_firmware-bee9183e7fae7c739b9c42dd4dc759783ac80e46.tar.gz qmk_firmware-bee9183e7fae7c739b9c42dd4dc759783ac80e46.zip | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'quantum/process_keycode/process_unicode_common.c')
| -rw-r--r-- | quantum/process_keycode/process_unicode_common.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 31bc3b7ab..1dbdec3e7 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c | |||
| @@ -1,10 +1,28 @@ | |||
| 1 | /* Copyright 2017 Jack Humbert | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #include "process_unicode_common.h" | 17 | #include "process_unicode_common.h" |
| 2 | 18 | ||
| 19 | static uint8_t input_mode; | ||
| 3 | uint8_t mods; | 20 | uint8_t mods; |
| 4 | 21 | ||
| 5 | void set_unicode_input_mode(uint8_t os_target) | 22 | void set_unicode_input_mode(uint8_t os_target) |
| 6 | { | 23 | { |
| 7 | input_mode = os_target; | 24 | input_mode = os_target; |
| 25 | eeprom_update_byte(EECONFIG_UNICODEMODE, os_target); | ||
| 8 | } | 26 | } |
| 9 | 27 | ||
| 10 | uint8_t get_unicode_input_mode(void) { | 28 | uint8_t get_unicode_input_mode(void) { |
| @@ -76,10 +94,22 @@ void unicode_input_finish (void) { | |||
| 76 | if (mods & MOD_BIT(KC_RGUI)) register_code(KC_RGUI); | 94 | if (mods & MOD_BIT(KC_RGUI)) register_code(KC_RGUI); |
| 77 | } | 95 | } |
| 78 | 96 | ||
| 97 | __attribute__((weak)) | ||
| 98 | uint16_t hex_to_keycode(uint8_t hex) | ||
| 99 | { | ||
| 100 | if (hex == 0x0) { | ||
| 101 | return KC_0; | ||
| 102 | } else if (hex < 0xA) { | ||
| 103 | return KC_1 + (hex - 0x1); | ||
| 104 | } else { | ||
| 105 | return KC_A + (hex - 0xA); | ||
| 106 | } | ||
| 107 | } | ||
| 108 | |||
| 79 | void register_hex(uint16_t hex) { | 109 | void register_hex(uint16_t hex) { |
| 80 | for(int i = 3; i >= 0; i--) { | 110 | for(int i = 3; i >= 0; i--) { |
| 81 | uint8_t digit = ((hex >> (i*4)) & 0xF); | 111 | uint8_t digit = ((hex >> (i*4)) & 0xF); |
| 82 | register_code(hex_to_keycode(digit)); | 112 | register_code(hex_to_keycode(digit)); |
| 83 | unregister_code(hex_to_keycode(digit)); | 113 | unregister_code(hex_to_keycode(digit)); |
| 84 | } | 114 | } |
| 85 | } \ No newline at end of file | 115 | } |
