Attached is a simple patch (for 0.9.0 and current cvs), that allows:

-usbdevice touchscreen

which behaves the same as touchpad, except the coordinates are screen
coordinates instead of scaled 32768 coordinates.

This makes qemu compatible with tslib, often used by xserver-kdrive.
tslib does not scale usb input to screen. tslib assumes input is screen
coordinates.

(Well tslib requires a small patch to allow button events to work like
pressure events).

Perhaps an additional or alternative change could separate usb
touchscreen support from tablet, such that ABS_PRESSURE events are
generated instead of left button.

-Don


diff -ru qemu-0.9.0/sdl.c qemu-0.9.0-touch/sdl.c
--- qemu-0.9.0/sdl.c	2007-02-05 15:01:54.000000000 -0800
+++ qemu-0.9.0-touch/sdl.c	2007-06-19 09:19:26.000000000 -0700
@@ -281,8 +287,10 @@
 	}
 
 	SDL_GetMouseState(&dx, &dy);
-	dx = dx * 0x7FFF / width;
-	dy = dy * 0x7FFF / height;
+	if(!use_absolute_screen_coordinates) {
+		dx = dx * 0x7FFF / width;
+		dy = dy * 0x7FFF / height;
+	}
     } else if (absolute_enabled) {
 	sdl_show_cursor();
 	absolute_enabled = 0;
diff -ru qemu-0.9.0/vl.c qemu-0.9.0-touch/vl.c
--- qemu-0.9.0/vl.c	2007-02-05 15:01:54.000000000 -0800
+++ qemu-0.9.0-touch/vl.c	2007-06-19 09:23:55.000000000 -0700
@@ -129,6 +129,7 @@
 static DisplayState display_state;
 int nographic;
 const char* keyboard_layout = NULL;
+int use_absolute_screen_coordinates = 0;
 int64_t ticks_per_sec;
 int boot_device = 'c';
 int ram_size;
@@ -3946,6 +3948,9 @@
         dev = usb_mouse_init();
     } else if (!strcmp(devname, "tablet")) {
 	dev = usb_tablet_init();
+    } else if (!strcmp(devname, "touchscreen")) {
+        use_absolute_screen_coordinates = 1;
+	dev = usb_tablet_init();
     } else if (strstart(devname, "disk:", &p)) {
         dev = usb_msd_init(p);
     } else {
diff -ru qemu-0.9.0/vl.h qemu-0.9.0-touch/vl.h
--- qemu-0.9.0/vl.h	2007-02-05 15:01:54.000000000 -0800
+++ qemu-0.9.0-touch/vl.h	2007-06-19 09:17:48.000000000 -0700
@@ -152,6 +152,7 @@
 extern int graphic_height;
 extern int graphic_depth;
 extern const char *keyboard_layout;
+extern int use_absolute_screen_coordinates;
 extern int kqemu_allowed;
 extern int win2k_install_hack;
 extern int usb_enabled;
diff -ru qemu/sdl.c qemu-touch/sdl.c
--- qemu/sdl.c	2007-06-19 09:34:11.000000000 -0700
+++ qemu-touch/sdl.c	2007-06-19 09:30:25.000000000 -0700
@@ -306,8 +306,10 @@
 	}
 
 	SDL_GetMouseState(&dx, &dy);
-	dx = dx * 0x7FFF / width;
-	dy = dy * 0x7FFF / height;
+	if(!use_absolute_screen_coordinates) {
+		dx = dx * 0x7FFF / width;
+		dy = dy * 0x7FFF / height;
+	}
     } else if (absolute_enabled) {
 	sdl_show_cursor();
 	absolute_enabled = 0;
diff -ru qemu/vl.c qemu-touch/vl.c
--- qemu/vl.c	2007-06-19 09:34:12.000000000 -0700
+++ qemu-touch/vl.c	2007-06-19 09:33:31.000000000 -0700
@@ -147,6 +147,7 @@
 static DisplayState display_state;
 int nographic;
 const char* keyboard_layout = NULL;
+int use_absolute_screen_coordinates = 0;
 int64_t ticks_per_sec;
 int boot_device = 'c';
 int ram_size;
@@ -543,7 +544,7 @@
 
     if (mouse_event) {
         if (graphic_rotate) {
-            if (qemu_put_mouse_event_current->qemu_put_mouse_event_absolute)
+            if (qemu_put_mouse_event_current->qemu_put_mouse_event_absolute && !use_absolute_screen_coordinates)
                 width = 0x7fff;
             else
                 width = graphic_width;
@@ -4319,6 +4320,9 @@
         dev = usb_mouse_init();
     } else if (!strcmp(devname, "tablet")) {
 	dev = usb_tablet_init();
+    } else if (!strcmp(devname, "touchscreen")) {
+        use_absolute_screen_coordinates = 1;
+	dev = usb_tablet_init();
     } else if (strstart(devname, "disk:", &p)) {
         dev = usb_msd_init(p);
     } else if (!strcmp(devname, "wacom-tablet")) {
diff -ru qemu/vl.h qemu-touch/vl.h
--- qemu/vl.h	2007-06-19 09:34:12.000000000 -0700
+++ qemu-touch/vl.h	2007-06-19 09:30:25.000000000 -0700
@@ -154,6 +154,7 @@
 extern int graphic_height;
 extern int graphic_depth;
 extern const char *keyboard_layout;
+extern int use_absolute_screen_coordinates;
 extern int kqemu_allowed;
 extern int win2k_install_hack;
 extern int usb_enabled;

Reply via email to