Discussion:
[SeaBIOS] Add support for legacy USB keyboard/mouse (PS/2 emulation for USB?)
Adam Rutkowski
2016-04-15 23:26:43 UTC
Permalink
Hello,

I think this is the right place to write about this. From a few days I'm fighting with not USB-aware OS-es in QEMU (like Windows 98, IBM OS/2, MS-DOS etc.). When I assign real USB keyboard and mouse to VM, keyboard partially works in DOS (keys like Alt aren't working), but mouse doesn't work at all. After starting, let's say Windows 98 Setup, keyboard stops working too. From my experience these peripherals works only in newer OSes like Windows 2000+ or Linux, because they initialize their own USB HID driver. I'm not using QEMU's emulated USB HID devices, because I utilize VGA passthrough, so I need direct access from guest machine.

Summarizing: is it possible to add full support for USB keyboard and mouse in SeaBIOS?

P.S. I apologize for any grammatical errors.
Kevin O'Connor
2016-04-16 01:03:02 UTC
Permalink
Post by Adam Rutkowski
Hello,
I think this is the right place to write about this. From a few days
I'm fighting with not USB-aware OS-es in QEMU (like Windows 98, IBM
OS/2, MS-DOS etc.). When I assign real USB keyboard and mouse to VM,
keyboard partially works in DOS (keys like Alt aren't working), but
mouse doesn't work at all.
In my quick tests on freedos, both the usb keyboard alt key and usb
mouse work. That said, I don't doubt old DOS device drivers and old
OSes (eg, win98) would attempt to directly access the ps2 hardware and
thus not benefit from the SeaBIOS USB drivers.
Post by Adam Rutkowski
After starting, let's say Windows 98
Setup, keyboard stops working too. From my experience these
peripherals works only in newer OSes like Windows 2000+ or Linux,
because they initialize their own USB HID driver. I'm not using
QEMU's emulated USB HID devices, because I utilize VGA passthrough,
so I need direct access from guest machine.
Summarizing: is it possible to add full support for USB keyboard and mouse in SeaBIOS?
Unfortunately, emulating a ps2 keyboard/mouse in SeaBIOS is very
difficult, and I don't think it's practical.

However, it should be easy to have QEMU emulate a ps2 keyboard/mouse.
It should also be possible to do that emulation even if the VGA is in
passthrough.

-Kevin
Adam Rutkowski
2016-04-16 09:19:15 UTC
Permalink
Post by Kevin O'Connor
Post by Adam Rutkowski
Hello,
I think this is the right place to write about this. From a few days
I'm fighting with not USB-aware OS-es in QEMU (like Windows 98, IBM
OS/2, MS-DOS etc.). When I assign real USB keyboard and mouse to VM,
keyboard partially works in DOS (keys like Alt aren't working), but
mouse doesn't work at all.
In my quick tests on freedos, both the usb keyboard alt key and usb
mouse work. That said, I don't doubt old DOS device drivers and old
OSes (eg, win98) would attempt to directly access the ps2 hardware and
thus not benefit from the SeaBIOS USB drivers.
I also tested FreeDOS both in QEMU standard emulation and with VGA
passthrough. In standard SDL window, both keyboard and mouse are
emulated properly and everything works fine, but not when passing real
graphics card to KVM. In this mode, I need to forward my real keyboard
and mouse to guest (because QEMU is running in with -nographic) and then
the weird things happen. Keyboard works, but only when program doesn't
take control over it. Alt key sometimes works, sometimes not. Numeric
keypad doesn't work at all (Numlock LED is on and can't be turned off).
Mouse doesn't work anywhere. I tried FreeDOS edit and the block cursor
doesn't move. Additionally, after launching FreeDOS Shell (dosshell.exe)
keyboard stops working.
Post by Kevin O'Connor
Post by Adam Rutkowski
After starting, let's say Windows 98
Setup, keyboard stops working too. From my experience these
peripherals works only in newer OSes like Windows 2000+ or Linux,
because they initialize their own USB HID driver. I'm not using
QEMU's emulated USB HID devices, because I utilize VGA passthrough,
so I need direct access from guest machine.
Summarizing: is it possible to add full support for USB keyboard and mouse in SeaBIOS?
Unfortunately, emulating a ps2 keyboard/mouse in SeaBIOS is very
difficult, and I don't think it's practical.
However, it should be easy to have QEMU emulate a ps2 keyboard/mouse.
It should also be possible to do that emulation even if the VGA is in
passthrough.
-Kevin
This is my command I'm using to run FreeDOS in PCI/VGA passthrough mode
using vfio:
qemu-system-x86_64 -nographic -hda /mnt/freedos.qcow2 -vga none
-enable-kvm -m 512 -cpu host -localtime -smp 4 -device
vfio-pci,host=01:00.0,x-vga=on -device vfio-pci,host=01:00.1 -netdev
user,id=net0 -device rtl8139,netdev=net0 -usb -device
usb-host,vendorid=0x09da,productid=0x9090 -device
usb-host,vendorid=0x046d,productid=0xc31b

I was looking for other methods to use keys and mouse, but I couldn't
find anything other than USB host-to-guest.

Adam
Gerd Hoffmann
2016-04-18 10:42:53 UTC
Permalink
Hi,
Post by Adam Rutkowski
initialize their own USB HID driver. I'm not using QEMU's emulated USB
HID devices, because I utilize VGA passthrough, so I need direct
access from guest machine.
Better use the emulated ps/2 devices.

Starting with qemu 2.6 qemu can read input events directly from linux
evdev devices. With older versions you have to use a dummy sdl/gtk/vnc
device to feed qemu with input events.

cheers,
Gerd

Loading...