BLeeEZ / rpi-kvm

Raspberry Pi K(V)M: Switch keyboard and mouse input between bluetooth clients.
GNU General Public License v3.0
37 stars 9 forks source link

Mouse pointer position is not repeatable #5

Open willberriss opened 2 years ago

willberriss commented 2 years ago

Hi Maximilian

I have noticed that moving the mouse in a perfect square repeatedly does not result in the pointer drawing the same square repeatedly. The square can drift left, right, up or down. I checked this by using a grid as the wallpaper on my phone and moving the mouse by hand in a constrained square boundary.

I was pretty sure it was drifting, but to be sure, I modified mouse.py to draw a "square" over and over on the screen. For example, I moved the mouse pointer right by 100 five times, then down by 100 five times, then left by 100 five times, then up by 100 five times, over and over. The square being drawn by the mouse pointer drifted across and down the screen, in a jerky manner. I was expecting the square to remain in the same place and not move at all.

Is this expected behaviour? If so, why?

Thanks in advance

Will

willberriss commented 2 years ago

Hi again Maximilian

I was hoping to be able to control the mouse accurately via a python script, to place the mouse in the same position each time. Ideally I need an absolute co-ordinate device rather than a relative one, so I tried altering the HID hex value in sdp_record.xml, changing 0x8106 to 0x8102, to see if it would change the relative position to an absolute position, but it did not work. I guess there is more to change in the HID descriptor. The change made no difference at all though, which surprised me. I thought it would break things but it just worked as before.

Would you happen to have a HID descriptor for an absolute pointer device, like a Wacom touch pad or anything similar that uses absolute position coordinates rather than relative motion? I would like to send the value (100, 100) and have the pointer go to that absolute position on the screen, rather than move by 100 in the x and y direction.

Thanks in advance

Will

willberriss commented 2 years ago

Hi again

I found a Wacom tablet at home and pasted its HID descriptor below. Will it just work if I use it in sdp_record.xml or are code changes required too?

$ sudo usbhid-dump -s 001:005 001:005:000:DESCRIPTOR 1662736860.746352 06 0D FF 09 01 A1 01 85 10 09 20 35 00 45 00 15 00 25 01 A1 00 09 42 09 44 09 5A 25 01 75 01 95 03 81 02 95 02 81 03 09 32 09 36 95 02 81 02 95 01 81 03 0A 30 01 65 11 55 0D 47 60 3B 00 00 27 60 3B 00 00 75 18 95 01 81 02 0A 31 01 47 1C 25 00 00 27 1C 25 00 00 81 02 09 30 55 00 65 00 26 FF 0F 75 10 81 02 75 08 95 06 81 03 0A 32 01 25 3F 75 08 95 01 81 02 09 5B 09 5C 17 00 00 00 80 27 FF FF FF 7F 75 20 95 02 81 02 09 77 15 00 26 FF 0F 75 10 95 01 81 02 C0 85 11 65 00 55 00 35 00 45 00 09 39 A1 00 0A 10 09 0A 11 09 0A 12 09 0A 13 09 15 00 25 01 75 01 95 04 81 02 95 04 81 03 75 08 95 07 81 03 C0 85 13 65 00 55 00 35 00 45 00 0A 13 10 A1 00 0A 3B 04 15 00 25 64 75 07 95 01 81 02 0A 04 04 25 01 75 01 81 02 09 00 26 FF 00 75 08 81 02 75 08 95 06 81 03 C0 09 0E A1 02 85 02 0A 02 10 15 01 25 02 75 08 95 01 B1 02 85 03 0A 03 10 15 00 26 FF 00 95 01 B1 02 85 04 0A 04 10 15 01 25 01 95 01 B1 02 85 07 0A 09 10 15 00 26 FF 00 95 01 B1 02 B1 03 0A 07 10 09 00 27 FF FF 00 00 75 10 95 02 B1 02 75 08 95 09 B1 03 85 0C 0A 30 0D 0A 31 0D 0A 32 0D 0A 33 0D 65 11 55 0D 35 00 46 C8 00 15 00 26 90 01 75 10 95 04 B1 02 85 0D 0A 0D 10 65 00 55 00 45 00 25 01 75 08 95 01 B1 02 85 14 0A 14 10 26 FF 00 95 0D B1 02 85 CC 0A CC 10 95 02 B1 02 85 31 0A 31 10 25 64 95 03 B1 02 95 02 B1 03 C0 0A AC 10 A1 02 15 00 26 FF 00 75 08 85 AC 09 00 96 BF 00 81 02 85 15 09 00 95 0E B1 02 85 33 09 00 95 12 B1 02 85 44 09 00 95 04 B1 02 85 45 09 00 95 20 B1 02 85 60 09 00 95 3F B1 02 85 61 09 00 95 3E B1 02 85 62 09 00 95 3E B1 02 85 65 09 00 95 04 B1 02 85 66 09 00 95 04 B1 02 85 67 09 00 95 04 B1 02 85 68 09 00 95 11 B1 02 85 6F 09 00 95 3E B1 02 85 CD 09 00 95 02 B1 02 85 16 09 00 95 0E B1 02 85 35 09 00 95 0A B1 02 C0 85 D0 09 01 96 08 00 B1 02 85 D1 09 01 96 04 01 B1 02 85 D2 09 01 96 04 01 B1 02 85 D3 09 01 96 04 00 B1 02 85 D4 09 01 96 04 00 B1 02 85 D5 09 01 96 04 00 B1 02 85 D6 09 01 96 04 00 B1 02 85 D7 09 01 96 08 00 B1 02 85 D8 09 01 96 0C 00 B1 02 85 D9 09 01 96 00 05 B1 02 85 DA 09 01 96 04 02 B1 02 85 DB 09 01 96 06 00 B1 02 85 DC 09 01 96 02 00 B1 02 85 DD 09 01 96 04 00 B1 02 85 DE 09 01 96 04 00 B1 02 85 DF 09 01 96 22 00 B1 02 85 E0 09 01 96 01 00 B1 02 85 E1 09 01 96 02 00 B1 02 85 E2 09 01 96 02 00 B1 02 85 E3 09 01 96 02 00 B1 02 85 E4 09 01 96 FF 01 B1 02 C0

