summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMildred Ki'lya <mildred593@online.fr>2008-08-06 21:40:11 +0200
committerChristoph Brill <egore911@egore911.de>2008-08-06 21:40:11 +0200
commitc32b4d47b94c2c18fab7f30588ddae8827e38f27 (patch)
tree3d0f9723f43b871ce0f01f940c4e9cd3016e2ae0
parentf04b27861983212bb6b216c589aa7b0b24256f63 (diff)
Add support for reporting multiple fingers as different buttons
This adds 3 new options. Use them as follows: Section "InputDevice" ... Option "ClickFinger1" "1" Option "ClickFinger2" "3" Option "ClickFinger3" "2" EndSection The driver would then report: * clicking one finger = left click * clicking with two fingers = right click * clicking with 3 fingers = middle mouse button
-rw-r--r--man/synaptics.man15
-rw-r--r--src/synaptics.c39
-rw-r--r--src/synaptics.h8
-rw-r--r--tools/synclient.c3
4 files changed, 65 insertions, 0 deletions
diff --git a/man/synaptics.man b/man/synaptics.man
index d4f5345..8e911f4 100644
--- a/man/synaptics.man
+++ b/man/synaptics.man
@@ -300,6 +300,21 @@ Which mouse button is reported on a non-corner three-finger tap.
.
Set to 0 to disable.
.TP
+.BI "Option \*qClickFinger1\*q \*q" integer \*q
+Which mouse button is reported when left-clicking with one finger.
+.
+Set to 0 to disable.
+.TP
+.BI "Option \*qClickFinger2\*q \*q" integer \*q
+Which mouse button is reported when left-clicking with two fingers.
+.
+Set to 0 to disable.
+.TP
+.BI "Option \*qClickFinger3\*q \*q" integer \*q
+Which mouse button is reported when left-clicking with three fingers.
+.
+Set to 0 to disable.
+.TP
.BI "Option \*qCircularScrolling\*q \*q" boolean \*q
If on, circular scrolling is used.
.TP
diff --git a/src/synaptics.c b/src/synaptics.c
index 0a2fcdf..d845068 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -415,6 +415,9 @@ SynapticsPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
pars->tap_action[F1_TAP] = xf86SetIntOption(opts, "TapButton1", 0);
pars->tap_action[F2_TAP] = xf86SetIntOption(opts, "TapButton2", 0);
pars->tap_action[F3_TAP] = xf86SetIntOption(opts, "TapButton3", 0);
+ pars->click_action[F1_CLICK1] = xf86SetIntOption(opts, "ClickFinger1", 1);
+ pars->click_action[F2_CLICK1] = xf86SetIntOption(opts, "ClickFinger2", 1);
+ pars->click_action[F3_CLICK1] = xf86SetIntOption(opts, "ClickFinger3", 1);
pars->circular_scrolling = xf86SetBoolOption(opts, "CircularScrolling", FALSE);
pars->circular_trigger = xf86SetIntOption(opts, "CircScrollTrigger", 0);
pars->circular_pad = xf86SetBoolOption(opts, "CircularPad", FALSE);
@@ -1699,6 +1702,37 @@ HandleScrolling(SynapticsPrivate *priv, struct SynapticsHwState *hw,
return delay;
}
+static int
+HandleClickWithFingers(SynapticsSHM *para, struct SynapticsHwState *hw)
+{
+ int action = 0;
+ switch(hw->numFingers){
+ case 1:
+ action = para->click_action[F1_CLICK1];
+ break;
+ case 2:
+ action = para->click_action[F2_CLICK1];
+ break;
+ case 3:
+ action = para->click_action[F3_CLICK1];
+ break;
+ }
+ switch(action){
+ case 1:
+ hw->left = 1;
+ break;
+ case 2:
+ hw->left = 0;
+ hw->middle = 1;
+ break;
+ case 3:
+ hw->left = 0;
+ hw->right = 1;
+ break;
+ }
+}
+
+
/*
* React on changes in the hardware state. This function is called every time
* the hardware state changes. The return value is used to specify how many
@@ -1756,6 +1790,11 @@ HandleState(LocalDevicePtr local, struct SynapticsHwState *hw)
/* 3rd button emulation */
hw->middle |= HandleMidButtonEmulation(priv, hw, &delay);
+ /* Fingers emulate other buttons */
+ if(hw->left && hw->numFingers >= 1){
+ HandleClickWithFingers(para, hw);
+ }
+
/* Two finger emulation */
if (hw->z >= para->emulate_twofinger_z && hw->numFingers == 1) {
hw->numFingers = 2;
diff --git a/src/synaptics.h b/src/synaptics.h
index 66e8542..d1f8772 100644
--- a/src/synaptics.h
+++ b/src/synaptics.h
@@ -39,6 +39,13 @@ typedef enum {
MAX_TAP
} TapEvent;
+typedef enum {
+ F1_CLICK1 = 0, /* Click left, one finger */
+ F2_CLICK1, /* Click left, two fingers */
+ F3_CLICK1, /* Click left, three fingers */
+ MAX_CLICK
+} ClickFingerEvent;
+
#define SYN_MAX_BUTTONS 12 /* Max number of mouse buttons */
struct SynapticsHwInfo {
@@ -111,6 +118,7 @@ typedef struct _SynapticsSHM
Bool locked_drags; /* Enable locked drags */
int locked_drag_time; /* timeout for locked drags */
int tap_action[MAX_TAP]; /* Button to report on tap events */
+ int click_action[MAX_CLICK]; /* Button to report on click with fingers */
Bool circular_scrolling; /* Enable circular scrolling */
double scroll_dist_circ; /* Scrolling angle radians */
int circular_trigger; /* Trigger area for circular scrolling */
diff --git a/tools/synclient.c b/tools/synclient.c
index f633988..7977d89 100644
--- a/tools/synclient.c
+++ b/tools/synclient.c
@@ -107,6 +107,9 @@ static struct Parameter params[] = {
DEFINE_PAR("TapButton1", tap_action[F1_TAP], PT_INT, 0, SYN_MAX_BUTTONS),
DEFINE_PAR("TapButton2", tap_action[F2_TAP], PT_INT, 0, SYN_MAX_BUTTONS),
DEFINE_PAR("TapButton3", tap_action[F3_TAP], PT_INT, 0, SYN_MAX_BUTTONS),
+ DEFINE_PAR("ClickFinger1", click_action[F1_CLICK1], PT_INT, 0, SYN_MAX_BUTTONS),
+ DEFINE_PAR("ClickFinger2", click_action[F2_CLICK1], PT_INT, 0, SYN_MAX_BUTTONS),
+ DEFINE_PAR("ClickFinger3", click_action[F3_CLICK1], PT_INT, 0, SYN_MAX_BUTTONS),
DEFINE_PAR("CircularScrolling", circular_scrolling, PT_BOOL, 0, 1),
DEFINE_PAR("CircScrollDelta", scroll_dist_circ, PT_DOUBLE, .01, 3),
DEFINE_PAR("CircScrollTrigger", circular_trigger, PT_INT, 0, 8),