Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux evdev: Added support for absolute mode mice, such as USB tablet or VirtualBox mouse integration #7899

Merged
merged 1 commit into from
Jul 10, 2023

Conversation

andre-barata
Copy link
Contributor

In cases where the mouse is being reported as absolute, such as an USB tablet device, the evdev handling code was not implementing scaling to screen size, and was ignoring the reported ABS_X/ABS_Y MAX values. So the mouse pointer was mostly outside the screen bounds.

(squashed version)

@slouken
Copy link
Collaborator

slouken commented Jun 30, 2023

This seems reasonable to me, @smcv, any thoughts?

@smcv
Copy link
Contributor

smcv commented Jul 10, 2023

I have no particular knowledge of how mice are represented in evdev, so no useful review from me here, sorry. The changes look plausible, at least.

In the commit message, I assume you mean "USB graphics tablet" (or just "graphics tablet" really), and "VirtualBox"?

It's common for virtual machine managers like VirtualBox and libvirt/qemu to emulate a USB graphics tablet in preference to emulating an actual mouse, if the guest OS supports it, because that means they can have a 1:1 mapping from cursor position on the host system to cursor position in the guest (particularly important if you're using an absolute pointing device on the host).

There are really two possible meanings for "mouse": either specifically a traditional mouse (which is always a relative pointing device), or a generic term for pointing devices, potentially either relative (traditional mice, trackballs, trackpads, pointing sticks) or absolute (basically graphics tablets, I can't think of any others). It seems SDL is using the more generic meaning in its API; hopefully that's clear from documentation.

@andre-barata andre-barata changed the title linux evdev: Added support for absolute mode mice, such as USB tablet or VirtuaBox mouse integration linux evdev: Added support for absolute mode mice, such as USB tablet or VirtualBox mouse integration Jul 10, 2023
@andre-barata
Copy link
Contributor Author

Hello Simon,

Exacly. I had a typo in the title, i did mean VirtualBox. In "mouse integration mode", virtualbox, emulates a USB grapthics tablet, which in linux-evdev, if the kernel/modules have been properly set, makes it available as an absolute pointing device, It could be debatable as for calling it a mouse, but I guess the intented cursor functionality is the same as a mouse, except with absolute positioning.

For me, this made it possible to use the mouse cursor in an non-X11/wayland with KMS/DRM inside a virtual machine with full mouse integration (no neet to capture / release the mouse cursor), such as the one available for X11. And yes probably in other virtualization solutions the result would be the same, and for real graphics tablet hardware,

@slouken slouken merged commit 9cd7cbe into libsdl-org:SDL2 Jul 10, 2023
37 checks passed
@slouken
Copy link
Collaborator

slouken commented Jul 10, 2023

Merged, thanks!

@slouken
Copy link
Collaborator

slouken commented Jul 10, 2023

@andre-barata, I ported this to SDL3, can you grab the latest SDL main code and make sure that works as well? You should be able to use the SDL test programs to verify this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants