]> git.friedersdorff.com Git - max/tmk_keyboard.git/commitdiff
FIX: send last report when idle timeouts. (pjrc)
authortmk <nobody@nowhere>
Wed, 9 Mar 2011 15:50:27 +0000 (00:50 +0900)
committertmk <nobody@nowhere>
Thu, 10 Mar 2011 02:17:54 +0000 (11:17 +0900)
adb.c [changed mode: 0644->0755]
adb_usb/Makefile [changed mode: 0644->0755]
adb_usb/config.h
adb_usb/matrix.c [changed mode: 0644->0755]
command.c [changed mode: 0644->0755]
pjrc/host.c
pjrc/usb.c
pjrc/usb_keyboard.c
vusb/host.c

diff --git a/adb.c b/adb.c
old mode 100644 (file)
new mode 100755 (executable)
index 6a3fb8e..006e424
--- a/adb.c
+++ b/adb.c
@@ -280,7 +280,6 @@ Pinouts
     4: GND
 
 
-
 Commands
 --------
     ADB command is 1byte and consists of 4bit-address, 2bit-command
@@ -381,6 +380,7 @@ Keyboard Data(Register0)
     You can read the state from PSW line(active low) however
     the switch has a special scancode 0x7F7F, so you can
     also read from Data line. It uses 0xFFFF for release scancode.
+    Release code seems to delay about some 100ms. Due to Mac soft power?
 
 Keyboard LEDs & state of keys(Register2)
     This register hold current state of three LEDs and nine keys.
old mode 100644 (file)
new mode 100755 (executable)
index 61e43a7..92b9ba1
@@ -44,7 +44,7 @@ USB_EXTRA_ENABLE = yes        # Enhanced feature for Windows(Audio control and System c
 
 
 #---------------- Programming Options --------------------------
-PROGRAM_CMD = teensy_loader_cli.exe -mmcu=$(MCU) -w -v $(TARGET).hex
+PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex
 
 
 
index ea78dd9bdb81e01fe3ecf3e0e2e432b42f6f6afc..adc76bd5225e3835f06cb0381875337a04876bee 100644 (file)
@@ -17,8 +17,8 @@
 
 /* key combination for command */
 #define IS_COMMAND() ( \
-    keyboard_report->mods == (BIT_LSHIFT | BIT_RSHIFT) || \
-    keyboard_report->mods == (BIT_LCTRL | BIT_RSHIFT) \
+    keyboard_report->mods == (BIT_LSHIFT | BIT_LCTRL | BIT_LALT | BIT_LGUI) || \
+    keyboard_report->mods == (BIT_LSHIFT | BIT_RSHIFT) \
 )
 
 
old mode 100644 (file)
new mode 100755 (executable)
index 72515dc..db20289
@@ -87,7 +87,7 @@ uint8_t matrix_scan(void)
             _register_key(key1);
     }
 
-    if (debug_matrix && matrix_is_modified()) {
+    if (debug_enable) {
         print("adb_host_kbd_recv: "); phex16(codes); print("\n");
     }
     return 1;
old mode 100644 (file)
new mode 100755 (executable)
index 7afed5d..cd51b79
--- a/command.c
+++ b/command.c
@@ -102,7 +102,10 @@ uint8_t command_proc(void)
             print("UDCON: "); phex(UDCON); print("\n");
             print("UDIEN: "); phex(UDIEN); print("\n");
             print("UDINT: "); phex(UDINT); print("\n");
-            print("host_keyboard_leds:"); phex(host_keyboard_leds()); print("\n");
+            print("usb_keyboard_leds:"); phex(usb_keyboard_leds); print("\n");
+            print("usb_keyboard_protocol: "); phex(usb_keyboard_protocol); print("\n");
+            print("usb_keyboard_idle_config:"); phex(usb_keyboard_idle_config); print("\n");
+            print("usb_keyboard_idle_count:"); phex(usb_keyboard_idle_count); print("\n");
 #endif
             break;
 #ifdef USB_NKRO_ENABLE
index 8da88517b5cffb8c59a61a8d62a6f59860e6cda9..b69c6cb20c513af34347200bc6fc686c97f6814a 100644 (file)
@@ -1,4 +1,5 @@
 #include <stdint.h>
+#include <avr/interrupt.h>
 #include "usb_keycodes.h"
 #include "usb_keyboard.h"
 #include "usb_mouse.h"
@@ -58,9 +59,12 @@ void host_add_code(uint8_t code)
 
 void host_swap_keyboard_report(void)
 {
+    uint8_t sreg = SREG;
+    cli();
     report_keyboard_t *tmp = keyboard_report_prev;
     keyboard_report_prev = keyboard_report;
     keyboard_report = tmp;
+    SREG = sreg;
 }
 
 void host_clear_keyboard_report(void)
index 9fd30dee3c6811fd21884a6ba721de6059645c5a..3cfe9473101f205aff807978113a4a3b93792948 100644 (file)
@@ -687,10 +687,11 @@ ISR(USB_GEN_vect)
                                usb_keyboard_idle_count++;
                                if (usb_keyboard_idle_count == usb_keyboard_idle_config) {
                                        usb_keyboard_idle_count = 0;
-                                       UEDATX = keyboard_report->mods;
+                                       UEDATX = keyboard_report_prev->mods;
                                        UEDATX = 0;
-                                       for (i=0; i<6; i++) {
-                                               UEDATX = keyboard_report->keys[i];
+                                        uint8_t keys = usb_keyboard_protocol ? KBD_REPORT_KEYS : 6;
+                                       for (i=0; i<keys; i++) {
+                                               UEDATX = keyboard_report_prev->keys[i];
                                        }
                                        UEINTX = 0x3A;
                                }
index fc05f7c9e74233b544dcc0d749bb91ce22612848..8aae2d3818159810151ef8fd8663a9c7cafd5fc2 100644 (file)
@@ -15,6 +15,7 @@ uint8_t usb_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;
 
 // count until idle timeout
index 05a1f29cd19716ed368f074a5ebe7ad47a63b086..901537bcb89bd3c94d5f88b6e24c667723c4884c 100644 (file)
@@ -1,3 +1,5 @@
+#include <stdint.h>
+#include <avr/interrupt.h>
 #include "usbdrv.h"
 #include "usbconfig.h"
 #include "print.h"
@@ -63,9 +65,12 @@ void host_add_code(uint8_t code)
 
 void host_swap_keyboard_report(void)
 {
+    uint8_t sreg = SREG;
+    cli();
     report_keyboard_t *tmp = keyboard_report_prev;
     keyboard_report_prev = keyboard_report;
     keyboard_report = tmp;
+    SREG = sreg;
 }
 
 void host_clear_keyboard_report(void)