On Tue, Sep 30, 2008 at 04:56:57PM +0200, Søren Hauberg wrote:
> Okay, here's my latest attempt at a patch. I've renamed "flip_[x|y]"
> to "invert_[x|y]" and moved them into "EvdevRec", I've removed
> "swap_xy", and I've moved the reading of parameters to PreInit.
>
> I hope that's what you wanted. If not let me know. I'm hoping to have
> access to the touch screen for an hour or two on friday, so I can do a
> bit more testing/development at that time.
Ok, I took your patches, split them up and fiddled with them a bit.
0004-Add-support-for-axis-inversion.patch
- self-explanatory, works well btw, at least for relative devices.
0005-Allow-specification-of-Min-Max-for-x-y-overriding-t.patch
- take config options MinX/MaxX/etc. if given. They override the
auto-detected values from xorg.conf
0006-Add-touchscreen-support.patch
- this is the core of your patch, the touchscreen support for BTN_TOUCH.
I got a patch for property support for axis inversion on top of those done as
well.
If we get property support for min/max x and update the ValuatorClassRec
accordingly (I need to find a method to do that without upsetting the server
and all client) then we can do the calibration on-the-fly.
Alternatively, if we find we can't touch the VCR, xf86ScaleAxis should do the
job (that's instead of your TRANFORM macro).
Cheers,
Peter
>From 23c90251b920e95baaf1755243282f7fcda2d231 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?S=C3=B8ren=20Hauberg?= <[EMAIL PROTECTED]>
Date: Wed, 1 Oct 2008 11:07:57 +0930
Subject: [PATCH] Add support for axis inversion.
---
src/evdev.c | 21 ++++++++++++++++++---
src/evdev.h | 2 ++
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/src/evdev.c b/src/evdev.c
index b678a0e..c5fd7d5 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -348,8 +348,13 @@ EvdevReadInput(InputInfoPtr pInfo)
}
}
- if (dx != 0 || dy != 0)
+ if (dx != 0 || dy != 0) {
+ if (pEvdev->invert_x)
+ dx *= -1;
+ if (pEvdev->invert_y)
+ dy *= -1;
xf86PostMotionEvent(pInfo->dev, FALSE, 0, 2, dx, dy);
+ }
/*
* Some devices only generate valid abs coords when BTN_DIGI is
@@ -361,8 +366,15 @@ EvdevReadInput(InputInfoPtr pInfo)
* just works.
*/
if (abs && pEvdev->tool) {
- xf86PostMotionEvent(pInfo->dev, TRUE, 0, 2,
- pEvdev->abs_x, pEvdev->abs_y);
+ int abs_x, abs_y;
+ abs_x = pEvdev->abs_x;
+ abs_y = pEvdev->abs_y;
+ if (pEvdev->invert_x)
+ abs_x = pEvdev->max_x - abs_x;
+ if (pEvdev->invert_y)
+ abs_y = pEvdev->max_y - abs_y;
+
+ xf86PostMotionEvent(pInfo->dev, TRUE, 0, 2, abs_x, abs_y);
}
}
@@ -1335,6 +1347,9 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
pEvdev->noXkb = noXkbExtension;
/* parse the XKB options during kbd setup */
+ pEvdev->invert_x = xf86SetBoolOption(pInfo->options, "InvertX", FALSE);
+ pEvdev->invert_y = xf86SetBoolOption(pInfo->options, "InvertY", FALSE);
+
if (EvdevProbe(pInfo)) {
close(pInfo->fd);
xf86DeleteInput(pInfo, 0);
diff --git a/src/evdev.h b/src/evdev.h
index c145fbc..525acb1 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -65,6 +65,8 @@ typedef struct {
int flags;
int tool;
int buttons; /* number of buttons */
+ BOOL invert_x;
+ BOOL invert_y;
/* XKB stuff has to be per-device rather than per-driver */
int noXkb;
--
1.5.4.3
>From 54abde575e180f0581d14937eb20ea06d8a4fd1a Mon Sep 17 00:00:00 2001
From: =?utf-8?q?S=C3=B8ren=20Hauberg?= <[EMAIL PROTECTED]>
Date: Wed, 1 Oct 2008 11:53:20 +0930
Subject: [PATCH] Allow specification of Min/Max for x/y, overriding the auto-detected values.
---
src/evdev.c | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/evdev.c b/src/evdev.c
index c5fd7d5..48cf1b0 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -776,10 +776,14 @@ EvdevAddAbsClass(DeviceIntPtr device)
return !Success;
}
- pEvdev->min_x = absinfo_x.minimum;
- pEvdev->max_x = absinfo_x.maximum;
- pEvdev->min_y = absinfo_y.minimum;
- pEvdev->max_y = absinfo_y.maximum;
+ if (pEvdev->min_x == -1)
+ pEvdev->min_x = absinfo_x.minimum;
+ if (pEvdev->max_x == -1)
+ pEvdev->max_x = absinfo_x.maximum;
+ if (pEvdev->min_y == -1)
+ pEvdev->min_y = absinfo_y.minimum;
+ if (pEvdev->max_y == -1)
+ pEvdev->max_y = absinfo_y.maximum;
if (!InitValuatorClassDeviceStruct(device, 2,
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 3
@@ -1350,6 +1354,11 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
pEvdev->invert_x = xf86SetBoolOption(pInfo->options, "InvertX", FALSE);
pEvdev->invert_y = xf86SetBoolOption(pInfo->options, "InvertY", FALSE);
+ pEvdev->min_x = xf86SetIntOption(pInfo->options, "MinX", -1);
+ pEvdev->max_x = xf86SetIntOption(pInfo->options, "MaxX", -1);
+ pEvdev->min_y = xf86SetIntOption(pInfo->options, "MinY", -1);
+ pEvdev->max_y = xf86SetIntOption(pInfo->options, "MaxY", -1);
+
if (EvdevProbe(pInfo)) {
close(pInfo->fd);
xf86DeleteInput(pInfo, 0);
--
1.5.4.3
>From 4fcddcf28cfce030e9c961edc3cc11b0960262af Mon Sep 17 00:00:00 2001
From: =?utf-8?q?S=C3=B8ren=20Hauberg?= <[EMAIL PROTECTED]>
Date: Wed, 1 Oct 2008 11:06:31 +0930
Subject: [PATCH] Add touchscreen support.
Touchscreens are devices that do not have buttons and only advertise
BTN_TOUCH. Add a new flag to note the device type.
If BTN_TOUCH is detected, change it to BTN_LEFT and process it normally.
---
src/evdev.c | 55 +++++++++++++++++++++++++++++++++++++------------------
1 files changed, 37 insertions(+), 18 deletions(-)
diff --git a/src/evdev.c b/src/evdev.c
index 48cf1b0..2125d06 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -75,6 +75,7 @@
#define EVDEV_ABSOLUTE_EVENTS (1 << 3)
#define EVDEV_TOUCHPAD (1 << 4)
#define EVDEV_INITIALIZED (1 << 5) /* WheelInit etc. called already? */
+#define EVDEV_TOUCHSCREEN (1 << 6)
#define MIN_KEYCODE 8
#define GLYPHS_PER_KEY 2
@@ -305,7 +306,12 @@ EvdevReadInput(InputInfoPtr pInfo)
case BTN_TOOL_MOUSE:
case BTN_TOOL_LENS:
pEvdev->tool = value ? ev.code : 0;
- break;
+ if (!(pEvdev->flags & EVDEV_TOUCHSCREEN))
+ break;
+ /* Treat BTN_TOUCH from devices that only have BTN_TOUCH as
+ * BTN_LEFT. */
+ ev.code = BTN_LEFT;
+ /* Intentional fallthrough! */
default:
button = EvdevUtilButtonEventToButtonNumber(ev.code);
@@ -1209,23 +1215,6 @@ EvdevProbe(InputInfoPtr pInfo)
has_keys = FALSE;
num_buttons = 0;
- if (TestBit(REL_X, rel_bitmask) && TestBit(REL_Y, rel_bitmask)) {
- xf86Msg(X_INFO, "%s: Found x and y relative axes\n", pInfo->name);
- pEvdev->flags |= EVDEV_RELATIVE_EVENTS;
- has_axes = TRUE;
- }
-
- if (TestBit(ABS_X, abs_bitmask) && TestBit(ABS_Y, abs_bitmask)) {
- xf86Msg(X_INFO, "%s: Found x and y absolute axes\n", pInfo->name);
- pEvdev->flags |= EVDEV_ABSOLUTE_EVENTS;
- if (TestBit(BTN_TOUCH, key_bitmask)) {
- xf86Msg(X_INFO, "%s: Found absolute touchpad\n", pInfo->name);
- pEvdev->flags |= EVDEV_TOUCHPAD;
- pEvdev->old_x = pEvdev->old_y = -1;
- }
- has_axes = TRUE;
- }
-
/* count all buttons */
for (i = BTN_MISC; i < BTN_JOYSTICK; i++)
{
@@ -1241,6 +1230,29 @@ EvdevProbe(InputInfoPtr pInfo)
num_buttons);
}
+ if (TestBit(REL_X, rel_bitmask) && TestBit(REL_Y, rel_bitmask)) {
+ xf86Msg(X_INFO, "%s: Found x and y relative axes\n", pInfo->name);
+ pEvdev->flags |= EVDEV_RELATIVE_EVENTS;
+ has_axes = TRUE;
+ }
+
+ if (TestBit(ABS_X, abs_bitmask) && TestBit(ABS_Y, abs_bitmask)) {
+ xf86Msg(X_INFO, "%s: Found x and y absolute axes\n", pInfo->name);
+ pEvdev->flags |= EVDEV_ABSOLUTE_EVENTS;
+ if (TestBit(BTN_TOUCH, key_bitmask)) {
+ if (num_buttons) {
+ xf86Msg(X_INFO, "%s: Found absolute touchpad\n", pInfo->name);
+ pEvdev->flags |= EVDEV_TOUCHPAD;
+ pEvdev->old_x = pEvdev->old_y = -1;
+ } else {
+ xf86Msg(X_INFO, "%s: Found absolute touchscreen\n", pInfo->name);
+ pEvdev->flags |= EVDEV_TOUCHSCREEN;
+ pEvdev->flags |= EVDEV_BUTTON_EVENTS;
+ }
+ }
+ has_axes = TRUE;
+ }
+
for (i = 0; i < BTN_MISC; i++)
if (TestBit(i, key_bitmask))
break;
@@ -1258,6 +1270,13 @@ EvdevProbe(InputInfoPtr pInfo)
pInfo->type_name = XI_MOUSE;
}
+ if (pEvdev->flags & EVDEV_TOUCHSCREEN) {
+ xf86Msg(X_INFO, "%s: Configuring as touchscreen\n", pInfo->name);
+ pInfo->type_name = XI_TOUCHSCREEN;
+ pInfo->flags |= XI86_POINTER_CAPABLE | XI86_SEND_DRAG_EVENTS |
+ XI86_CONFIGURED;
+ }
+
if (has_keys) {
if (pEvdev->kernel24) {
xf86Msg(X_INFO, "%s: Kernel < 2.6 is too old, ignoring keyboard\n",
--
1.5.4.3
_______________________________________________
xorg mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/xorg