summaryrefslogtreecommitdiffstats
path: root/protocol/pjrc
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2014-04-25 15:32:21 +0900
committertmk <nobody@nowhere>2014-04-27 04:16:49 +0900
commit5e3f2d2b2e5065a04495f2c55fae0849966b5d23 (patch)
tree4e224b2a2d6a6445ae489ab0b1c150cc3c4a83e4 /protocol/pjrc
parent62117e7ea77bf036e4e08bb02d682311e3c3d401 (diff)
Make NKRO deafult when it is available
- NKRO is used only when keyboard_protocol = 1(report)
Diffstat (limited to 'protocol/pjrc')
-rw-r--r--protocol/pjrc/usb.c18
-rw-r--r--protocol/pjrc/usb_keyboard.c11
-rw-r--r--protocol/pjrc/usb_keyboard.h2
3 files changed, 14 insertions, 17 deletions
diff --git a/protocol/pjrc/usb.c b/protocol/pjrc/usb.c
index 393b36f78e..b09ad3f233 100644
--- a/protocol/pjrc/usb.c
+++ b/protocol/pjrc/usb.c
@@ -38,6 +38,7 @@
#include "sleep_led.h"
#endif
#include "suspend.h"
+#include "action.h"
#include "action_util.h"
@@ -692,20 +693,20 @@ ISR(USB_GEN_vect)
}
/* TODO: should keep IDLE rate on each keyboard interface */
#ifdef NKRO_ENABLE
- if (!keyboard_nkro && usb_keyboard_idle_config && (++div4 & 3) == 0) {
+ if (!keyboard_nkro && keyboard_idle && (++div4 & 3) == 0) {
#else
- if (usb_keyboard_idle_config && (++div4 & 3) == 0) {
+ if (keyboard_idle && (++div4 & 3) == 0) {
#endif
UENUM = KBD_ENDPOINT;
if (UEINTX & (1<<RWAL)) {
usb_keyboard_idle_count++;
- if (usb_keyboard_idle_count == usb_keyboard_idle_config) {
+ if (usb_keyboard_idle_count == keyboard_idle) {
usb_keyboard_idle_count = 0;
/* TODO: fix keyboard_report inconsistency */
/* To avoid Mac SET_IDLE behaviour.
UEDATX = keyboard_report_prev->mods;
UEDATX = 0;
- uint8_t keys = usb_keyboard_protocol ? KBD_REPORT_KEYS : 6;
+ uint8_t keys = keyboard_protocol ? KBD_REPORT_KEYS : 6;
for (uint8_t i=0; i<keys; i++) {
UEDATX = keyboard_report_prev->keys[i];
}
@@ -901,13 +902,13 @@ ISR(USB_COM_vect)
}
if (bRequest == HID_GET_IDLE) {
usb_wait_in_ready();
- UEDATX = usb_keyboard_idle_config;
+ UEDATX = keyboard_idle;
usb_send_in();
return;
}
if (bRequest == HID_GET_PROTOCOL) {
usb_wait_in_ready();
- UEDATX = usb_keyboard_protocol;
+ UEDATX = keyboard_protocol;
usb_send_in();
return;
}
@@ -921,14 +922,15 @@ ISR(USB_COM_vect)
return;
}
if (bRequest == HID_SET_IDLE) {
- usb_keyboard_idle_config = (wValue >> 8);
+ keyboard_idle = (wValue >> 8);
usb_keyboard_idle_count = 0;
//usb_wait_in_ready();
usb_send_in();
return;
}
if (bRequest == HID_SET_PROTOCOL) {
- usb_keyboard_protocol = wValue;
+ keyboard_protocol = wValue;
+ clear_keyboard();
//usb_wait_in_ready();
usb_send_in();
return;
diff --git a/protocol/pjrc/usb_keyboard.c b/protocol/pjrc/usb_keyboard.c
index de798fcc22..c11995db6f 100644
--- a/protocol/pjrc/usb_keyboard.c
+++ b/protocol/pjrc/usb_keyboard.c
@@ -34,12 +34,12 @@
// protocol setting from the host. We use exactly the same report
// either way, so this variable only stores the setting since we
// are required to be able to report which setting is in use.
-uint8_t usb_keyboard_protocol=1;
+uint8_t keyboard_protocol=1;
// the idle configuration, how often we send the report to the
// host (ms * 4) even when it hasn't changed
// Windows and Linux set 0 while OS X sets 6(24ms) by SET_IDLE request.
-uint8_t usb_keyboard_idle_config=125;
+uint8_t keyobard_idle=125;
// count until idle timeout
uint8_t usb_keyboard_idle_count=0;
@@ -56,15 +56,12 @@ int8_t usb_keyboard_send_report(report_keyboard_t *report)
int8_t result = 0;
#ifdef NKRO_ENABLE
- if (keyboard_nkro)
+ if (keyboard_nkro && keyboard_protocol)
result = send_report(report, KBD2_ENDPOINT, 0, KBD2_SIZE);
else
#endif
{
- if (usb_keyboard_protocol)
- result = send_report(report, KBD_ENDPOINT, 0, KBD_SIZE);
- else
- result = send_report(report, KBD_ENDPOINT, 0, 6);
+ result = send_report(report, KBD_ENDPOINT, 0, KBD_SIZE);
}
if (result) return result;
diff --git a/protocol/pjrc/usb_keyboard.h b/protocol/pjrc/usb_keyboard.h
index c362ca3b86..9b798e9a86 100644
--- a/protocol/pjrc/usb_keyboard.h
+++ b/protocol/pjrc/usb_keyboard.h
@@ -30,8 +30,6 @@
#include "host.h"
-extern uint8_t usb_keyboard_protocol;
-extern uint8_t usb_keyboard_idle_config;
extern uint8_t usb_keyboard_idle_count;
extern volatile uint8_t usb_keyboard_leds;