FIX: send last report when idle timeouts. (pjrc)
This commit is contained in:
parent
1a7c3585ed
commit
cec2549505
9 changed files with 23 additions and 9 deletions
2
adb.c
Normal file → Executable file
2
adb.c
Normal file → Executable file
|
@ -280,7 +280,6 @@ Pinouts
|
||||||
4: GND
|
4: GND
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Commands
|
Commands
|
||||||
--------
|
--------
|
||||||
ADB command is 1byte and consists of 4bit-address, 2bit-command
|
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
|
You can read the state from PSW line(active low) however
|
||||||
the switch has a special scancode 0x7F7F, so you can
|
the switch has a special scancode 0x7F7F, so you can
|
||||||
also read from Data line. It uses 0xFFFF for release scancode.
|
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)
|
Keyboard LEDs & state of keys(Register2)
|
||||||
This register hold current state of three LEDs and nine keys.
|
This register hold current state of three LEDs and nine keys.
|
||||||
|
|
2
adb_usb/Makefile
Normal file → Executable file
2
adb_usb/Makefile
Normal file → Executable file
|
@ -44,7 +44,7 @@ USB_EXTRA_ENABLE = yes # Enhanced feature for Windows(Audio control and System c
|
||||||
|
|
||||||
|
|
||||||
#---------------- Programming Options --------------------------
|
#---------------- 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
/* key combination for command */
|
/* key combination for command */
|
||||||
#define IS_COMMAND() ( \
|
#define IS_COMMAND() ( \
|
||||||
keyboard_report->mods == (BIT_LSHIFT | BIT_RSHIFT) || \
|
keyboard_report->mods == (BIT_LSHIFT | BIT_LCTRL | BIT_LALT | BIT_LGUI) || \
|
||||||
keyboard_report->mods == (BIT_LCTRL | BIT_RSHIFT) \
|
keyboard_report->mods == (BIT_LSHIFT | BIT_RSHIFT) \
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
2
adb_usb/matrix.c
Normal file → Executable file
2
adb_usb/matrix.c
Normal file → Executable file
|
@ -87,7 +87,7 @@ uint8_t matrix_scan(void)
|
||||||
_register_key(key1);
|
_register_key(key1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug_matrix && matrix_is_modified()) {
|
if (debug_enable) {
|
||||||
print("adb_host_kbd_recv: "); phex16(codes); print("\n");
|
print("adb_host_kbd_recv: "); phex16(codes); print("\n");
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
5
command.c
Normal file → Executable file
5
command.c
Normal file → Executable file
|
@ -102,7 +102,10 @@ uint8_t command_proc(void)
|
||||||
print("UDCON: "); phex(UDCON); print("\n");
|
print("UDCON: "); phex(UDCON); print("\n");
|
||||||
print("UDIEN: "); phex(UDIEN); print("\n");
|
print("UDIEN: "); phex(UDIEN); print("\n");
|
||||||
print("UDINT: "); phex(UDINT); 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
|
#endif
|
||||||
break;
|
break;
|
||||||
#ifdef USB_NKRO_ENABLE
|
#ifdef USB_NKRO_ENABLE
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
#include "usb_keycodes.h"
|
#include "usb_keycodes.h"
|
||||||
#include "usb_keyboard.h"
|
#include "usb_keyboard.h"
|
||||||
#include "usb_mouse.h"
|
#include "usb_mouse.h"
|
||||||
|
@ -58,9 +59,12 @@ void host_add_code(uint8_t code)
|
||||||
|
|
||||||
void host_swap_keyboard_report(void)
|
void host_swap_keyboard_report(void)
|
||||||
{
|
{
|
||||||
|
uint8_t sreg = SREG;
|
||||||
|
cli();
|
||||||
report_keyboard_t *tmp = keyboard_report_prev;
|
report_keyboard_t *tmp = keyboard_report_prev;
|
||||||
keyboard_report_prev = keyboard_report;
|
keyboard_report_prev = keyboard_report;
|
||||||
keyboard_report = tmp;
|
keyboard_report = tmp;
|
||||||
|
SREG = sreg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void host_clear_keyboard_report(void)
|
void host_clear_keyboard_report(void)
|
||||||
|
|
|
@ -687,10 +687,11 @@ ISR(USB_GEN_vect)
|
||||||
usb_keyboard_idle_count++;
|
usb_keyboard_idle_count++;
|
||||||
if (usb_keyboard_idle_count == usb_keyboard_idle_config) {
|
if (usb_keyboard_idle_count == usb_keyboard_idle_config) {
|
||||||
usb_keyboard_idle_count = 0;
|
usb_keyboard_idle_count = 0;
|
||||||
UEDATX = keyboard_report->mods;
|
UEDATX = keyboard_report_prev->mods;
|
||||||
UEDATX = 0;
|
UEDATX = 0;
|
||||||
for (i=0; i<6; i++) {
|
uint8_t keys = usb_keyboard_protocol ? KBD_REPORT_KEYS : 6;
|
||||||
UEDATX = keyboard_report->keys[i];
|
for (i=0; i<keys; i++) {
|
||||||
|
UEDATX = keyboard_report_prev->keys[i];
|
||||||
}
|
}
|
||||||
UEINTX = 0x3A;
|
UEINTX = 0x3A;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ uint8_t usb_keyboard_protocol=1;
|
||||||
|
|
||||||
// the idle configuration, how often we send the report to the
|
// the idle configuration, how often we send the report to the
|
||||||
// host (ms * 4) even when it hasn't changed
|
// 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 usb_keyboard_idle_config=125;
|
||||||
|
|
||||||
// count until idle timeout
|
// count until idle timeout
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
#include "usbdrv.h"
|
#include "usbdrv.h"
|
||||||
#include "usbconfig.h"
|
#include "usbconfig.h"
|
||||||
#include "print.h"
|
#include "print.h"
|
||||||
|
@ -63,9 +65,12 @@ void host_add_code(uint8_t code)
|
||||||
|
|
||||||
void host_swap_keyboard_report(void)
|
void host_swap_keyboard_report(void)
|
||||||
{
|
{
|
||||||
|
uint8_t sreg = SREG;
|
||||||
|
cli();
|
||||||
report_keyboard_t *tmp = keyboard_report_prev;
|
report_keyboard_t *tmp = keyboard_report_prev;
|
||||||
keyboard_report_prev = keyboard_report;
|
keyboard_report_prev = keyboard_report;
|
||||||
keyboard_report = tmp;
|
keyboard_report = tmp;
|
||||||
|
SREG = sreg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void host_clear_keyboard_report(void)
|
void host_clear_keyboard_report(void)
|
||||||
|
|
Loading…
Reference in a new issue