From 0c25a46dc85eb5b5d5cdfe30ec7074760dfd6399 Mon Sep 17 00:00:00 2001 From: tmk Date: Wed, 30 Mar 2022 09:40:04 +0900 Subject: [PATCH] adb_usb: Fix for weirdness of 2-button mouses #724 This ignores 'optional second button' in Apple Classic Mouse protocol as Mac OS9 and OSX does. This is needed and useful in most cases. NeXT ADB Mouse is an exception, this disables its right button. You can disable this using `ADB_MOUSE_2ND_BUTTON_QUIRK` in config.h. --- converter/adb_usb/config.h | 5 +++++ converter/adb_usb/matrix.c | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/converter/adb_usb/config.h b/converter/adb_usb/config.h index 70c5e67d..a0996d03 100644 --- a/converter/adb_usb/config.h +++ b/converter/adb_usb/config.h @@ -42,6 +42,11 @@ along with this program. If not, see . // Mouse Extended Report #define MOUSE_EXT_REPORT +// Second button in Apple Classic Mouse protocol is ignored as Mac OS9 and OSX does. +// Without this some of 2-button mouses are unusable. +// https://github.com/tmk/tmk_keyboard/issues/724 +#define ADB_MOUSE_2ND_BUTTON_QUIRK + /* ADB port setting */ #define ADB_PORT PORTD diff --git a/converter/adb_usb/matrix.c b/converter/adb_usb/matrix.c index 54ffb084..fd33aaaa 100644 --- a/converter/adb_usb/matrix.c +++ b/converter/adb_usb/matrix.c @@ -507,6 +507,13 @@ void adb_mouse_task(void) if (buf[0] & 0x40) yneg = true; if (buf[1] & 0x40) xneg = true; len = 2; + + #ifdef ADB_MOUSE_2ND_BUTTON_QUIRK + // Ignore b01('optional second button') as OSX/MacOS9 does. + // Some mouses misuse the bit and make it unusable. + // https://github.com/tmk/tmk_keyboard/issues/724 + buf[1] |= 0x80; + #endif } // Make unused buf bytes compatible with Extended Mouse Protocol