* [Qemu-devel] [PATCH] touchscreen screen coordinates
@ 2007-06-19 17:34 dmlist
2007-06-19 23:04 ` andrzej zaborowski
0 siblings, 1 reply; 2+ messages in thread
From: dmlist @ 2007-06-19 17:34 UTC (permalink / raw)
To: qemu-devel
[-- 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;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] touchscreen screen coordinates
2007-06-19 17:34 [Qemu-devel] [PATCH] touchscreen screen coordinates dmlist
@ 2007-06-19 23:04 ` andrzej zaborowski
0 siblings, 0 replies; 2+ messages in thread
From: andrzej zaborowski @ 2007-06-19 23:04 UTC (permalink / raw)
To: qemu-devel
Hi,
On 19/06/07, dmlist@openright.org <dmlist@openright.org> wrote:
>
> 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.
To be precise, tslib assumes that you calibrate the touchscreen on
first boot, or have an /etc/pointercal file provided. So this is
another way to have it report the right 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.
This is why -usbdevice wacom-tablet was added. It lets you use
unmodified tslib because the linux driver for the tablet reports also
touch pressure. It works for OpenEmbedded builds for i386 and arm
(although for arm there is also the ADS7846 touchscreen).
Adding a HID touchscreen may be another possibility.
Regards,
Andrzej
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-06-19 23:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-19 17:34 [Qemu-devel] [PATCH] touchscreen screen coordinates dmlist
2007-06-19 23:04 ` andrzej zaborowski
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).