QEMU and mouse integration in DOS

Currently, special wctablet serial device of QEMU needs an additional patch to work properly with DOS. The patch itself is rather small:

chardev/wctablet.c | 5 ++++-

 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/chardev/wctablet.c b/chardev/wctablet.c
index 95e005f5a5..0e53b194d8 100644
--- a/chardev/wctablet.c
+++ b/chardev/wctablet.c
@@ -139,7 +139,10 @@ static void wctablet_queue_event(TabletChardev *tablet)
codes[5] = codes[5] | WC_L7(nexY);

    if (tablet->btns[INPUT_BUTTON_LEFT])  {
-        codes[0] = 0xa0;
+        //codes[0] = 0xa0;
+        codes[0] |= 0x0c; /* 0x08 (button pressed) + pressure p0 bit */
+        codes[3] |= 0x0c; /* 8 (button number is 1) + pressure p1 bit */
+        codes[6] = 0x3f;  /* high positive pressure is applied */
     }

     wctablet_queue_output(tablet, codes, 7);
--

Getting QEMU source code, patching and building it is out of scope for this instruction. But when you have patched and recompiled QEMU, the following steps are needed to get mouse integration with DOS running in QEMU:

  1. You have to install a DOS mouse emulation driver for the Wacom PenPartner serial tablet. You can download this driver from the Internet Archive.
  2. Now you have to unpack this zip archive and copy the WMOUSE.COM file to the guest operating system drive. It may be easier to mount your hard drive image to the host operating system and copy needed file from there. Following steps will mount your QCOW image to your host filesystem:
    1. turn on NDB support:
      sudo modprobe nbd max_part=8

    2. attach your image as an NDB device:
      sudo qemu-nbd --connect=/dev/nbd0 <image.qcow>

    3. look at the partition table of your image to find which partition to mount:sudo fdisk /dev/nbd0 -l
    4. mount the needed partition to your host filesystem (let’s suppose you are mounting your 1st partition to /mnt/):
      sudo mount /dev/nbd0p1 /mnt/
    5. copy WMOUSE.COM file from the downloaded ZIP archive into your image.

    6. Unmount the image and detach it from the NBD:
      sudo umount /dev/nbd0p1
      sudo qemu-nbd --disconnect /dev/nbd0

  3. Run your virtual machine with two additional parameters. The first one will create a special character device with some arbitrary name you (e.g. “mywctablet1”). The second one will attach this character device to your serial (COM) port:

    qemu-system-i386 -m 1 -hda image.qcow -chardev wctablet,id=mywctablet1 -serial chardev:mywctablet1

  4. QEMU will use the new wctablet device to control your pointer, but to make DOS “see” it as mouse you need to run the driver with parameters to make it using absolute positioning mode and proper tablet dimensions:

    qemu-system-i386 -m 32 -hda image.qcow -chardev
    wctablet,id=somename -serial chardev:somename

  5. Now you can run any DOS programs which use normal DOS-compatible mouse. For example, here we tested it with OpenGEM graphical shell in FreeDOS:

QEMU and mouse integration in Windows 95 and Windows 95 OSR2

Special wctablet serial device supported by QEMU is able to bring mouse integration in the same way as “-usb-device tablet” (old way) and “-usb -device usb-tablet” (new way) do.

Note: It was noticed, that under QEMU 2.11 Windows 95 with serial tablet hangs and thus doesn’t work. In earlier and later versions everything is working. Windows 95 OSR2 works with mouse integration in all tested versions.

The following steps are needed to get mouse integration with Windows 95 and Windows 95 OSR2 running in QEMU:

  1. You will need to install a driver for the Wacom PenPartner serial tabled. You can download the driver installation CD here
  2. Run your virtual machine with the downloaded ISO image in addition to your HDD image with Windows, and add two additional command line parameters. The first one will create a special character device with some arbitrary name you (e.g. “mywctablet1”). The second one will attach this character device to your serial (COM) port:

    qemu-system-i386 -m 32 -hda image.qcow -cdrom Wacom\ Pen\ Partner\ \(Version\ 2.50\)\(WACOM\)\(1 997\).iso -chardev wctablet,id=somename -serial chardev:somename

  3. QEMU will use the new wctablet device to control your pointer, but Windows knows nothing about it yet. So use your keyboard (Tab, arrow keys and Enter) for navigaton. Open the needed folder in a file manager, run Setup.exe and proceed with the installation as follows:

    Now select “Tablet Only” (you may just press the “O” key to make it selected):

  4. Now there is one more step, which is needed only for Windows 95 (Windows 95 OSR2 works OK without it). When the installation is finished, you should close the installer and run it once again (otherwise driver may not work after reboot):

    Now when you press “OK”, the Windows will restart and the driver will work.

  5. You will have mouse integration each time when you run your virtual machine as follows:

    qemu-system-i386 -m 32 -hda {guest_system_img} -chardev wctablet,id=somename -serial chardev:somename

