gpm icon indicating copy to clipboard operation
gpm copied to clipboard

Add support for VirtualBox guests

Open fonic opened this issue 6 years ago • 6 comments

This adds support for the 'USB Tablet' absolute pointing device emulated by VirtualBox. This enables Linux guests to seamlessly integrate, i.e. the pointer doesn't have to be captured by the guest anymore.

Pointer movement, all five buttons (two of them being mapped to 'middle') and both vertical and horizontal wheels are supported.

Vertical mouse wheel functionality could be verified using links in framebuffer mode. Horizontal wheel is untested due to the lack of a device with that feature.

Tested with:

  • Gentoo Linux host, amd64, VirtualBox 5.1.26
  • Ubuntu Server 16.04.3 LTS guest, both plain textmode and framebuffer

Please note:

  • the commented out code sections for wheel handling just reflect different approaches with the preferred one currently being active
  • gpm has to be instructed to use the appropriate input device, using /dev/input/mice will not work
  • makes #7, which was a rather unclean approach, obsolete

fonic avatar Aug 28 '17 13:08 fonic

Tested on Arch x64 inside VBox 5.1.30 works well with 1 minor quirk: After changing rows / lines of the console (using eg. setfont), there's a dead space in bottom right corner. You need to pass it until mouse pointer starts moving on console or in opposite direction leaves VBox window. Everything get back to normal after switching forth and back active console screen but at least 1 mouse event must be generated on another screen. :)

msokalski avatar Feb 12 '18 18:02 msokalski

@fonic, thank you for this! I was about to write a PR for supporting a QEMU USB Tablet, but after looking at yours and trying it, it works as-is for QEMU on Arch.

I think this would be great to get merged.

It might be worth naming it something different than vbox though, since it works for QEMU. I don't have a great suggestion for this. Maybe vmtablet, but perhaps that's too generic, because I have no idea how and if VMWare handles absolute positioning.

It also might be a good idea to put the last part of the patch in alphabetical order, whether it stays as vbox or is renamed to something else. The order given in the code is the order displayed by -t help, and at quick glance, it appears the rest are in alphabetical order except for at the top mman and ms.

jamespharvey20 avatar Aug 19 '19 01:08 jamespharvey20

Does this patch implement general USB tablet support? How is it specific to virtualbox? What about qemu?

The real issue here seems to be that gpm seems to lack support for tablet devices (which by definition send absolute coordinates, AFAIK). So what's missing to have general tablet support?

skoehler avatar Apr 23 '23 21:04 skoehler

Does this patch implement general USB tablet support? How is it specific to virtualbox? What about qemu?

This has been developed for and tested with VirtualBox, that's what makes it specific. @jamespharvey20 has tested it successfully on QEMU. I don't use QEMU and thus haven't verified. I could, but then there seems to be little interest in merging this PR (it's been open for almost 6 years now), so why invest precious time.

Does this implement general USB tablet support? Who knows. It might, it might not. I don't own any USB tablets and thus can't verify.

The real issue here seems to be that gpm seems to lack support for tablet devices (which by definition send absolute coordinates, AFAIK). So what's missing to have general tablet support?

Well, feel free to put in some work and investigate how [USB] tablets of different vendors work. The question is whether tablets in general present themselves like VirtualBox's USB tablet or not (quote from my own commit):

/*
 * USB Tablet emulated by VirtualBox for seamless mouse integration
 *
 * The 'VirtualBox USB Tablet' is an absolute pointing device which
 * uses values of range 0-32767 for both axes, reports five button
 * states (left, right, middle, side, extra) and two wheel states
 * (vertical, horizontal; both relative)
 */

fonic avatar Apr 24 '23 08:04 fonic