1
0
Fork 0

Fix Locking CapsLock support in ADB converter

This commit is contained in:
tmk 2013-03-12 12:10:12 +09:00
parent c0137b4b32
commit c4ab832be0
5 changed files with 16 additions and 37 deletions

View file

@ -25,8 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "print.h"
#include "util.h"
#include "debug.h"
#include "host.h"
#include "led.h"
#include "adb.h"
#include "matrix.h"
@ -38,8 +36,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# error "MATRIX_ROWS must not exceed 255"
#endif
#define ADB_CAPS_UP (ADB_CAPS | 0x80)
static bool is_modified = false;
@ -98,12 +94,6 @@ uint8_t matrix_scan(void)
print("adb_host_kbd_recv: "); phex16(codes); print("\n");
}
#ifdef MATRIX_HAS_LOCKING_CAPS
// Send Caps key up event
if (matrix_is_on(MATRIX_ROW(ADB_CAPS), MATRIX_COL(ADB_CAPS))) {
register_key(ADB_CAPS_UP);
}
#endif
if (codes == 0) { // no keys
return 0;
} else if (codes == 0x7F7F) { // power key press
@ -116,23 +106,6 @@ uint8_t matrix_scan(void)
for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;
return key1;
} else {
#ifdef MATRIX_HAS_LOCKING_CAPS
if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) {
// Ignore LockingCaps key down event when CAPS LOCK is on
if (key0 == ADB_CAPS && (key1 == ADB_CAPS || key1 == 0xFF)) return 0;
if (key0 == ADB_CAPS) key0 = key1;
if (key1 == ADB_CAPS) key1 = 0xFF;
// Convert LockingCaps key up event into down event
if (key0 == ADB_CAPS_UP) key0 = ADB_CAPS;
if (key1 == ADB_CAPS_UP) key1 = ADB_CAPS;
} else {
// ADB_CAPS LOCK off:
// Ignore LockingCaps key up event when ADB_CAPS LOCK is off
if (key0 == ADB_CAPS_UP && (key1 == ADB_CAPS_UP || key1 == 0xFF)) return 0;
if (key0 == ADB_CAPS_UP) key0 = key1;
if (key1 == ADB_CAPS_UP) key1 = 0xFF;
}
#endif
register_key(key0);
if (key1 != 0xFF) // key1 is 0xFF when no second key.
register_key(key1);