tmk / tmk_keyboard

Keyboard firmwares for Atmel AVR and Cortex-M
3.98k stars 1.7k forks source link

PS/2 3-Button Intellimouse recognized as Default #716

Closed Bmkool closed 2 years ago

Bmkool commented 2 years ago

The 3 button PS/2 Intellimouse is recognized as a standard PS/2 mouse by the library.

In converter/ibmpc_usb/ibmpc_usb.cpp.

MOUSE_INTELLI:
                    // Intellimouse protocol: 3
                    xprintf("\nINT: ");
                    ibmpc.host_send(0xF3); ibmpc.host_send(0xC8);
                    ibmpc.host_send(0xF3); ibmpc.host_send(0x64);
                    ibmpc.host_send(0xF3); ibmpc.host_send(0x50);
                    mouse_id = ((read_keyboard_id() >> 8) == MOUSE_INTELLI ? MOUSE_INTELLI : MOUSE_DEFAULT);

                    // Intellimouse Explorer protocol: 4
                    xprintf("\nEXP: ");
                    ibmpc.host_send(0xF3); ibmpc.host_send(0xC8);
                    ibmpc.host_send(0xF3); ibmpc.host_send(0xC8);
                    ibmpc.host_send(0xF3); ibmpc.host_send(0x50);
                    mouse_id = ((read_keyboard_id() >> 8) == MOUSE_EXPLORER ? MOUSE_EXPLORER : MOUSE_DEFAULT);

                    // Not Intellimouse
                    if (mouse_id == 0) {
                        xprintf("\nDEF: ");
                        ibmpc.host_send(0xF6);  // Set Default
                    }

Looks like the mouse_id gets set back to default in the protocol 4 check even if the ID 03 is read again.

tmk commented 2 years ago

How should we fix for this?

and what does the "3 button PS/2 Intellimouse" look like? It has scroll wheel, right?

Bmkool commented 2 years ago

Yes that's a three button with the scroll wheel. I think I fixed it by adding a check before the Intellimouse explorer that it is indeed an Intellimouse:

MOUSE_INTELLI:
                    // Intellimouse protocol: 3
                    xprintf("\nINT: ");
                    ibmpc.host_send(0xF3); ibmpc.host_send(0xC8);
                    ibmpc.host_send(0xF3); ibmpc.host_send(0x64);
                    ibmpc.host_send(0xF3); ibmpc.host_send(0x50);
                    mouse_id = ((read_keyboard_id() >> 8) == MOUSE_INTELLI ? MOUSE_INTELLI : MOUSE_DEFAULT);
                    if (MOUSE_INTELLI == mouse_id) {
                        // Intellimouse Explorer protocol: 4
                        xprintf("\nEXP: ");
                        ibmpc.host_send(0xF3); ibmpc.host_send(0xC8);
                        ibmpc.host_send(0xF3); ibmpc.host_send(0xC8);
                        ibmpc.host_send(0xF3); ibmpc.host_send(0x50);
                        mouse_id = ((read_keyboard_id() >> 8) == MOUSE_EXPLORER ? MOUSE_EXPLORER : MOUSE_INTELLI);
                    }

                    // Not Intellimouse
                    if (mouse_id == 0) {
                        xprintf("\nDEF: ");
                        ibmpc.host_send(0xF6);  // Set Default
                    }

Although I don't have an Intellimouse explorer to test this with, according to this that appears to be the expected behavior.

tmk commented 2 years ago

I see. It makes sense now.

Does this change work for you? I tested with my Logitech MX510, which supports Explorer protocol.

--- a/converter/ibmpc_usb/ibmpc_usb.cpp
+++ b/converter/ibmpc_usb/ibmpc_usb.cpp
@@ -458,7 +458,7 @@ MOUSE_INTELLI:
                     ibmpc.host_send(0xF3); ibmpc.host_send(0xC8);
                     ibmpc.host_send(0xF3); ibmpc.host_send(0xC8);
                     ibmpc.host_send(0xF3); ibmpc.host_send(0x50);
-                    mouse_id = ((read_keyboard_id() >> 8) == MOUSE_EXPLORER ? MOUSE_EXPLORER : MOUSE_DEFAULT);
+                    mouse_id = ((read_keyboard_id() >> 8) == MOUSE_EXPLORER ? MOUSE_EXPLORER : mouse_id);

                     // Not Intellimouse
                     if (mouse_id == 0) {
Bmkool commented 2 years ago

Yep looks good to me.

tmk commented 2 years ago

Thanks.