diff options
author | IBNobody <IBNobody@users.noreply.github.com> | 2016-09-06 23:19:01 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-06 23:19:01 -0500 |
commit | 558f3ec1eb325caf706efc15e2fab26121aba442 (patch) | |
tree | a14b00c189492426beadc69c2094055f833b811f | |
parent | f0388a5b1334ce0b8c8a359a0a8a1460e456b8c5 (diff) | |
download | qmk_firmware-558f3ec1eb325caf706efc15e2fab26121aba442.tar.gz qmk_firmware-558f3ec1eb325caf706efc15e2fab26121aba442.zip |
Use keyboard config for nkro (#7)
* removing nkro references - wip
* changed NKRO to be defined by keymap_config
-rw-r--r-- | keyboards/planck/keymaps/pvc/Makefile | 4 | ||||
-rw-r--r-- | keyboards/planck/keymaps/pvc/keymap.c | 5 | ||||
-rw-r--r-- | quantum/keycode_config.h | 5 | ||||
-rw-r--r-- | quantum/keymap.h | 1 | ||||
-rw-r--r-- | quantum/quantum.c | 124 | ||||
-rw-r--r-- | tmk_core/common/action_util.c | 10 | ||||
-rw-r--r-- | tmk_core/common/bootmagic.c | 4 | ||||
-rw-r--r-- | tmk_core/common/command.c | 6 | ||||
-rw-r--r-- | tmk_core/common/host.c | 5 | ||||
-rw-r--r-- | tmk_core/common/host.h | 4 | ||||
-rw-r--r-- | tmk_core/common/keyboard.c | 4 | ||||
-rw-r--r-- | tmk_core/common/magic.c | 4 | ||||
-rw-r--r-- | tmk_core/protocol/chibios/usb_main.c | 19 | ||||
-rw-r--r-- | tmk_core/protocol/lufa/lufa.c | 9 | ||||
-rw-r--r-- | tmk_core/protocol/pjrc/usb.c | 18 | ||||
-rw-r--r-- | tmk_core/protocol/pjrc/usb_keyboard.c | 8 | ||||
-rw-r--r-- | tmk_core/readme.md | 2 |
17 files changed, 131 insertions, 101 deletions
diff --git a/keyboards/planck/keymaps/pvc/Makefile b/keyboards/planck/keymaps/pvc/Makefile index 0b2f060de..19c3abc6c 100644 --- a/keyboards/planck/keymaps/pvc/Makefile +++ b/keyboards/planck/keymaps/pvc/Makefile | |||
@@ -1,9 +1,9 @@ | |||
1 | 1 | ||
2 | # Build Options | 2 | # Build Options |
3 | # change to "no" to disable the options, or define them in the Makefile in | 3 | # change to "no" to disable the options, or define them in the Makefile in |
4 | # the appropriate keymap folder that will get included automatically | 4 | # the appropriate keymap folder that will get included automatically |
5 | # | 5 | # |
6 | BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) | 6 | BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) |
7 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) | 7 | MOUSEKEY_ENABLE = yes # Mouse keys(+4700) |
8 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) | 8 | EXTRAKEY_ENABLE = yes # Audio control and System control(+450) |
9 | CONSOLE_ENABLE = no # Console for debug(+400) | 9 | CONSOLE_ENABLE = no # Console for debug(+400) |
diff --git a/keyboards/planck/keymaps/pvc/keymap.c b/keyboards/planck/keymaps/pvc/keymap.c index 8ff40f377..23aedfc99 100644 --- a/keyboards/planck/keymaps/pvc/keymap.c +++ b/keyboards/planck/keymaps/pvc/keymap.c | |||
@@ -83,6 +83,7 @@ enum keyboard_macros { | |||
83 | #define SC_ACLS LALT(KC_F4) | 83 | #define SC_ACLS LALT(KC_F4) |
84 | #define SC_CCLS LCTL(KC_F4) | 84 | #define SC_CCLS LCTL(KC_F4) |
85 | 85 | ||
86 | #define TG_NKRO MAGIC_TOGGLE_NKRO | ||
86 | #define OS_SHFT KC_FN0 | 87 | #define OS_SHFT KC_FN0 |
87 | 88 | ||
88 | #define _______ KC_TRNS | 89 | #define _______ KC_TRNS |
@@ -206,7 +207,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
206 | [LAYER_ADJUST] = { | 207 | [LAYER_ADJUST] = { |
207 | { XXXXXXX, M_BRTOG, M_BSPDU, M_BSPDD, M_BDFLT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, MU_TOG , AU_TOG }, | 208 | { XXXXXXX, M_BRTOG, M_BSPDU, M_BSPDD, M_BDFLT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, MU_TOG , AU_TOG }, |
208 | { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX }, | 209 | { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX }, |
209 | { XXXXXXX, M_QWRTY, XXXXXXX, XXXXXXX, M_BACKL, RESET , XXXXXXX, M_MOUSE, XXXXXXX, XXXXXXX, MUV_IN , XXXXXXX }, | 210 | { XXXXXXX, M_QWRTY, XXXXXXX, XXXXXXX, M_BACKL, RESET , TG_NKRO, M_MOUSE, XXXXXXX, XXXXXXX, MUV_IN , XXXXXXX }, |
210 | { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, M_UPPER, XXXXXXX, XXXXXXX, M_LOWER, XXXXXXX, TMPO_DN, MUV_DE , TMPO_UP } | 211 | { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, M_UPPER, XXXXXXX, XXXXXXX, M_LOWER, XXXXXXX, TMPO_DN, MUV_DE , TMPO_UP } |
211 | }, | 212 | }, |
212 | 213 | ||
@@ -236,7 +237,7 @@ void persistant_default_layer_set(uint16_t default_layer) | |||
236 | } | 237 | } |
237 | 238 | ||
238 | const uint16_t PROGMEM fn_actions[] = { | 239 | const uint16_t PROGMEM fn_actions[] = { |
239 | [0] = ACTION_MODS_ONESHOT(MOD_LSFT), | 240 | [0] = ACTION_MODS_ONESHOT(MOD_RSFT), |
240 | }; | 241 | }; |
241 | 242 | ||
242 | const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | 243 | const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) |
diff --git a/quantum/keycode_config.h b/quantum/keycode_config.h index 6216eefc9..c15b0d32f 100644 --- a/quantum/keycode_config.h +++ b/quantum/keycode_config.h | |||
@@ -1,6 +1,9 @@ | |||
1 | #include "eeconfig.h" | 1 | #include "eeconfig.h" |
2 | #include "keycode.h" | 2 | #include "keycode.h" |
3 | 3 | ||
4 | #ifndef KEYCODE_CONFIG_H | ||
5 | #define KEYCODE_CONFIG_H | ||
6 | |||
4 | uint16_t keycode_config(uint16_t keycode); | 7 | uint16_t keycode_config(uint16_t keycode); |
5 | 8 | ||
6 | /* NOTE: Not portable. Bit field order depends on implementation */ | 9 | /* NOTE: Not portable. Bit field order depends on implementation */ |
@@ -19,3 +22,5 @@ typedef union { | |||
19 | } keymap_config_t; | 22 | } keymap_config_t; |
20 | 23 | ||
21 | extern keymap_config_t keymap_config; | 24 | extern keymap_config_t keymap_config; |
25 | |||
26 | #endif /* KEYCODE_CONFIG_H */ | ||
diff --git a/quantum/keymap.h b/quantum/keymap.h index f2d94d75c..98ddfd0c5 100644 --- a/quantum/keymap.h +++ b/quantum/keymap.h | |||
@@ -111,6 +111,7 @@ enum quantum_keycodes { | |||
111 | MAGIC_UNSWAP_BACKSLASH_BACKSPACE, | 111 | MAGIC_UNSWAP_BACKSLASH_BACKSPACE, |
112 | MAGIC_UNHOST_NKRO, | 112 | MAGIC_UNHOST_NKRO, |
113 | MAGIC_UNSWAP_ALT_GUI, | 113 | MAGIC_UNSWAP_ALT_GUI, |
114 | MAGIC_TOGGLE_NKRO, | ||
114 | 115 | ||
115 | // Leader key | 116 | // Leader key |
116 | #ifndef DISABLE_LEADER | 117 | #ifndef DISABLE_LEADER |
diff --git a/quantum/quantum.c b/quantum/quantum.c index fa86b6220..a16bd5443 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
@@ -27,10 +27,6 @@ static void do_code16 (uint16_t code, void (*f) (uint8_t)) { | |||
27 | f(KC_RGUI); | 27 | f(KC_RGUI); |
28 | } | 28 | } |
29 | 29 | ||
30 | #ifdef NKRO_ENABLE | ||
31 | extern bool keyboard_nkro; | ||
32 | #endif | ||
33 | |||
34 | void register_code16 (uint16_t code) { | 30 | void register_code16 (uint16_t code) { |
35 | do_code16 (code, register_code); | 31 | do_code16 (code, register_code); |
36 | register_code (code); | 32 | register_code (code); |
@@ -203,7 +199,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
203 | return false; | 199 | return false; |
204 | break; | 200 | break; |
205 | #endif | 201 | #endif |
206 | case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_UNSWAP_ALT_GUI: | 202 | case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO: |
207 | if (record->event.pressed) { | 203 | if (record->event.pressed) { |
208 | // MAGIC actions (BOOTMAGIC without the boot) | 204 | // MAGIC actions (BOOTMAGIC without the boot) |
209 | if (!eeconfig_is_enabled()) { | 205 | if (!eeconfig_is_enabled()) { |
@@ -211,57 +207,73 @@ bool process_record_quantum(keyrecord_t *record) { | |||
211 | } | 207 | } |
212 | /* keymap config */ | 208 | /* keymap config */ |
213 | keymap_config.raw = eeconfig_read_keymap(); | 209 | keymap_config.raw = eeconfig_read_keymap(); |
214 | if (keycode == MAGIC_SWAP_CONTROL_CAPSLOCK) { | 210 | switch (keycode) |
215 | keymap_config.swap_control_capslock = 1; | 211 | { |
216 | } else if (keycode == MAGIC_CAPSLOCK_TO_CONTROL) { | 212 | case MAGIC_SWAP_CONTROL_CAPSLOCK: |
217 | keymap_config.capslock_to_control = 1; | 213 | keymap_config.swap_control_capslock = true; |
218 | } else if (keycode == MAGIC_SWAP_LALT_LGUI) { | 214 | break; |
219 | keymap_config.swap_lalt_lgui = 1; | 215 | case MAGIC_CAPSLOCK_TO_CONTROL: |
220 | } else if (keycode == MAGIC_SWAP_RALT_RGUI) { | 216 | keymap_config.capslock_to_control = true; |
221 | keymap_config.swap_ralt_rgui = 1; | 217 | break; |
222 | } else if (keycode == MAGIC_NO_GUI) { | 218 | case MAGIC_SWAP_LALT_LGUI: |
223 | keymap_config.no_gui = 1; | 219 | keymap_config.swap_lalt_lgui = true; |
224 | } else if (keycode == MAGIC_SWAP_GRAVE_ESC) { | 220 | break; |
225 | keymap_config.swap_grave_esc = 1; | 221 | case MAGIC_SWAP_RALT_RGUI: |
226 | } else if (keycode == MAGIC_SWAP_BACKSLASH_BACKSPACE) { | 222 | keymap_config.swap_ralt_rgui = true; |
227 | keymap_config.swap_backslash_backspace = 1; | 223 | break; |
228 | } else if (keycode == MAGIC_HOST_NKRO) { | 224 | case MAGIC_NO_GUI: |
229 | keymap_config.nkro = 1; | 225 | keymap_config.no_gui = true; |
230 | 226 | break; | |
231 | #ifdef NKRO_ENABLE | 227 | case MAGIC_SWAP_GRAVE_ESC: |
232 | clear_keyboard(); // clear to prevent stuck keys | 228 | keymap_config.swap_grave_esc = true; |
233 | keyboard_nkro = keymap_config.nkro; | 229 | break; |
234 | #endif | 230 | case MAGIC_SWAP_BACKSLASH_BACKSPACE: |
235 | } else if (keycode == MAGIC_SWAP_ALT_GUI) { | 231 | keymap_config.swap_backslash_backspace = true; |
236 | keymap_config.swap_lalt_lgui = 1; | 232 | break; |
237 | keymap_config.swap_ralt_rgui = 1; | 233 | case MAGIC_HOST_NKRO: |
238 | } | 234 | keymap_config.nkro = true; |
239 | /* UNs */ | 235 | break; |
240 | else if (keycode == MAGIC_UNSWAP_CONTROL_CAPSLOCK) { | 236 | case MAGIC_SWAP_ALT_GUI: |
241 | keymap_config.swap_control_capslock = 0; | 237 | keymap_config.swap_lalt_lgui = true; |
242 | } else if (keycode == MAGIC_UNCAPSLOCK_TO_CONTROL) { | 238 | keymap_config.swap_ralt_rgui = true; |
243 | keymap_config.capslock_to_control = 0; | 239 | break; |
244 | } else if (keycode == MAGIC_UNSWAP_LALT_LGUI) { | 240 | case MAGIC_UNSWAP_CONTROL_CAPSLOCK: |
245 | keymap_config.swap_lalt_lgui = 0; | 241 | keymap_config.swap_control_capslock = false; |
246 | } else if (keycode == MAGIC_UNSWAP_RALT_RGUI) { | 242 | break; |
247 | keymap_config.swap_ralt_rgui = 0; | 243 | case MAGIC_UNCAPSLOCK_TO_CONTROL: |
248 | } else if (keycode == MAGIC_UNNO_GUI) { | 244 | keymap_config.capslock_to_control = false; |
249 | keymap_config.no_gui = 0; | 245 | break; |
250 | } else if (keycode == MAGIC_UNSWAP_GRAVE_ESC) { | 246 | case MAGIC_UNSWAP_LALT_LGUI: |
251 | keymap_config.swap_grave_esc = 0; | 247 | keymap_config.swap_lalt_lgui = false; |
252 | } else if (keycode == MAGIC_UNSWAP_BACKSLASH_BACKSPACE) { | 248 | break; |
253 | keymap_config.swap_backslash_backspace = 0; | 249 | case MAGIC_UNSWAP_RALT_RGUI: |
254 | } else if (keycode == MAGIC_UNHOST_NKRO) { | 250 | keymap_config.swap_ralt_rgui = false; |
255 | keymap_config.nkro = 0; | 251 | break; |
256 | #ifdef NKRO_ENABLE | 252 | case MAGIC_UNNO_GUI: |
257 | clear_keyboard(); // clear to prevent stuck keys | 253 | keymap_config.no_gui = false; |
258 | keyboard_nkro = keymap_config.nkro; | 254 | break; |
259 | #endif | 255 | case MAGIC_UNSWAP_GRAVE_ESC: |
260 | } else if (keycode == MAGIC_UNSWAP_ALT_GUI) { | 256 | keymap_config.swap_grave_esc = false; |
261 | keymap_config.swap_lalt_lgui = 0; | 257 | break; |
262 | keymap_config.swap_ralt_rgui = 0; | 258 | case MAGIC_UNSWAP_BACKSLASH_BACKSPACE: |
259 | keymap_config.swap_backslash_backspace = false; | ||
260 | break; | ||
261 | case MAGIC_UNHOST_NKRO: | ||
262 | keymap_config.nkro = false; | ||
263 | break; | ||
264 | case MAGIC_UNSWAP_ALT_GUI: | ||
265 | keymap_config.swap_lalt_lgui = false; | ||
266 | keymap_config.swap_ralt_rgui = false; | ||
267 | break; | ||
268 | case MAGIC_TOGGLE_NKRO: | ||
269 | keymap_config.nkro = !keymap_config.nkro; | ||
270 | break; | ||
271 | default: | ||
272 | break; | ||
263 | } | 273 | } |
264 | eeconfig_update_keymap(keymap_config.raw); | 274 | eeconfig_update_keymap(keymap_config.raw); |
275 | clear_keyboard(); // clear to prevent stuck keys | ||
276 | |||
265 | return false; | 277 | return false; |
266 | } | 278 | } |
267 | break; | 279 | break; |
@@ -284,7 +296,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
284 | unregister_mods(MOD_BIT(KC_LSFT)); | 296 | unregister_mods(MOD_BIT(KC_LSFT)); |
285 | } | 297 | } |
286 | return false; | 298 | return false; |
287 | break; | 299 | // break; |
288 | } | 300 | } |
289 | 301 | ||
290 | case KC_RSPC: { | 302 | case KC_RSPC: { |
@@ -306,7 +318,7 @@ bool process_record_quantum(keyrecord_t *record) { | |||
306 | unregister_mods(MOD_BIT(KC_RSFT)); | 318 | unregister_mods(MOD_BIT(KC_RSFT)); |
307 | } | 319 | } |
308 | return false; | 320 | return false; |
309 | break; | 321 | // break; |
310 | } | 322 | } |
311 | default: { | 323 | default: { |
312 | shift_interrupted[0] = true; | 324 | shift_interrupted[0] = true; |
diff --git a/tmk_core/common/action_util.c b/tmk_core/common/action_util.c index 61ff202be..cb4b25264 100644 --- a/tmk_core/common/action_util.c +++ b/tmk_core/common/action_util.c | |||
@@ -20,6 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
20 | #include "action_util.h" | 20 | #include "action_util.h" |
21 | #include "action_layer.h" | 21 | #include "action_layer.h" |
22 | #include "timer.h" | 22 | #include "timer.h" |
23 | #include "keycode_config.h" | ||
24 | |||
25 | extern keymap_config_t keymap_config; | ||
26 | |||
23 | 27 | ||
24 | static inline void add_key_byte(uint8_t code); | 28 | static inline void add_key_byte(uint8_t code); |
25 | static inline void del_key_byte(uint8_t code); | 29 | static inline void del_key_byte(uint8_t code); |
@@ -139,7 +143,7 @@ void send_keyboard_report(void) { | |||
139 | void add_key(uint8_t key) | 143 | void add_key(uint8_t key) |
140 | { | 144 | { |
141 | #ifdef NKRO_ENABLE | 145 | #ifdef NKRO_ENABLE |
142 | if (keyboard_protocol && keyboard_nkro) { | 146 | if (keyboard_protocol && keymap_config.nkro) { |
143 | add_key_bit(key); | 147 | add_key_bit(key); |
144 | return; | 148 | return; |
145 | } | 149 | } |
@@ -150,7 +154,7 @@ void add_key(uint8_t key) | |||
150 | void del_key(uint8_t key) | 154 | void del_key(uint8_t key) |
151 | { | 155 | { |
152 | #ifdef NKRO_ENABLE | 156 | #ifdef NKRO_ENABLE |
153 | if (keyboard_protocol && keyboard_nkro) { | 157 | if (keyboard_protocol && keymap_config.nkro) { |
154 | del_key_bit(key); | 158 | del_key_bit(key); |
155 | return; | 159 | return; |
156 | } | 160 | } |
@@ -231,7 +235,7 @@ uint8_t has_anymod(void) | |||
231 | uint8_t get_first_key(void) | 235 | uint8_t get_first_key(void) |
232 | { | 236 | { |
233 | #ifdef NKRO_ENABLE | 237 | #ifdef NKRO_ENABLE |
234 | if (keyboard_protocol && keyboard_nkro) { | 238 | if (keyboard_protocol && keymap_config.nkro) { |
235 | uint8_t i = 0; | 239 | uint8_t i = 0; |
236 | for (; i < KEYBOARD_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++) | 240 | for (; i < KEYBOARD_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++) |
237 | ; | 241 | ; |
diff --git a/tmk_core/common/bootmagic.c b/tmk_core/common/bootmagic.c index 6730a2a4a..2c6bcbae5 100644 --- a/tmk_core/common/bootmagic.c +++ b/tmk_core/common/bootmagic.c | |||
@@ -83,10 +83,6 @@ void bootmagic(void) | |||
83 | } | 83 | } |
84 | eeconfig_update_keymap(keymap_config.raw); | 84 | eeconfig_update_keymap(keymap_config.raw); |
85 | 85 | ||
86 | #ifdef NKRO_ENABLE | ||
87 | keyboard_nkro = keymap_config.nkro; | ||
88 | #endif | ||
89 | |||
90 | /* default layer */ | 86 | /* default layer */ |
91 | uint8_t default_layer = 0; | 87 | uint8_t default_layer = 0; |
92 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_0)) { default_layer |= (1<<0); } | 88 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_0)) { default_layer |= (1<<0); } |
diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c index 476fc6fe3..54d6117fd 100644 --- a/tmk_core/common/command.c +++ b/tmk_core/common/command.c | |||
@@ -238,7 +238,7 @@ static void print_status(void) | |||
238 | print_val_hex8(keyboard_protocol); | 238 | print_val_hex8(keyboard_protocol); |
239 | print_val_hex8(keyboard_idle); | 239 | print_val_hex8(keyboard_idle); |
240 | #ifdef NKRO_ENABLE | 240 | #ifdef NKRO_ENABLE |
241 | print_val_hex8(keyboard_nkro); | 241 | print_val_hex8(keymap_config.nkro); |
242 | #endif | 242 | #endif |
243 | print_val_hex32(timer_read32()); | 243 | print_val_hex32(timer_read32()); |
244 | 244 | ||
@@ -435,8 +435,8 @@ static bool command_common(uint8_t code) | |||
435 | // NKRO toggle | 435 | // NKRO toggle |
436 | case MAGIC_KC(MAGIC_KEY_NKRO): | 436 | case MAGIC_KC(MAGIC_KEY_NKRO): |
437 | clear_keyboard(); // clear to prevent stuck keys | 437 | clear_keyboard(); // clear to prevent stuck keys |
438 | keyboard_nkro = !keyboard_nkro; | 438 | keymap_config.nkro = !keymap_config.nkro; |
439 | if (keyboard_nkro) { | 439 | if (keymap_config.nkro) { |
440 | print("NKRO: on\n"); | 440 | print("NKRO: on\n"); |
441 | } else { | 441 | } else { |
442 | print("NKRO: off\n"); | 442 | print("NKRO: off\n"); |
diff --git a/tmk_core/common/host.c b/tmk_core/common/host.c index 11a05c2dd..e12b62216 100644 --- a/tmk_core/common/host.c +++ b/tmk_core/common/host.c | |||
@@ -22,11 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
22 | #include "util.h" | 22 | #include "util.h" |
23 | #include "debug.h" | 23 | #include "debug.h" |
24 | 24 | ||
25 | |||
26 | #ifdef NKRO_ENABLE | ||
27 | bool keyboard_nkro = true; | ||
28 | #endif | ||
29 | |||
30 | static host_driver_t *driver; | 25 | static host_driver_t *driver; |
31 | static uint16_t last_system_report = 0; | 26 | static uint16_t last_system_report = 0; |
32 | static uint16_t last_consumer_report = 0; | 27 | static uint16_t last_consumer_report = 0; |
diff --git a/tmk_core/common/host.h b/tmk_core/common/host.h index 9814b10d2..aeabba710 100644 --- a/tmk_core/common/host.h +++ b/tmk_core/common/host.h | |||
@@ -28,10 +28,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
28 | extern "C" { | 28 | extern "C" { |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | #ifdef NKRO_ENABLE | ||
32 | extern bool keyboard_nkro; | ||
33 | #endif | ||
34 | |||
35 | extern uint8_t keyboard_idle; | 31 | extern uint8_t keyboard_idle; |
36 | extern uint8_t keyboard_protocol; | 32 | extern uint8_t keyboard_protocol; |
37 | 33 | ||
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index c46a701b3..371d93f3e 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c | |||
@@ -57,6 +57,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
57 | # include "visualizer/visualizer.h" | 57 | # include "visualizer/visualizer.h" |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | |||
61 | |||
60 | #ifdef MATRIX_HAS_GHOST | 62 | #ifdef MATRIX_HAS_GHOST |
61 | static bool has_ghost_in_row(uint8_t row) | 63 | static bool has_ghost_in_row(uint8_t row) |
62 | { | 64 | { |
@@ -106,7 +108,7 @@ void keyboard_init(void) { | |||
106 | rgblight_init(); | 108 | rgblight_init(); |
107 | #endif | 109 | #endif |
108 | #if defined(NKRO_ENABLE) && defined(FORCE_NKRO) | 110 | #if defined(NKRO_ENABLE) && defined(FORCE_NKRO) |
109 | keyboard_nkro = true; | 111 | keymap_config.nkro = 1; |
110 | #endif | 112 | #endif |
111 | } | 113 | } |
112 | 114 | ||
diff --git a/tmk_core/common/magic.c b/tmk_core/common/magic.c index 194e4cc02..49617a3d1 100644 --- a/tmk_core/common/magic.c +++ b/tmk_core/common/magic.c | |||
@@ -27,10 +27,6 @@ void magic(void) | |||
27 | /* keymap config */ | 27 | /* keymap config */ |
28 | keymap_config.raw = eeconfig_read_keymap(); | 28 | keymap_config.raw = eeconfig_read_keymap(); |
29 | 29 | ||
30 | #ifdef NKRO_ENABLE | ||
31 | keyboard_nkro = keymap_config.nkro; | ||
32 | #endif | ||
33 | |||
34 | uint8_t default_layer = 0; | 30 | uint8_t default_layer = 0; |
35 | default_layer = eeconfig_read_default_layer(); | 31 | default_layer = eeconfig_read_default_layer(); |
36 | default_layer_set((uint32_t)default_layer); | 32 | default_layer_set((uint32_t)default_layer); |
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index e2c9d9bf1..d0c72c46c 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c | |||
@@ -28,6 +28,12 @@ | |||
28 | #include "led.h" | 28 | #include "led.h" |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | #ifdef NKRO_ENABLE | ||
32 | #include "keycode_config.h" | ||
33 | |||
34 | extern keymap_config_t keymap_config; | ||
35 | #endif | ||
36 | |||
31 | /* --------------------------------------------------------- | 37 | /* --------------------------------------------------------- |
32 | * Global interface variables and declarations | 38 | * Global interface variables and declarations |
33 | * --------------------------------------------------------- | 39 | * --------------------------------------------------------- |
@@ -39,9 +45,6 @@ uint16_t keyboard_led_stats __attribute__((aligned(2))) = 0; | |||
39 | volatile uint16_t keyboard_idle_count = 0; | 45 | volatile uint16_t keyboard_idle_count = 0; |
40 | static virtual_timer_t keyboard_idle_timer; | 46 | static virtual_timer_t keyboard_idle_timer; |
41 | static void keyboard_idle_timer_cb(void *arg); | 47 | static void keyboard_idle_timer_cb(void *arg); |
42 | #ifdef NKRO_ENABLE | ||
43 | extern bool keyboard_nkro; | ||
44 | #endif /* NKRO_ENABLE */ | ||
45 | 48 | ||
46 | report_keyboard_t keyboard_report_sent = {{0}}; | 49 | report_keyboard_t keyboard_report_sent = {{0}}; |
47 | #ifdef MOUSE_ENABLE | 50 | #ifdef MOUSE_ENABLE |
@@ -943,8 +946,8 @@ static bool usb_request_hook_cb(USBDriver *usbp) { | |||
943 | if((usbp->setup[4] == KBD_INTERFACE) && (usbp->setup[5] == 0)) { /* wIndex */ | 946 | if((usbp->setup[4] == KBD_INTERFACE) && (usbp->setup[5] == 0)) { /* wIndex */ |
944 | keyboard_protocol = ((usbp->setup[2]) != 0x00); /* LSB(wValue) */ | 947 | keyboard_protocol = ((usbp->setup[2]) != 0x00); /* LSB(wValue) */ |
945 | #ifdef NKRO_ENABLE | 948 | #ifdef NKRO_ENABLE |
946 | keyboard_nkro = !!keyboard_protocol; | 949 | keymap_config.nkro = !!keyboard_protocol; |
947 | if(!keyboard_nkro && keyboard_idle) { | 950 | if(!keymap_config.nkro && keyboard_idle) { |
948 | #else /* NKRO_ENABLE */ | 951 | #else /* NKRO_ENABLE */ |
949 | if(keyboard_idle) { | 952 | if(keyboard_idle) { |
950 | #endif /* NKRO_ENABLE */ | 953 | #endif /* NKRO_ENABLE */ |
@@ -962,7 +965,7 @@ static bool usb_request_hook_cb(USBDriver *usbp) { | |||
962 | keyboard_idle = usbp->setup[3]; /* MSB(wValue) */ | 965 | keyboard_idle = usbp->setup[3]; /* MSB(wValue) */ |
963 | /* arm the timer */ | 966 | /* arm the timer */ |
964 | #ifdef NKRO_ENABLE | 967 | #ifdef NKRO_ENABLE |
965 | if(!keyboard_nkro && keyboard_idle) { | 968 | if(!keymap_config.nkro && keyboard_idle) { |
966 | #else /* NKRO_ENABLE */ | 969 | #else /* NKRO_ENABLE */ |
967 | if(keyboard_idle) { | 970 | if(keyboard_idle) { |
968 | #endif /* NKRO_ENABLE */ | 971 | #endif /* NKRO_ENABLE */ |
@@ -1089,7 +1092,7 @@ static void keyboard_idle_timer_cb(void *arg) { | |||
1089 | } | 1092 | } |
1090 | 1093 | ||
1091 | #ifdef NKRO_ENABLE | 1094 | #ifdef NKRO_ENABLE |
1092 | if(!keyboard_nkro && keyboard_idle) { | 1095 | if(!keymap_config.nkro && keyboard_idle) { |
1093 | #else /* NKRO_ENABLE */ | 1096 | #else /* NKRO_ENABLE */ |
1094 | if(keyboard_idle) { | 1097 | if(keyboard_idle) { |
1095 | #endif /* NKRO_ENABLE */ | 1098 | #endif /* NKRO_ENABLE */ |
@@ -1122,7 +1125,7 @@ void send_keyboard(report_keyboard_t *report) { | |||
1122 | osalSysUnlock(); | 1125 | osalSysUnlock(); |
1123 | 1126 | ||
1124 | #ifdef NKRO_ENABLE | 1127 | #ifdef NKRO_ENABLE |
1125 | if(keyboard_nkro) { /* NKRO protocol */ | 1128 | if(keymap_config.nkro) { /* NKRO protocol */ |
1126 | /* need to wait until the previous packet has made it through */ | 1129 | /* need to wait until the previous packet has made it through */ |
1127 | /* can rewrite this using the synchronous API, then would wait | 1130 | /* can rewrite this using the synchronous API, then would wait |
1128 | * until *after* the packet has been transmitted. I think | 1131 | * until *after* the packet has been transmitted. I think |
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 9b201374a..01c0e45b0 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c | |||
@@ -52,6 +52,13 @@ | |||
52 | #include "descriptor.h" | 52 | #include "descriptor.h" |
53 | #include "lufa.h" | 53 | #include "lufa.h" |
54 | 54 | ||
55 | #ifdef NKRO_ENABLE | ||
56 | #include "keycode_config.h" | ||
57 | |||
58 | extern keymap_config_t keymap_config; | ||
59 | #endif | ||
60 | |||
61 | |||
55 | #ifdef AUDIO_ENABLE | 62 | #ifdef AUDIO_ENABLE |
56 | #include <audio.h> | 63 | #include <audio.h> |
57 | #endif | 64 | #endif |
@@ -502,7 +509,7 @@ static void send_keyboard(report_keyboard_t *report) | |||
502 | 509 | ||
503 | /* Select the Keyboard Report Endpoint */ | 510 | /* Select the Keyboard Report Endpoint */ |
504 | #ifdef NKRO_ENABLE | 511 | #ifdef NKRO_ENABLE |
505 | if (keyboard_protocol && keyboard_nkro) { | 512 | if (keyboard_protocol && keymap_config.nkro) { |
506 | /* Report protocol - NKRO */ | 513 | /* Report protocol - NKRO */ |
507 | Endpoint_SelectEndpoint(NKRO_IN_EPNUM); | 514 | Endpoint_SelectEndpoint(NKRO_IN_EPNUM); |
508 | 515 | ||
diff --git a/tmk_core/protocol/pjrc/usb.c b/tmk_core/protocol/pjrc/usb.c index 1e6ba8719..09efbe076 100644 --- a/tmk_core/protocol/pjrc/usb.c +++ b/tmk_core/protocol/pjrc/usb.c | |||
@@ -1,17 +1,17 @@ | |||
1 | /* USB Keyboard Plus Debug Channel Example for Teensy USB Development Board | 1 | /* USB Keyboard Plus Debug Channel Example for Teensy USB Development Board |
2 | * http://www.pjrc.com/teensy/usb_keyboard.html | 2 | * http://www.pjrc.com/teensy/usb_keyboard.html |
3 | * Copyright (c) 2009 PJRC.COM, LLC | 3 | * Copyright (c) 2009 PJRC.COM, LLC |
4 | * | 4 | * |
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy | 5 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
6 | * of this software and associated documentation files (the "Software"), to deal | 6 | * of this software and associated documentation files (the "Software"), to deal |
7 | * in the Software without restriction, including without limitation the rights | 7 | * in the Software without restriction, including without limitation the rights |
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
9 | * copies of the Software, and to permit persons to whom the Software is | 9 | * copies of the Software, and to permit persons to whom the Software is |
10 | * furnished to do so, subject to the following conditions: | 10 | * furnished to do so, subject to the following conditions: |
11 | * | 11 | * |
12 | * The above copyright notice and this permission notice shall be included in | 12 | * The above copyright notice and this permission notice shall be included in |
13 | * all copies or substantial portions of the Software. | 13 | * all copies or substantial portions of the Software. |
14 | * | 14 | * |
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
@@ -41,6 +41,12 @@ | |||
41 | #include "action.h" | 41 | #include "action.h" |
42 | #include "action_util.h" | 42 | #include "action_util.h" |
43 | 43 | ||
44 | #ifdef NKRO_ENABLE | ||
45 | #include "keycode_config.h" | ||
46 | |||
47 | extern keymap_config_t keymap_config; | ||
48 | #endif | ||
49 | |||
44 | 50 | ||
45 | /************************************************************************** | 51 | /************************************************************************** |
46 | * | 52 | * |
@@ -694,7 +700,7 @@ ISR(USB_GEN_vect) | |||
694 | } | 700 | } |
695 | /* TODO: should keep IDLE rate on each keyboard interface */ | 701 | /* TODO: should keep IDLE rate on each keyboard interface */ |
696 | #ifdef NKRO_ENABLE | 702 | #ifdef NKRO_ENABLE |
697 | if (!keyboard_nkro && keyboard_idle && (++div4 & 3) == 0) { | 703 | if (!keymap_config.nkro && keyboard_idle && (++div4 & 3) == 0) { |
698 | #else | 704 | #else |
699 | if (keyboard_idle && (++div4 & 3) == 0) { | 705 | if (keyboard_idle && (++div4 & 3) == 0) { |
700 | #endif | 706 | #endif |
@@ -881,7 +887,7 @@ ISR(USB_COM_vect) | |||
881 | #endif | 887 | #endif |
882 | if (bmRequestType == 0x00 && wValue == DEVICE_REMOTE_WAKEUP) { | 888 | if (bmRequestType == 0x00 && wValue == DEVICE_REMOTE_WAKEUP) { |
883 | if (bRequest == SET_FEATURE) { | 889 | if (bRequest == SET_FEATURE) { |
884 | remote_wakeup = true; | 890 | remote_wakeup = true; |
885 | } else { | 891 | } else { |
886 | remote_wakeup = false; | 892 | remote_wakeup = false; |
887 | } | 893 | } |
@@ -932,7 +938,7 @@ ISR(USB_COM_vect) | |||
932 | if (bRequest == HID_SET_PROTOCOL) { | 938 | if (bRequest == HID_SET_PROTOCOL) { |
933 | keyboard_protocol = wValue; | 939 | keyboard_protocol = wValue; |
934 | #ifdef NKRO_ENABLE | 940 | #ifdef NKRO_ENABLE |
935 | keyboard_nkro = !!keyboard_protocol; | 941 | keymap_config.nkro = !!keyboard_protocol; |
936 | #endif | 942 | #endif |
937 | clear_keyboard(); | 943 | clear_keyboard(); |
938 | //usb_wait_in_ready(); | 944 | //usb_wait_in_ready(); |
diff --git a/tmk_core/protocol/pjrc/usb_keyboard.c b/tmk_core/protocol/pjrc/usb_keyboard.c index 4b87b5d7b..05f479734 100644 --- a/tmk_core/protocol/pjrc/usb_keyboard.c +++ b/tmk_core/protocol/pjrc/usb_keyboard.c | |||
@@ -30,6 +30,12 @@ | |||
30 | #include "util.h" | 30 | #include "util.h" |
31 | #include "host.h" | 31 | #include "host.h" |
32 | 32 | ||
33 | #ifdef NKRO_ENABLE | ||
34 | #include "keycode_config.h" | ||
35 | |||
36 | extern keymap_config_t keymap_config; | ||
37 | #endif | ||
38 | |||
33 | 39 | ||
34 | // protocol setting from the host. We use exactly the same report | 40 | // protocol setting from the host. We use exactly the same report |
35 | // either way, so this variable only stores the setting since we | 41 | // either way, so this variable only stores the setting since we |
@@ -56,7 +62,7 @@ int8_t usb_keyboard_send_report(report_keyboard_t *report) | |||
56 | int8_t result = 0; | 62 | int8_t result = 0; |
57 | 63 | ||
58 | #ifdef NKRO_ENABLE | 64 | #ifdef NKRO_ENABLE |
59 | if (keyboard_nkro) | 65 | if (keymap_config.nkro) |
60 | result = send_report(report, KBD2_ENDPOINT, 0, KBD2_SIZE); | 66 | result = send_report(report, KBD2_ENDPOINT, 0, KBD2_SIZE); |
61 | else | 67 | else |
62 | #endif | 68 | #endif |
diff --git a/tmk_core/readme.md b/tmk_core/readme.md index f460d0ed4..324232851 100644 --- a/tmk_core/readme.md +++ b/tmk_core/readme.md | |||
@@ -23,7 +23,7 @@ These features can be used in your keyboard. | |||
23 | * Mouse key - Mouse control with keyboard | 23 | * Mouse key - Mouse control with keyboard |
24 | * System Control Key - Power Down, Sleep, Wake Up and USB Remote Wake up | 24 | * System Control Key - Power Down, Sleep, Wake Up and USB Remote Wake up |
25 | * Media Control Key - Volume Down/Up, Mute, Next/Prev track, Play, Stop and etc | 25 | * Media Control Key - Volume Down/Up, Mute, Next/Prev track, Play, Stop and etc |
26 | * USB NKRO - 120 keys(+ 8 modifiers) simultaneously | 26 | * USB NKRO - 240 keys(+ 8 modifiers) simultaneously |
27 | * PS/2 mouse support - PS/2 mouse(TrackPoint) as composite device | 27 | * PS/2 mouse support - PS/2 mouse(TrackPoint) as composite device |
28 | * Keyboard protocols - PS/2, ADB, M0110, Sun and other old keyboard protocols | 28 | * Keyboard protocols - PS/2, ADB, M0110, Sun and other old keyboard protocols |
29 | * User Function - Customizable function of key with writing code | 29 | * User Function - Customizable function of key with writing code |