aboutsummaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2017-02-19 00:04:14 -0500
committerJack Humbert <jack.humb@gmail.com>2017-02-19 00:04:14 -0500
commitc2239e6b96fdea11d449d220db3d8bca40b38bde (patch)
tree0c2fe7df345868b56dfb3478ceb1b54a1e8eec29 /quantum
parent8d0fdf10086a0e8a1615f0521fccf1f5a2806497 (diff)
parent49e72632d2200fc3bf71d5ced2aa43058da3b2e0 (diff)
downloadqmk_firmware-c2239e6b96fdea11d449d220db3d8bca40b38bde.tar.gz
qmk_firmware-c2239e6b96fdea11d449d220db3d8bca40b38bde.zip
merging
Diffstat (limited to 'quantum')
-rw-r--r--quantum/audio/voices.c1
-rw-r--r--quantum/fauxclicky.c68
-rw-r--r--quantum/fauxclicky.h99
-rw-r--r--quantum/keymap_common.c3
-rw-r--r--quantum/keymap_extras/keymap_french.h4
-rw-r--r--quantum/process_keycode/process_ucis.c133
-rw-r--r--quantum/process_keycode/process_ucis.h35
-rw-r--r--quantum/process_keycode/process_unicode.c285
-rw-r--r--quantum/process_keycode/process_unicode.h160
-rw-r--r--quantum/process_keycode/process_unicode_common.c85
-rw-r--r--quantum/process_keycode/process_unicode_common.h132
-rw-r--r--quantum/process_keycode/process_unicodemap.c54
-rw-r--r--quantum/process_keycode/process_unicodemap.h9
-rw-r--r--quantum/quantum.c39
-rw-r--r--quantum/quantum.h10
-rw-r--r--quantum/quantum_keycodes.h23
-rw-r--r--quantum/template/rules.mk1
17 files changed, 691 insertions, 450 deletions
diff --git a/quantum/audio/voices.c b/quantum/audio/voices.c
index 8326e91ea..c2edb75f0 100644
--- a/quantum/audio/voices.c
+++ b/quantum/audio/voices.c
@@ -24,6 +24,7 @@ void voice_deiterate() {
24 24
25float voice_envelope(float frequency) { 25float voice_envelope(float frequency) {
26 // envelope_index ranges from 0 to 0xFFFF, which is preserved at 880.0 Hz 26 // envelope_index ranges from 0 to 0xFFFF, which is preserved at 880.0 Hz
27 __attribute__ ((unused))
27 uint16_t compensated_index = (uint16_t)((float)envelope_index * (880.0 / frequency)); 28 uint16_t compensated_index = (uint16_t)((float)envelope_index * (880.0 / frequency));
28 29
29 switch (voice) { 30 switch (voice) {
diff --git a/quantum/fauxclicky.c b/quantum/fauxclicky.c
new file mode 100644
index 000000000..13273e705
--- /dev/null
+++ b/quantum/fauxclicky.c
@@ -0,0 +1,68 @@
1/*
2Copyright 2017 Priyadi Iman Nurcahyo
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8This program is distributed in the hope that it will be useful,
9but WITHOUT ANY WARRANTY; without even the implied warranty of
10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11GNU General Public License for more details.
12You should have received a copy of the GNU General Public License
13along with this program. If not, see <http://www.gnu.org/licenses/>.
14*/
15
16#include <avr/interrupt.h>
17#include <avr/io.h>
18#include <timer.h>
19#include <fauxclicky.h>
20#include <stdbool.h>
21#include <musical_notes.h>
22
23__attribute__ ((weak))
24float fauxclicky_pressed_note[2] = MUSICAL_NOTE(_F3, 2);
25__attribute__ ((weak))
26float fauxclicky_released_note[2] = MUSICAL_NOTE(_A3, 2);
27__attribute__ ((weak))
28float fauxclicky_beep_note[2] = MUSICAL_NOTE(_C3, 2);
29
30bool fauxclicky_enabled = true;
31uint16_t note_start = 0;
32bool note_playing = false;
33uint16_t note_period = 0;
34
35void fauxclicky_init()
36{
37 // Set port PC6 (OC3A and /OC4A) as output
38 DDRC |= _BV(PORTC6);
39
40 // TCCR3A / TCCR3B: Timer/Counter #3 Control Registers
41 TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30);
42 TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30);
43}
44
45void fauxclicky_stop()
46{
47 FAUXCLICKY_DISABLE_OUTPUT;
48 note_playing = false;
49}
50
51void fauxclicky_play(float note[2]) {
52 if (!fauxclicky_enabled) return;
53 if (note_playing) fauxclicky_stop();
54 FAUXCLICKY_TIMER_PERIOD = (uint16_t)(((float)F_CPU) / (note[0] * FAUXCLICKY_CPU_PRESCALER));
55 FAUXCLICKY_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (note[0] * FAUXCLICKY_CPU_PRESCALER)) / 2);
56 note_playing = true;
57 note_period = (note[1] / 16) * (60 / (float)FAUXCLICKY_TEMPO) * 100; // check this
58 note_start = timer_read();
59 FAUXCLICKY_ENABLE_OUTPUT;
60}
61
62void fauxclicky_check() {
63 if (!note_playing) return;
64
65 if (timer_elapsed(note_start) > note_period) {
66 fauxclicky_stop();
67 }
68}
diff --git a/quantum/fauxclicky.h b/quantum/fauxclicky.h
new file mode 100644
index 000000000..109bd0d83
--- /dev/null
+++ b/quantum/fauxclicky.h
@@ -0,0 +1,99 @@
1/*
2Copyright 2017 Priyadi Iman Nurcahyo
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8This program is distributed in the hope that it will be useful,
9but WITHOUT ANY WARRANTY; without even the implied warranty of
10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11GNU General Public License for more details.
12You should have received a copy of the GNU General Public License
13along with this program. If not, see <http://www.gnu.org/licenses/>.
14*/
15
16#ifdef AUDIO_ENABLE
17#error "AUDIO_ENABLE and FAUXCLICKY_ENABLE cannot be both enabled"
18#endif
19
20#include "musical_notes.h"
21#include "stdbool.h"
22
23__attribute__ ((weak))
24float fauxclicky_pressed_note[2];
25__attribute__ ((weak))
26float fauxclicky_released_note[2];
27__attribute__ ((weak))
28float fauxclicky_beep_note[2];
29
30bool fauxclicky_enabled;
31
32//
33// tempo in BPM
34//
35
36#ifndef FAUXCLICKY_TEMPO
37#define FAUXCLICKY_TEMPO TEMPO_DEFAULT
38#endif
39
40// beep on press
41#define FAUXCLICKY_ACTION_PRESS fauxclicky_play(fauxclicky_pressed_note)
42
43// beep on release
44#define FAUXCLICKY_ACTION_RELEASE fauxclicky_play(fauxclicky_released_note)
45
46// general purpose beep
47#define FAUXCLICKY_BEEP fauxclicky_play(fauxclicky_beep_note)
48
49// enable
50#define FAUXCLICKY_ON fauxclicky_enabled = true
51
52// disable
53#define FAUXCLICKY_OFF do { \
54 fauxclicky_enabled = false; \
55 fauxclicky_stop(); \
56} while (0)
57
58// toggle
59#define FAUXCLICKY_TOGGLE do { \
60 if (fauxclicky_enabled) { \
61 FAUXCLICKY_OFF; \
62 } else { \
63 FAUXCLICKY_ON; \
64 } \
65} while (0)
66
67//
68// pin configuration
69//
70
71#ifndef FAUXCLICKY_CPU_PRESCALER
72#define FAUXCLICKY_CPU_PRESCALER 8
73#endif
74
75#ifndef FAUXCLICKY_ENABLE_OUTPUT
76#define FAUXCLICKY_ENABLE_OUTPUT TCCR3A |= _BV(COM3A1);
77#endif
78
79#ifndef FAUXCLICKY_DISABLE_OUTPUT
80#define FAUXCLICKY_DISABLE_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0));
81#endif
82
83#ifndef FAUXCLICKY_TIMER_PERIOD
84#define FAUXCLICKY_TIMER_PERIOD ICR3
85#endif
86
87#ifndef FAUXCLICKY_DUTY_CYCLE
88#define FAUXCLICKY_DUTY_CYCLE OCR3A
89#endif
90
91//
92// definitions
93//
94
95void fauxclicky_init(void);
96void fauxclicky_stop(void);
97void fauxclicky_play(float note[2]);
98void fauxclicky_check(void);
99
diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c
index 54b872d49..002eabd85 100644
--- a/quantum/keymap_common.c
+++ b/quantum/keymap_common.c
@@ -119,6 +119,9 @@ action_t action_for_key(uint8_t layer, keypos_t key)
119 mod = keycode & 0xFF; 119 mod = keycode & 0xFF;
120 action.code = ACTION_MODS_ONESHOT(mod); 120 action.code = ACTION_MODS_ONESHOT(mod);
121 break; 121 break;
122 case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX:
123 action.code = ACTION_LAYER_TAP_TOGGLE(keycode & 0xFF);
124 break;
122 case QK_MOD_TAP ... QK_MOD_TAP_MAX: 125 case QK_MOD_TAP ... QK_MOD_TAP_MAX:
123 action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0x1F, keycode & 0xFF); 126 action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0x1F, keycode & 0xFF);
124 break; 127 break;
diff --git a/quantum/keymap_extras/keymap_french.h b/quantum/keymap_extras/keymap_french.h
index 834c69650..401bbdf64 100644
--- a/quantum/keymap_extras/keymap_french.h
+++ b/quantum/keymap_extras/keymap_french.h
@@ -4,7 +4,9 @@
4#include "keymap.h" 4#include "keymap.h"
5 5
6// Alt gr 6// Alt gr
7#ifndef ALGR
7#define ALGR(kc) RALT(kc) 8#define ALGR(kc) RALT(kc)
9#endif
8#define NO_ALGR KC_RALT 10#define NO_ALGR KC_RALT
9 11
10// Normal characters 12// Normal characters
@@ -72,7 +74,7 @@
72#define FR_PIPE ALGR(KC_6) 74#define FR_PIPE ALGR(KC_6)
73#define FR_GRV ALGR(KC_7) 75#define FR_GRV ALGR(KC_7)
74#define FR_BSLS ALGR(KC_8) 76#define FR_BSLS ALGR(KC_8)
75#define FR_CIRC ALGR(KC_9) 77#define FR_CCIRC ALGR(KC_9)
76#define FR_AT ALGR(KC_0) 78#define FR_AT ALGR(KC_0)
77#define FR_RBRC ALGR(FR_RPRN) 79#define FR_RBRC ALGR(FR_RPRN)
78#define FR_RCBR ALGR(FR_EQL) 80#define FR_RCBR ALGR(FR_EQL)
diff --git a/quantum/process_keycode/process_ucis.c b/quantum/process_keycode/process_ucis.c
new file mode 100644
index 000000000..4ad2533b0
--- /dev/null
+++ b/quantum/process_keycode/process_ucis.c
@@ -0,0 +1,133 @@
1#include "process_ucis.h"
2
3qk_ucis_state_t qk_ucis_state;
4
5void qk_ucis_start(void) {
6 qk_ucis_state.count = 0;
7 qk_ucis_state.in_progress = true;
8
9 qk_ucis_start_user();
10}
11
12__attribute__((weak))
13void qk_ucis_start_user(void) {
14 unicode_input_start();
15 register_hex(0x2328);
16 unicode_input_finish();
17}
18
19static bool is_uni_seq(char *seq) {
20 uint8_t i;
21
22 for (i = 0; seq[i]; i++) {
23 uint16_t code;
24 if (('1' <= seq[i]) && (seq[i] <= '0'))
25 code = seq[i] - '1' + KC_1;
26 else
27 code = seq[i] - 'a' + KC_A;
28
29 if (i > qk_ucis_state.count || qk_ucis_state.codes[i] != code)
30 return false;
31 }
32
33 return (qk_ucis_state.codes[i] == KC_ENT ||
34 qk_ucis_state.codes[i] == KC_SPC);
35}
36
37__attribute__((weak))
38void qk_ucis_symbol_fallback (void) {
39 for (uint8_t i = 0; i < qk_ucis_state.count - 1; i++) {
40 uint8_t code = qk_ucis_state.codes[i];
41 register_code(code);
42 unregister_code(code);
43 wait_ms(UNICODE_TYPE_DELAY);
44 }
45}
46
47void register_ucis(const char *hex) {
48 for(int i = 0; hex[i]; i++) {
49 uint8_t kc = 0;
50 char c = hex[i];
51
52 switch (c) {
53 case '0':
54 kc = KC_0;
55 break;
56 case '1' ... '9':
57 kc = c - '1' + KC_1;
58 break;
59 case 'a' ... 'f':
60 kc = c - 'a' + KC_A;
61 break;
62 case 'A' ... 'F':
63 kc = c - 'A' + KC_A;
64 break;
65 }
66
67 if (kc) {
68 register_code (kc);
69 unregister_code (kc);
70 wait_ms (UNICODE_TYPE_DELAY);
71 }
72 }
73}
74
75bool process_ucis (uint16_t keycode, keyrecord_t *record) {
76 uint8_t i;
77
78 if (!qk_ucis_state.in_progress)
79 return true;
80
81 if (qk_ucis_state.count >= UCIS_MAX_SYMBOL_LENGTH &&
82 !(keycode == KC_BSPC || keycode == KC_ESC || keycode == KC_SPC || keycode == KC_ENT)) {
83 return false;
84 }
85
86 if (!record->event.pressed)
87 return true;
88
89 qk_ucis_state.codes[qk_ucis_state.count] = keycode;
90 qk_ucis_state.count++;
91
92 if (keycode == KC_BSPC) {
93 if (qk_ucis_state.count >= 2) {
94 qk_ucis_state.count -= 2;
95 return true;
96 } else {
97 qk_ucis_state.count--;
98 return false;
99 }
100 }
101
102 if (keycode == KC_ENT || keycode == KC_SPC || keycode == KC_ESC) {
103 bool symbol_found = false;
104
105 for (i = qk_ucis_state.count; i > 0; i--) {
106 register_code (KC_BSPC);
107 unregister_code (KC_BSPC);
108 wait_ms(UNICODE_TYPE_DELAY);
109 }
110
111 if (keycode == KC_ESC) {
112 qk_ucis_state.in_progress = false;
113 return false;
114 }
115
116 unicode_input_start();
117 for (i = 0; ucis_symbol_table[i].symbol; i++) {
118 if (is_uni_seq (ucis_symbol_table[i].symbol)) {
119 symbol_found = true;
120 register_ucis(ucis_symbol_table[i].code + 2);
121 break;
122 }
123 }
124 if (!symbol_found) {
125 qk_ucis_symbol_fallback();
126 }
127 unicode_input_finish();
128
129 qk_ucis_state.in_progress = false;
130 return false;
131 }
132 return true;
133} \ No newline at end of file
diff --git a/quantum/process_keycode/process_ucis.h b/quantum/process_keycode/process_ucis.h
new file mode 100644
index 000000000..4332f57b3
--- /dev/null
+++ b/quantum/process_keycode/process_ucis.h
@@ -0,0 +1,35 @@
1#ifndef PROCESS_UCIS_H
2#define PROCESS_UCIS_H
3
4#include "quantum.h"
5#include "process_unicode_common.h"
6
7#ifndef UCIS_MAX_SYMBOL_LENGTH
8#define UCIS_MAX_SYMBOL_LENGTH 32
9#endif
10
11typedef struct {
12 char *symbol;
13 char *code;
14} qk_ucis_symbol_t;
15
16typedef struct {
17 uint8_t count;
18 uint16_t codes[UCIS_MAX_SYMBOL_LENGTH];
19 bool in_progress:1;
20} qk_ucis_state_t;
21
22extern qk_ucis_state_t qk_ucis_state;
23
24#define UCIS_TABLE(...) {__VA_ARGS__, {NULL, NULL}}
25#define UCIS_SYM(name, code) {name, #code}
26
27extern const qk_ucis_symbol_t ucis_symbol_table[];
28
29void qk_ucis_start(void);
30void qk_ucis_start_user(void);
31void qk_ucis_symbol_fallback (void);
32void register_ucis(const char *hex);
33bool process_ucis (uint16_t keycode, keyrecord_t *record);
34
35#endif
diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c
index 9d01a592d..ccae6fdca 100644
--- a/quantum/process_keycode/process_unicode.c
+++ b/quantum/process_keycode/process_unicode.c
@@ -1,103 +1,6 @@
1#include "process_unicode.h" 1#include "process_unicode.h"
2#include "action_util.h" 2#include "action_util.h"
3 3
4static uint8_t input_mode;
5uint8_t mods;
6
7__attribute__((weak))
8uint16_t hex_to_keycode(uint8_t hex)
9{
10 if (hex == 0x0) {
11 return KC_0;
12 } else if (hex < 0xA) {
13 return KC_1 + (hex - 0x1);
14 } else {
15 return KC_A + (hex - 0xA);
16 }
17}
18
19void set_unicode_input_mode(uint8_t os_target)
20{
21 input_mode = os_target;
22}
23
24uint8_t get_unicode_input_mode(void) {
25 return input_mode;
26}
27
28__attribute__((weak))
29void unicode_input_start (void) {
30 // save current mods
31 mods = keyboard_report->mods;
32
33 // unregister all mods to start from clean state
34 if (mods & MOD_BIT(KC_LSFT)) unregister_code(KC_LSFT);
35 if (mods & MOD_BIT(KC_RSFT)) unregister_code(KC_RSFT);
36 if (mods & MOD_BIT(KC_LCTL)) unregister_code(KC_LCTL);
37 if (mods & MOD_BIT(KC_RCTL)) unregister_code(KC_RCTL);
38 if (mods & MOD_BIT(KC_LALT)) unregister_code(KC_LALT);
39 if (mods & MOD_BIT(KC_RALT)) unregister_code(KC_RALT);
40 if (mods & MOD_BIT(KC_LGUI)) unregister_code(KC_LGUI);
41 if (mods & MOD_BIT(KC_RGUI)) unregister_code(KC_RGUI);
42
43 switch(input_mode) {
44 case UC_OSX:
45 register_code(KC_LALT);
46 break;
47 case UC_LNX:
48 register_code(KC_LCTL);
49 register_code(KC_LSFT);
50 register_code(KC_U);
51 unregister_code(KC_U);
52 unregister_code(KC_LSFT);
53 unregister_code(KC_LCTL);
54 break;
55 case UC_WIN:
56 register_code(KC_LALT);
57 register_code(KC_PPLS);
58 unregister_code(KC_PPLS);
59 break;
60 case UC_WINC:
61 register_code(KC_RALT);
62 unregister_code(KC_RALT);
63 register_code(KC_U);
64 unregister_code(KC_U);
65 }
66 wait_ms(UNICODE_TYPE_DELAY);
67}
68
69__attribute__((weak))
70void unicode_input_finish (void) {
71 switch(input_mode) {
72 case UC_OSX:
73 case UC_WIN:
74 unregister_code(KC_LALT);
75 break;
76 case UC_LNX:
77 register_code(KC_SPC);
78 unregister_code(KC_SPC);
79 break;
80 }
81
82 // reregister previously set mods
83 if (mods & MOD_BIT(KC_LSFT)) register_code(KC_LSFT);
84 if (mods & MOD_BIT(KC_RSFT)) register_code(KC_RSFT);
85 if (mods & MOD_BIT(KC_LCTL)) register_code(KC_LCTL);
86 if (mods & MOD_BIT(KC_RCTL)) register_code(KC_RCTL);
87 if (mods & MOD_BIT(KC_LALT)) register_code(KC_LALT);
88 if (mods & MOD_BIT(KC_RALT)) register_code(KC_RALT);
89 if (mods & MOD_BIT(KC_LGUI)) register_code(KC_LGUI);
90 if (mods & MOD_BIT(KC_RGUI)) register_code(KC_RGUI);
91}
92
93void register_hex(uint16_t hex) {
94 for(int i = 3; i >= 0; i--) {
95 uint8_t digit = ((hex >> (i*4)) & 0xF);
96 register_code(hex_to_keycode(digit));
97 unregister_code(hex_to_keycode(digit));
98 }
99}
100
101bool process_unicode(uint16_t keycode, keyrecord_t *record) { 4bool process_unicode(uint16_t keycode, keyrecord_t *record) {
102 if (keycode > QK_UNICODE && record->event.pressed) { 5 if (keycode > QK_UNICODE && record->event.pressed) {
103 uint16_t unicode = keycode & 0x7FFF; 6 uint16_t unicode = keycode & 0x7FFF;
@@ -108,191 +11,3 @@ bool process_unicode(uint16_t keycode, keyrecord_t *record) {
108 return true; 11 return true;
109} 12}
110 13
111#ifdef UNICODEMAP_ENABLE
112__attribute__((weak))
113const uint32_t PROGMEM unicode_map[] = {
114};
115
116void register_hex32(uint32_t hex) {
117 uint8_t onzerostart = 1;
118 for(int i = 7; i >= 0; i--) {
119 if (i <= 3) {
120 onzerostart = 0;
121 }
122 uint8_t digit = ((hex >> (i*4)) & 0xF);
123 if (digit == 0) {
124 if (onzerostart == 0) {
125 register_code(hex_to_keycode(digit));
126 unregister_code(hex_to_keycode(digit));
127 }
128 } else {
129 register_code(hex_to_keycode(digit));
130 unregister_code(hex_to_keycode(digit));
131 onzerostart = 0;
132 }
133 }
134}
135
136__attribute__((weak))
137void unicode_map_input_error() {}
138
139bool process_unicode_map(uint16_t keycode, keyrecord_t *record) {
140 if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) {
141 const uint32_t* map = unicode_map;
142 uint16_t index = keycode - QK_UNICODE_MAP;
143 uint32_t code = pgm_read_dword_far(&map[index]);
144 if (code > 0xFFFF && code <= 0x10ffff && input_mode == UC_OSX) {
145 // Convert to UTF-16 surrogate pair
146 code -= 0x10000;
147 uint32_t lo = code & 0x3ff;
148 uint32_t hi = (code & 0xffc00) >> 10;
149 unicode_input_start();
150 register_hex32(hi + 0xd800);
151 register_hex32(lo + 0xdc00);
152 unicode_input_finish();
153 } else if ((code > 0x10ffff && input_mode == UC_OSX) || (code > 0xFFFFF && input_mode == UC_LNX)) {
154 // when character is out of range supported by the OS
155 unicode_map_input_error();
156 } else {
157 unicode_input_start();
158 register_hex32(code);
159 unicode_input_finish();
160 }
161 }
162 return true;
163}
164#endif
165
166#ifdef UCIS_ENABLE
167qk_ucis_state_t qk_ucis_state;
168
169void qk_ucis_start(void) {
170 qk_ucis_state.count = 0;
171 qk_ucis_state.in_progress = true;
172
173 qk_ucis_start_user();
174}
175
176__attribute__((weak))
177void qk_ucis_start_user(void) {
178 unicode_input_start();
179 register_hex(0x2328);
180 unicode_input_finish();
181}
182
183static bool is_uni_seq(char *seq) {
184 uint8_t i;
185
186 for (i = 0; seq[i]; i++) {
187 uint16_t code;
188 if (('1' <= seq[i]) && (seq[i] <= '0'))
189 code = seq[i] - '1' + KC_1;
190 else
191 code = seq[i] - 'a' + KC_A;
192
193 if (i > qk_ucis_state.count || qk_ucis_state.codes[i] != code)
194 return false;
195 }
196
197 return (qk_ucis_state.codes[i] == KC_ENT ||
198 qk_ucis_state.codes[i] == KC_SPC);
199}
200
201__attribute__((weak))
202void qk_ucis_symbol_fallback (void) {
203 for (uint8_t i = 0; i < qk_ucis_state.count - 1; i++) {
204 uint8_t code = qk_ucis_state.codes[i];
205 register_code(code);
206 unregister_code(code);
207 wait_ms(UNICODE_TYPE_DELAY);
208 }
209}
210
211void register_ucis(const char *hex) {
212 for(int i = 0; hex[i]; i++) {
213 uint8_t kc = 0;
214 char c = hex[i];
215
216 switch (c) {
217 case '0':
218 kc = KC_0;
219 break;
220 case '1' ... '9':
221 kc = c - '1' + KC_1;
222 break;
223 case 'a' ... 'f':
224 kc = c - 'a' + KC_A;
225 break;
226 case 'A' ... 'F':
227 kc = c - 'A' + KC_A;
228 break;
229 }
230
231 if (kc) {
232 register_code (kc);
233 unregister_code (kc);
234 wait_ms (UNICODE_TYPE_DELAY);
235 }
236 }
237}
238
239bool process_ucis (uint16_t keycode, keyrecord_t *record) {
240 uint8_t i;
241
242 if (!qk_ucis_state.in_progress)
243 return true;
244
245 if (qk_ucis_state.count >= UCIS_MAX_SYMBOL_LENGTH &&
246 !(keycode == KC_BSPC || keycode == KC_ESC || keycode == KC_SPC || keycode == KC_ENT)) {
247 return false;
248 }
249
250 if (!record->event.pressed)
251 return true;
252
253 qk_ucis_state.codes[qk_ucis_state.count] = keycode;
254 qk_ucis_state.count++;
255
256 if (keycode == KC_BSPC) {
257 if (qk_ucis_state.count >= 2) {
258 qk_ucis_state.count -= 2;
259 return true;
260 } else {
261 qk_ucis_state.count--;
262 return false;
263 }
264 }
265
266 if (keycode == KC_ENT || keycode == KC_SPC || keycode == KC_ESC) {
267 bool symbol_found = false;
268
269 for (i = qk_ucis_state.count; i > 0; i--) {
270 register_code (KC_BSPC);
271 unregister_code (KC_BSPC);
272 wait_ms(UNICODE_TYPE_DELAY);
273 }
274
275 if (keycode == KC_ESC) {
276 qk_ucis_state.in_progress = false;
277 return false;
278 }
279
280 unicode_input_start();
281 for (i = 0; ucis_symbol_table[i].symbol; i++) {
282 if (is_uni_seq (ucis_symbol_table[i].symbol)) {
283 symbol_found = true;
284 register_ucis(ucis_symbol_table[i].code + 2);
285 break;
286 }
287 }
288 if (!symbol_found) {
289 qk_ucis_symbol_fallback();
290 }
291 unicode_input_finish();
292
293 qk_ucis_state.in_progress = false;
294 return false;
295 }
296 return true;
297}
298#endif
diff --git a/quantum/process_keycode/process_unicode.h b/quantum/process_keycode/process_unicode.h
index f17cfa6cf..4c21f11eb 100644
--- a/quantum/process_keycode/process_unicode.h
+++ b/quantum/process_keycode/process_unicode.h
@@ -2,166 +2,8 @@
2#define PROCESS_UNICODE_H 2#define PROCESS_UNICODE_H
3 3
4#include "quantum.h" 4#include "quantum.h"
5 5#include "process_unicode_common.h"
6#define UC_OSX 0 // Mac OS X
7#define UC_LNX 1 // Linux
8#define UC_WIN 2 // Windows 'HexNumpad'
9#define UC_BSD 3 // BSD (not implemented)
10#define UC_WINC 4 // WinCompose https://github.com/samhocevar/wincompose
11
12#ifndef UNICODE_TYPE_DELAY
13#define UNICODE_TYPE_DELAY 10
14#endif
15
16void set_unicode_input_mode(uint8_t os_target);
17uint8_t get_unicode_input_mode(void);
18void unicode_input_start(void);
19void unicode_input_finish(void);
20void register_hex(uint16_t hex);
21 6
22bool process_unicode(uint16_t keycode, keyrecord_t *record); 7bool process_unicode(uint16_t keycode, keyrecord_t *record);
23 8
24#ifdef UNICODEMAP_ENABLE
25void unicode_map_input_error(void);
26bool process_unicode_map(uint16_t keycode, keyrecord_t *record);
27#endif
28
29#ifdef UCIS_ENABLE
30#ifndef UCIS_MAX_SYMBOL_LENGTH
31#define UCIS_MAX_SYMBOL_LENGTH 32
32#endif
33
34typedef struct {
35 char *symbol;
36 char *code;
37} qk_ucis_symbol_t;
38
39typedef struct {
40 uint8_t count;
41 uint16_t codes[UCIS_MAX_SYMBOL_LENGTH];
42 bool in_progress:1;
43} qk_ucis_state_t;
44
45extern qk_ucis_state_t qk_ucis_state;
46
47#define UCIS_TABLE(...) {__VA_ARGS__, {NULL, NULL}}
48#define UCIS_SYM(name, code) {name, #code}
49
50extern const qk_ucis_symbol_t ucis_symbol_table[];
51
52void qk_ucis_start(void);
53void qk_ucis_start_user(void);
54void qk_ucis_symbol_fallback (void);
55void register_ucis(const char *hex);
56bool process_ucis (uint16_t keycode, keyrecord_t *record);
57
58#endif
59
60#define UC_BSPC UC(0x0008)
61
62#define UC_SPC UC(0x0020)
63
64#define UC_EXLM UC(0x0021)
65#define UC_DQUT UC(0x0022)
66#define UC_HASH UC(0x0023)
67#define UC_DLR UC(0x0024)
68#define UC_PERC UC(0x0025)
69#define UC_AMPR UC(0x0026)
70#define UC_QUOT UC(0x0027)
71#define UC_LPRN UC(0x0028)
72#define UC_RPRN UC(0x0029)
73#define UC_ASTR UC(0x002A)
74#define UC_PLUS UC(0x002B)
75#define UC_COMM UC(0x002C)
76#define UC_DASH UC(0x002D)
77#define UC_DOT UC(0x002E)
78#define UC_SLSH UC(0x002F)
79
80#define UC_0 UC(0x0030)
81#define UC_1 UC(0x0031)
82#define UC_2 UC(0x0032)
83#define UC_3 UC(0x0033)
84#define UC_4 UC(0x0034)
85#define UC_5 UC(0x0035)
86#define UC_6 UC(0x0036)
87#define UC_7 UC(0x0037)
88#define UC_8 UC(0x0038)
89#define UC_9 UC(0x0039)
90
91#define UC_COLN UC(0x003A)
92#define UC_SCLN UC(0x003B)
93#define UC_LT UC(0x003C)
94#define UC_EQL UC(0x003D)
95#define UC_GT UC(0x003E)
96#define UC_QUES UC(0x003F)
97#define UC_AT UC(0x0040)
98
99#define UC_A UC(0x0041)
100#define UC_B UC(0x0042)
101#define UC_C UC(0x0043)
102#define UC_D UC(0x0044)
103#define UC_E UC(0x0045)
104#define UC_F UC(0x0046)
105#define UC_G UC(0x0047)
106#define UC_H UC(0x0048)
107#define UC_I UC(0x0049)
108#define UC_J UC(0x004A)
109#define UC_K UC(0x004B)
110#define UC_L UC(0x004C)
111#define UC_M UC(0x004D)
112#define UC_N UC(0x004E)
113#define UC_O UC(0x004F)
114#define UC_P UC(0x0050)
115#define UC_Q UC(0x0051)
116#define UC_R UC(0x0052)
117#define UC_S UC(0x0053)
118#define UC_T UC(0x0054)
119#define UC_U UC(0x0055)
120#define UC_V UC(0x0056)
121#define UC_W UC(0x0057)
122#define UC_X UC(0x0058)
123#define UC_Y UC(0x0059)
124#define UC_Z UC(0x005A)
125
126#define UC_LBRC UC(0x005B)
127#define UC_BSLS UC(0x005C)
128#define UC_RBRC UC(0x005D)
129#define UC_CIRM UC(0x005E)
130#define UC_UNDR UC(0x005F)
131
132#define UC_GRV UC(0x0060)
133
134#define UC_a UC(0x0061)
135#define UC_b UC(0x0062)
136#define UC_c UC(0x0063)
137#define UC_d UC(0x0064)
138#define UC_e UC(0x0065)
139#define UC_f UC(0x0066)
140#define UC_g UC(0x0067)
141#define UC_h UC(0x0068)
142#define UC_i UC(0x0069)
143#define UC_j UC(0x006A)
144#define UC_k UC(0x006B)
145#define UC_l UC(0x006C)
146#define UC_m UC(0x006D)
147#define UC_n UC(0x006E)
148#define UC_o UC(0x006F)
149#define UC_p UC(0x0070)
150#define UC_q UC(0x0071)
151#define UC_r UC(0x0072)
152#define UC_s UC(0x0073)
153#define UC_t UC(0x0074)
154#define UC_u UC(0x0075)
155#define UC_v UC(0x0076)
156#define UC_w UC(0x0077)
157#define UC_x UC(0x0078)
158#define UC_y UC(0x0079)
159#define UC_z UC(0x007A)
160
161#define UC_LCBR UC(0x007B)
162#define UC_PIPE UC(0x007C)
163#define UC_RCBR UC(0x007D)
164#define UC_TILD UC(0x007E)
165#define UC_DEL UC(0x007F)
166
167#endif 9#endif
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c
new file mode 100644
index 000000000..31bc3b7ab
--- /dev/null
+++ b/quantum/process_keycode/process_unicode_common.c
@@ -0,0 +1,85 @@
1#include "process_unicode_common.h"
2
3uint8_t mods;
4
5void set_unicode_input_mode(uint8_t os_target)
6{
7 input_mode = os_target;
8}
9
10uint8_t get_unicode_input_mode(void) {
11 return input_mode;
12}
13
14__attribute__((weak))
15void unicode_input_start (void) {
16 // save current mods
17 mods = keyboard_report->mods;
18
19 // unregister all mods to start from clean state
20 if (mods & MOD_BIT(KC_LSFT)) unregister_code(KC_LSFT);
21 if (mods & MOD_BIT(KC_RSFT)) unregister_code(KC_RSFT);
22 if (mods & MOD_BIT(KC_LCTL)) unregister_code(KC_LCTL);
23 if (mods & MOD_BIT(KC_RCTL)) unregister_code(KC_RCTL);
24 if (mods & MOD_BIT(KC_LALT)) unregister_code(KC_LALT);
25 if (mods & MOD_BIT(KC_RALT)) unregister_code(KC_RALT);
26 if (mods & MOD_BIT(KC_LGUI)) unregister_code(KC_LGUI);
27 if (mods & MOD_BIT(KC_RGUI)) unregister_code(KC_RGUI);
28
29 switch(input_mode) {
30 case UC_OSX:
31 register_code(KC_LALT);
32 break;
33 case UC_LNX:
34 register_code(KC_LCTL);
35 register_code(KC_LSFT);
36 register_code(KC_U);
37 unregister_code(KC_U);
38 unregister_code(KC_LSFT);
39 unregister_code(KC_LCTL);
40 break;
41 case UC_WIN:
42 register_code(KC_LALT);
43 register_code(KC_PPLS);
44 unregister_code(KC_PPLS);
45 break;
46 case UC_WINC:
47 register_code(KC_RALT);
48 unregister_code(KC_RALT);
49 register_code(KC_U);
50 unregister_code(KC_U);
51 }
52 wait_ms(UNICODE_TYPE_DELAY);
53}
54
55__attribute__((weak))
56void unicode_input_finish (void) {
57 switch(input_mode) {
58 case UC_OSX:
59 case UC_WIN:
60 unregister_code(KC_LALT);
61 break;
62 case UC_LNX:
63 register_code(KC_SPC);
64 unregister_code(KC_SPC);
65 break;
66 }
67
68 // reregister previously set mods
69 if (mods & MOD_BIT(KC_LSFT)) register_code(KC_LSFT);
70 if (mods & MOD_BIT(KC_RSFT)) register_code(KC_RSFT);
71 if (mods & MOD_BIT(KC_LCTL)) register_code(KC_LCTL);
72 if (mods & MOD_BIT(KC_RCTL)) register_code(KC_RCTL);
73 if (mods & MOD_BIT(KC_LALT)) register_code(KC_LALT);
74 if (mods & MOD_BIT(KC_RALT)) register_code(KC_RALT);
75 if (mods & MOD_BIT(KC_LGUI)) register_code(KC_LGUI);
76 if (mods & MOD_BIT(KC_RGUI)) register_code(KC_RGUI);
77}
78
79void register_hex(uint16_t hex) {
80 for(int i = 3; i >= 0; i--) {
81 uint8_t digit = ((hex >> (i*4)) & 0xF);
82 register_code(hex_to_keycode(digit));
83 unregister_code(hex_to_keycode(digit));
84 }
85} \ No newline at end of file
diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h
new file mode 100644
index 000000000..864693cdd
--- /dev/null
+++ b/quantum/process_keycode/process_unicode_common.h
@@ -0,0 +1,132 @@
1#ifndef PROCESS_UNICODE_COMMON_H
2#define PROCESS_UNICODE_COMMON_H
3
4#include "quantum.h"
5
6#ifndef UNICODE_TYPE_DELAY
7#define UNICODE_TYPE_DELAY 10
8#endif
9
10__attribute__ ((unused))
11static uint8_t input_mode;
12
13void set_unicode_input_mode(uint8_t os_target);
14uint8_t get_unicode_input_mode(void);
15void unicode_input_start(void);
16void unicode_input_finish(void);
17void register_hex(uint16_t hex);
18
19#define UC_OSX 0 // Mac OS X
20#define UC_LNX 1 // Linux
21#define UC_WIN 2 // Windows 'HexNumpad'
22#define UC_BSD 3 // BSD (not implemented)
23#define UC_WINC 4 // WinCompose https://github.com/samhocevar/wincompose
24
25#define UC_BSPC UC(0x0008)
26
27#define UC_SPC UC(0x0020)
28
29#define UC_EXLM UC(0x0021)
30#define UC_DQUT UC(0x0022)
31#define UC_HASH UC(0x0023)
32#define UC_DLR UC(0x0024)
33#define UC_PERC UC(0x0025)
34#define UC_AMPR UC(0x0026)
35#define UC_QUOT UC(0x0027)
36#define UC_LPRN UC(0x0028)
37#define UC_RPRN UC(0x0029)
38#define UC_ASTR UC(0x002A)
39#define UC_PLUS UC(0x002B)
40#define UC_COMM UC(0x002C)
41#define UC_DASH UC(0x002D)
42#define UC_DOT UC(0x002E)
43#define UC_SLSH UC(0x002F)
44
45#define UC_0 UC(0x0030)
46#define UC_1 UC(0x0031)
47#define UC_2 UC(0x0032)
48#define UC_3 UC(0x0033)
49#define UC_4 UC(0x0034)
50#define UC_5 UC(0x0035)
51#define UC_6 UC(0x0036)
52#define UC_7 UC(0x0037)
53#define UC_8 UC(0x0038)
54#define UC_9 UC(0x0039)
55
56#define UC_COLN UC(0x003A)
57#define UC_SCLN UC(0x003B)
58#define UC_LT UC(0x003C)
59#define UC_EQL UC(0x003D)
60#define UC_GT UC(0x003E)
61#define UC_QUES UC(0x003F)
62#define UC_AT UC(0x0040)
63
64#define UC_A UC(0x0041)
65#define UC_B UC(0x0042)
66#define UC_C UC(0x0043)
67#define UC_D UC(0x0044)
68#define UC_E UC(0x0045)
69#define UC_F UC(0x0046)
70#define UC_G UC(0x0047)
71#define UC_H UC(0x0048)
72#define UC_I UC(0x0049)
73#define UC_J UC(0x004A)
74#define UC_K UC(0x004B)
75#define UC_L UC(0x004C)
76#define UC_M UC(0x004D)
77#define UC_N UC(0x004E)
78#define UC_O UC(0x004F)
79#define UC_P UC(0x0050)
80#define UC_Q UC(0x0051)
81#define UC_R UC(0x0052)
82#define UC_S UC(0x0053)
83#define UC_T UC(0x0054)
84#define UC_U UC(0x0055)
85#define UC_V UC(0x0056)
86#define UC_W UC(0x0057)
87#define UC_X UC(0x0058)
88#define UC_Y UC(0x0059)
89#define UC_Z UC(0x005A)
90
91#define UC_LBRC UC(0x005B)
92#define UC_BSLS UC(0x005C)
93#define UC_RBRC UC(0x005D)
94#define UC_CIRM UC(0x005E)
95#define UC_UNDR UC(0x005F)
96
97#define UC_GRV UC(0x0060)
98
99#define UC_a UC(0x0061)
100#define UC_b UC(0x0062)
101#define UC_c UC(0x0063)
102#define UC_d UC(0x0064)
103#define UC_e UC(0x0065)
104#define UC_f UC(0x0066)
105#define UC_g UC(0x0067)
106#define UC_h UC(0x0068)
107#define UC_i UC(0x0069)
108#define UC_j UC(0x006A)
109#define UC_k UC(0x006B)
110#define UC_l UC(0x006C)
111#define UC_m UC(0x006D)
112#define UC_n UC(0x006E)
113#define UC_o UC(0x006F)
114#define UC_p UC(0x0070)
115#define UC_q UC(0x0071)
116#define UC_r UC(0x0072)
117#define UC_s UC(0x0073)
118#define UC_t UC(0x0074)
119#define UC_u UC(0x0075)
120#define UC_v UC(0x0076)
121#define UC_w UC(0x0077)
122#define UC_x UC(0x0078)
123#define UC_y UC(0x0079)
124#define UC_z UC(0x007A)
125
126#define UC_LCBR UC(0x007B)
127#define UC_PIPE UC(0x007C)
128#define UC_RCBR UC(0x007D)
129#define UC_TILD UC(0x007E)
130#define UC_DEL UC(0x007F)
131
132#endif \ No newline at end of file
diff --git a/quantum/process_keycode/process_unicodemap.c b/quantum/process_keycode/process_unicodemap.c
new file mode 100644
index 000000000..37f10df86
--- /dev/null
+++ b/quantum/process_keycode/process_unicodemap.c
@@ -0,0 +1,54 @@
1#include "process_unicodemap.h"
2
3__attribute__((weak))
4const uint32_t PROGMEM unicode_map[] = {
5};
6
7void register_hex32(uint32_t hex) {
8 uint8_t onzerostart = 1;
9 for(int i = 7; i >= 0; i--) {
10 if (i <= 3) {
11 onzerostart = 0;
12 }
13 uint8_t digit = ((hex >> (i*4)) & 0xF);
14 if (digit == 0) {
15 if (onzerostart == 0) {
16 register_code(hex_to_keycode(digit));
17 unregister_code(hex_to_keycode(digit));
18 }
19 } else {
20 register_code(hex_to_keycode(digit));
21 unregister_code(hex_to_keycode(digit));
22 onzerostart = 0;
23 }
24 }
25}
26
27__attribute__((weak))
28void unicode_map_input_error() {}
29
30bool process_unicode_map(uint16_t keycode, keyrecord_t *record) {
31 if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) {
32 const uint32_t* map = unicode_map;
33 uint16_t index = keycode - QK_UNICODE_MAP;
34 uint32_t code = pgm_read_dword_far(&map[index]);
35 if (code > 0xFFFF && code <= 0x10ffff && input_mode == UC_OSX) {
36 // Convert to UTF-16 surrogate pair
37 code -= 0x10000;
38 uint32_t lo = code & 0x3ff;
39 uint32_t hi = (code & 0xffc00) >> 10;
40 unicode_input_start();
41 register_hex32(hi + 0xd800);
42 register_hex32(lo + 0xdc00);
43 unicode_input_finish();
44 } else if ((code > 0x10ffff && input_mode == UC_OSX) || (code > 0xFFFFF && input_mode == UC_LNX)) {
45 // when character is out of range supported by the OS
46 unicode_map_input_error();
47 } else {
48 unicode_input_start();
49 register_hex32(code);
50 unicode_input_finish();
51 }
52 }
53 return true;
54} \ No newline at end of file
diff --git a/quantum/process_keycode/process_unicodemap.h b/quantum/process_keycode/process_unicodemap.h
new file mode 100644
index 000000000..64a7a0109
--- /dev/null
+++ b/quantum/process_keycode/process_unicodemap.h
@@ -0,0 +1,9 @@
1#ifndef PROCESS_UNICODEMAP_H
2#define PROCESS_UNICODEMAP_H
3
4#include "quantum.h"
5#include "process_unicode_common.h"
6
7void unicode_map_input_error(void);
8bool process_unicode_map(uint16_t keycode, keyrecord_t *record);
9#endif \ No newline at end of file
diff --git a/quantum/quantum.c b/quantum/quantum.c
index 95f06d95d..761ba37f3 100644
--- a/quantum/quantum.c
+++ b/quantum/quantum.c
@@ -7,8 +7,14 @@
7#define TAPPING_TERM 200 7#define TAPPING_TERM 200
8#endif 8#endif
9 9
10<<<<<<< HEAD
10#include "backlight.h" 11#include "backlight.h"
11extern backlight_config_t backlight_config; 12extern backlight_config_t backlight_config;
13=======
14#ifdef FAUXCLICKY_ENABLE
15#include "fauxclicky.h"
16#endif
17>>>>>>> 49e72632d2200fc3bf71d5ced2aa43058da3b2e0
12 18
13static void do_code16 (uint16_t code, void (*f) (uint8_t)) { 19static void do_code16 (uint16_t code, void (*f) (uint8_t)) {
14 switch (code) { 20 switch (code) {
@@ -199,6 +205,26 @@ bool process_record_quantum(keyrecord_t *record) {
199 } 205 }
200 return false; 206 return false;
201 break; 207 break;
208 #ifdef FAUXCLICKY_ENABLE
209 case FC_TOG:
210 if (record->event.pressed) {
211 FAUXCLICKY_TOGGLE;
212 }
213 return false;
214 break;
215 case FC_ON:
216 if (record->event.pressed) {
217 FAUXCLICKY_ON;
218 }
219 return false;
220 break;
221 case FC_OFF:
222 if (record->event.pressed) {
223 FAUXCLICKY_OFF;
224 }
225 return false;
226 break;
227 #endif
202 #ifdef RGBLIGHT_ENABLE 228 #ifdef RGBLIGHT_ENABLE
203 case RGB_TOG: 229 case RGB_TOG:
204 if (record->event.pressed) { 230 if (record->event.pressed) {
@@ -979,6 +1005,19 @@ void send_nibble(uint8_t number) {
979 } 1005 }
980} 1006}
981 1007
1008
1009__attribute__((weak))
1010uint16_t hex_to_keycode(uint8_t hex)
1011{
1012 if (hex == 0x0) {
1013 return KC_0;
1014 } else if (hex < 0xA) {
1015 return KC_1 + (hex - 0x1);
1016 } else {
1017 return KC_A + (hex - 0xA);
1018 }
1019}
1020
982void api_send_unicode(uint32_t unicode) { 1021void api_send_unicode(uint32_t unicode) {
983#ifdef API_ENABLE 1022#ifdef API_ENABLE
984 uint8_t chunk[4]; 1023 uint8_t chunk[4];
diff --git a/quantum/quantum.h b/quantum/quantum.h
index 2470d8c7d..259bac369 100644
--- a/quantum/quantum.h
+++ b/quantum/quantum.h
@@ -56,6 +56,14 @@ extern uint32_t default_layer_state;
56 #include "process_unicode.h" 56 #include "process_unicode.h"
57#endif 57#endif
58 58
59#ifdef UCIS_ENABLE
60 #include "process_ucis.h"
61#endif
62
63#ifdef UNICODEMAP_ENABLE
64 #include "process_unicodemap.h"
65#endif
66
59#include "process_tap_dance.h" 67#include "process_tap_dance.h"
60 68
61#ifdef PRINTING_ENABLE 69#ifdef PRINTING_ENABLE
@@ -118,7 +126,7 @@ void send_dword(uint32_t number);
118void send_word(uint16_t number); 126void send_word(uint16_t number);
119void send_byte(uint8_t number); 127void send_byte(uint8_t number);
120void send_nibble(uint8_t number); 128void send_nibble(uint8_t number);
121 129uint16_t hex_to_keycode(uint8_t hex);
122 130
123void led_set_user(uint8_t usb_led); 131void led_set_user(uint8_t usb_led);
124void led_set_kb(uint8_t usb_led); 132void led_set_kb(uint8_t usb_led);
diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h
index ab2e79026..63b626926 100644
--- a/quantum/quantum_keycodes.h
+++ b/quantum/quantum_keycodes.h
@@ -41,16 +41,21 @@ enum quantum_keycodes {
41#endif 41#endif
42 QK_TAP_DANCE = 0x5700, 42 QK_TAP_DANCE = 0x5700,
43 QK_TAP_DANCE_MAX = 0x57FF, 43 QK_TAP_DANCE_MAX = 0x57FF,
44#ifdef UNICODEMAP_ENABLE 44 QK_LAYER_TAP_TOGGLE = 0x5800,
45 QK_UNICODE_MAP = 0x5800, 45 QK_LAYER_TAP_TOGGLE_MAX = 0x58FF,
46 QK_UNICODE_MAP_MAX = 0x5BFF,
47#endif
48 QK_MOD_TAP = 0x6000, 46 QK_MOD_TAP = 0x6000,
49 QK_MOD_TAP_MAX = 0x7FFF, 47 QK_MOD_TAP_MAX = 0x7FFF,
48#if defined(UNICODEMAP_ENABLE) && defined(UNICODE_ENABLE)
49 #error "Cannot enable both UNICODEMAP && UNICODE"
50#endif
50#ifdef UNICODE_ENABLE 51#ifdef UNICODE_ENABLE
51 QK_UNICODE = 0x8000, 52 QK_UNICODE = 0x8000,
52 QK_UNICODE_MAX = 0xFFFF, 53 QK_UNICODE_MAX = 0xFFFF,
53#endif 54#endif
55#ifdef UNICODEMAP_ENABLE
56 QK_UNICODE_MAP = 0x8000,
57 QK_UNICODE_MAP_MAX = 0x83FF,
58#endif
54 59
55 // Loose keycodes - to be used directly 60 // Loose keycodes - to be used directly
56 61
@@ -86,6 +91,13 @@ enum quantum_keycodes {
86 AU_OFF, 91 AU_OFF,
87 AU_TOG, 92 AU_TOG,
88 93
94#ifdef FAUXCLICKY_ENABLE
95 // Faux clicky
96 FC_ON,
97 FC_OFF,
98 FC_TOG,
99#endif
100
89 // Music mode on/off/toggle 101 // Music mode on/off/toggle
90 MU_ON, 102 MU_ON,
91 MU_OFF, 103 MU_OFF,
@@ -297,6 +309,9 @@ enum quantum_keycodes {
297// One-shot mod 309// One-shot mod
298#define OSM(mod) (mod | QK_ONE_SHOT_MOD) 310#define OSM(mod) (mod | QK_ONE_SHOT_MOD)
299 311
312// Layer tap-toggle
313#define TT(layer) (layer | QK_LAYER_TAP_TOGGLE)
314
300// M-od, T-ap - 256 keycode max 315// M-od, T-ap - 256 keycode max
301#define MT(mod, kc) (kc | QK_MOD_TAP | ((mod & 0x1F) << 8)) 316#define MT(mod, kc) (kc | QK_MOD_TAP | ((mod & 0x1F) << 8))
302 317
diff --git a/quantum/template/rules.mk b/quantum/template/rules.mk
index 55898147d..bad3387bf 100644
--- a/quantum/template/rules.mk
+++ b/quantum/template/rules.mk
@@ -65,3 +65,4 @@ MIDI_ENABLE ?= no # MIDI controls
65UNICODE_ENABLE ?= no # Unicode 65UNICODE_ENABLE ?= no # Unicode
66BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID 66BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID
67AUDIO_ENABLE ?= no # Audio output on port C6 67AUDIO_ENABLE ?= no # Audio output on port C6
68FAUXCLICKY_ENABLE ?= no # Use buzzer to emulate clicky switches