diff options
| author | Shay Green <gblargg@gmail.com> | 2013-11-26 15:21:43 -0600 |
|---|---|---|
| committer | Shay Green <gblargg@gmail.com> | 2013-11-26 15:21:43 -0600 |
| commit | 263c462656646a90295b4368d96e3ea09739bedf (patch) | |
| tree | c054edd43246e4324b69f5fee6c7453dc3372cdd | |
| parent | 4e36159be226e544dfebbe06b1955261951209a4 (diff) | |
| download | qmk_firmware-263c462656646a90295b4368d96e3ea09739bedf.tar.gz qmk_firmware-263c462656646a90295b4368d96e3ea09739bedf.zip | |
Fixed handling of ADB event with key down and key up for same key all in one
| -rw-r--r-- | converter/adb_usb/matrix.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/converter/adb_usb/matrix.c b/converter/adb_usb/matrix.c index d1b67d38d..405391865 100644 --- a/converter/adb_usb/matrix.c +++ b/converter/adb_usb/matrix.c | |||
| @@ -88,12 +88,26 @@ void matrix_init(void) | |||
| 88 | 88 | ||
| 89 | uint8_t matrix_scan(void) | 89 | uint8_t matrix_scan(void) |
| 90 | { | 90 | { |
| 91 | /* extra_key is volatile and more convoluted than necessary because gcc refused | ||
| 92 | to generate valid code otherwise. Making extra_key uint8_t and constructing codes | ||
| 93 | here via codes = extra_key<<8 | 0xFF; would consistently fail to even LOAD | ||
| 94 | extra_key from memory, and leave garbage in the high byte of codes. I tried | ||
| 95 | dozens of code variations and it kept generating broken assembly output. So | ||
| 96 | beware if attempting to make extra_key code more logical and efficient. */ | ||
| 97 | static volatile uint16_t extra_key = 0xFFFF; | ||
| 91 | uint16_t codes; | 98 | uint16_t codes; |
| 92 | uint8_t key0, key1; | 99 | uint8_t key0, key1; |
| 93 | 100 | ||
| 94 | is_modified = false; | 101 | is_modified = false; |
| 95 | _delay_ms(12); // delay for preventing overload of poor ADB keyboard controller | 102 | |
| 96 | codes = adb_host_kbd_recv(); | 103 | codes = extra_key; |
| 104 | extra_key = 0xFFFF; | ||
| 105 | |||
| 106 | if ( codes == 0xFFFF ) | ||
| 107 | { | ||
| 108 | _delay_ms(12); // delay for preventing overload of poor ADB keyboard controller | ||
| 109 | codes = adb_host_kbd_recv(); | ||
| 110 | } | ||
| 97 | key0 = codes>>8; | 111 | key0 = codes>>8; |
| 98 | key1 = codes&0xFF; | 112 | key1 = codes&0xFF; |
| 99 | 113 | ||
| @@ -113,7 +127,7 @@ uint8_t matrix_scan(void) | |||
| 113 | } else { | 127 | } else { |
| 114 | register_key(key0); | 128 | register_key(key0); |
| 115 | if (key1 != 0xFF) // key1 is 0xFF when no second key. | 129 | if (key1 != 0xFF) // key1 is 0xFF when no second key. |
| 116 | register_key(key1); | 130 | extra_key = key1<<8 | 0xFF; // process in a separate call |
| 117 | } | 131 | } |
| 118 | 132 | ||
| 119 | return 1; | 133 | return 1; |