QEMU and mouse integration in Windows 3.x

Special wctablet serial device supported by QEMU is able to bring mouse integration in the same way as “-usb-device tablet” (old way) and “-usb -device usb-tablet” (new way) do.

The following steps are needed to get mouse integration with Windows 3.x running in QEMU:

  1. You will need to install a driver for the Wacom PenPartner serial tabled. You can download the driver installation CD here
  2. Now you have to make files from this CD visible to the guest operating system.

    A) If your Windows 3.x installation already has CD-ROM drivers, you can simply add“-cdrom <image.iso>”to the QEMU command line. If that-s not your case, adding CD-ROM DOS drivers is rather tricky, so it may be easier to follow the plan B:

    B) If you have no CD-ROM driver installed, it may be easier to mount your hard drive image to the host operating system and copy needed files from there. Following steps will mount your QCOW image to your host filesystem:

    1. turn on NDB support:

      sudo modprobe nbd max_part=8

    2. attach your image as an NDB device:

      sudo qemu-nbd --connect=/dev/nbd0 <image.qcow>

    3. look at the partition table of your image to find which partition to mount:

      sudo fdisk /dev/nbd0 -l

    4. mount the needed partition to your host filesystem (let’s suppose you are mounting your 1st partition to /mnt/):

      sudo mount /dev/nbd0p1 /mnt/

    5. copy files from the downloaded CD into your image. You can “unpack” ISO images as archive. If you would like to save space, copy everything but the COREL folder (the one which has nothing to do with the driver but is about 500 Mb in size).
    6. Unmount the image and detach it from the NBD:

      sudo umount /dev/nbd0p1
      sudo qemu-nbd --disconnect /dev/nbd0

  1. Run your virtual machine with two additional parameters. The first one will create a special character device with some arbitrary name you (e.g. “mywctablet1”). The second one will attach this character device to your serial (COM) port:

    qemu-system-i386 -m 32 -hda image.qcow -chardev wctablet,id=mywctablet1 -serial chardev:mywctablet1

    Note: don’t forget to add “-cdrom <image.iso>” to the QEMU command line if you will read driver from CD

  2. QEMU will use the new wctablet device to control your pointer, but Windows knows nothing about it yet. So go to QEMU Monitor and switch your pointing device to mouse:
    1. Press Ctrl + Alt + 2, to go into the monitor:
    2. Enter the “mouse_set 3” command to use ps/2 mouse (two other devices are your tablet and your keyboard).
    3. Press Ctrl + Alt + 1 to switch back to your GUEST screen from QEMU monitor.
  1. When Windows have been booted, open the needed folder in a file manager:
  2. Run setup.exe and follow the instructions:
  3. Reboot your system when the driver installation is finished.
  4. Now you will have mouse integration each time when you run your virtual machine as follows:

    qemu-system-i386 -m 32 -hda image.qcow -chardev
    wctablet,id=somename -serial chardev:somename

Legacy OS mouse integration

Problem description

Running old-time OS in emulator often comes with a problem of non-coinciding cursors. This problem arises from the availability of two different types of cursor positioning devices: ones with relative coordinates (computer mice) and ones with absolute coordinates (tablets and touchscreens). Relative positioning devices provide operating system with the vector of the cursor movement instead of it's new coordinates, and as a result, different cursor acceleration formulas are breaking coincidence of host and guest systems cursor.

Mainstream visualization systems (including QEMU) can emulate as relative pointing devices (PS/2 and serial mice), so an absolute pointing device (USB Wacom tablet in case of QEMU). Mode with absolute coordinates allows host cursor to control guest OS and is called “mouse integration mode” in desktop virtualization systems. But mouse integration is available only if guest OS either has special driver from the virtual machine vendor, or supports USB tablet. In all other situations desktop virtual machines use “mouse lock mode,” when host cursor is hidden until some dedicated hotkey is pressed, and user can interact with the guest system only. This mode is not only less convenient for operation, but it is usable for the web access to the virtualized system. So projects providing web demonstration of old operating systems have to show user two cursors moving with different speed:

Solution

Starting from version 1.9, QEMU implements emulation of the RS-232 Wacom tablet (wctablet) as an additional character device backend. Currently it is the only virtualization system with such capabilities.

Guest OS still needs drivers for such tablet, which exist for DOS, OS/2, Windows 3.x and Windows 95, BeOS, Mac OS 9.x and Mac OS X, and some other systems.

You can test how this feature works with our pre-configured Windows 3.11 image – just run it with the following command:

qemu-system-i386 -m 32 -hda win311.qcow -chardev wctablet,id=wacom -serial chardev:wacom

This ostimeline subproject was created as a hub for the information on how to find and install necessary drivers for the pre-USB operating systems to achieve mouse integration.