aboutsummaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
authorIBNobody <IBNobody@users.noreply.github.com>2016-09-06 23:19:01 -0500
committerGitHub <noreply@github.com>2016-09-06 23:19:01 -0500
commit558f3ec1eb325caf706efc15e2fab26121aba442 (patch)
treea14b00c189492426beadc69c2094055f833b811f /tmk_core
parentf0388a5b1334ce0b8c8a359a0a8a1460e456b8c5 (diff)
downloadqmk_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
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/common/action_util.c10
-rw-r--r--tmk_core/common/bootmagic.c4
-rw-r--r--tmk_core/common/command.c6
-rw-r--r--tmk_core/common/host.c5
-rw-r--r--tmk_core/common/host.h4
-rw-r--r--tmk_core/common/keyboard.c4
-rw-r--r--tmk_core/common/magic.c4
-rw-r--r--tmk_core/protocol/chibios/usb_main.c19
-rw-r--r--tmk_core/protocol/lufa/lufa.c9
-rw-r--r--tmk_core/protocol/pjrc/usb.c18
-rw-r--r--tmk_core/protocol/pjrc/usb_keyboard.c8
-rw-r--r--tmk_core/readme.md2
12 files changed, 52 insertions, 41 deletions
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
25extern keymap_config_t keymap_config;
26
23 27
24static inline void add_key_byte(uint8_t code); 28static inline void add_key_byte(uint8_t code);
25static inline void del_key_byte(uint8_t code); 29static inline void del_key_byte(uint8_t code);
@@ -139,7 +143,7 @@ void send_keyboard_report(void) {
139void add_key(uint8_t key) 143void 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)
150void del_key(uint8_t key) 154void 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)
231uint8_t get_first_key(void) 235uint8_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
27bool keyboard_nkro = true;
28#endif
29
30static host_driver_t *driver; 25static host_driver_t *driver;
31static uint16_t last_system_report = 0; 26static uint16_t last_system_report = 0;
32static uint16_t last_consumer_report = 0; 27static 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/>.
28extern "C" { 28extern "C" {
29#endif 29#endif
30 30
31#ifdef NKRO_ENABLE
32extern bool keyboard_nkro;
33#endif
34
35extern uint8_t keyboard_idle; 31extern uint8_t keyboard_idle;
36extern uint8_t keyboard_protocol; 32extern 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
61static bool has_ghost_in_row(uint8_t row) 63static 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;
39volatile uint16_t keyboard_idle_count = 0; 45volatile uint16_t keyboard_idle_count = 0;
40static virtual_timer_t keyboard_idle_timer; 46static virtual_timer_t keyboard_idle_timer;
41static void keyboard_idle_timer_cb(void *arg); 47static void keyboard_idle_timer_cb(void *arg);
42#ifdef NKRO_ENABLE
43extern bool keyboard_nkro;
44#endif /* NKRO_ENABLE */
45 48
46report_keyboard_t keyboard_report_sent = {{0}}; 49report_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