$ sudo lsusb -s 001:005 -v

Bus 001 Device 005: ID 056a:0374 Wacom Co., Ltd CTL-4100 [Intuos (S)] Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 0 bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x056a Wacom Co., Ltd idProduct 0x0374 CTL-4100 [Intuos (S)] bcdDevice 1.11 iManufacturer 1 Wacom Co.,Ltd. iProduct 2 Intuos S iSerial 3 8EH00R2010832 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 0x0022 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0x80 (Bus Powered) MaxPower 500mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 3 Human Interface Device bInterfaceSubClass 0 bInterfaceProtocol 0 iInterface 0 HID Device Descriptor: bLength 9 bDescriptorType 33 bcdHID 1.10 bCountryCode 0 Not supported bNumDescriptors 1 bDescriptorType 34 Report wDescriptorLength 759 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 0x0040 1x 64 bytes bInterval 1 can't get device qualifier: Resource temporarily unavailable can't get debug descriptor: Resource temporarily unavailable Device Status: 0x0000 (Bus Powered)

BLeeEZ commented 2 years ago

The whole HID descriptor is only real testable with the device in hand. I am not an expert is this domain. This was just a hobby project and I did some reading.

To test HID descriptor changes you need to remove rpi-kvm from your pc‘s Bluetooth devices. The descriptor is saved on the clients machine and then always used. To update / test modifications you need to completely remove and reestablish the connection.

I think the code needs adjustments to support absolute values. The hid descriptor describes the usb messages send to the client and the representation of the bytes. I don’t know if additional information needs to be send for absolute pointer devises.

willberriss commented 2 years ago

Thank you very much for your reply and the information, it’s very much appreciated. I will have to look into it and research it some more. Thanks again. :) Will

spoelstraethan commented 10 months ago

As mentioned, mice operate in relative positioning mode while some touch pads, most touchscreens, and most graphics tablets operate in absolute positioning mode.

The other thing to keep in mind is there are times even with a locally attached input device that the kernel will drop events it receives too quickly in order to keep the rest of the system responsive, as soon as you introduce any kind of hop whether via a wired connection over USB or ethernet or wireless via Wi-Fi or Bluetooth that introduces some extra latency as well as the potential for other buffers and congestion control to drop things.

If you check out iSticktoit.net there's a good post on the Raspberry Pi gadget mode composite functionality where you can have the Raspberry Pi act as a keyboard and mouse and there are some descriptors for the HID capabilities there.