hrvach / deskhop

Fast Desktop Switching Device
GNU General Public License v3.0
5.96k stars 166 forks source link

Middle mouse button sends multiple button presses #99

Closed techge closed 1 week ago

techge commented 3 weeks ago

I had a strange behavior where pressing the middle mouse button (the one of the wheel) resulting in "going back" in my browser (like using the previous page icon in the browser).

After checking xev with and without deskhop, I realized that deskhop is sending three buttons when using the middle mouse button: 2, 8, 9. When using the very same mouse without deskhop, only button 2 is send (as intended).

Button 8 and 9 is sometimes associated with thumb buttons which are usually used for going back or forward. See this arch wiki page. This is why my browser behaves the way described above.

So question is... why does deskhop send three buttons instead of just button 2 as it is supposed to (imho)? Can we fix that?

hrvach commented 3 weeks ago

Can you put the mouse usb hid descriptor and a few captured reports from both the mouse and the box? Buttons shouldn't be altered in any way, but bugs do happen

techge commented 3 weeks ago

Okay, this was tested on an Arch Linux system and with my qubes (not that this should really matter).

Let's start with the mouse without deskhop...

mousedescriptor

003:004:000:DESCRIPTOR         1717929035.232328
 05 01 09 02 A1 01 09 01 A1 00 05 09 19 01 29 03
 15 00 25 01 95 03 75 01 81 02 95 01 75 05 81 01
 05 01 09 30 09 31 16 00 F8 26 FF 07 75 0C 95 02
 81 06 09 38 15 81 25 7F 75 08 95 01 81 06 C0 C0

mouse key presses

ButtonPress event, serial 34, synthetic NO, window 0x1200001,
    root 0x2ef, subw 0x0, time 13083897, (230,411), root:(916,435),
    state 0x0, button 2, same_screen YES

ButtonRelease event, serial 34, synthetic NO, window 0x1200001,
    root 0x2ef, subw 0x0, time 13084056, (230,411), root:(916,435),
    state 0x200, button 2, same_screen YES

When using deskhop the situation is differently...

deskhop descriptor

003:002:001:DESCRIPTOR         1717928928.394696
 05 01 09 02 A1 01 85 01 09 01 A1 00 05 09 19 01
 29 05 15 00 25 01 95 05 75 01 81 02 95 01 75 03
 81 01 05 01 09 30 09 31 15 81 25 7F 95 02 75 08
 81 06 09 38 15 81 25 7F 95 01 75 08 81 06 05 0C
 0A 38 02 15 81 25 7F 95 01 75 08 81 06 C0 C0

003:002:000:DESCRIPTOR         1717928928.395154
 05 01 09 06 A1 01 85 01 05 07 19 E0 29 E7 15 00
 25 01 95 08 75 01 81 02 95 01 75 08 81 01 05 08
 19 01 29 05 95 05 75 01 91 02 95 01 75 03 91 01
 05 07 19 00 2A FF 00 15 00 26 FF 00 95 06 75 08
 81 00 C0 05 01 09 02 A1 01 85 02 09 01 A1 00 05
 09 19 01 29 05 15 00 25 01 95 05 75 01 81 02 95
 01 75 03 81 01 05 01 09 30 09 31 15 00 26 FF 7F
 75 10 95 02 81 02 09 38 15 81 25 7F 95 01 75 08
 81 06 95 01 75 08 81 01 C0 C0 05 0C 09 01 A1 01
 85 04 15 01 26 FF 0F 19 01 2A FF 0F 75 10 95 02
 81 00 C0

deskhop mouse key presses

ButtonPress event, serial 31, synthetic NO, window 0x1200001,
    root 0x2ef, subw 0x0, time 13009991, (272,440), root:(958,464),
    state 0x0, button 2, same_screen YES

ButtonPress event, serial 31, synthetic NO, window 0x1200001,
    root 0x2ef, subw 0x0, time 13009991, (272,440), root:(958,464),
    state 0x200, button 8, same_screen YES

ButtonPress event, serial 31, synthetic NO, window 0x1200001,
    root 0x2ef, subw 0x0, time 13009991, (272,440), root:(958,464),
    state 0x200, button 9, same_screen YES 

ButtonRelease event, serial 31, synthetic NO, window 0x1200001,
    root 0x2ef, subw 0x0, time 13010151, (272,440), root:(958,464),
    state 0x200, button 2, same_screen YES 

ButtonRelease event, serial 31, synthetic NO, window 0x1200001,
    root 0x2ef, subw 0x0, time 13010151, (272,440), root:(958,464),
    state 0x0, button 8, same_screen YES

ButtonRelease event, serial 31, synthetic NO, window 0x1200001,
    root 0x2ef, subw 0x0, time 13010151, (272,440), root:(958,464),
    state 0x0, button 9, same_screen YES
techge commented 3 weeks ago

Btw I also realized that mouse movements and button presses coming from a qmk keyboard are seemingly not transmitted by deskhop as well. I do not expect this to work (as in "it is fine if it does not"), but might be an indicator that the library is not just transferring every key press as is?

techge commented 3 weeks ago

I tried to look around a bit in the code to find the cause of this behavior and now I am wondering...

We have an update routine here where we store the values of an uint32_t in an int16_t variable. Honest question as I am not an too experienced (c) developer: this might be a problem, doesn't it?

techge commented 3 weeks ago

Although I am still wondering if the above would be an issue, it might be related to my mouse in the end. Today I wanted to test around again, but could not reproduce the issue. The only difference I could think of is the mouse and keyboard setup I am using right now.

I gonna test the original mouse/keyboard pair end of next week and report my findings.

techge commented 1 week ago

Okay, the behavior only occurs with a specific mouse I have. Why that is, I can not explain. Anyway, I do not think deskhop need to support any random mouse, there are more interesting topics and said mouse is really a shitty throw-away one, therefore I am closing this issue.