MrTanoshii / rusty-autoclicker

A pure Rust portable auto clicker built for Linux, macOS & Windows.
Creative Commons Zero v1.0 Universal
71 stars 12 forks source link

fix reported mouse buttons Left/Middle/Right instead of Left/Right/Middle #46

Closed correabuscar closed 1 year ago

correabuscar commented 1 year ago

tested on linux with two different mouses

MrTanoshii commented 1 year ago

Hmm odd, my specs are as follows:

Win10, Win11, Ubuntu22.04 (using WSL) I tested using 2 logitech and 3 generic mice (USB), connected to different ports

It seems to work correctly on my side.

What I have not tested is buttons 4 and 5

Can you please tell me a bit more about your mouse config?

correabuscar commented 1 year ago

EDIT: Might be that on windows the buttons are put in that "array"(or wut) in a different order than on Linux. I'll check how it looks like on Windows, for me, first.

Hmm odd, my specs are as follows:

Win10, Win11, Ubuntu22.04 (using WSL) I tested using 2 logitech and 3 generic mice (USB), connected to different ports

It seems to work correctly on my side.

What I have not tested is buttons 4 and 5

Can you please tell me a bit more about your mouse config?

wow, I didn't expect that to work for you and not for me, hmm... Buttons 4&5 are definitely not detected for me but only one mouse has them(and they work in firefox as back/forward webpage)

Both mice are on USB, both connected at the same time on two different ports on the motherboard Asus Prime Z370-A

Mouse 1: GEMBIRD, P/N: MUS-GU-01 (good but now double clicks sometimes and wheel scroll became useless; has 5 buttons aside from the dpi one) Mouse 2: iBOX, Model: IMOFIN1 (smelled like burnt plastic for like 3 years after bought, has weird shape for a mouse - will hurt your hand, but wheel scroll works well; has 3 buttons aside from the dpi one)

I've tested this so far only under Gentoo Linux (I'll edit this after booting on win11), kernel 6.2.2

Some things from dmesg and Xorg.0.log:

$ dmesg|grep -i mouse
[   34.636356] mousedev: PS/2 mouse device common for all mice
[   35.067393] usb 2-6: Product: USB Optical Mouse
[   35.090330] input: USB Optical Mouse as /devices/pci0000:00/0000:00:14.0/usb2/2-6/2-6:1.0/0003:1BCF:0005.0001/input/input18
[   35.092035] hid-generic 0003:1BCF:0005.0001: input,hidraw0: USB HID v1.10 Mouse [USB Optical Mouse] on usb-0000:00:14.0-6/input0
[   36.088239] usb 2-14: Product: USB Optical Mouse
[   36.103596] input: USB Optical Mouse  Keyboard as /devices/pci0000:00/0000:00:14.0/usb2/2-14/2-14:1.0/0003:1BCF:0053.0005/input/input22
[   36.159578] input: USB Optical Mouse  Mouse as /devices/pci0000:00/0000:00:14.0/usb2/2-14/2-14:1.0/0003:1BCF:0053.0005/input/input23
[   36.160579] hid-generic 0003:1BCF:0053.0005: input,hidraw4: USB HID v1.10 Keyboard [USB Optical Mouse ] on usb-0000:00:14.0-14/input0
[   57.784229] elogind-daemon[14384]: Watching system buttons on /dev/input/event22 (USB Optical Mouse  Keyboard)
$ grep -i mouse /home/user/.local/share/xorg/Xorg.0.log
[    88.458] (==) intel(0): Silken mouse enabled
[    88.482] (==) NVIDIA(G0): Silken mouse enabled
[    88.877] (II) XINPUT: Adding extended input device "Razer Razer Lycosa Consumer Control" (type: MOUSE, id 11)
[    88.881] (II) config/udev: Adding input device USB Optical Mouse  Keyboard (/dev/input/event22)
[    88.881] (**) USB Optical Mouse  Keyboard: Applying InputClass "evdev keyboard catchall"
[    88.881] (**) USB Optical Mouse  Keyboard: Applying InputClass "libinput keyboard catchall"
[    88.881] (**) USB Optical Mouse  Keyboard: Applying InputClass "system-keyboard"
[    88.881] (**) USB Optical Mouse  Keyboard: Applying InputClass "system-keyboard"
[    88.881] (II) Using input driver 'libinput' for 'USB Optical Mouse  Keyboard'
[    88.881] (**) USB Optical Mouse  Keyboard: always reports core events
[    88.882] (II) event22 - USB Optical Mouse  Keyboard: is tagged by udev as: Keyboard
[    88.882] (II) event22 - USB Optical Mouse  Keyboard: device is a keyboard
[    88.882] (II) event22 - USB Optical Mouse  Keyboard: device removed
[    88.882] (II) libinput: USB Optical Mouse  Keyboard: needs a virtual subdevice
[    88.882] (II) XINPUT: Adding extended input device "USB Optical Mouse  Keyboard" (type: MOUSE, id 13)
[    88.882] (**) USB Optical Mouse  Keyboard: (accel) selected scheme none/0
[    88.882] (**) USB Optical Mouse  Keyboard: (accel) acceleration factor: 2.000
[    88.882] (**) USB Optical Mouse  Keyboard: (accel) acceleration threshold: 4
[    88.883] (II) event22 - USB Optical Mouse  Keyboard: is tagged by udev as: Keyboard
[    88.883] (II) event22 - USB Optical Mouse  Keyboard: device is a keyboard
[    88.883] (II) config/udev: Adding input device USB Optical Mouse  Mouse (/dev/input/event23)
[    88.883] (**) USB Optical Mouse  Mouse: Applying InputClass "evdev pointer catchall"
[    88.883] (**) USB Optical Mouse  Mouse: Applying InputClass "libinput pointer catchall"
[    88.883] (II) Using input driver 'libinput' for 'USB Optical Mouse  Mouse'
[    88.884] (**) USB Optical Mouse  Mouse: always reports core events
[    88.884] (II) event23 - USB Optical Mouse  Mouse: is tagged by udev as: Mouse
[    88.885] (II) event23 - USB Optical Mouse  Mouse: device is a pointer
[    88.885] (II) event23 - USB Optical Mouse  Mouse: device removed
[    88.885] (II) XINPUT: Adding extended input device "USB Optical Mouse  Mouse" (type: MOUSE, id 14)
[    88.885] (**) USB Optical Mouse  Mouse: (accel) selected scheme none/0
[    88.885] (**) USB Optical Mouse  Mouse: (accel) acceleration factor: 2.000
[    88.885] (**) USB Optical Mouse  Mouse: (accel) acceleration threshold: 4
[    88.886] (II) event23 - USB Optical Mouse  Mouse: is tagged by udev as: Mouse
[    88.886] (II) event23 - USB Optical Mouse  Mouse: device is a pointer
[    88.886] (II) config/udev: Adding input device USB Optical Mouse  Mouse (/dev/input/mouse1)
[    88.886] (II) config/udev: Adding input device USB Optical Mouse (/dev/input/event18)
[    88.886] (**) USB Optical Mouse: Applying InputClass "evdev pointer catchall"
[    88.886] (**) USB Optical Mouse: Applying InputClass "libinput pointer catchall"
[    88.886] (II) Using input driver 'libinput' for 'USB Optical Mouse'
[    88.887] (**) USB Optical Mouse: always reports core events
[    88.887] (II) event18 - USB Optical Mouse: is tagged by udev as: Mouse
[    88.887] (II) event18 - USB Optical Mouse: device is a pointer
[    88.888] (II) event18 - USB Optical Mouse: device removed
[    88.888] (II) XINPUT: Adding extended input device "USB Optical Mouse" (type: MOUSE, id 15)
[    88.888] (**) USB Optical Mouse: (accel) selected scheme none/0
[    88.888] (**) USB Optical Mouse: (accel) acceleration factor: 2.000
[    88.888] (**) USB Optical Mouse: (accel) acceleration threshold: 4
[    88.888] (II) event18 - USB Optical Mouse: is tagged by udev as: Mouse
[    88.888] (II) event18 - USB Optical Mouse: device is a pointer
[    88.889] (II) config/udev: Adding input device USB Optical Mouse (/dev/input/mouse0)
[    88.997] (**) USB Optical Mouse  Keyboard: Applying InputClass "evdev keyboard catchall"
[    88.997] (**) USB Optical Mouse  Keyboard: Applying InputClass "libinput keyboard catchall"
[    88.997] (**) USB Optical Mouse  Keyboard: Applying InputClass "system-keyboard"
[    88.997] (**) USB Optical Mouse  Keyboard: Applying InputClass "system-keyboard"
[    88.997] (II) Using input driver 'libinput' for 'USB Optical Mouse  Keyboard'
[    88.997] (**) USB Optical Mouse  Keyboard: always reports core events
[    88.997] (II) libinput: USB Optical Mouse  Keyboard: is a virtual subdevice
[    88.997] (II) XINPUT: Adding extended input device "USB Optical Mouse  Keyboard" (type: KEYBOARD, id 17)

lsusb -vv about the mice:

Bus 002 Device 002: ID 1bcf:0005 Sunplus Innovation Technology Inc. Optical Mouse
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x1bcf Sunplus Innovation Technology Inc.
  idProduct          0x0005 Optical Mouse
  bcdDevice            0.14
  iManufacturer           0
  iProduct                2 USB Optical Mouse
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0022
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower               98mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      2 Mouse
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      75
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0007  1x 7 bytes
        bInterval              10
Device Status:     0x0000
  (Bus Powered)

Bus 002 Device 005: ID 1bcf:0053 Sunplus Innovation Technology Inc. USB Optical Mouse
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x1bcf Sunplus Innovation Technology Inc.
  idProduct          0x0053
  bcdDevice            0.72
  iManufacturer           0
  iProduct                2 USB Optical Mouse
  iSerial                 0
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0022
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower               98mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      2 Mouse
      iInterface              0
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     134
     can't get device qualifier: Resource temporarily unavailable
can't get debug descriptor: Resource temporarily unavailable
can't get debug descriptor: Resource temporarily unavailable
    Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
Device Status:     0x0000
  (Bus Powered)
$ lxqt-config
add "us" "basic"
Detected "USB Optical Mouse  Mouse" on "/dev/input/event23"
xinput driver: "libinput"
Detected "USB Optical Mouse" on "/dev/input/event18"
xinput driver: "libinput"

mouse1of2_screen-2023-03-10-11-06-50 mouse2of2_screen-2023-03-10-11-06-31

correabuscar commented 1 year ago

Can confirm that the buttons work as intended in win11 (without this PR, that is), and button 4(go back one page, alt-left arrow, in firefox) and button 5(go forward one page, alt-right arrow) are also detected.

So this must be an underlying issue ? different OS-es, different order of buttons in that array.

MrTanoshii commented 1 year ago

Hmm, I'll investigate further and if it's related to different OS-es, it can be fixed