aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2009-05-16 20:11:08 +0200
committerHenrik Rydberg <rydberg@euromail.se>2009-05-16 20:11:08 +0200
commitca85f84aedb3b4cfd78dfe1874239421de8807d6 (patch)
tree282b54229e03183afcc7ea80f4cacbb19c132c16 /src
parentba20f03d7d2794b3d794e839ba1db45ba327bb62 (diff)
downloadxorg-input-kobomultitouch-ca85f84aedb3b4cfd78dfe1874239421de8807d6.tar.gz
xorg-input-kobomultitouch-ca85f84aedb3b4cfd78dfe1874239421de8807d6.tar.bz2
xorg-input-kobomultitouch-ca85f84aedb3b4cfd78dfe1874239421de8807d6.zip
Add multi-finger button and scroll from experimental
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src')
-rw-r--r--src/gestures.c10
-rw-r--r--src/gestures.h6
-rw-r--r--src/multitouch.c51
-rw-r--r--src/state.c4
4 files changed, 61 insertions, 10 deletions
diff --git a/src/gestures.c b/src/gestures.c
index 8dfb939..9a1281c 100644
--- a/src/gestures.c
+++ b/src/gestures.c
@@ -25,6 +25,16 @@ void extract_gestures(struct Gestures *gs, struct MTouch* mt)
gs->dy /= dn;
if (nsf == 1)
SETBIT(gs->type, GS_MOVE);
+ if (nsf == 2)
+ SETBIT(gs->type, GS_VSCROLL);
+ if (nsf == 3)
+ SETBIT(gs->type, GS_HSCROLL);
+ }
+ if (mt->ns.button == (1U << MT_BUTTON_LEFT)) {
+ if (nsf == 2)
+ mt->ns.button = (1U << MT_BUTTON_RIGHT);
+ if (nsf == 3)
+ mt->ns.button = (1U << MT_BUTTON_MIDDLE);
}
for (i = 0; i < DIM_BUTTON; i++) {
if (GETBIT(mt->ns.button, i) != GETBIT(mt->os.button, i)) {
diff --git a/src/gestures.h b/src/gestures.h
index 18ac920..de029b7 100644
--- a/src/gestures.h
+++ b/src/gestures.h
@@ -5,8 +5,10 @@
////////////////////////////////////////////////////////
-#define GS_MOVE 0
-#define GS_BUTTON 1
+#define GS_BUTTON 0
+#define GS_MOVE 1
+#define GS_VSCROLL 2
+#define GS_HSCROLL 3
////////////////////////////////////////////////////////
diff --git a/src/multitouch.c b/src/multitouch.c
index 99807b9..11f1e19 100644
--- a/src/multitouch.c
+++ b/src/multitouch.c
@@ -120,20 +120,59 @@ static int device_close(LocalDevicePtr local)
////////////////////////////////////////////////////////////////////////////
+static void tickle_button(LocalDevicePtr local, int id)
+{
+ xf86PostButtonEvent(local->dev, FALSE, id, 1, 0, 0);
+ xf86PostButtonEvent(local->dev, FALSE, id, 0, 0, 0);
+}
+
+////////////////////////////////////////////////////////////////////////////
+
static void handle_gestures(LocalDevicePtr local,
- const struct Gestures *gs)
+ const struct Gestures *gs,
+ const struct Capabilities *caps)
{
+ static int vscroll, hscroll;
int i;
- if (GETBIT(gs->type, GS_MOVE)) {
- xf86PostMotionEvent(local->dev, 0, 0, 2, gs->dx, gs->dy);
- //xf86Msg(X_INFO, "motion: %d %d\n", gs->dx, gs->dy);
- }
for (i = 0; i < gs->nbt; i++) {
xf86PostButtonEvent(local->dev, FALSE,
gs->btix[i], gs->btval[i],
0, 0);
xf86Msg(X_INFO, "button: %d %d\n", gs->btix[i], gs->btval[i]);
}
+ if (GETBIT(gs->type, GS_MOVE)) {
+ xf86PostMotionEvent(local->dev, 0, 0, 2,
+ gs->dx, gs->dy);
+ xf86Msg(X_INFO, "motion: %d %d\n", gs->dx, gs->dy);
+ }
+ if (GETBIT(gs->type, GS_VSCROLL)) {
+ int vstep = 0.03 * (caps->abs_position_y.maximum -
+ caps->abs_position_y.minimum);
+ vscroll += gs->dy;
+ while (vscroll > vstep) {
+ tickle_button(local, 5);
+ vscroll -= vstep;
+ }
+ while (vscroll < -vstep) {
+ tickle_button(local, 4);
+ vscroll += vstep;
+ }
+ xf86Msg(X_INFO, "vscroll: %d\n", gs->dy);
+ }
+ if (GETBIT(gs->type, GS_HSCROLL)) {
+ int hstep = 0.1 * (caps->abs_position_x.maximum -
+ caps->abs_position_x.minimum);
+ hscroll += gs->dx;
+ while (hscroll > hstep) {
+ tickle_button(local, 6);
+ hscroll -= hstep;
+ }
+ while (hscroll < -hstep) {
+ tickle_button(local, 7);
+ hscroll += hstep;
+ }
+ xf86Msg(X_INFO, "hscroll: %d\n", gs->dx);
+ }
}
////////////////////////////////////////////////////////////////////////////
@@ -146,7 +185,7 @@ static void read_input(LocalDevicePtr local)
while (read_synchronized_event(mt, local->fd)) {
parse_event(mt);
extract_gestures(&gs, mt);
- handle_gestures(local, &gs);
+ handle_gestures(local, &gs, &mt->caps);
}
}
diff --git a/src/state.c b/src/state.c
index 290ec95..9bac532 100644
--- a/src/state.c
+++ b/src/state.c
@@ -2,8 +2,8 @@
#include <stdlib.h>
#include <limits.h>
-const double FTW = 0.1;
-const double FTS = 0.1;
+const double FTW = 0.05;
+const double FTS = 0.05;
/******************************************************/