qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: dmlist@openright.org
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] touchscreen screen coordinates
Date: Tue, 19 Jun 2007 10:34:54 -0700	[thread overview]
Message-ID: <1182274494.6537.1195974043@webmail.messagingengine.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 632 bytes --]


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



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: qemu-0.9.0-touch.patch --]
[-- Type: text/x-patch; name="qemu-0.9.0-touch.patch", Size: 1602 bytes --]

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;

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: qemu-20070619-touch.patch --]
[-- Type: text/x-patch; name="qemu-20070619-touch.patch", Size: 1928 bytes --]

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	other threads:[~2007-06-19 17:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-19 17:34 dmlist [this message]
2007-06-19 23:04 ` [Qemu-devel] [PATCH] touchscreen screen coordinates andrzej zaborowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1182274494.6537.1195974043@webmail.messagingengine.com \
    --to=dmlist@openright.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).