summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/alpscomm.c97
-rw-r--r--src/eventcomm.c663
-rw-r--r--src/eventcomm.h8
-rw-r--r--src/properties.c583
-rw-r--r--src/ps2comm.c534
-rw-r--r--src/ps2comm.h17
-rw-r--r--src/psmcomm.c71
-rw-r--r--src/synaptics.c2554
-rw-r--r--src/synapticsstr.h361
-rw-r--r--src/synproto.c42
-rw-r--r--src/synproto.h54
11 files changed, 2566 insertions, 2418 deletions
diff --git a/src/alpscomm.c b/src/alpscomm.c
index 8988e6b..0bf0447 100644
--- a/src/alpscomm.c
+++ b/src/alpscomm.c
@@ -39,14 +39,14 @@
#include "ps2comm.h"
#include <xf86.h>
-
/* Wait for the channel to go silent, which means we're in sync */
static void
ALPS_sync(int fd)
{
byte buffer[64];
+
while (xf86WaitForInput(fd, 250000) > 0) {
- xf86ReadSerial(fd, &buffer, 64);
+ xf86ReadSerial(fd, &buffer, 64);
}
}
@@ -98,7 +98,7 @@ ALPS_packet_ok(struct CommData *comm)
{
/* ALPS absolute mode packets start with 0b11111mrl */
if ((comm->protoBuf[0] & 0xf8) == 0xf8)
- return TRUE;
+ return TRUE;
return FALSE;
}
@@ -108,24 +108,23 @@ ALPS_get_packet(struct CommData *comm, InputInfoPtr pInfo)
int c;
while ((c = XisbRead(comm->buffer)) >= 0) {
- unsigned char u = (unsigned char)c;
-
- comm->protoBuf[comm->protoBufTail++] = u;
-
- if (comm->protoBufTail == 3) { /* PS/2 packet received? */
- if ((comm->protoBuf[0] & 0xc8) == 0x08) {
- comm->protoBufTail = 0;
- return TRUE;
- }
- }
-
- if (comm->protoBufTail >= 6) { /* Full packet received */
- comm->protoBufTail = 0;
- if (ALPS_packet_ok(comm))
- return TRUE;
- while ((c = XisbRead(comm->buffer)) >= 0)
- ; /* If packet is invalid, re-sync */
- }
+ unsigned char u = (unsigned char) c;
+
+ comm->protoBuf[comm->protoBufTail++] = u;
+
+ if (comm->protoBufTail == 3) { /* PS/2 packet received? */
+ if ((comm->protoBuf[0] & 0xc8) == 0x08) {
+ comm->protoBufTail = 0;
+ return TRUE;
+ }
+ }
+
+ if (comm->protoBufTail >= 6) { /* Full packet received */
+ comm->protoBufTail = 0;
+ if (ALPS_packet_ok(comm))
+ return TRUE;
+ while ((c = XisbRead(comm->buffer)) >= 0); /* If packet is invalid, re-sync */
+ }
}
return FALSE;
@@ -157,48 +156,50 @@ ALPS_process_packet(unsigned char *packet, struct SynapticsHwState *hw)
hw->millis = GetTimeInMillis();
- x = (packet[1] & 0x7f) | ((packet[2] & 0x78) << (7-3));
- y = (packet[4] & 0x7f) | ((packet[3] & 0x70) << (7-4));
+ x = (packet[1] & 0x7f) | ((packet[2] & 0x78) << (7 - 3));
+ y = (packet[4] & 0x7f) | ((packet[3] & 0x70) << (7 - 4));
z = packet[5];
- if (z == 127) { /* DualPoint stick is relative, not absolute */
- hw->left = packet[3] & 1;
- hw->right = (packet[3] >> 1) & 1;
- return;
+ if (z == 127) { /* DualPoint stick is relative, not absolute */
+ hw->left = packet[3] & 1;
+ hw->right = (packet[3] >> 1) & 1;
+ return;
}
/* Handle normal packets */
hw->x = hw->y = hw->z = hw->numFingers = hw->fingerWidth = 0;
hw->left = hw->right = hw->up = hw->down = hw->middle = FALSE;
for (i = 0; i < 8; i++)
- hw->multi[i] = FALSE;
+ hw->multi[i] = FALSE;
if (z > 0) {
- hw->x = x;
- hw->y = y;
+ hw->x = x;
+ hw->y = y;
}
hw->z = z;
hw->numFingers = (z > 0) ? 1 : 0;
hw->fingerWidth = 5;
- left |= (packet[2] ) & 1;
- left |= (packet[3] ) & 1;
+ left |= (packet[2]) & 1;
+ left |= (packet[3]) & 1;
right |= (packet[3] >> 1) & 1;
if (packet[0] == 0xff) {
- int back = (packet[3] >> 2) & 1;
- int forward = (packet[2] >> 2) & 1;
- if (back && forward) {
- middle = 1;
- back = 0;
- forward = 0;
- }
- hw->down = back;
- hw->up = forward;
- } else {
- left |= (packet[0] ) & 1;
- right |= (packet[0] >> 1) & 1;
- middle |= (packet[0] >> 2) & 1;
- middle |= (packet[3] >> 2) & 1;
+ int back = (packet[3] >> 2) & 1;
+ int forward = (packet[2] >> 2) & 1;
+
+ if (back && forward) {
+ middle = 1;
+ back = 0;
+ forward = 0;
+ }
+ hw->down = back;
+ hw->up = forward;
+ }
+ else {
+ left |= (packet[0]) & 1;
+ right |= (packet[0] >> 1) & 1;
+ middle |= (packet[0] >> 2) & 1;
+ middle |= (packet[3] >> 2) & 1;
}
hw->left = left;
@@ -208,13 +209,13 @@ ALPS_process_packet(unsigned char *packet, struct SynapticsHwState *hw)
static Bool
ALPSReadHwState(InputInfoPtr pInfo,
- struct CommData *comm, struct SynapticsHwState *hwRet)
+ struct CommData *comm, struct SynapticsHwState *hwRet)
{
unsigned char *buf = comm->protoBuf;
struct SynapticsHwState *hw = comm->hwState;
if (!ALPS_get_packet(comm, pInfo))
- return FALSE;
+ return FALSE;
ALPS_process_packet(buf, hw);
diff --git a/src/eventcomm.c b/src/eventcomm.c
index 4ef8ad6..89a8a3a 100644
--- a/src/eventcomm.c
+++ b/src/eventcomm.c
@@ -63,8 +63,7 @@
/**
* Protocol-specific data.
*/
-struct eventcomm_proto_data
-{
+struct eventcomm_proto_data {
/**
* Do we need to grab the event device?
* Note that in the current flow, this variable is always false and
@@ -99,9 +98,10 @@ EventProtoDataAlloc(void)
#ifdef HAVE_MULTITOUCH
static int
-last_mt_vals_slot(const SynapticsPrivate *priv)
+last_mt_vals_slot(const SynapticsPrivate * priv)
{
- struct eventcomm_proto_data *proto_data = (struct eventcomm_proto_data*)priv->proto_data;
+ struct eventcomm_proto_data *proto_data =
+ (struct eventcomm_proto_data *) priv->proto_data;
int value = proto_data->cur_slot - proto_data->mtdev->caps.slot.minimum;
return value < priv->num_slots ? value : -1;
@@ -110,14 +110,14 @@ last_mt_vals_slot(const SynapticsPrivate *priv)
static void
UninitializeTouch(InputInfoPtr pInfo)
{
- SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
- struct eventcomm_proto_data *proto_data = (struct eventcomm_proto_data*)priv->proto_data;
+ SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
+ struct eventcomm_proto_data *proto_data =
+ (struct eventcomm_proto_data *) priv->proto_data;
if (!priv->has_touch)
return;
- if (proto_data->last_mt_vals)
- {
+ if (proto_data->last_mt_vals) {
int i;
for (i = 0; i < priv->num_slots; i++)
@@ -134,16 +134,16 @@ UninitializeTouch(InputInfoPtr pInfo)
static void
InitializeTouch(InputInfoPtr pInfo)
{
- SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
- struct eventcomm_proto_data *proto_data = (struct eventcomm_proto_data*)priv->proto_data;
+ SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
+ struct eventcomm_proto_data *proto_data =
+ (struct eventcomm_proto_data *) priv->proto_data;
int i;
if (!priv->has_touch)
return;
proto_data->mtdev = mtdev_new_open(pInfo->fd);
- if (!proto_data->mtdev)
- {
+ if (!proto_data->mtdev) {
xf86IDrvMsg(pInfo, X_WARNING,
"failed to create mtdev instance, ignoring touch events\n");
return;
@@ -152,23 +152,19 @@ InitializeTouch(InputInfoPtr pInfo)
proto_data->cur_slot = proto_data->mtdev->caps.slot.value;
proto_data->num_touches = 0;
- proto_data->last_mt_vals = calloc(priv->num_slots,
- sizeof(ValuatorMask *));
- if (!proto_data->last_mt_vals)
- {
+ proto_data->last_mt_vals = calloc(priv->num_slots, sizeof(ValuatorMask *));
+ if (!proto_data->last_mt_vals) {
xf86IDrvMsg(pInfo, X_WARNING,
"failed to allocate MT last values mask array\n");
UninitializeTouch(pInfo);
return;
}
- for (i = 0; i < priv->num_slots; i++)
- {
+ for (i = 0; i < priv->num_slots; i++) {
int j;
proto_data->last_mt_vals[i] = valuator_mask_new(4 + priv->num_mt_axes);
- if (!proto_data->last_mt_vals[i])
- {
+ if (!proto_data->last_mt_vals[i]) {
xf86IDrvMsg(pInfo, X_WARNING,
"failed to allocate MT last values mask\n");
UninitializeTouch(pInfo);
@@ -186,20 +182,22 @@ InitializeTouch(InputInfoPtr pInfo)
#endif
static Bool
-EventDeviceOnHook(InputInfoPtr pInfo, SynapticsParameters *para)
+EventDeviceOnHook(InputInfoPtr pInfo, SynapticsParameters * para)
{
- SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
- struct eventcomm_proto_data *proto_data = (struct eventcomm_proto_data*)priv->proto_data;
+ SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
+ struct eventcomm_proto_data *proto_data =
+ (struct eventcomm_proto_data *) priv->proto_data;
if (para->grab_event_device) {
- /* Try to grab the event device so that data don't leak to /dev/input/mice */
- int ret;
- SYSCALL(ret = ioctl(pInfo->fd, EVIOCGRAB, (pointer)1));
- if (ret < 0) {
- xf86IDrvMsg(pInfo, X_WARNING, "can't grab event device, errno=%d\n",
- errno);
- return FALSE;
- }
+ /* Try to grab the event device so that data don't leak to /dev/input/mice */
+ int ret;
+
+ SYSCALL(ret = ioctl(pInfo->fd, EVIOCGRAB, (pointer) 1));
+ if (ret < 0) {
+ xf86IDrvMsg(pInfo, X_WARNING, "can't grab event device, errno=%d\n",
+ errno);
+ return FALSE;
+ }
}
proto_data->need_grab = FALSE;
@@ -239,13 +237,12 @@ static Bool
event_query_is_touchpad(int fd, BOOL test_grab)
{
int ret = FALSE, rc;
- unsigned long evbits[NBITS(EV_MAX)] = {0};
- unsigned long absbits[NBITS(ABS_MAX)] = {0};
- unsigned long keybits[NBITS(KEY_MAX)] = {0};
+ unsigned long evbits[NBITS(EV_MAX)] = { 0 };
+ unsigned long absbits[NBITS(ABS_MAX)] = { 0 };
+ unsigned long keybits[NBITS(KEY_MAX)] = { 0 };
- if (test_grab)
- {
- SYSCALL(rc = ioctl(fd, EVIOCGRAB, (pointer)1));
+ if (test_grab) {
+ SYSCALL(rc = ioctl(fd, EVIOCGRAB, (pointer) 1));
if (rc < 0)
return FALSE;
}
@@ -254,54 +251,53 @@ event_query_is_touchpad(int fd, BOOL test_grab)
SYSCALL(rc = ioctl(fd, EVIOCGBIT(0, sizeof(evbits)), evbits));
if (rc < 0)
- goto unwind;
+ goto unwind;
if (!TEST_BIT(EV_SYN, evbits) ||
- !TEST_BIT(EV_ABS, evbits) ||
- !TEST_BIT(EV_KEY, evbits))
- goto unwind;
+ !TEST_BIT(EV_ABS, evbits) || !TEST_BIT(EV_KEY, evbits))
+ goto unwind;
SYSCALL(rc = ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbits)), absbits));
if (rc < 0)
- goto unwind;
- if (!TEST_BIT(ABS_X, absbits) ||
- !TEST_BIT(ABS_Y, absbits))
- goto unwind;
+ goto unwind;
+ if (!TEST_BIT(ABS_X, absbits) || !TEST_BIT(ABS_Y, absbits))
+ goto unwind;
SYSCALL(rc = ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybits)), keybits));
if (rc < 0)
- goto unwind;
+ goto unwind;
/* we expect touchpad either report raw pressure or touches */
if (!TEST_BIT(ABS_PRESSURE, absbits) && !TEST_BIT(BTN_TOUCH, keybits))
- goto unwind;
+ goto unwind;
/* all Synaptics-like touchpad report BTN_TOOL_FINGER */
if (!TEST_BIT(BTN_TOOL_FINGER, keybits))
- goto unwind;
+ goto unwind;
if (TEST_BIT(BTN_TOOL_PEN, keybits))
- goto unwind; /* Don't match wacom tablets */
+ goto unwind; /* Don't match wacom tablets */
ret = TRUE;
-unwind:
+ unwind:
if (test_grab)
- SYSCALL(ioctl(fd, EVIOCGRAB, (pointer)0));
+ SYSCALL(ioctl(fd, EVIOCGRAB, (pointer) 0));
return (ret == TRUE);
}
typedef struct {
- short vendor;
- short product;
- enum TouchpadModel model;
+ short vendor;
+ short product;
+ enum TouchpadModel model;
} model_lookup_t;
+
#define PRODUCT_ANY 0x0000
static model_lookup_t model_lookup_table[] = {
- {0x0002, 0x0007, MODEL_SYNAPTICS},
- {0x0002, 0x0008, MODEL_ALPS},
- {0x05ac, PRODUCT_ANY, MODEL_APPLETOUCH},
- {0x0002, 0x000e, MODEL_ELANTECH},
- {0x0, 0x0, 0x0}
+ {0x0002, 0x0007, MODEL_SYNAPTICS},
+ {0x0002, 0x0008, MODEL_ALPS},
+ {0x05ac, PRODUCT_ANY, MODEL_APPLETOUCH},
+ {0x0002, 0x000e, MODEL_ELANTECH},
+ {0x0, 0x0, 0x0}
};
/**
@@ -315,7 +311,8 @@ static model_lookup_t model_lookup_table[] = {
* @return TRUE on success or FALSE otherwise.
*/
static Bool
-event_query_model(int fd, enum TouchpadModel *model_out, unsigned short *vendor_id, unsigned short *product_id)
+event_query_model(int fd, enum TouchpadModel *model_out,
+ unsigned short *vendor_id, unsigned short *product_id)
{
struct input_id id;
int rc;
@@ -325,9 +322,11 @@ event_query_model(int fd, enum TouchpadModel *model_out, unsigned short *vendor_
if (rc < 0)
return FALSE;
- for(model_lookup = model_lookup_table; model_lookup->vendor; model_lookup++) {
- if(model_lookup->vendor == id.vendor &&
- (model_lookup->product == id.product|| model_lookup->product == PRODUCT_ANY))
+ for (model_lookup = model_lookup_table; model_lookup->vendor;
+ model_lookup++) {
+ if (model_lookup->vendor == id.vendor &&
+ (model_lookup->product == id.product ||
+ model_lookup->product == PRODUCT_ANY))
*model_out = model_lookup->model;
}
@@ -356,71 +355,68 @@ event_get_abs(InputInfoPtr pInfo, int fd, int code,
int *min, int *max, int *fuzz, int *res)
{
int rc;
- struct input_absinfo abs = {0};
+ struct input_absinfo abs = { 0 };
SYSCALL(rc = ioctl(fd, EVIOCGABS(code), &abs));
if (rc < 0) {
- xf86IDrvMsg(pInfo, X_ERROR, "%s EVIOCGABS error on %d (%s)\n",
- __func__, code, strerror(errno));
- return errno;
+ xf86IDrvMsg(pInfo, X_ERROR, "%s EVIOCGABS error on %d (%s)\n",
+ __func__, code, strerror(errno));
+ return errno;
}
*min = abs.minimum;
*max = abs.maximum;
/* We dont trust a zero fuzz as it probably is just a lazy value */
if (fuzz && abs.fuzz > 0)
- *fuzz = abs.fuzz;
+ *fuzz = abs.fuzz;
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30)
if (res)
- *res = abs.resolution;
+ *res = abs.resolution;
#endif
return 0;
}
-
/* Query device for axis ranges */
static void
event_query_axis_ranges(InputInfoPtr pInfo)
{
- SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
+ SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
struct eventcomm_proto_data *proto_data = priv->proto_data;
- unsigned long absbits[NBITS(ABS_MAX)] = {0};
- unsigned long keybits[NBITS(KEY_MAX)] = {0};
- char buf[256] = {0};
+ unsigned long absbits[NBITS(ABS_MAX)] = { 0 };
+ unsigned long keybits[NBITS(KEY_MAX)] = { 0 };
+ char buf[256] = { 0 };
int rc;
/* The kernel's fuzziness concept seems a bit weird, but it can more or
* less be applied as hysteresis directly, i.e. no factor here. */
event_get_abs(pInfo, pInfo->fd, ABS_X, &priv->minx, &priv->maxx,
- &priv->synpara.hyst_x, &priv->resx);
+ &priv->synpara.hyst_x, &priv->resx);
event_get_abs(pInfo, pInfo->fd, ABS_Y, &priv->miny, &priv->maxy,
- &priv->synpara.hyst_y, &priv->resy);
+ &priv->synpara.hyst_y, &priv->resy);
priv->has_pressure = FALSE;
priv->has_width = FALSE;
SYSCALL(rc = ioctl(pInfo->fd, EVIOCGBIT(EV_ABS, sizeof(absbits)), absbits));
- if (rc >= 0)
- {
- priv->has_pressure = (TEST_BIT(ABS_PRESSURE, absbits) != 0);
- priv->has_width = (TEST_BIT(ABS_TOOL_WIDTH, absbits) != 0);
+ if (rc >= 0) {
+ priv->has_pressure = (TEST_BIT(ABS_PRESSURE, absbits) != 0);
+ priv->has_width = (TEST_BIT(ABS_TOOL_WIDTH, absbits) != 0);
}
else
- xf86IDrvMsg(pInfo, X_ERROR, "failed to query ABS bits (%s)\n", strerror(errno));
+ xf86IDrvMsg(pInfo, X_ERROR, "failed to query ABS bits (%s)\n",
+ strerror(errno));
if (priv->has_pressure)
- event_get_abs(pInfo, pInfo->fd, ABS_PRESSURE, &priv->minp, &priv->maxp,
- NULL, NULL);
+ event_get_abs(pInfo, pInfo->fd, ABS_PRESSURE, &priv->minp, &priv->maxp,
+ NULL, NULL);
if (priv->has_width)
- event_get_abs(pInfo, pInfo->fd, ABS_TOOL_WIDTH,
- &priv->minw, &priv->maxw,
- NULL, NULL);
+ event_get_abs(pInfo, pInfo->fd, ABS_TOOL_WIDTH,
+ &priv->minw, &priv->maxw, NULL, NULL);
#if HAVE_MULTITOUCH
- if (priv->has_touch)
- {
+ if (priv->has_touch) {
int st_minx = priv->minx;
int st_maxx = priv->maxx;
int st_miny = priv->miny;
@@ -441,51 +437,48 @@ event_query_axis_ranges(InputInfoPtr pInfo)
#endif
SYSCALL(rc = ioctl(pInfo->fd, EVIOCGBIT(EV_KEY, sizeof(keybits)), keybits));
- if (rc >= 0)
- {
- priv->has_left = (TEST_BIT(BTN_LEFT, keybits) != 0);
- priv->has_right = (TEST_BIT(BTN_RIGHT, keybits) != 0);
- priv->has_middle = (TEST_BIT(BTN_MIDDLE, keybits) != 0);
- priv->has_double = (TEST_BIT(BTN_TOOL_DOUBLETAP, keybits) != 0);
- priv->has_triple = (TEST_BIT(BTN_TOOL_TRIPLETAP, keybits) != 0);
-
- if ((TEST_BIT(BTN_0, keybits) != 0) ||
- (TEST_BIT(BTN_1, keybits) != 0) ||
- (TEST_BIT(BTN_2, keybits) != 0) ||
- (TEST_BIT(BTN_3, keybits) != 0))
- priv->has_scrollbuttons = 1;
+ if (rc >= 0) {
+ priv->has_left = (TEST_BIT(BTN_LEFT, keybits) != 0);
+ priv->has_right = (TEST_BIT(BTN_RIGHT, keybits) != 0);
+ priv->has_middle = (TEST_BIT(BTN_MIDDLE, keybits) != 0);
+ priv->has_double = (TEST_BIT(BTN_TOOL_DOUBLETAP, keybits) != 0);
+ priv->has_triple = (TEST_BIT(BTN_TOOL_TRIPLETAP, keybits) != 0);
+
+ if ((TEST_BIT(BTN_0, keybits) != 0) ||
+ (TEST_BIT(BTN_1, keybits) != 0) ||
+ (TEST_BIT(BTN_2, keybits) != 0) || (TEST_BIT(BTN_3, keybits) != 0))
+ priv->has_scrollbuttons = 1;
}
/* Now print the device information */
xf86IDrvMsg(pInfo, X_PROBED, "x-axis range %d - %d\n",
- priv->minx, priv->maxx);
+ priv->minx, priv->maxx);
xf86IDrvMsg(pInfo, X_PROBED, "y-axis range %d - %d\n",
- priv->miny, priv->maxy);
+ priv->miny, priv->maxy);
if (priv->has_pressure)
- xf86IDrvMsg(pInfo, X_PROBED, "pressure range %d - %d\n",
- priv->minp, priv->maxp);
+ xf86IDrvMsg(pInfo, X_PROBED, "pressure range %d - %d\n",
+ priv->minp, priv->maxp);
else
- xf86IDrvMsg(pInfo, X_INFO,
- "device does not report pressure, will use touch data.\n");
+ xf86IDrvMsg(pInfo, X_INFO,
+ "device does not report pressure, will use touch data.\n");
if (priv->has_width)
- xf86IDrvMsg(pInfo, X_PROBED, "finger width range %d - %d\n",
- priv->minw, priv->maxw);
+ xf86IDrvMsg(pInfo, X_PROBED, "finger width range %d - %d\n",
+ priv->minw, priv->maxw);
else
- xf86IDrvMsg(pInfo, X_INFO,
- "device does not report finger width.\n");
+ xf86IDrvMsg(pInfo, X_INFO, "device does not report finger width.\n");
if (priv->has_left)
- strcat(buf, " left");
+ strcat(buf, " left");
if (priv->has_right)
- strcat(buf, " right");
+ strcat(buf, " right");
if (priv->has_middle)
- strcat(buf, " middle");
+ strcat(buf, " middle");
if (priv->has_double)
- strcat(buf, " double");
+ strcat(buf, " double");
if (priv->has_triple)
- strcat(buf, " triple");
+ strcat(buf, " triple");
if (priv->has_scrollbuttons)
- strcat(buf, " scroll-buttons");
+ strcat(buf, " scroll-buttons");
xf86IDrvMsg(pInfo, X_PROBED, "buttons:%s\n", buf);
}
@@ -493,11 +486,12 @@ event_query_axis_ranges(InputInfoPtr pInfo)
static Bool
EventQueryHardware(InputInfoPtr pInfo)
{
- SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
+ SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
struct eventcomm_proto_data *proto_data = priv->proto_data;
- if (!event_query_is_touchpad(pInfo->fd, (proto_data) ? proto_data->need_grab : TRUE))
- return FALSE;
+ if (!event_query_is_touchpad
+ (pInfo->fd, (proto_data) ? proto_data->need_grab : TRUE))
+ return FALSE;
xf86IDrvMsg(pInfo, X_PROBED, "touchpad found\n");
@@ -508,7 +502,7 @@ static Bool
SynapticsReadEvent(InputInfoPtr pInfo, struct input_event *ev)
{
#ifdef HAVE_MULTITOUCH
- SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
+ SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
struct eventcomm_proto_data *proto_data = priv->proto_data;
#endif
int rc = TRUE;
@@ -517,18 +511,20 @@ SynapticsReadEvent(InputInfoPtr pInfo, struct input_event *ev)
#ifdef HAVE_MULTITOUCH
if (proto_data->mtdev)
len = mtdev_get(proto_data->mtdev, pInfo->fd, ev, 1) *
- sizeof(struct input_event);
+ sizeof(struct input_event);
else
#endif
len = read(pInfo->fd, ev, sizeof(*ev));
- if (len <= 0)
- {
+ if (len <= 0) {
/* We use X_NONE here because it doesn't alloc */
if (errno != EAGAIN)
- xf86MsgVerb(X_NONE, 0, "%s: Read error %s\n", pInfo->name, strerror(errno));
+ xf86MsgVerb(X_NONE, 0, "%s: Read error %s\n", pInfo->name,
+ strerror(errno));
rc = FALSE;
- } else if (len % sizeof(*ev)) {
- xf86MsgVerb(X_NONE, 0, "%s: Read error, invalid number of bytes.", pInfo->name);
+ }
+ else if (len % sizeof(*ev)) {
+ xf86MsgVerb(X_NONE, 0, "%s: Read error, invalid number of bytes.",
+ pInfo->name);
rc = FALSE;
}
return rc;
@@ -536,7 +532,7 @@ SynapticsReadEvent(InputInfoPtr pInfo, struct input_event *ev)
#ifdef HAVE_MULTITOUCH
static Bool
-EventTouchSlotPreviouslyOpen(SynapticsPrivate *priv, int slot)
+EventTouchSlotPreviouslyOpen(SynapticsPrivate * priv, int slot)
{
int i;
@@ -553,17 +549,16 @@ EventProcessTouchEvent(InputInfoPtr pInfo, struct SynapticsHwState *hw,
struct input_event *ev)
{
#ifdef HAVE_MULTITOUCH
- SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
+ SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
struct eventcomm_proto_data *proto_data = priv->proto_data;
if (!priv->has_touch)
return;
- if (ev->code == ABS_MT_SLOT)
- {
+ if (ev->code == ABS_MT_SLOT) {
proto_data->cur_slot = ev->value;
- } else
- {
+ }
+ else {
int slot_index = last_mt_vals_slot(priv);
if (slot_index < 0)
@@ -572,10 +567,8 @@ EventProcessTouchEvent(InputInfoPtr pInfo, struct SynapticsHwState *hw,
if (hw->slot_state[slot_index] == SLOTSTATE_EMPTY ||
hw->slot_state[slot_index] == SLOTSTATE_OPEN_EMPTY)
hw->slot_state[slot_index] = SLOTSTATE_UPDATE;
- if (ev->code == ABS_MT_TRACKING_ID)
- {
- if (ev->value >= 0)
- {
+ if (ev->code == ABS_MT_TRACKING_ID) {
+ if (ev->value >= 0) {
hw->slot_state[slot_index] = SLOTSTATE_OPEN;
proto_data->num_touches++;
@@ -586,22 +579,21 @@ EventProcessTouchEvent(InputInfoPtr pInfo, struct SynapticsHwState *hw,
xf86IDrvMsg(pInfo, X_WARNING,
"Attempted to copy values from out-of-range "
"slot, touch events may be incorrect.\n");
- } else
- {
+ }
+ else {
hw->slot_state[slot_index] = SLOTSTATE_CLOSE;
proto_data->num_touches--;
}
- } else
- {
+ }
+ else {
int map = proto_data->axis_map[ev->code - ABS_MT_TOUCH_MAJOR];
+
valuator_mask_set(hw->mt_mask[slot_index], map, ev->value);
- if (slot_index >= 0)
- {
+ if (slot_index >= 0) {
ValuatorMask *mask = proto_data->last_mt_vals[slot_index];
int last_val = valuator_mask_get(mask, map);
- if (EventTouchSlotPreviouslyOpen(priv, slot_index))
- {
+ if (EventTouchSlotPreviouslyOpen(priv, slot_index)) {
if (ev->code == ABS_MT_POSITION_X)
hw->cumulative_dx += ev->value - last_val;
else if (ev->code == ABS_MT_POSITION_Y)
@@ -623,18 +615,19 @@ EventProcessTouchEvent(InputInfoPtr pInfo, struct SynapticsHwState *hw,
* @param comm Assembled information from previous events.
* @return The number of fingers currently set.
*/
-static int count_fingers(InputInfoPtr pInfo, const struct CommData *comm)
+static int
+count_fingers(InputInfoPtr pInfo, const struct CommData *comm)
{
- SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
+ SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
struct eventcomm_proto_data *proto_data = priv->proto_data;
int fingers = 0;
if (comm->oneFinger)
- fingers = 1;
+ fingers = 1;
else if (comm->twoFingers)
- fingers = 2;
+ fingers = 2;
else if (comm->threeFingers)
- fingers = 3;
+ fingers = 3;
#ifdef HAVE_MULTITOUCH
if (priv->has_touch && proto_data->num_touches > fingers)
@@ -644,135 +637,137 @@ static int count_fingers(InputInfoPtr pInfo, const struct CommData *comm)
return fingers;
}
-
static inline double
apply_st_scaling(struct eventcomm_proto_data *proto_data, int value, int axis)
{
- return value * proto_data->st_to_mt_scale[axis] + proto_data->st_to_mt_offset[axis];
+ return value * proto_data->st_to_mt_scale[axis] +
+ proto_data->st_to_mt_offset[axis];
}
Bool
EventReadHwState(InputInfoPtr pInfo,
- struct CommData *comm, struct SynapticsHwState *hwRet)
+ struct CommData *comm, struct SynapticsHwState *hwRet)
{
struct input_event ev;
Bool v;
struct SynapticsHwState *hw = comm->hwState;
- SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
+ SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
SynapticsParameters *para = &priv->synpara;
struct eventcomm_proto_data *proto_data = priv->proto_data;
SynapticsResetTouchHwState(hw, FALSE);
/* Reset cumulative values if buttons were not previously pressed */
- if (!hw->left && !hw->right && !hw->middle)
- {
+ if (!hw->left && !hw->right && !hw->middle) {
hw->cumulative_dx = hw->x;
hw->cumulative_dy = hw->y;
}
while (SynapticsReadEvent(pInfo, &ev)) {
- switch (ev.type) {
- case EV_SYN:
- switch (ev.code) {
- case SYN_REPORT:
- hw->numFingers = count_fingers(pInfo, comm);
- hw->millis = 1000 * ev.time.tv_sec + ev.time.tv_usec / 1000;
- SynapticsCopyHwState(hwRet, hw);
- return TRUE;
- }
- break;
- case EV_KEY:
- v = (ev.value ? TRUE : FALSE);
- switch (ev.code) {
- case BTN_LEFT:
- hw->left = v;
- break;
- case BTN_RIGHT:
- hw->right = v;
- break;
- case BTN_MIDDLE:
- hw->middle = v;
- break;
- case BTN_FORWARD:
- hw->up = v;
- break;
- case BTN_BACK:
- hw->down = v;
- break;
- case BTN_0:
- hw->multi[0] = v;
- break;
- case BTN_1:
- hw->multi[1] = v;
- break;
- case BTN_2:
- hw->multi[2] = v;
- break;
- case BTN_3:
- hw->multi[3] = v;
- break;
- case BTN_4:
- hw->multi[4] = v;
- break;
- case BTN_5:
- hw->multi[5] = v;
- break;
- case BTN_6:
- hw->multi[6] = v;
- break;
- case BTN_7:
- hw->multi[7] = v;
- break;
- case BTN_TOOL_FINGER:
- comm->oneFinger = v;
- break;
- case BTN_TOOL_DOUBLETAP:
- comm->twoFingers = v;
- break;
- case BTN_TOOL_TRIPLETAP:
- comm->threeFingers = v;
- break;
- case BTN_TOUCH:
- if (!priv->has_pressure)
- hw->z = v ? para->finger_high + 1 : 0;
- break;
- }
- break;
- case EV_ABS:
- if (ev.code < ABS_MT_SLOT) {
- switch (ev.code) {
- case ABS_X:
- hw->x = apply_st_scaling(proto_data, ev.value, 0);
- break;
- case ABS_Y:
- hw->y = apply_st_scaling(proto_data, ev.value, 1);
- break;
- case ABS_PRESSURE:
- hw->z = ev.value;
- break;
- case ABS_TOOL_WIDTH:
- hw->fingerWidth = ev.value;
- break;
- }
- } else
- EventProcessTouchEvent(pInfo, hw, &ev);
- break;
- }
+ switch (ev.type) {
+ case EV_SYN:
+ switch (ev.code) {
+ case SYN_REPORT:
+ hw->numFingers = count_fingers(pInfo, comm);
+ hw->millis = 1000 * ev.time.tv_sec + ev.time.tv_usec / 1000;
+ SynapticsCopyHwState(hwRet, hw);
+ return TRUE;
+ }
+ break;
+ case EV_KEY:
+ v = (ev.value ? TRUE : FALSE);
+ switch (ev.code) {
+ case BTN_LEFT:
+ hw->left = v;
+ break;
+ case BTN_RIGHT:
+ hw->right = v;
+ break;
+ case BTN_MIDDLE:
+ hw->middle = v;
+ break;
+ case BTN_FORWARD:
+ hw->up = v;
+ break;
+ case BTN_BACK:
+ hw->down = v;
+ break;
+ case BTN_0:
+ hw->multi[0] = v;
+ break;
+ case BTN_1:
+ hw->multi[1] = v;
+ break;
+ case BTN_2:
+ hw->multi[2] = v;
+ break;
+ case BTN_3:
+ hw->multi[3] = v;
+ break;
+ case BTN_4:
+ hw->multi[4] = v;
+ break;
+ case BTN_5:
+ hw->multi[5] = v;
+ break;
+ case BTN_6:
+ hw->multi[6] = v;
+ break;
+ case BTN_7:
+ hw->multi[7] = v;
+ break;
+ case BTN_TOOL_FINGER:
+ comm->oneFinger = v;
+ break;
+ case BTN_TOOL_DOUBLETAP:
+ comm->twoFingers = v;
+ break;
+ case BTN_TOOL_TRIPLETAP:
+ comm->threeFingers = v;
+ break;
+ case BTN_TOUCH:
+ if (!priv->has_pressure)
+ hw->z = v ? para->finger_high + 1 : 0;
+ break;
+ }
+ break;
+ case EV_ABS:
+ if (ev.code < ABS_MT_SLOT) {
+ switch (ev.code) {
+ case ABS_X:
+ hw->x = apply_st_scaling(proto_data, ev.value, 0);
+ break;
+ case ABS_Y:
+ hw->y = apply_st_scaling(proto_data, ev.value, 1);
+ break;
+ case ABS_PRESSURE:
+ hw->z = ev.value;
+ break;
+ case ABS_TOOL_WIDTH:
+ hw->fingerWidth = ev.value;
+ break;
+ }
+ }
+ else
+ EventProcessTouchEvent(pInfo, hw, &ev);
+ break;
+ }
}
return FALSE;
}
/* filter for the AutoDevProbe scandir on /dev/input */
-static int EventDevOnly(const struct dirent *dir) {
- return strncmp(EVENT_DEV_NAME, dir->d_name, 5) == 0;
+static int
+EventDevOnly(const struct dirent *dir)
+{
+ return strncmp(EVENT_DEV_NAME, dir->d_name, 5) == 0;
}
#ifdef HAVE_MULTITOUCH
static void
event_query_touch(InputInfoPtr pInfo)
{
- SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
+ SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
SynapticsParameters *para = &priv->synpara;
struct eventcomm_proto_data *proto_data = priv->proto_data;
struct mtdev *mtdev;
@@ -785,53 +780,46 @@ event_query_touch(InputInfoPtr pInfo)
#ifdef EVIOCGPROP
SYSCALL(rc = ioctl(pInfo->fd, EVIOCGPROP(sizeof(prop)), &prop));
- if (rc >= 0 && BitIsOn(&prop, INPUT_PROP_SEMI_MT))
- {
+ if (rc >= 0 && BitIsOn(&prop, INPUT_PROP_SEMI_MT)) {
xf86IDrvMsg(pInfo, X_INFO,
"ignoring touch events for semi-multitouch device\n");
priv->has_semi_mt = TRUE;
}
- if (rc >= 0 && BitIsOn(&prop, INPUT_PROP_BUTTONPAD))
- {
+ if (rc >= 0 && BitIsOn(&prop, INPUT_PROP_BUTTONPAD)) {
xf86IDrvMsg(pInfo, X_INFO, "found clickpad property\n");
para->clickpad = TRUE;
}
#endif
mtdev = mtdev_new_open(pInfo->fd);
- if (!mtdev)
- {
+ if (!mtdev) {
xf86IDrvMsg(pInfo, X_WARNING,
"failed to open mtdev when querying touch capabilities\n");
return;
}
- for (i = 0; i < MT_ABS_SIZE; i++)
- {
- if (mtdev->caps.has_abs[i])
- {
- switch (i)
- {
+ for (i = 0; i < MT_ABS_SIZE; i++) {
+ if (mtdev->caps.has_abs[i]) {
+ switch (i) {
/* X and Y axis info is handed by synaptics already */
- case ABS_MT_POSITION_X - ABS_MT_TOUCH_MAJOR:
- case ABS_MT_POSITION_Y - ABS_MT_TOUCH_MAJOR:
+ case ABS_MT_POSITION_X - ABS_MT_TOUCH_MAJOR:
+ case ABS_MT_POSITION_Y - ABS_MT_TOUCH_MAJOR:
/* Skip tracking ID info */
- case ABS_MT_TRACKING_ID - ABS_MT_TOUCH_MAJOR:
- break;
- default:
- priv->num_mt_axes++;
- break;
+ case ABS_MT_TRACKING_ID - ABS_MT_TOUCH_MAJOR:
+ break;
+ default:
+ priv->num_mt_axes++;
+ break;
}
priv->has_touch = TRUE;
}
}
- if (priv->has_touch)
- {
+ if (priv->has_touch) {
int axnum;
- static const char *labels[] =
- {
+
+ static const char *labels[] = {
AXIS_LABEL_PROP_ABS_MT_TOUCH_MAJOR,
AXIS_LABEL_PROP_ABS_MT_TOUCH_MINOR,
AXIS_LABEL_PROP_ABS_MT_WIDTH_MAJOR,
@@ -847,56 +835,50 @@ event_query_touch(InputInfoPtr pInfo)
if (mtdev->caps.slot.maximum > 0)
priv->max_touches = mtdev->caps.slot.maximum -
- mtdev->caps.slot.minimum + 1;
+ mtdev->caps.slot.minimum + 1;
priv->touch_axes = malloc(priv->num_mt_axes *
sizeof(SynapticsTouchAxisRec));
- if (!priv->touch_axes)
- {
+ if (!priv->touch_axes) {
priv->has_touch = FALSE;
goto out;
}
axnum = 0;
- for (i = 0; i < MT_ABS_SIZE; i++)
- {
- if (mtdev->caps.has_abs[i])
- {
- switch (i)
- {
+ for (i = 0; i < MT_ABS_SIZE; i++) {
+ if (mtdev->caps.has_abs[i]) {
+ switch (i) {
/* X and Y axis info is handed by synaptics already, we just
* need to map the evdev codes to the valuator numbers */
- case ABS_MT_POSITION_X - ABS_MT_TOUCH_MAJOR:
- proto_data->axis_map[i] = 0;
- break;
+ case ABS_MT_POSITION_X - ABS_MT_TOUCH_MAJOR:
+ proto_data->axis_map[i] = 0;
+ break;
- case ABS_MT_POSITION_Y - ABS_MT_TOUCH_MAJOR:
- proto_data->axis_map[i] = 1;
- break;
+ case ABS_MT_POSITION_Y - ABS_MT_TOUCH_MAJOR:
+ proto_data->axis_map[i] = 1;
+ break;
/* Skip tracking ID info */
- case ABS_MT_TRACKING_ID - ABS_MT_TOUCH_MAJOR:
- break;
-
- default:
- priv->touch_axes[axnum].label = labels[i];
- priv->touch_axes[axnum].min =
- mtdev->caps.abs[i].minimum;
- priv->touch_axes[axnum].max =
- mtdev->caps.abs[i].maximum;
- /* Kernel provides units/mm, X wants units/m */
- priv->touch_axes[axnum].res =
- mtdev->caps.abs[i].resolution * 1000;
- /* Valuators 0-3 are used for X, Y, and scrolling */
- proto_data->axis_map[i] = 4 + axnum;
- axnum++;
- break;
+ case ABS_MT_TRACKING_ID - ABS_MT_TOUCH_MAJOR:
+ break;
+
+ default:
+ priv->touch_axes[axnum].label = labels[i];
+ priv->touch_axes[axnum].min = mtdev->caps.abs[i].minimum;
+ priv->touch_axes[axnum].max = mtdev->caps.abs[i].maximum;
+ /* Kernel provides units/mm, X wants units/m */
+ priv->touch_axes[axnum].res =
+ mtdev->caps.abs[i].resolution * 1000;
+ /* Valuators 0-3 are used for X, Y, and scrolling */
+ proto_data->axis_map[i] = 4 + axnum;
+ axnum++;
+ break;
}
}
}
}
-out:
+ out:
mtdev_close(mtdev);
}
#endif
@@ -907,8 +889,9 @@ out:
static void
EventReadDevDimensions(InputInfoPtr pInfo)
{
- SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
+ SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
struct eventcomm_proto_data *proto_data = priv->proto_data;
+
#ifdef HAVE_MULTITOUCH
int i;
#endif
@@ -922,14 +905,15 @@ EventReadDevDimensions(InputInfoPtr pInfo)
proto_data->cur_slot = -1;
#endif
- if (event_query_is_touchpad(pInfo->fd, (proto_data) ? proto_data->need_grab : TRUE))
- {
+ if (event_query_is_touchpad
+ (pInfo->fd, (proto_data) ? proto_data->need_grab : TRUE)) {
#ifdef HAVE_MULTITOUCH
event_query_touch(pInfo);
#endif
event_query_axis_ranges(pInfo);
}
- event_query_model(pInfo->fd, &priv->model, &priv->id_vendor, &priv->id_product);
+ event_query_model(pInfo->fd, &priv->model, &priv->id_vendor,
+ &priv->id_product);
xf86IDrvMsg(pInfo, X_PROBED, "Vendor %#hx Product %#hx\n",
priv->id_vendor, priv->id_product);
@@ -945,59 +929,60 @@ EventAutoDevProbe(InputInfoPtr pInfo, const char *device)
struct dirent **namelist;
if (device) {
- int fd = -1;
- SYSCALL(fd = open(device, O_RDONLY));
- if (fd >= 0)
- {
- touchpad_found = event_query_is_touchpad(fd, TRUE);
+ int fd = -1;
+
+ SYSCALL(fd = open(device, O_RDONLY));
+ if (fd >= 0) {
+ touchpad_found = event_query_is_touchpad(fd, TRUE);
- SYSCALL(close(fd));
+ SYSCALL(close(fd));
/* if a device is set and not a touchpad (or already grabbed),
* we must return FALSE. Otherwise, we'll add a device that
* wasn't requested for and repeat
* f5687a6741a19ef3081e7fd83ac55f6df8bcd5c2. */
- return touchpad_found;
- }
+ return touchpad_found;
+ }
}
i = scandir(DEV_INPUT_EVENT, &namelist, EventDevOnly, alphasort);
if (i < 0) {
- xf86IDrvMsg(pInfo, X_ERROR, "Couldn't open %s\n", DEV_INPUT_EVENT);
- return FALSE;
+ xf86IDrvMsg(pInfo, X_ERROR, "Couldn't open %s\n", DEV_INPUT_EVENT);
+ return FALSE;
}
else if (i == 0) {
- xf86IDrvMsg(pInfo, X_ERROR, "The /dev/input/event* device nodes seem to be missing\n");
- free(namelist);
- return FALSE;
+ xf86IDrvMsg(pInfo, X_ERROR,
+ "The /dev/input/event* device nodes seem to be missing\n");
+ free(namelist);
+ return FALSE;
}
while (i--) {
- char fname[64];
- int fd = -1;
-
- if (!touchpad_found) {
- sprintf(fname, "%s/%s", DEV_INPUT_EVENT, namelist[i]->d_name);
- SYSCALL(fd = open(fname, O_RDONLY));
- if (fd < 0)
- continue;
-
- if (event_query_is_touchpad(fd, TRUE)) {
- touchpad_found = TRUE;
- xf86IDrvMsg(pInfo, X_PROBED, "auto-dev sets device to %s\n",
- fname);
- pInfo->options =
- xf86ReplaceStrOption(pInfo->options, "Device", fname);
- }
- SYSCALL(close(fd));
- }
- free(namelist[i]);
+ char fname[64];
+ int fd = -1;
+
+ if (!touchpad_found) {
+ sprintf(fname, "%s/%s", DEV_INPUT_EVENT, namelist[i]->d_name);
+ SYSCALL(fd = open(fname, O_RDONLY));
+ if (fd < 0)
+ continue;
+
+ if (event_query_is_touchpad(fd, TRUE)) {
+ touchpad_found = TRUE;
+ xf86IDrvMsg(pInfo, X_PROBED, "auto-dev sets device to %s\n",
+ fname);
+ pInfo->options =
+ xf86ReplaceStrOption(pInfo->options, "Device", fname);
+ }
+ SYSCALL(close(fd));
+ }
+ free(namelist[i]);
}
free(namelist);
if (!touchpad_found) {
- xf86IDrvMsg(pInfo, X_ERROR, "no synaptics event device found\n");
- return FALSE;
+ xf86IDrvMsg(pInfo, X_ERROR, "no synaptics event device found\n");
+ return FALSE;
}
return TRUE;
diff --git a/src/eventcomm.h b/src/eventcomm.h
index 70bfc18..30c09ee 100644
--- a/src/eventcomm.h
+++ b/src/eventcomm.h
@@ -38,11 +38,11 @@
struct eventcomm_proto_data;
-extern struct eventcomm_proto_data *
-EventProtoDataAlloc(void);
+extern struct eventcomm_proto_data *EventProtoDataAlloc(void);
extern Bool
+
EventReadHwState(InputInfoPtr pInfo,
- struct CommData *comm, struct SynapticsHwState *hwRet);
+ struct CommData *comm, struct SynapticsHwState *hwRet);
-#endif /* _EVENTCOMM_H_ */
+#endif /* _EVENTCOMM_H_ */
diff --git a/src/properties.c b/src/properties.c
index 783b516..44ac306 100644
--- a/src/properties.c
+++ b/src/properties.c
@@ -53,49 +53,49 @@
static Atom float_type;
-Atom prop_edges = 0;
-Atom prop_finger = 0;
-Atom prop_tap_time = 0;
-Atom prop_tap_move = 0;
-Atom prop_tap_durations = 0;
-Atom prop_clickpad = 0;
-Atom prop_tap_fast = 0;
-Atom prop_middle_timeout = 0;
-Atom prop_twofinger_pressure = 0;
-Atom prop_twofinger_width = 0;
-Atom prop_scrolldist = 0;
-Atom prop_scrolledge = 0;
-Atom prop_scrolltwofinger = 0;
-Atom prop_speed = 0;
-Atom prop_edgemotion_pressure = 0;
-Atom prop_edgemotion_speed = 0;
-Atom prop_edgemotion_always = 0;
-Atom prop_buttonscroll = 0;
-Atom prop_buttonscroll_repeat = 0;
-Atom prop_buttonscroll_time = 0;
-Atom prop_off = 0;
-Atom prop_lockdrags = 0;
-Atom prop_lockdrags_time = 0;
-Atom prop_tapaction = 0;
-Atom prop_clickaction = 0;
-Atom prop_circscroll = 0;
-Atom prop_circscroll_dist = 0;
-Atom prop_circscroll_trigger = 0;
-Atom prop_circpad = 0;
-Atom prop_palm = 0;
-Atom prop_palm_dim = 0;
-Atom prop_coastspeed = 0;
-Atom prop_pressuremotion = 0;
+Atom prop_edges = 0;
+Atom prop_finger = 0;
+Atom prop_tap_time = 0;
+Atom prop_tap_move = 0;
+Atom prop_tap_durations = 0;
+Atom prop_clickpad = 0;
+Atom prop_tap_fast = 0;
+Atom prop_middle_timeout = 0;
+Atom prop_twofinger_pressure = 0;
+Atom prop_twofinger_width = 0;
+Atom prop_scrolldist = 0;
+Atom prop_scrolledge = 0;
+Atom prop_scrolltwofinger = 0;
+Atom prop_speed = 0;
+Atom prop_edgemotion_pressure = 0;
+Atom prop_edgemotion_speed = 0;
+Atom prop_edgemotion_always = 0;
+Atom prop_buttonscroll = 0;
+Atom prop_buttonscroll_repeat = 0;
+Atom prop_buttonscroll_time = 0;
+Atom prop_off = 0;
+Atom prop_lockdrags = 0;
+Atom prop_lockdrags_time = 0;
+Atom prop_tapaction = 0;
+Atom prop_clickaction = 0;
+Atom prop_circscroll = 0;
+Atom prop_circscroll_dist = 0;
+Atom prop_circscroll_trigger = 0;
+Atom prop_circpad = 0;
+Atom prop_palm = 0;
+Atom prop_palm_dim = 0;
+Atom prop_coastspeed = 0;
+Atom prop_pressuremotion = 0;
Atom prop_pressuremotion_factor = 0;
-Atom prop_grab = 0;
-Atom prop_gestures = 0;
-Atom prop_capabilities = 0;
-Atom prop_resolution = 0;
-Atom prop_area = 0;
-Atom prop_softbutton_areas = 0;
-Atom prop_noise_cancellation = 0;
-Atom prop_product_id = 0;
-Atom prop_device_node = 0;
+Atom prop_grab = 0;
+Atom prop_gestures = 0;
+Atom prop_capabilities = 0;
+Atom prop_resolution = 0;
+Atom prop_area = 0;
+Atom prop_softbutton_areas = 0;
+Atom prop_noise_cancellation = 0;
+Atom prop_product_id = 0;
+Atom prop_device_node = 0;
static Atom
InitTypedAtom(DeviceIntPtr dev, char *name, Atom type, int format, int nvalues,
@@ -103,27 +103,35 @@ InitTypedAtom(DeviceIntPtr dev, char *name, Atom type, int format, int nvalues,
{
int i;
Atom atom;
- uint8_t val_8[9]; /* we never have more than 9 values in an atom */
+ uint8_t val_8[9]; /* we never have more than 9 values in an atom */
uint16_t val_16[9];
uint32_t val_32[9];
pointer converted;
-
- for (i = 0; i < nvalues; i++)
- {
- switch(format)
- {
- case 8: val_8[i] = values[i]; break;
- case 16: val_16[i] = values[i]; break;
- case 32: val_32[i] = values[i]; break;
+ for (i = 0; i < nvalues; i++) {
+ switch (format) {
+ case 8:
+ val_8[i] = values[i];
+ break;
+ case 16:
+ val_16[i] = values[i];
+ break;
+ case 32:
+ val_32[i] = values[i];
+ break;
}
}
- switch(format)
- {
- case 8: converted = val_8; break;
- case 16: converted = val_16; break;
- case 32: converted = val_32; break;
+ switch (format) {
+ case 8:
+ converted = val_8;
+ break;
+ case 16:
+ converted = val_16;
+ break;
+ case 32:
+ converted = val_32;
+ break;
}
atom = MakeAtom(name, strlen(name), TRUE);
@@ -166,7 +174,8 @@ InitSoftButtonProperty(InputInfoPtr pInfo)
values[5] = para->softbutton_areas[1][1];
values[6] = para->softbutton_areas[1][2];
values[7] = para->softbutton_areas[1][3];
- prop_softbutton_areas = InitAtom(pInfo->dev, SYNAPTICS_PROP_SOFTBUTTON_AREAS, 32, 8, values);
+ prop_softbutton_areas =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_SOFTBUTTON_AREAS, 32, 8, values);
}
void
@@ -174,15 +183,13 @@ InitDeviceProperties(InputInfoPtr pInfo)
{
SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
SynapticsParameters *para = &priv->synpara;
- int values[9]; /* we never have more than 9 values in an atom */
- float fvalues[4]; /* never have more than 4 float values */
+ int values[9]; /* we never have more than 9 values in an atom */
+ float fvalues[4]; /* never have more than 4 float values */
float_type = XIGetKnownProperty(XATOM_FLOAT);
- if (!float_type)
- {
+ if (!float_type) {
float_type = MakeAtom(XATOM_FLOAT, strlen(XATOM_FLOAT), TRUE);
- if (!float_type)
- {
+ if (!float_type) {
xf86IDrvMsg(pInfo, X_ERROR, "Failed to init float atom. "
"Disabling property support.\n");
return;
@@ -201,35 +208,45 @@ InitDeviceProperties(InputInfoPtr pInfo)
values[2] = para->finger_press;
prop_finger = InitAtom(pInfo->dev, SYNAPTICS_PROP_FINGER, 32, 3, values);
- prop_tap_time = InitAtom(pInfo->dev, SYNAPTICS_PROP_TAP_TIME, 32, 1, &para->tap_time);
- prop_tap_move = InitAtom(pInfo->dev, SYNAPTICS_PROP_TAP_MOVE, 32, 1, &para->tap_move);
+ prop_tap_time =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_TAP_TIME, 32, 1, &para->tap_time);
+ prop_tap_move =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_TAP_MOVE, 32, 1, &para->tap_move);
values[0] = para->single_tap_timeout;
values[1] = para->tap_time_2;
values[2] = para->click_time;
- prop_tap_durations = InitAtom(pInfo->dev, SYNAPTICS_PROP_TAP_DURATIONS, 32, 3, values);
- prop_clickpad = InitAtom(pInfo->dev, SYNAPTICS_PROP_CLICKPAD, 8, 1,
- &para->clickpad);
- prop_tap_fast = InitAtom(pInfo->dev, SYNAPTICS_PROP_TAP_FAST, 8, 1, &para->fast_taps);
- prop_middle_timeout = InitAtom(pInfo->dev, SYNAPTICS_PROP_MIDDLE_TIMEOUT,
- 32, 1, &para->emulate_mid_button_time);
- prop_twofinger_pressure = InitAtom(pInfo->dev, SYNAPTICS_PROP_TWOFINGER_PRESSURE,
- 32, 1, &para->emulate_twofinger_z);
- prop_twofinger_width = InitAtom(pInfo->dev, SYNAPTICS_PROP_TWOFINGER_WIDTH,
- 32, 1, &para->emulate_twofinger_w);
+ prop_tap_durations =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_TAP_DURATIONS, 32, 3, values);
+ prop_clickpad =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_CLICKPAD, 8, 1, &para->clickpad);
+ prop_tap_fast =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_TAP_FAST, 8, 1, &para->fast_taps);
+ prop_middle_timeout =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_MIDDLE_TIMEOUT, 32, 1,
+ &para->emulate_mid_button_time);
+ prop_twofinger_pressure =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_TWOFINGER_PRESSURE, 32, 1,
+ &para->emulate_twofinger_z);
+ prop_twofinger_width =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_TWOFINGER_WIDTH, 32, 1,
+ &para->emulate_twofinger_w);
values[0] = para->scroll_dist_vert;
values[1] = para->scroll_dist_horiz;
- prop_scrolldist = InitAtom(pInfo->dev, SYNAPTICS_PROP_SCROLL_DISTANCE, 32, 2, values);
+ prop_scrolldist =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_SCROLL_DISTANCE, 32, 2, values);
values[0] = para->scroll_edge_vert;
values[1] = para->scroll_edge_horiz;
values[2] = para->scroll_edge_corner;
- prop_scrolledge = InitAtom(pInfo->dev, SYNAPTICS_PROP_SCROLL_EDGE,8, 3, values);
+ prop_scrolledge =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_SCROLL_EDGE, 8, 3, values);
values[0] = para->scroll_twofinger_vert;
values[1] = para->scroll_twofinger_horiz;
- prop_scrolltwofinger = InitAtom(pInfo->dev, SYNAPTICS_PROP_SCROLL_TWOFINGER,8, 2, values);
+ prop_scrolltwofinger =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_SCROLL_TWOFINGER, 8, 2, values);
fvalues[0] = para->min_speed;
fvalues[1] = para->max_speed;
@@ -239,63 +256,96 @@ InitDeviceProperties(InputInfoPtr pInfo)
values[0] = para->edge_motion_min_z;
values[1] = para->edge_motion_max_z;
- prop_edgemotion_pressure = InitAtom(pInfo->dev, SYNAPTICS_PROP_EDGEMOTION_PRESSURE, 32, 2, values);
+ prop_edgemotion_pressure =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_EDGEMOTION_PRESSURE, 32, 2, values);
values[0] = para->edge_motion_min_speed;
values[1] = para->edge_motion_max_speed;
- prop_edgemotion_speed = InitAtom(pInfo->dev, SYNAPTICS_PROP_EDGEMOTION_SPEED, 32, 2, values);
- prop_edgemotion_always = InitAtom(pInfo->dev, SYNAPTICS_PROP_EDGEMOTION, 8, 1, &para->edge_motion_use_always);
+ prop_edgemotion_speed =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_EDGEMOTION_SPEED, 32, 2, values);
+ prop_edgemotion_always =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_EDGEMOTION, 8, 1,
+ &para->edge_motion_use_always);
- if (priv->has_scrollbuttons)
- {
+ if (priv->has_scrollbuttons) {
values[0] = para->updown_button_scrolling;
values[1] = para->leftright_button_scrolling;
- prop_buttonscroll = InitAtom(pInfo->dev, SYNAPTICS_PROP_BUTTONSCROLLING, 8, 2, values);
+ prop_buttonscroll =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_BUTTONSCROLLING, 8, 2, values);
values[0] = para->updown_button_repeat;
values[1] = para->leftright_button_repeat;
- prop_buttonscroll_repeat = InitAtom(pInfo->dev, SYNAPTICS_PROP_BUTTONSCROLLING_REPEAT, 8, 2, values);
- prop_buttonscroll_time = InitAtom(pInfo->dev, SYNAPTICS_PROP_BUTTONSCROLLING_TIME, 32, 1, &para->scroll_button_repeat);
+ prop_buttonscroll_repeat =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_BUTTONSCROLLING_REPEAT, 8, 2,
+ values);
+ prop_buttonscroll_time =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_BUTTONSCROLLING_TIME, 32, 1,
+ &para->scroll_button_repeat);
}
- prop_off = InitAtom(pInfo->dev, SYNAPTICS_PROP_OFF, 8, 1, &para->touchpad_off);
- prop_lockdrags = InitAtom(pInfo->dev, SYNAPTICS_PROP_LOCKED_DRAGS, 8, 1, &para->locked_drags);
- prop_lockdrags_time = InitAtom(pInfo->dev, SYNAPTICS_PROP_LOCKED_DRAGS_TIMEOUT, 32, 1, &para->locked_drag_time);
+ prop_off =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_OFF, 8, 1, &para->touchpad_off);
+ prop_lockdrags =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_LOCKED_DRAGS, 8, 1,
+ &para->locked_drags);
+ prop_lockdrags_time =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_LOCKED_DRAGS_TIMEOUT, 32, 1,
+ &para->locked_drag_time);
memcpy(values, para->tap_action, MAX_TAP * sizeof(int));
- prop_tapaction = InitAtom(pInfo->dev, SYNAPTICS_PROP_TAP_ACTION, 8, MAX_TAP, values);
+ prop_tapaction =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_TAP_ACTION, 8, MAX_TAP, values);
memcpy(values, para->click_action, MAX_CLICK * sizeof(int));
- prop_clickaction = InitAtom(pInfo->dev, SYNAPTICS_PROP_CLICK_ACTION, 8, MAX_CLICK, values);
+ prop_clickaction =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_CLICK_ACTION, 8, MAX_CLICK, values);
- prop_circscroll = InitAtom(pInfo->dev, SYNAPTICS_PROP_CIRCULAR_SCROLLING, 8, 1, &para->circular_scrolling);
+ prop_circscroll =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_CIRCULAR_SCROLLING, 8, 1,
+ &para->circular_scrolling);
fvalues[0] = para->scroll_dist_circ;
- prop_circscroll_dist = InitFloatAtom(pInfo->dev, SYNAPTICS_PROP_CIRCULAR_SCROLLING_DIST, 1, fvalues);
-
- prop_circscroll_trigger = InitAtom(pInfo->dev, SYNAPTICS_PROP_CIRCULAR_SCROLLING_TRIGGER, 8, 1, &para->circular_trigger);
- prop_circpad = InitAtom(pInfo->dev, SYNAPTICS_PROP_CIRCULAR_PAD, 8, 1, &para->circular_pad);
- prop_palm = InitAtom(pInfo->dev, SYNAPTICS_PROP_PALM_DETECT, 8, 1, &para->palm_detect);
+ prop_circscroll_dist =
+ InitFloatAtom(pInfo->dev, SYNAPTICS_PROP_CIRCULAR_SCROLLING_DIST, 1,
+ fvalues);
+
+ prop_circscroll_trigger =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_CIRCULAR_SCROLLING_TRIGGER, 8, 1,
+ &para->circular_trigger);
+ prop_circpad =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_CIRCULAR_PAD, 8, 1,
+ &para->circular_pad);
+ prop_palm =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_PALM_DETECT, 8, 1,
+ &para->palm_detect);
values[0] = para->palm_min_width;
values[1] = para->palm_min_z;
- prop_palm_dim = InitAtom(pInfo->dev, SYNAPTICS_PROP_PALM_DIMENSIONS, 32, 2, values);
+ prop_palm_dim =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_PALM_DIMENSIONS, 32, 2, values);
fvalues[0] = para->coasting_speed;
fvalues[1] = para->coasting_friction;
- prop_coastspeed = InitFloatAtom(pInfo->dev, SYNAPTICS_PROP_COASTING_SPEED, 2, fvalues);
+ prop_coastspeed =
+ InitFloatAtom(pInfo->dev, SYNAPTICS_PROP_COASTING_SPEED, 2, fvalues);
values[0] = para->press_motion_min_z;
values[1] = para->press_motion_max_z;
- prop_pressuremotion = InitTypedAtom(pInfo->dev, SYNAPTICS_PROP_PRESSURE_MOTION, XA_CARDINAL, 32, 2, values);
+ prop_pressuremotion =
+ InitTypedAtom(pInfo->dev, SYNAPTICS_PROP_PRESSURE_MOTION, XA_CARDINAL,
+ 32, 2, values);
fvalues[0] = para->press_motion_min_factor;
fvalues[1] = para->press_motion_max_factor;
- prop_pressuremotion_factor = InitFloatAtom(pInfo->dev, SYNAPTICS_PROP_PRESSURE_MOTION_FACTOR, 2, fvalues);
+ prop_pressuremotion_factor =
+ InitFloatAtom(pInfo->dev, SYNAPTICS_PROP_PRESSURE_MOTION_FACTOR, 2,
+ fvalues);
- prop_grab = InitAtom(pInfo->dev, SYNAPTICS_PROP_GRAB, 8, 1, &para->grab_event_device);
+ prop_grab =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_GRAB, 8, 1,
+ &para->grab_event_device);
values[0] = para->tap_and_drag_gesture;
prop_gestures = InitAtom(pInfo->dev, SYNAPTICS_PROP_GESTURES, 8, 1, values);
@@ -307,11 +357,13 @@ InitDeviceProperties(InputInfoPtr pInfo)
values[4] = priv->has_triple;
values[5] = priv->has_pressure;
values[6] = priv->has_width;
- prop_capabilities = InitAtom(pInfo->dev, SYNAPTICS_PROP_CAPABILITIES, 8, 7, values);
+ prop_capabilities =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_CAPABILITIES, 8, 7, values);
values[0] = para->resolution_vert;
values[1] = para->resolution_horiz;
- prop_resolution = InitAtom(pInfo->dev, SYNAPTICS_PROP_RESOLUTION, 32, 2, values);
+ prop_resolution =
+ InitAtom(pInfo->dev, SYNAPTICS_PROP_RESOLUTION, 32, 2, values);
values[0] = para->area_left_edge;
values[1] = para->area_right_edge;
@@ -325,19 +377,20 @@ InitDeviceProperties(InputInfoPtr pInfo)
values[0] = para->hyst_x;
values[1] = para->hyst_y;
prop_noise_cancellation = InitAtom(pInfo->dev,
- SYNAPTICS_PROP_NOISE_CANCELLATION, 32, 2, values);
+ SYNAPTICS_PROP_NOISE_CANCELLATION, 32, 2,
+ values);
/* only init product_id property if we actually know them */
- if (priv->id_vendor || priv->id_product)
- {
+ if (priv->id_vendor || priv->id_product) {
values[0] = priv->id_vendor;
values[1] = priv->id_product;
- prop_product_id = InitAtom(pInfo->dev, XI_PROP_PRODUCT_ID, 32, 2, values);
+ prop_product_id =
+ InitAtom(pInfo->dev, XI_PROP_PRODUCT_ID, 32, 2, values);
}
- if (priv->device)
- {
- prop_device_node = MakeAtom(XI_PROP_DEVICE_NODE, strlen(XI_PROP_DEVICE_NODE), TRUE);
+ if (priv->device) {
+ prop_device_node =
+ MakeAtom(XI_PROP_DEVICE_NODE, strlen(XI_PROP_DEVICE_NODE), TRUE);
XIChangeDeviceProperty(pInfo->dev, prop_device_node, XA_STRING, 8,
PropModeReplace, strlen(priv->device),
(pointer) priv->device, FALSE);
@@ -357,200 +410,201 @@ SetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop,
/* If checkonly is set, no parameters may be changed. So just let the code
* change temporary variables and forget about it. */
- if (checkonly)
- {
+ if (checkonly) {
tmp = *para;
para = &tmp;
}
- if (property == prop_edges)
- {
+ if (property == prop_edges) {
INT32 *edges;
+
if (prop->size != 4 || prop->format != 32 || prop->type != XA_INTEGER)
return BadMatch;
- edges = (INT32*)prop->data;
+ edges = (INT32 *) prop->data;
if (edges[0] > edges[1] || edges[2] > edges[3])
return BadValue;
- para->left_edge = edges[0];
- para->right_edge = edges[1];
- para->top_edge = edges[2];
+ para->left_edge = edges[0];
+ para->right_edge = edges[1];
+ para->top_edge = edges[2];
para->bottom_edge = edges[3];
- } else if (property == prop_finger)
- {
+ }
+ else if (property == prop_finger) {
INT32 *finger;
+
if (prop->size != 3 || prop->format != 32 || prop->type != XA_INTEGER)
return BadMatch;
- finger = (INT32*)prop->data;
+ finger = (INT32 *) prop->data;
if (finger[0] > finger[1])
return BadValue;
- para->finger_low = finger[0];
- para->finger_high = finger[1];
+ para->finger_low = finger[0];
+ para->finger_high = finger[1];
para->finger_press = finger[2];
- } else if (property == prop_tap_time)
- {
+ }
+ else if (property == prop_tap_time) {
if (prop->size != 1 || prop->format != 32 || prop->type != XA_INTEGER)
return BadMatch;
- para->tap_time = *(INT32*)prop->data;
+ para->tap_time = *(INT32 *) prop->data;
- } else if (property == prop_tap_move)
- {
+ }
+ else if (property == prop_tap_move) {
if (prop->size != 1 || prop->format != 32 || prop->type != XA_INTEGER)
return BadMatch;
- para->tap_move = *(INT32*)prop->data;
- } else if (property == prop_tap_durations)
- {
+ para->tap_move = *(INT32 *) prop->data;
+ }
+ else if (property == prop_tap_durations) {
INT32 *timeouts;
if (prop->size != 3 || prop->format != 32 || prop->type != XA_INTEGER)
return BadMatch;
- timeouts = (INT32*)prop->data;
+ timeouts = (INT32 *) prop->data;
para->single_tap_timeout = timeouts[0];
- para->tap_time_2 = timeouts[1];
- para->click_time = timeouts[2];
- } else if (property == prop_clickpad) {
+ para->tap_time_2 = timeouts[1];
+ para->click_time = timeouts[2];
+ }
+ else if (property == prop_clickpad) {
BOOL value;
if (prop->size != 1 || prop->format != 8 || prop->type != XA_INTEGER)
return BadMatch;
- value = *(BOOL*)prop->data;
+ value = *(BOOL *) prop->data;
if (!para->clickpad && value && !prop_softbutton_areas)
InitSoftButtonProperty(pInfo);
- else if (para->clickpad && !value && prop_softbutton_areas)
- {
+ else if (para->clickpad && !value && prop_softbutton_areas) {
XIDeleteDeviceProperty(dev, prop_softbutton_areas, FALSE);
prop_softbutton_areas = 0;
}
- para->clickpad = *(BOOL*)prop->data;
- } else if (property == prop_tap_fast)
- {
+ para->clickpad = *(BOOL *) prop->data;
+ }
+ else if (property == prop_tap_fast) {
if (prop->size != 1 || prop->format != 8 || prop->type != XA_INTEGER)
return BadMatch;
- para->fast_taps = *(BOOL*)prop->data;
+ para->fast_taps = *(BOOL *) prop->data;
- } else if (property == prop_middle_timeout)
- {
+ }
+ else if (property == prop_middle_timeout) {
if (prop->size != 1 || prop->format != 32 || prop->type != XA_INTEGER)
return BadMatch;
- para->emulate_mid_button_time = *(INT32*)prop->data;
- } else if (property == prop_twofinger_pressure)
- {
+ para->emulate_mid_button_time = *(INT32 *) prop->data;
+ }
+ else if (property == prop_twofinger_pressure) {
if (prop->size != 1 || prop->format != 32 || prop->type != XA_INTEGER)
return BadMatch;
- para->emulate_twofinger_z = *(INT32*)prop->data;
- } else if (property == prop_twofinger_width)
- {
+ para->emulate_twofinger_z = *(INT32 *) prop->data;
+ }
+ else if (property == prop_twofinger_width) {
if (prop->size != 1 || prop->format != 32 || prop->type != XA_INTEGER)
return BadMatch;
- para->emulate_twofinger_w = *(INT32*)prop->data;
- } else if (property == prop_scrolldist)
- {
+ para->emulate_twofinger_w = *(INT32 *) prop->data;
+ }
+ else if (property == prop_scrolldist) {
INT32 *dist;
+
if (prop->size != 2 || prop->format != 32 || prop->type != XA_INTEGER)
return BadMatch;
- dist = (INT32*)prop->data;
- if (para->scroll_dist_vert != dist[0])
- {
+ dist = (INT32 *) prop->data;
+ if (para->scroll_dist_vert != dist[0]) {
para->scroll_dist_vert = dist[0];
#ifdef HAVE_SMOOTH_SCROLL
SetScrollValuator(dev, priv->scroll_axis_vert, SCROLL_TYPE_VERTICAL,
para->scroll_dist_vert, 0);
#endif
}
- if (para->scroll_dist_horiz != dist[1])
- {
+ if (para->scroll_dist_horiz != dist[1]) {
para->scroll_dist_horiz = dist[1];
#ifdef HAVE_SMOOTH_SCROLL
- SetScrollValuator(dev, priv->scroll_axis_horiz, SCROLL_TYPE_HORIZONTAL,
- para->scroll_dist_horiz, 0);
+ SetScrollValuator(dev, priv->scroll_axis_horiz,
+ SCROLL_TYPE_HORIZONTAL, para->scroll_dist_horiz,
+ 0);
#endif
}
- } else if (property == prop_scrolledge)
- {
+ }
+ else if (property == prop_scrolledge) {
CARD8 *edge;
+
if (prop->size != 3 || prop->format != 8 || prop->type != XA_INTEGER)
return BadMatch;
- edge = (BOOL*)prop->data;
- para->scroll_edge_vert = edge[0];
- para->scroll_edge_horiz = edge[1];
+ edge = (BOOL *) prop->data;
+ para->scroll_edge_vert = edge[0];
+ para->scroll_edge_horiz = edge[1];
para->scroll_edge_corner = edge[2];
- } else if (property == prop_scrolltwofinger)
- {
+ }
+ else if (property == prop_scrolltwofinger) {
CARD8 *twofinger;
if (prop->size != 2 || prop->format != 8 || prop->type != XA_INTEGER)
return BadMatch;
- twofinger = (BOOL*)prop->data;
- para->scroll_twofinger_vert = twofinger[0];
+ twofinger = (BOOL *) prop->data;
+ para->scroll_twofinger_vert = twofinger[0];
para->scroll_twofinger_horiz = twofinger[1];
- } else if (property == prop_speed)
- {
+ }
+ else if (property == prop_speed) {
float *speed;
if (prop->size != 4 || prop->format != 32 || prop->type != float_type)
return BadMatch;
- speed = (float*)prop->data;
+ speed = (float *) prop->data;
para->min_speed = speed[0];
para->max_speed = speed[1];
para->accl = speed[2];
para->trackstick_speed = speed[3];
- } else if (property == prop_edgemotion_pressure)
- {
+ }
+ else if (property == prop_edgemotion_pressure) {
CARD32 *pressure;
if (prop->size != 2 || prop->format != 32 || prop->type != XA_INTEGER)
return BadMatch;
- pressure = (CARD32*)prop->data;
+ pressure = (CARD32 *) prop->data;
if (pressure[0] > pressure[1])
return BadValue;
para->edge_motion_min_z = pressure[0];
para->edge_motion_max_z = pressure[1];
- } else if (property == prop_edgemotion_speed)
- {
+ }
+ else if (property == prop_edgemotion_speed) {
CARD32 *speed;
if (prop->size != 2 || prop->format != 32 || prop->type != XA_INTEGER)
return BadMatch;
- speed = (CARD32*)prop->data;
+ speed = (CARD32 *) prop->data;
if (speed[0] > speed[1])
return BadValue;
para->edge_motion_min_speed = speed[0];
para->edge_motion_max_speed = speed[1];
- } else if (property == prop_edgemotion_always)
- {
+ }
+ else if (property == prop_edgemotion_always) {
if (prop->size != 1 || prop->format != 8 || prop->type != XA_INTEGER)
return BadMatch;
- para->edge_motion_use_always = *(BOOL*)prop->data;
+ para->edge_motion_use_always = *(BOOL *) prop->data;
- } else if (property == prop_buttonscroll)
- {
+ }
+ else if (property == prop_buttonscroll) {
BOOL *scroll;
if (!priv->has_scrollbuttons)
@@ -559,12 +613,12 @@ SetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop,
if (prop->size != 2 || prop->format != 8 || prop->type != XA_INTEGER)
return BadMatch;
- scroll = (BOOL*)prop->data;
- para->updown_button_scrolling = scroll[0];
+ scroll = (BOOL *) prop->data;
+ para->updown_button_scrolling = scroll[0];
para->leftright_button_scrolling = scroll[1];
- } else if (property == prop_buttonscroll_repeat)
- {
+ }
+ else if (property == prop_buttonscroll_repeat) {
BOOL *repeat;
if (!priv->has_scrollbuttons)
@@ -573,203 +627,212 @@ SetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop,
if (prop->size != 2 || prop->format != 8 || prop->type != XA_INTEGER)
return BadMatch;
- repeat = (BOOL*)prop->data;
- para->updown_button_repeat = repeat[0];
+ repeat = (BOOL *) prop->data;
+ para->updown_button_repeat = repeat[0];
para->leftright_button_repeat = repeat[1];
- } else if (property == prop_buttonscroll_time)
- {
+ }
+ else if (property == prop_buttonscroll_time) {
if (!priv->has_scrollbuttons)
return BadMatch;
if (prop->size != 1 || prop->format != 32 || prop->type != XA_INTEGER)
return BadMatch;
- para->scroll_button_repeat = *(INT32*)prop->data;
+ para->scroll_button_repeat = *(INT32 *) prop->data;
- } else if (property == prop_off)
- {
+ }
+ else if (property == prop_off) {
CARD8 off;
+
if (prop->size != 1 || prop->format != 8 || prop->type != XA_INTEGER)
return BadMatch;
- off = *(CARD8*)prop->data;
+ off = *(CARD8 *) prop->data;
if (off > 2)
return BadValue;
para->touchpad_off = off;
- } else if (property == prop_gestures)
- {
+ }
+ else if (property == prop_gestures) {
BOOL *gestures;
if (prop->size != 1 || prop->format != 8 || prop->type != XA_INTEGER)
return BadMatch;
- gestures = (BOOL*)prop->data;
+ gestures = (BOOL *) prop->data;
para->tap_and_drag_gesture = gestures[0];
- } else if (property == prop_lockdrags)
- {
+ }
+ else if (property == prop_lockdrags) {
if (prop->size != 1 || prop->format != 8 || prop->type != XA_INTEGER)
return BadMatch;
- para->locked_drags = *(BOOL*)prop->data;
- } else if (property == prop_lockdrags_time)
- {
+ para->locked_drags = *(BOOL *) prop->data;
+ }
+ else if (property == prop_lockdrags_time) {
if (prop->size != 1 || prop->format != 32 || prop->type != XA_INTEGER)
return BadMatch;
- para->locked_drag_time = *(INT32*)prop->data;
- } else if (property == prop_tapaction)
- {
+ para->locked_drag_time = *(INT32 *) prop->data;
+ }
+ else if (property == prop_tapaction) {
int i;
CARD8 *action;
- if (prop->size > MAX_TAP || prop->format != 8 || prop->type != XA_INTEGER)
+ if (prop->size > MAX_TAP || prop->format != 8 ||
+ prop->type != XA_INTEGER)
return BadMatch;
- action = (CARD8*)prop->data;
+ action = (CARD8 *) prop->data;
for (i = 0; i < MAX_TAP; i++)
para->tap_action[i] = action[i];
- } else if (property == prop_clickaction)
- {
+ }
+ else if (property == prop_clickaction) {
int i;
CARD8 *action;
- if (prop->size > MAX_CLICK || prop->format != 8 || prop->type != XA_INTEGER)
+ if (prop->size > MAX_CLICK || prop->format != 8 ||
+ prop->type != XA_INTEGER)
return BadMatch;
- action = (CARD8*)prop->data;
+ action = (CARD8 *) prop->data;
for (i = 0; i < MAX_CLICK; i++)
para->click_action[i] = action[i];
- } else if (property == prop_circscroll)
- {
+ }
+ else if (property == prop_circscroll) {
if (prop->size != 1 || prop->format != 8 || prop->type != XA_INTEGER)
return BadMatch;
- para->circular_scrolling = *(BOOL*)prop->data;
+ para->circular_scrolling = *(BOOL *) prop->data;
- } else if (property == prop_circscroll_dist)
- {
+ }
+ else if (property == prop_circscroll_dist) {
float circdist;
if (prop->size != 1 || prop->format != 32 || prop->type != float_type)
return BadMatch;
- circdist = *(float*)prop->data;
+ circdist = *(float *) prop->data;
para->scroll_dist_circ = circdist;
- } else if (property == prop_circscroll_trigger)
- {
+ }
+ else if (property == prop_circscroll_trigger) {
int trigger;
+
if (prop->size != 1 || prop->format != 8 || prop->type != XA_INTEGER)
return BadMatch;
- trigger = *(CARD8*)prop->data;
+ trigger = *(CARD8 *) prop->data;
if (trigger > 8)
return BadValue;
para->circular_trigger = trigger;
- } else if (property == prop_circpad)
- {
+ }
+ else if (property == prop_circpad) {
if (prop->size != 1 || prop->format != 8 || prop->type != XA_INTEGER)
return BadMatch;
- para->circular_pad = *(BOOL*)prop->data;
- } else if (property == prop_palm)
- {
+ para->circular_pad = *(BOOL *) prop->data;
+ }
+ else if (property == prop_palm) {
if (prop->size != 1 || prop->format != 8 || prop->type != XA_INTEGER)
return BadMatch;
- para->palm_detect = *(BOOL*)prop->data;
- } else if (property == prop_palm_dim)
- {
+ para->palm_detect = *(BOOL *) prop->data;
+ }
+ else if (property == prop_palm_dim) {
INT32 *dim;
if (prop->size != 2 || prop->format != 32 || prop->type != XA_INTEGER)
return BadMatch;
- dim = (INT32*)prop->data;
+ dim = (INT32 *) prop->data;
para->palm_min_width = dim[0];
- para->palm_min_z = dim[1];
- } else if (property == prop_coastspeed)
- {
+ para->palm_min_z = dim[1];
+ }
+ else if (property == prop_coastspeed) {
float *coast_speeds;
if (prop->size != 2 || prop->format != 32 || prop->type != float_type)
return BadMatch;
- coast_speeds = (float*)prop->data;
+ coast_speeds = (float *) prop->data;
para->coasting_speed = coast_speeds[0];
para->coasting_friction = coast_speeds[1];
- } else if (property == prop_pressuremotion)
- {
+ }
+ else if (property == prop_pressuremotion) {
CARD32 *press;
+
if (prop->size != 2 || prop->format != 32 || prop->type != XA_CARDINAL)
return BadMatch;
- press = (CARD32*)prop->data;
+ press = (CARD32 *) prop->data;
if (press[0] > press[1])
return BadValue;
para->press_motion_min_z = press[0];
para->press_motion_max_z = press[1];
- } else if (property == prop_grab)
- {
+ }
+ else if (property == prop_grab) {
if (prop->size != 1 || prop->format != 8 || prop->type != XA_INTEGER)
return BadMatch;
- para->grab_event_device = *(BOOL*)prop->data;
- } else if (property == prop_capabilities)
- {
+ para->grab_event_device = *(BOOL *) prop->data;
+ }
+ else if (property == prop_capabilities) {
/* read-only */
return BadValue;
- } else if (property == prop_resolution)
- {
+ }
+ else if (property == prop_resolution) {
/* read-only */
return BadValue;
- } else if (property == prop_area)
- {
+ }
+ else if (property == prop_area) {
INT32 *area;
+
if (prop->size != 4 || prop->format != 32 || prop->type != XA_INTEGER)
return BadMatch;
- area = (INT32*)prop->data;
- if ((((area[0] != 0) && (area[1] != 0)) && (area[0] > area[1]) ) || (((area[2] != 0) && (area[3] != 0)) && (area[2] > area[3])))
+ area = (INT32 *) prop->data;
+ if ((((area[0] != 0) && (area[1] != 0)) && (area[0] > area[1])) ||
+ (((area[2] != 0) && (area[3] != 0)) && (area[2] > area[3])))
return BadValue;
- para->area_left_edge = area[0];
- para->area_right_edge = area[1];
- para->area_top_edge = area[2];
+ para->area_left_edge = area[0];
+ para->area_right_edge = area[1];
+ para->area_top_edge = area[2];
para->area_bottom_edge = area[3];
- } else if (property == prop_softbutton_areas)
- {
+ }
+ else if (property == prop_softbutton_areas) {
int *areas;
if (prop->size != 8 || prop->format != 32 || prop->type != XA_INTEGER)
return BadMatch;
- areas = (int*)prop->data;
+ areas = (int *) prop->data;
if (!SynapticsIsSoftButtonAreasValid(areas))
return BadValue;
memcpy(para->softbutton_areas[0], areas, 4 * sizeof(int));
memcpy(para->softbutton_areas[1], areas + 4, 4 * sizeof(int));
- } else if (property == prop_noise_cancellation) {
+ }
+ else if (property == prop_noise_cancellation) {
INT32 *hyst;
+
if (prop->size != 2 || prop->format != 32 || prop->type != XA_INTEGER)
return BadMatch;
- hyst = (INT32*)prop->data;
+ hyst = (INT32 *) prop->data;
if (hyst[0] < 0 || hyst[1] < 0)
return BadValue;
para->hyst_x = hyst[0];
para->hyst_y = hyst[1];
- } else if (property == prop_product_id || property == prop_device_node)
- return BadValue; /* read-only */
+ }
+ else if (property == prop_product_id || property == prop_device_node)
+ return BadValue; /* read-only */
return Success;
}
-
diff --git a/src/ps2comm.c b/src/ps2comm.c
index 5b34414..f88b5cb 100644
--- a/src/ps2comm.c
+++ b/src/ps2comm.c
@@ -43,7 +43,7 @@
#include "ps2comm.h"
#include <xf86.h>
-#define MAX_UNSYNC_PACKETS 10 /* i.e. 10 to 60 bytes */
+#define MAX_UNSYNC_PACKETS 10 /* i.e. 10 to 60 bytes */
/*
* The x/y limits are taken from the Synaptics TouchPad interfacing Guide,
* section 2.3.2, which says that they should be valid regardless of the
@@ -91,15 +91,15 @@
* Read a byte from the ps/2 port
*/
static Bool
-ps2_getbyte(int fd, byte *b)
+ps2_getbyte(int fd, byte * b)
{
if (xf86WaitForInput(fd, 50000) > 0) {
- if (xf86ReadSerial(fd, b, 1) != 1) {
- PS2DBG(ErrorF("ps2_getbyte: No byte read\n"));
- return FALSE;
- }
- PS2DBG(ErrorF("ps2_getbyte: byte %02X read\n", *b));
- return TRUE;
+ if (xf86ReadSerial(fd, b, 1) != 1) {
+ PS2DBG(ErrorF("ps2_getbyte: No byte read\n"));
+ return FALSE;
+ }
+ PS2DBG(ErrorF("ps2_getbyte: byte %02X read\n", *b));
+ return TRUE;
}
PS2DBG(ErrorF("ps2_getbyte: timeout xf86WaitForInput\n"));
return FALSE;
@@ -114,17 +114,17 @@ ps2_putbyte(int fd, byte b)
byte ack;
if (xf86WriteSerial(fd, &b, 1) != 1) {
- PS2DBG(ErrorF("ps2_putbyte: error xf86WriteSerial\n"));
- return FALSE;
+ PS2DBG(ErrorF("ps2_putbyte: error xf86WriteSerial\n"));
+ return FALSE;
}
PS2DBG(ErrorF("ps2_putbyte: byte %02X send\n", b));
/* wait for an ACK */
if (!ps2_getbyte(fd, &ack)) {
- return FALSE;
+ return FALSE;
}
if (ack != PS2_ACK) {
- PS2DBG(ErrorF("ps2_putbyte: wrong acknowledge 0x%02x\n", ack));
- return FALSE;
+ PS2DBG(ErrorF("ps2_putbyte: wrong acknowledge 0x%02x\n", ack));
+ return FALSE;
}
return TRUE;
}
@@ -142,14 +142,14 @@ ps2_special_cmd(int fd, byte cmd)
/* initialize with 'inert' command */
if (!ps2_putbyte(fd, PS2_CMD_SET_SCALING_1_1))
- return FALSE;
+ return FALSE;
/* send 4x 2-bits with set resolution command */
for (i = 0; i < 4; i++) {
- if (!ps2_putbyte(fd, PS2_CMD_SET_RESOLUTION) ||
- !ps2_putbyte(fd, (cmd >> 6) & 0x3))
- return FALSE;
- cmd <<= 2;
+ if (!ps2_putbyte(fd, PS2_CMD_SET_RESOLUTION) ||
+ !ps2_putbyte(fd, (cmd >> 6) & 0x3))
+ return FALSE;
+ cmd <<= 2;
}
return TRUE;
}
@@ -161,8 +161,7 @@ static Bool
ps2_send_cmd(int fd, byte c)
{
PS2DBG(ErrorF("send command: 0x%02X\n", c));
- return (ps2_special_cmd(fd, c) &&
- ps2_putbyte(fd, PS2_CMD_STATUS_REQUEST));
+ return (ps2_special_cmd(fd, c) && ps2_putbyte(fd, PS2_CMD_STATUS_REQUEST));
}
/*****************************************************************************
@@ -177,8 +176,7 @@ ps2_synaptics_set_mode(int fd, byte mode)
{
PS2DBG(ErrorF("set mode byte to: 0x%02X\n", mode));
return (ps2_special_cmd(fd, mode) &&
- ps2_putbyte(fd, PS2_CMD_SET_SAMPLE_RATE) &&
- ps2_putbyte(fd, 0x14));
+ ps2_putbyte(fd, PS2_CMD_SET_SAMPLE_RATE) && ps2_putbyte(fd, 0x14));
}
/*
@@ -192,18 +190,20 @@ ps2_synaptics_reset(int fd)
xf86FlushInput(fd);
PS2DBG(ErrorF("Reset the Touchpad...\n"));
if (!ps2_putbyte(fd, PS2_CMD_RESET)) {
- PS2DBG(ErrorF("...failed\n"));
- return FALSE;
+ PS2DBG(ErrorF("...failed\n"));
+ return FALSE;
}
xf86WaitForInput(fd, 4000000);
if (ps2_getbyte(fd, &r[0]) && ps2_getbyte(fd, &r[1])) {
- if (r[0] == 0xAA && r[1] == 0x00) {
- PS2DBG(ErrorF("...done\n"));
- return TRUE;
- } else {
- PS2DBG(ErrorF("...failed. Wrong reset ack 0x%02x, 0x%02x\n", r[0], r[1]));
- return FALSE;
- }
+ if (r[0] == 0xAA && r[1] == 0x00) {
+ PS2DBG(ErrorF("...done\n"));
+ return TRUE;
+ }
+ else {
+ PS2DBG(ErrorF
+ ("...failed. Wrong reset ack 0x%02x, 0x%02x\n", r[0], r[1]));
+ return FALSE;
+ }
}
PS2DBG(ErrorF("...failed\n"));
return FALSE;
@@ -222,13 +222,12 @@ ps2_synaptics_model_id(int fd, struct PS2SynapticsHwInfo *synhw)
synhw->model_id = 0;
if (ps2_send_cmd(fd, SYN_QUE_MODEL) &&
- ps2_getbyte(fd, &mi[0]) &&
- ps2_getbyte(fd, &mi[1]) &&
- ps2_getbyte(fd, &mi[2])) {
- synhw->model_id = (mi[0] << 16) | (mi[1] << 8) | mi[2];
- PS2DBG(ErrorF("model-id %06X\n", synhw->model_id));
- PS2DBG(ErrorF("...done.\n"));
- return TRUE;
+ ps2_getbyte(fd, &mi[0]) &&
+ ps2_getbyte(fd, &mi[1]) && ps2_getbyte(fd, &mi[2])) {
+ synhw->model_id = (mi[0] << 16) | (mi[1] << 8) | mi[2];
+ PS2DBG(ErrorF("model-id %06X\n", synhw->model_id));
+ PS2DBG(ErrorF("...done.\n"));
+ return TRUE;
}
PS2DBG(ErrorF("...failed.\n"));
return FALSE;
@@ -248,27 +247,27 @@ ps2_synaptics_capability(int fd, struct PS2SynapticsHwInfo *synhw)
synhw->capabilities = 0;
synhw->ext_cap = 0;
if (ps2_send_cmd(fd, SYN_QUE_CAPABILITIES) &&
- ps2_getbyte(fd, &cap[0]) &&
- ps2_getbyte(fd, &cap[1]) &&
- ps2_getbyte(fd, &cap[2])) {
- synhw->capabilities = (cap[0] << 16) | (cap[1] << 8) | cap[2];
- PS2DBG(ErrorF("capabilities %06X\n", synhw->capabilities));
- if (SYN_CAP_VALID(synhw)) {
- if (SYN_EXT_CAP_REQUESTS(synhw)) {
- if (ps2_send_cmd(fd, SYN_QUE_EXT_CAPAB) &&
- ps2_getbyte(fd, &cap[0]) &&
- ps2_getbyte(fd, &cap[1]) &&
- ps2_getbyte(fd, &cap[2])) {
- synhw->ext_cap = (cap[0] << 16) | (cap[1] << 8) | cap[2];
- PS2DBG(ErrorF("ext-capability %06X\n", synhw->ext_cap));
- } else {
- PS2DBG(ErrorF("synaptics says, that it has extended-capabilities, "
- "but I cannot read them."));
- }
- }
- PS2DBG(ErrorF("...done.\n"));
- return TRUE;
- }
+ ps2_getbyte(fd, &cap[0]) &&
+ ps2_getbyte(fd, &cap[1]) && ps2_getbyte(fd, &cap[2])) {
+ synhw->capabilities = (cap[0] << 16) | (cap[1] << 8) | cap[2];
+ PS2DBG(ErrorF("capabilities %06X\n", synhw->capabilities));
+ if (SYN_CAP_VALID(synhw)) {
+ if (SYN_EXT_CAP_REQUESTS(synhw)) {
+ if (ps2_send_cmd(fd, SYN_QUE_EXT_CAPAB) &&
+ ps2_getbyte(fd, &cap[0]) &&
+ ps2_getbyte(fd, &cap[1]) && ps2_getbyte(fd, &cap[2])) {
+ synhw->ext_cap = (cap[0] << 16) | (cap[1] << 8) | cap[2];
+ PS2DBG(ErrorF("ext-capability %06X\n", synhw->ext_cap));
+ }
+ else {
+ PS2DBG(ErrorF
+ ("synaptics says, that it has extended-capabilities, "
+ "but I cannot read them."));
+ }
+ }
+ PS2DBG(ErrorF("...done.\n"));
+ return TRUE;
+ }
}
PS2DBG(ErrorF("...failed.\n"));
return FALSE;
@@ -287,15 +286,14 @@ ps2_synaptics_identify(int fd, struct PS2SynapticsHwInfo *synhw)
synhw->identity = 0;
if (ps2_send_cmd(fd, SYN_QUE_IDENTIFY) &&
- ps2_getbyte(fd, &id[0]) &&
- ps2_getbyte(fd, &id[1]) &&
- ps2_getbyte(fd, &id[2])) {
- synhw->identity = (id[0] << 16) | (id[1] << 8) | id[2];
- PS2DBG(ErrorF("ident %06X\n", synhw->identity));
- if (SYN_ID_IS_SYNAPTICS(synhw)) {
- PS2DBG(ErrorF("...done.\n"));
- return TRUE;
- }
+ ps2_getbyte(fd, &id[0]) &&
+ ps2_getbyte(fd, &id[1]) && ps2_getbyte(fd, &id[2])) {
+ synhw->identity = (id[0] << 16) | (id[1] << 8) | id[2];
+ PS2DBG(ErrorF("ident %06X\n", synhw->identity));
+ if (SYN_ID_IS_SYNAPTICS(synhw)) {
+ PS2DBG(ErrorF("...done.\n"));
+ return TRUE;
+ }
}
PS2DBG(ErrorF("...failed.\n"));
return FALSE;
@@ -315,57 +313,63 @@ ps2_synaptics_disable_device(int fd)
}
static Bool
-ps2_query_is_synaptics(InputInfoPtr pInfo, int fd, struct PS2SynapticsHwInfo* synhw)
+ps2_query_is_synaptics(InputInfoPtr pInfo, int fd,
+ struct PS2SynapticsHwInfo *synhw)
{
int i;
for (i = 0; i < 3; i++) {
- if (ps2_synaptics_disable_device(fd))
- break;
+ if (ps2_synaptics_disable_device(fd))
+ break;
}
xf86WaitForInput(fd, 20000);
xf86FlushInput(fd);
if (ps2_synaptics_identify(fd, synhw)) {
- return TRUE;
- } else {
- xf86IDrvMsg(pInfo, X_ERROR, "Query no Synaptics: %06X\n", synhw->identity);
- return FALSE;
+ return TRUE;
+ }
+ else {
+ xf86IDrvMsg(pInfo, X_ERROR, "Query no Synaptics: %06X\n",
+ synhw->identity);
+ return FALSE;
}
}
void
ps2_print_ident(InputInfoPtr pInfo, const struct PS2SynapticsHwInfo *synhw)
{
- xf86IDrvMsg(pInfo, X_PROBED, " Synaptics Touchpad, model: %d\n", SYN_ID_MODEL(synhw));
+ xf86IDrvMsg(pInfo, X_PROBED, " Synaptics Touchpad, model: %d\n",
+ SYN_ID_MODEL(synhw));
xf86IDrvMsg(pInfo, X_PROBED, " Firmware: %d.%d\n", SYN_ID_MAJOR(synhw),
- SYN_ID_MINOR(synhw));
+ SYN_ID_MINOR(synhw));
if (SYN_MODEL_ROT180(synhw))
- xf86IDrvMsg(pInfo, X_PROBED, " 180 degree mounted touchpad\n");
+ xf86IDrvMsg(pInfo, X_PROBED, " 180 degree mounted touchpad\n");
if (SYN_MODEL_PORTRAIT(synhw))
- xf86IDrvMsg(pInfo, X_PROBED, " portrait touchpad\n");
+ xf86IDrvMsg(pInfo, X_PROBED, " portrait touchpad\n");
xf86IDrvMsg(pInfo, X_PROBED, " Sensor: %d\n", SYN_MODEL_SENSOR(synhw));
if (SYN_MODEL_NEWABS(synhw))
- xf86IDrvMsg(pInfo, X_PROBED, " new absolute packet format\n");
+ xf86IDrvMsg(pInfo, X_PROBED, " new absolute packet format\n");
if (SYN_MODEL_PEN(synhw))
- xf86IDrvMsg(pInfo, X_PROBED, " pen detection\n");
+ xf86IDrvMsg(pInfo, X_PROBED, " pen detection\n");
if (SYN_CAP_EXTENDED(synhw)) {
- xf86IDrvMsg(pInfo, X_PROBED, " Touchpad has extended capability bits\n");
- if (SYN_CAP_MULTI_BUTTON_NO(synhw))
- xf86IDrvMsg(pInfo, X_PROBED, " -> %d multi buttons, i.e. besides standard buttons\n",
- (int)(SYN_CAP_MULTI_BUTTON_NO(synhw)));
- if (SYN_CAP_MIDDLE_BUTTON(synhw))
- xf86IDrvMsg(pInfo, X_PROBED, " -> middle button\n");
- if (SYN_CAP_FOUR_BUTTON(synhw))
- xf86IDrvMsg(pInfo, X_PROBED, " -> four buttons\n");
- if (SYN_CAP_MULTIFINGER(synhw))
- xf86IDrvMsg(pInfo, X_PROBED, " -> multifinger detection\n");
- if (SYN_CAP_PALMDETECT(synhw))
- xf86IDrvMsg(pInfo, X_PROBED, " -> palm detection\n");
- if (SYN_CAP_PASSTHROUGH(synhw))
- xf86IDrvMsg(pInfo, X_PROBED, " -> pass-through port\n");
+ xf86IDrvMsg(pInfo, X_PROBED,
+ " Touchpad has extended capability bits\n");
+ if (SYN_CAP_MULTI_BUTTON_NO(synhw))
+ xf86IDrvMsg(pInfo, X_PROBED,
+ " -> %d multi buttons, i.e. besides standard buttons\n",
+ (int) (SYN_CAP_MULTI_BUTTON_NO(synhw)));
+ if (SYN_CAP_MIDDLE_BUTTON(synhw))
+ xf86IDrvMsg(pInfo, X_PROBED, " -> middle button\n");
+ if (SYN_CAP_FOUR_BUTTON(synhw))
+ xf86IDrvMsg(pInfo, X_PROBED, " -> four buttons\n");
+ if (SYN_CAP_MULTIFINGER(synhw))
+ xf86IDrvMsg(pInfo, X_PROBED, " -> multifinger detection\n");
+ if (SYN_CAP_PALMDETECT(synhw))
+ xf86IDrvMsg(pInfo, X_PROBED, " -> palm detection\n");
+ if (SYN_CAP_PASSTHROUGH(synhw))
+ xf86IDrvMsg(pInfo, X_PROBED, " -> pass-through port\n");
}
}
@@ -382,38 +386,38 @@ static Bool
PS2QueryHardware(InputInfoPtr pInfo)
{
int mode;
- SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
+ SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
struct PS2SynapticsHwInfo *synhw;
if (!priv->proto_data)
priv->proto_data = calloc(1, sizeof(struct PS2SynapticsHwInfo));
- synhw = (struct PS2SynapticsHwInfo*)priv->proto_data;
+ synhw = (struct PS2SynapticsHwInfo *) priv->proto_data;
/* is the synaptics touchpad active? */
if (!ps2_query_is_synaptics(pInfo, pInfo->fd, synhw))
- return FALSE;
+ return FALSE;
xf86IDrvMsg(pInfo, X_PROBED, "synaptics touchpad found\n");
if (!ps2_synaptics_reset(pInfo->fd))
- xf86IDrvMsg(pInfo, X_ERROR, "reset failed\n");
+ xf86IDrvMsg(pInfo, X_ERROR, "reset failed\n");
if (!ps2_synaptics_identify(pInfo->fd, synhw))
- return FALSE;
+ return FALSE;
if (!ps2_synaptics_model_id(pInfo->fd, synhw))
- return FALSE;
+ return FALSE;
if (!ps2_synaptics_capability(pInfo->fd, synhw))
- return FALSE;
+ return FALSE;
mode = SYN_BIT_ABSOLUTE_MODE | SYN_BIT_HIGH_RATE;
if (SYN_ID_MAJOR(synhw) >= 4)
- mode |= SYN_BIT_DISABLE_GESTURE;
+ mode |= SYN_BIT_DISABLE_GESTURE;
if (SYN_CAP_EXTENDED(synhw))
- mode |= SYN_BIT_W_MODE;
+ mode |= SYN_BIT_W_MODE;
if (!ps2_synaptics_set_mode(pInfo->fd, mode))
- return FALSE;
+ return FALSE;
ps2_synaptics_enable_device(pInfo->fd);
@@ -432,23 +436,23 @@ ps2_packet_ok(struct PS2SynapticsHwInfo *synhw, struct CommData *comm)
int newabs = SYN_MODEL_NEWABS(synhw);
if (newabs ? ((buf[0] & 0xC0) != 0x80) : ((buf[0] & 0xC0) != 0xC0)) {
- DBG(4, "Synaptics driver lost sync at 1st byte\n");
- return FALSE;
+ DBG(4, "Synaptics driver lost sync at 1st byte\n");
+ return FALSE;
}
if (!newabs && ((buf[1] & 0x60) != 0x00)) {
- DBG(4, "Synaptics driver lost sync at 2nd byte\n");
- return FALSE;
+ DBG(4, "Synaptics driver lost sync at 2nd byte\n");
+ return FALSE;
}
if ((newabs ? ((buf[3] & 0xC0) != 0xC0) : ((buf[3] & 0xC0) != 0x80))) {
- DBG(4, "Synaptics driver lost sync at 4th byte\n");
- return FALSE;
+ DBG(4, "Synaptics driver lost sync at 4th byte\n");
+ return FALSE;
}
if (!newabs && ((buf[4] & 0x60) != 0x00)) {
- DBG(4, "Synaptics driver lost sync at 5th byte\n");
- return FALSE;
+ DBG(4, "Synaptics driver lost sync at 5th byte\n");
+ return FALSE;
}
return TRUE;
@@ -456,60 +460,64 @@ ps2_packet_ok(struct PS2SynapticsHwInfo *synhw, struct CommData *comm)
static Bool
ps2_synaptics_get_packet(InputInfoPtr pInfo, struct PS2SynapticsHwInfo *synhw,
- struct SynapticsProtocolOperations *proto_ops,
- struct CommData *comm)
+ struct SynapticsProtocolOperations *proto_ops,
+ struct CommData *comm)
{
int count = 0;
int c;
unsigned char u;
while ((c = XisbRead(comm->buffer)) >= 0) {
- u = (unsigned char)c;
-
- /* test if there is a reset sequence received */
- if ((c == 0x00) && (comm->lastByte == 0xAA)) {
- if (xf86WaitForInput(pInfo->fd, 50000) == 0) {
- DBG(7, "Reset received\n");
- proto_ops->QueryHardware(pInfo);
- } else
- DBG(3, "faked reset received\n");
- }
- comm->lastByte = u;
-
- /* to avoid endless loops */
- if (count++ > 30) {
- xf86IDrvMsg(pInfo, X_ERROR, "Synaptics driver lost sync... got gigantic packet!\n");
- return FALSE;
- }
-
- comm->protoBuf[comm->protoBufTail++] = u;
-
- /* Check that we have a valid packet. If not, we are out of sync,
- so we throw away the first byte in the packet.*/
- if (comm->protoBufTail >= 6) {
- if (!ps2_packet_ok(synhw, comm)) {
- int i;
- for (i = 0; i < comm->protoBufTail - 1; i++)
- comm->protoBuf[i] = comm->protoBuf[i + 1];
- comm->protoBufTail--;
- comm->outOfSync++;
- if (comm->outOfSync > MAX_UNSYNC_PACKETS) {
- comm->outOfSync = 0;
- DBG(3, "Synaptics synchronization lost too long -> reset touchpad.\n");
- proto_ops->QueryHardware(pInfo); /* including a reset */
- continue;
- }
- }
- }
-
- if (comm->protoBufTail >= 6) { /* Full packet received */
- if (comm->outOfSync > 0) {
- comm->outOfSync = 0;
- DBG(4, "Synaptics driver resynced.\n");
- }
- comm->protoBufTail = 0;
- return TRUE;
- }
+ u = (unsigned char) c;
+
+ /* test if there is a reset sequence received */
+ if ((c == 0x00) && (comm->lastByte == 0xAA)) {
+ if (xf86WaitForInput(pInfo->fd, 50000) == 0) {
+ DBG(7, "Reset received\n");
+ proto_ops->QueryHardware(pInfo);
+ }
+ else
+ DBG(3, "faked reset received\n");
+ }
+ comm->lastByte = u;
+
+ /* to avoid endless loops */
+ if (count++ > 30) {
+ xf86IDrvMsg(pInfo, X_ERROR,
+ "Synaptics driver lost sync... got gigantic packet!\n");
+ return FALSE;
+ }
+
+ comm->protoBuf[comm->protoBufTail++] = u;
+
+ /* Check that we have a valid packet. If not, we are out of sync,
+ so we throw away the first byte in the packet. */
+ if (comm->protoBufTail >= 6) {
+ if (!ps2_packet_ok(synhw, comm)) {
+ int i;
+
+ for (i = 0; i < comm->protoBufTail - 1; i++)
+ comm->protoBuf[i] = comm->protoBuf[i + 1];
+ comm->protoBufTail--;
+ comm->outOfSync++;
+ if (comm->outOfSync > MAX_UNSYNC_PACKETS) {
+ comm->outOfSync = 0;
+ DBG(3,
+ "Synaptics synchronization lost too long -> reset touchpad.\n");
+ proto_ops->QueryHardware(pInfo); /* including a reset */
+ continue;
+ }
+ }
+ }
+
+ if (comm->protoBufTail >= 6) { /* Full packet received */
+ if (comm->outOfSync > 0) {
+ comm->outOfSync = 0;
+ DBG(4, "Synaptics driver resynced.\n");
+ }
+ comm->protoBufTail = 0;
+ return TRUE;
+ }
}
return FALSE;
@@ -517,20 +525,19 @@ ps2_synaptics_get_packet(InputInfoPtr pInfo, struct PS2SynapticsHwInfo *synhw,
Bool
PS2ReadHwStateProto(InputInfoPtr pInfo,
- struct SynapticsProtocolOperations *proto_ops,
- struct CommData *comm, struct SynapticsHwState *hwRet)
+ struct SynapticsProtocolOperations *proto_ops,
+ struct CommData *comm, struct SynapticsHwState *hwRet)
{
unsigned char *buf = comm->protoBuf;
struct SynapticsHwState *hw = comm->hwState;
- SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
+ SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
SynapticsParameters *para = &priv->synpara;
struct PS2SynapticsHwInfo *synhw;
int newabs;
int w, i;
- synhw = (struct PS2SynapticsHwInfo*)priv->proto_data;
- if (!synhw)
- {
+ synhw = (struct PS2SynapticsHwInfo *) priv->proto_data;
+ if (!synhw) {
xf86IDrvMsg(pInfo, X_ERROR,
"PS2ReadHwState, synhw is NULL. This is a bug.\n");
return FALSE;
@@ -539,115 +546,110 @@ PS2ReadHwStateProto(InputInfoPtr pInfo,
newabs = SYN_MODEL_NEWABS(synhw);
if (!ps2_synaptics_get_packet(pInfo, synhw, proto_ops, comm))
- return FALSE;
+ return FALSE;
/* Handle normal packets */
hw->x = hw->y = hw->z = hw->numFingers = hw->fingerWidth = 0;
hw->left = hw->right = hw->up = hw->down = hw->middle = FALSE;
for (i = 0; i < 8; i++)
- hw->multi[i] = FALSE;
-
- if (newabs) { /* newer protos...*/
- DBG(7, "using new protocols\n");
- hw->x = (((buf[3] & 0x10) << 8) |
- ((buf[1] & 0x0f) << 8) |
- buf[4]);
- hw->y = (((buf[3] & 0x20) << 7) |
- ((buf[1] & 0xf0) << 4) |
- buf[5]);
-
- hw->z = buf[2];
- w = (((buf[0] & 0x30) >> 2) |
- ((buf[0] & 0x04) >> 1) |
- ((buf[3] & 0x04) >> 2));
-
- hw->left = (buf[0] & 0x01) ? 1 : 0;
- hw->right = (buf[0] & 0x02) ? 1 : 0;
-
- if (SYN_CAP_EXTENDED(synhw)) {
- if (SYN_CAP_MIDDLE_BUTTON(synhw)) {
- hw->middle = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
- }
- if (SYN_CAP_FOUR_BUTTON(synhw)) {
- hw->up = ((buf[3] & 0x01)) ? 1 : 0;
- if (hw->left)
- hw->up = !hw->up;
- hw->down = ((buf[3] & 0x02)) ? 1 : 0;
- if (hw->right)
- hw->down = !hw->down;
- }
- if (SYN_CAP_MULTI_BUTTON_NO(synhw)) {
- if ((buf[3] & 2) ? !hw->right : hw->right) {
- switch (SYN_CAP_MULTI_BUTTON_NO(synhw) & ~0x01) {
- default:
- break;
- case 8:
- hw->multi[7] = ((buf[5] & 0x08)) ? 1 : 0;
- hw->multi[6] = ((buf[4] & 0x08)) ? 1 : 0;
- case 6:
- hw->multi[5] = ((buf[5] & 0x04)) ? 1 : 0;
- hw->multi[4] = ((buf[4] & 0x04)) ? 1 : 0;
- case 4:
- hw->multi[3] = ((buf[5] & 0x02)) ? 1 : 0;
- hw->multi[2] = ((buf[4] & 0x02)) ? 1 : 0;
- case 2:
- hw->multi[1] = ((buf[5] & 0x01)) ? 1 : 0;
- hw->multi[0] = ((buf[4] & 0x01)) ? 1 : 0;
- }
- }
- }
- }
- } else { /* old proto...*/
- DBG(7, "using old protocol\n");
- hw->x = (((buf[1] & 0x1F) << 8) |
- buf[2]);
- hw->y = (((buf[4] & 0x1F) << 8) |
- buf[5]);
-
- hw->z = (((buf[0] & 0x30) << 2) |
- (buf[3] & 0x3F));
- w = (((buf[1] & 0x80) >> 4) |
- ((buf[0] & 0x04) >> 1));
-
- hw->left = (buf[0] & 0x01) ? 1 : 0;
- hw->right = (buf[0] & 0x02) ? 1 : 0;
+ hw->multi[i] = FALSE;
+
+ if (newabs) { /* newer protos... */
+ DBG(7, "using new protocols\n");
+ hw->x = (((buf[3] & 0x10) << 8) | ((buf[1] & 0x0f) << 8) | buf[4]);
+ hw->y = (((buf[3] & 0x20) << 7) | ((buf[1] & 0xf0) << 4) | buf[5]);
+
+ hw->z = buf[2];
+ w = (((buf[0] & 0x30) >> 2) |
+ ((buf[0] & 0x04) >> 1) | ((buf[3] & 0x04) >> 2));
+
+ hw->left = (buf[0] & 0x01) ? 1 : 0;
+ hw->right = (buf[0] & 0x02) ? 1 : 0;
+
+ if (SYN_CAP_EXTENDED(synhw)) {
+ if (SYN_CAP_MIDDLE_BUTTON(synhw)) {
+ hw->middle = ((buf[0] ^ buf[3]) & 0x01) ? 1 : 0;
+ }
+ if (SYN_CAP_FOUR_BUTTON(synhw)) {
+ hw->up = ((buf[3] & 0x01)) ? 1 : 0;
+ if (hw->left)
+ hw->up = !hw->up;
+ hw->down = ((buf[3] & 0x02)) ? 1 : 0;
+ if (hw->right)
+ hw->down = !hw->down;
+ }
+ if (SYN_CAP_MULTI_BUTTON_NO(synhw)) {
+ if ((buf[3] & 2) ? !hw->right : hw->right) {
+ switch (SYN_CAP_MULTI_BUTTON_NO(synhw) & ~0x01) {
+ default:
+ break;
+ case 8:
+ hw->multi[7] = ((buf[5] & 0x08)) ? 1 : 0;
+ hw->multi[6] = ((buf[4] & 0x08)) ? 1 : 0;
+ case 6:
+ hw->multi[5] = ((buf[5] & 0x04)) ? 1 : 0;
+ hw->multi[4] = ((buf[4] & 0x04)) ? 1 : 0;
+ case 4:
+ hw->multi[3] = ((buf[5] & 0x02)) ? 1 : 0;
+ hw->multi[2] = ((buf[4] & 0x02)) ? 1 : 0;
+ case 2:
+ hw->multi[1] = ((buf[5] & 0x01)) ? 1 : 0;
+ hw->multi[0] = ((buf[4] & 0x01)) ? 1 : 0;
+ }
+ }
+ }
+ }
+ }
+ else { /* old proto... */
+ DBG(7, "using old protocol\n");
+ hw->x = (((buf[1] & 0x1F) << 8) | buf[2]);
+ hw->y = (((buf[4] & 0x1F) << 8) | buf[5]);
+
+ hw->z = (((buf[0] & 0x30) << 2) | (buf[3] & 0x3F));
+ w = (((buf[1] & 0x80) >> 4) | ((buf[0] & 0x04) >> 1));
+
+ hw->left = (buf[0] & 0x01) ? 1 : 0;
+ hw->right = (buf[0] & 0x02) ? 1 : 0;
}
hw->y = YMAX_NOMINAL + YMIN_NOMINAL - hw->y;
if (hw->z >= para->finger_high) {
- int w_ok = 0;
- /*
- * Use capability bits to decide if the w value is valid.
- * If not, set it to 5, which corresponds to a finger of
- * normal width.
- */
- if (SYN_CAP_EXTENDED(synhw)) {
- if ((w >= 0) && (w <= 1)) {
- w_ok = SYN_CAP_MULTIFINGER(synhw);
- } else if (w == 2) {
- w_ok = SYN_MODEL_PEN(synhw);
- } else if ((w >= 4) && (w <= 15)) {
- w_ok = SYN_CAP_PALMDETECT(synhw);
- }
- }
- if (!w_ok)
- w = 5;
-
- switch (w) {
- case 0:
- hw->numFingers = 2;
- hw->fingerWidth = 5;
- break;
- case 1:
- hw->numFingers = 3;
- hw->fingerWidth = 5;
- break;
- default:
- hw->numFingers = 1;
- hw->fingerWidth = w;
- break;
- }
+ int w_ok = 0;
+
+ /*
+ * Use capability bits to decide if the w value is valid.
+ * If not, set it to 5, which corresponds to a finger of
+ * normal width.
+ */
+ if (SYN_CAP_EXTENDED(synhw)) {
+ if ((w >= 0) && (w <= 1)) {
+ w_ok = SYN_CAP_MULTIFINGER(synhw);
+ }
+ else if (w == 2) {
+ w_ok = SYN_MODEL_PEN(synhw);
+ }
+ else if ((w >= 4) && (w <= 15)) {
+ w_ok = SYN_CAP_PALMDETECT(synhw);
+ }
+ }
+ if (!w_ok)
+ w = 5;
+
+ switch (w) {
+ case 0:
+ hw->numFingers = 2;
+ hw->fingerWidth = 5;
+ break;
+ case 1:
+ hw->numFingers = 3;
+ hw->fingerWidth = 5;
+ break;
+ default:
+ hw->numFingers = 1;
+ hw->fingerWidth = w;
+ break;
+ }
}
hw->millis = GetTimeInMillis();
SynapticsCopyHwState(hwRet, hw);
diff --git a/src/ps2comm.h b/src/ps2comm.h
index 1b303ca..6f1a96a 100644
--- a/src/ps2comm.h
+++ b/src/ps2comm.h
@@ -95,16 +95,17 @@
typedef unsigned char byte;
struct PS2SynapticsHwInfo {
- unsigned int model_id; /* Model-ID */
- unsigned int capabilities; /* Capabilities */
- unsigned int ext_cap; /* Extended Capabilities */
- unsigned int identity; /* Identification */
+ unsigned int model_id; /* Model-ID */
+ unsigned int capabilities; /* Capabilities */
+ unsigned int ext_cap; /* Extended Capabilities */
+ unsigned int identity; /* Identification */
};
Bool ps2_putbyte(int fd, byte b);
-void ps2_print_ident(InputInfoPtr pInfo, const struct PS2SynapticsHwInfo *synhw);
+void ps2_print_ident(InputInfoPtr pInfo,
+ const struct PS2SynapticsHwInfo *synhw);
Bool PS2ReadHwStateProto(InputInfoPtr pInfo,
- struct SynapticsProtocolOperations *proto_ops,
- struct CommData *comm, struct SynapticsHwState *hwRet);
+ struct SynapticsProtocolOperations *proto_ops,
+ struct CommData *comm, struct SynapticsHwState *hwRet);
-#endif /* _PS2COMM_H_ */
+#endif /* _PS2COMM_H_ */
diff --git a/src/psmcomm.c b/src/psmcomm.c
index 37a6f5e..478202a 100644
--- a/src/psmcomm.c
+++ b/src/psmcomm.c
@@ -47,7 +47,7 @@
#include "synproto.h"
#include "synaptics.h"
#include "synapticsstr.h"
-#include "ps2comm.h" /* ps2_print_ident() */
+#include "ps2comm.h" /* ps2_print_ident() */
#include <xf86.h>
#define SYSCALL(call) while (((call) == -1) && (errno == EINTR))
@@ -57,15 +57,15 @@
* See also the SYN_ID_* macros
*/
static Bool
-psm_synaptics_identify(int fd, synapticshw_t *ident)
+psm_synaptics_identify(int fd, synapticshw_t * ident)
{
int ret;
SYSCALL(ret = ioctl(fd, MOUSE_SYN_GETHWINFO, ident));
if (ret == 0)
- return TRUE;
+ return TRUE;
else
- return FALSE;
+ return FALSE;
}
/* This define is used in a ioctl but not in mouse.h :/ */
@@ -84,46 +84,49 @@ PSMQueryIsSynaptics(InputInfoPtr pInfo)
*/
SYSCALL(ret = ioctl(pInfo->fd, MOUSE_SETLEVEL, &level));
if (ret != 0) {
- xf86IDrvMsg(pInfo, X_ERROR, "%s Can't set native mode\n", pInfo->name);
- return FALSE;
+ xf86IDrvMsg(pInfo, X_ERROR, "%s Can't set native mode\n", pInfo->name);
+ return FALSE;
}
SYSCALL(ret = ioctl(pInfo->fd, MOUSE_GETHWINFO, &mhw));
if (ret != 0) {
- xf86IDrvMsg(pInfo, X_ERROR, "%s Can't get hardware info\n", pInfo->name);
- return FALSE;
+ xf86IDrvMsg(pInfo, X_ERROR, "%s Can't get hardware info\n",
+ pInfo->name);
+ return FALSE;
}
if (mhw.model == MOUSE_MODEL_SYNAPTICS) {
- return TRUE;
- } else {
- xf86IDrvMsg(pInfo, X_ERROR, "%s Found no Synaptics, found Mouse model %d instead\n",
- pInfo->name, mhw.model);
- return FALSE;
+ return TRUE;
+ }
+ else {
+ xf86IDrvMsg(pInfo, X_ERROR,
+ "%s Found no Synaptics, found Mouse model %d instead\n",
+ pInfo->name, mhw.model);
+ return FALSE;
}
}
static void
-convert_hw_info(const synapticshw_t *psm_ident, struct PS2SynapticsHwInfo *synhw)
+convert_hw_info(const synapticshw_t * psm_ident,
+ struct PS2SynapticsHwInfo *synhw)
{
memset(synhw, 0, sizeof(*synhw));
synhw->model_id = ((psm_ident->infoRot180 << 23) |
- (psm_ident->infoPortrait << 22) |
- (psm_ident->infoSensor << 16) |
- (psm_ident->infoHardware << 9) |
- (psm_ident->infoNewAbs << 7) |
- (psm_ident->capPen << 6) |
- (psm_ident->infoSimplC << 5) |
- (psm_ident->infoGeometry));
+ (psm_ident->infoPortrait << 22) |
+ (psm_ident->infoSensor << 16) |
+ (psm_ident->infoHardware << 9) |
+ (psm_ident->infoNewAbs << 7) |
+ (psm_ident->capPen << 6) |
+ (psm_ident->infoSimplC << 5) |
+ (psm_ident->infoGeometry));
synhw->capabilities = ((psm_ident->capExtended << 23) |
- (psm_ident->capPassthrough << 7) |
- (psm_ident->capSleep << 4) |
- (psm_ident->capFourButtons << 3) |
- (psm_ident->capMultiFinger << 1) |
- (psm_ident->capPalmDetect));
+ (psm_ident->capPassthrough << 7) |
+ (psm_ident->capSleep << 4) |
+ (psm_ident->capFourButtons << 3) |
+ (psm_ident->capMultiFinger << 1) |
+ (psm_ident->capPalmDetect));
synhw->ext_cap = 0;
synhw->identity = ((psm_ident->infoMajor) |
- (0x47 << 8) |
- (psm_ident->infoMinor << 16));
+ (0x47 << 8) | (psm_ident->infoMinor << 16));
}
static Bool
@@ -133,20 +136,20 @@ PSMQueryHardware(InputInfoPtr pInfo)
struct PS2SynapticsHwInfo *synhw;
SynapticsPrivate *priv;
- priv = (SynapticsPrivate *)pInfo->private;
+ priv = (SynapticsPrivate *) pInfo->private;
- if(!priv->proto_data)
+ if (!priv->proto_data)
priv->proto_data = calloc(1, sizeof(struct PS2SynapticsHwInfo));
- synhw = (struct PS2SynapticsHwInfo*)priv->proto_data;
+ synhw = (struct PS2SynapticsHwInfo *) priv->proto_data;
/* is the synaptics touchpad active? */
if (!PSMQueryIsSynaptics(pInfo))
- return FALSE;
+ return FALSE;
xf86IDrvMsg(pInfo, X_PROBED, "synaptics touchpad found\n");
if (!psm_synaptics_identify(pInfo->fd, &psm_ident))
- return FALSE;
+ return FALSE;
convert_hw_info(&psm_ident, synhw);
@@ -157,7 +160,7 @@ PSMQueryHardware(InputInfoPtr pInfo)
static Bool
PSMReadHwState(InputInfoPtr pInfo,
- struct CommData *comm, struct SynapticsHwState *hwRet)
+ struct CommData *comm, struct SynapticsHwState *hwRet)
{
return PS2ReadHwStateProto(pInfo, &psm_proto_operations, comm, hwRet);
}
diff --git a/src/synaptics.c b/src/synaptics.c
index 77eb5be..809a275 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -55,7 +55,6 @@
* Trademarks are the property of their respective owners.
*/
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -118,7 +117,7 @@ typedef enum {
#endif
#ifndef M_SQRT1_2
-#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
+#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
#endif
#define INPUT_BUFFER_SIZE 200
@@ -129,14 +128,15 @@ typedef enum {
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
static int SynapticsPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags);
#else
-static InputInfoPtr SynapticsPreInit(InputDriverPtr drv, IDevPtr dev, int flags);
+static InputInfoPtr SynapticsPreInit(InputDriverPtr drv, IDevPtr dev,
+ int flags);
#endif
static void SynapticsUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags);
static Bool DeviceControl(DeviceIntPtr, int);
static void ReadInput(InputInfoPtr);
-static int HandleState(InputInfoPtr, struct SynapticsHwState*, CARD32 now,
+static int HandleState(InputInfoPtr, struct SynapticsHwState *, CARD32 now,
Bool from_timer);
-static int ControlProc(InputInfoPtr, xDeviceCtl*);
+static int ControlProc(InputInfoPtr, xDeviceCtl *);
static int SwitchMode(ClientPtr, DeviceIntPtr, int);
static Bool DeviceInit(DeviceIntPtr);
static Bool DeviceOn(DeviceIntPtr);
@@ -144,8 +144,9 @@ static Bool DeviceOff(DeviceIntPtr);
static Bool DeviceClose(DeviceIntPtr);
static Bool QueryHardware(InputInfoPtr);
static void ReadDevDimensions(InputInfoPtr);
-static void ScaleCoordinates(SynapticsPrivate *priv, struct SynapticsHwState *hw);
-static void CalculateScalingCoeffs(SynapticsPrivate *priv);
+static void ScaleCoordinates(SynapticsPrivate * priv,
+ struct SynapticsHwState *hw);
+static void CalculateScalingCoeffs(SynapticsPrivate * priv);
static void SanitizeDimensions(InputInfoPtr pInfo);
void InitDeviceProperties(InputInfoPtr pInfo);
@@ -157,16 +158,20 @@ const static struct {
struct SynapticsProtocolOperations *proto_ops;
} protocols[] = {
#ifdef BUILD_EVENTCOMM
- {"event", &event_proto_operations},
+ {
+ "event", &event_proto_operations},
#endif
#ifdef BUILD_PSMCOMM
- {"psm", &psm_proto_operations},
+ {
+ "psm", &psm_proto_operations},
#endif
#ifdef BUILD_PS2COMM
- {"psaux", &psaux_proto_operations},
- {"alps", &alps_proto_operations},
+ {
+ "psaux", &psaux_proto_operations}, {
+ "alps", &alps_proto_operations},
#endif
- {NULL, NULL}
+ {
+ NULL, NULL}
};
InputDriverRec SYNAPTICS = {
@@ -204,7 +209,6 @@ _X_EXPORT XF86ModuleData synapticsModuleData = {
NULL
};
-
/*****************************************************************************
* Function Definitions
****************************************************************************/
@@ -220,48 +224,44 @@ _X_EXPORT XF86ModuleData synapticsModuleData = {
static void
SanitizeDimensions(InputInfoPtr pInfo)
{
- SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
+ SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
- if (priv->minx >= priv->maxx)
- {
- priv->minx = 1615;
- priv->maxx = 5685;
- priv->resx = 0;
+ if (priv->minx >= priv->maxx) {
+ priv->minx = 1615;
+ priv->maxx = 5685;
+ priv->resx = 0;
- xf86IDrvMsg(pInfo, X_PROBED,
- "invalid x-axis range. defaulting to %d - %d\n",
- priv->minx, priv->maxx);
+ xf86IDrvMsg(pInfo, X_PROBED,
+ "invalid x-axis range. defaulting to %d - %d\n",
+ priv->minx, priv->maxx);
}
- if (priv->miny >= priv->maxy)
- {
- priv->miny = 1729;
- priv->maxy = 4171;
- priv->resy = 0;
+ if (priv->miny >= priv->maxy) {
+ priv->miny = 1729;
+ priv->maxy = 4171;
+ priv->resy = 0;
- xf86IDrvMsg(pInfo, X_PROBED,
- "invalid y-axis range. defaulting to %d - %d\n",
- priv->miny, priv->maxy);
+ xf86IDrvMsg(pInfo, X_PROBED,
+ "invalid y-axis range. defaulting to %d - %d\n",
+ priv->miny, priv->maxy);
}
- if (priv->minp >= priv->maxp)
- {
- priv->minp = 0;
- priv->maxp = 255;
+ if (priv->minp >= priv->maxp) {
+ priv->minp = 0;
+ priv->maxp = 255;
- xf86IDrvMsg(pInfo, X_PROBED,
- "invalid pressure range. defaulting to %d - %d\n",
- priv->minp, priv->maxp);
+ xf86IDrvMsg(pInfo, X_PROBED,
+ "invalid pressure range. defaulting to %d - %d\n",
+ priv->minp, priv->maxp);
}
- if (priv->minw >= priv->maxw)
- {
- priv->minw = 0;
- priv->maxw = 15;
+ if (priv->minw >= priv->maxw) {
+ priv->minw = 0;
+ priv->maxw = 15;
- xf86IDrvMsg(pInfo, X_PROBED,
- "invalid finger width range. defaulting to %d - %d\n",
- priv->minw, priv->maxw);
+ xf86IDrvMsg(pInfo, X_PROBED,
+ "invalid finger width range. defaulting to %d - %d\n",
+ priv->minw, priv->maxw);
}
}
@@ -309,24 +309,25 @@ alloc_shm_data(InputInfoPtr pInfo)
SynapticsPrivate *priv = pInfo->private;
if (priv->synshm)
- return TRUE; /* Already allocated */
+ return TRUE; /* Already allocated */
if (priv->shm_config) {
- if ((shmid = shmget(SHM_SYNAPTICS, 0, 0)) != -1)
- shmctl(shmid, IPC_RMID, NULL);
- if ((shmid = shmget(SHM_SYNAPTICS, sizeof(SynapticsSHM),
- 0774 | IPC_CREAT)) == -1) {
- xf86IDrvMsg(pInfo, X_ERROR, "error shmget\n");
- return FALSE;
- }
- if ((priv->synshm = (SynapticsSHM*)shmat(shmid, NULL, 0)) == NULL) {
- xf86IDrvMsg(pInfo, X_ERROR, "error shmat\n");
- return FALSE;
- }
- } else {
- priv->synshm = calloc(1, sizeof(SynapticsSHM));
- if (!priv->synshm)
- return FALSE;
+ if ((shmid = shmget(SHM_SYNAPTICS, 0, 0)) != -1)
+ shmctl(shmid, IPC_RMID, NULL);
+ if ((shmid = shmget(SHM_SYNAPTICS, sizeof(SynapticsSHM),
+ 0774 | IPC_CREAT)) == -1) {
+ xf86IDrvMsg(pInfo, X_ERROR, "error shmget\n");
+ return FALSE;
+ }
+ if ((priv->synshm = (SynapticsSHM *) shmat(shmid, NULL, 0)) == NULL) {
+ xf86IDrvMsg(pInfo, X_ERROR, "error shmat\n");
+ return FALSE;
+ }
+ }
+ else {
+ priv->synshm = calloc(1, sizeof(SynapticsSHM));
+ if (!priv->synshm)
+ return FALSE;
}
return TRUE;
@@ -336,46 +337,46 @@ alloc_shm_data(InputInfoPtr pInfo)
* Free SynapticsParameters data previously allocated by alloc_shm_data().
*/
static void
-free_shm_data(SynapticsPrivate *priv)
+free_shm_data(SynapticsPrivate * priv)
{
int shmid;
if (!priv->synshm)
- return;
+ return;
if (priv->shm_config) {
- if ((shmid = shmget(SHM_SYNAPTICS, 0, 0)) != -1)
- shmctl(shmid, IPC_RMID, NULL);
- } else {
- free(priv->synshm);
+ if ((shmid = shmget(SHM_SYNAPTICS, 0, 0)) != -1)
+ shmctl(shmid, IPC_RMID, NULL);
+ }
+ else {
+ free(priv->synshm);
}
priv->synshm = NULL;
}
static void
-calculate_edge_widths(SynapticsPrivate *priv, int *l, int *r, int *t, int *b)
+calculate_edge_widths(SynapticsPrivate * priv, int *l, int *r, int *t, int *b)
{
int width, height;
- int ewidth, eheight; /* edge width/height */
+ int ewidth, eheight; /* edge width/height */
width = abs(priv->maxx - priv->minx);
height = abs(priv->maxy - priv->miny);
- if (priv->model == MODEL_SYNAPTICS)
- {
+ if (priv->model == MODEL_SYNAPTICS) {
ewidth = width * .07;
eheight = height * .07;
- } else if (priv->model == MODEL_ALPS)
- {
+ }
+ else if (priv->model == MODEL_ALPS) {
ewidth = width * .15;
eheight = height * .15;
- } else if (priv->model == MODEL_APPLETOUCH)
- {
+ }
+ else if (priv->model == MODEL_APPLETOUCH) {
ewidth = width * .085;
eheight = height * .085;
- } else
- {
+ }
+ else {
ewidth = width * .04;
eheight = height * .054;
}
@@ -387,7 +388,7 @@ calculate_edge_widths(SynapticsPrivate *priv, int *l, int *r, int *t, int *b)
}
static void
-calculate_tap_hysteresis(SynapticsPrivate *priv, int range,
+calculate_tap_hysteresis(SynapticsPrivate * priv, int range,
int *fingerLow, int *fingerHigh, int *fingerPress)
{
if (priv->model == MODEL_ELANTECH) {
@@ -395,11 +396,12 @@ calculate_tap_hysteresis(SynapticsPrivate *priv, int range,
* number of fingers correctly. See Documentation/elantech.txt
* in the kernel.
*/
- *fingerLow = priv->minp + 1;
+ *fingerLow = priv->minp + 1;
*fingerHigh = priv->minp + 1;
- } else {
- *fingerLow = priv->minp + range * (25.0/256);
- *fingerHigh = priv->minp + range * (30.0/256);
+ }
+ else {
+ *fingerLow = priv->minp + range * (25.0 / 256);
+ *fingerHigh = priv->minp + range * (30.0 / 256);
}
*fingerPress = priv->minp + range * 1.000;
@@ -411,25 +413,28 @@ calculate_tap_hysteresis(SynapticsPrivate *priv, int range,
* int. So - check first for percent, then call xf86Set* again to get
* the log message.
*/
-static int set_percent_option(pointer options, const char* optname,
- const int range, const int offset,
- const int default_value)
+static int
+set_percent_option(pointer options, const char *optname,
+ const int range, const int offset, const int default_value)
{
int result;
+
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 11
double percent = xf86CheckPercentOption(options, optname, -1);
if (percent >= 0.0) {
percent = xf86SetPercentOption(options, optname, -1);
- result = percent/100.0 * range + offset;
- } else
+ result = percent / 100.0 * range + offset;
+ }
+ else
#endif
result = xf86SetIntOption(options, optname, default_value);
return result;
}
-Bool SynapticsIsSoftButtonAreasValid(int *values)
+Bool
+SynapticsIsSoftButtonAreasValid(int *values)
{
Bool right_disabled = FALSE;
Bool middle_disabled = FALSE;
@@ -451,8 +456,8 @@ Bool SynapticsIsSoftButtonAreasValid(int *values)
middle_disabled = TRUE;
if (!right_disabled &&
- ((values[0] && values[0] == values[1]) ||
- (values[2] && values[2] == values[3])))
+ ((values[0] && values[0] == values[1]) ||
+ (values[2] && values[2] == values[3])))
return FALSE;
if (!middle_disabled &&
@@ -461,8 +466,7 @@ Bool SynapticsIsSoftButtonAreasValid(int *values)
return FALSE;
/* Check for overlapping button areas */
- if (!right_disabled && !middle_disabled)
- {
+ if (!right_disabled && !middle_disabled) {
int right_left = values[0] ? values[0] : INT_MIN;
int right_right = values[1] ? values[1] : INT_MAX;
int right_top = values[2] ? values[2] : INT_MIN;
@@ -474,8 +478,7 @@ Bool SynapticsIsSoftButtonAreasValid(int *values)
/* If areas overlap in the Y axis */
if ((right_bottom <= middle_bottom && right_bottom >= middle_top) ||
- (right_top <= middle_bottom && right_top >= middle_top))
- {
+ (right_top <= middle_bottom && right_top >= middle_top)) {
/* Check for overlapping left edges */
if ((right_left < middle_left && right_right >= middle_left) ||
(middle_left < right_left && middle_right >= right_left))
@@ -489,8 +492,7 @@ Bool SynapticsIsSoftButtonAreasValid(int *values)
/* If areas overlap in the X axis */
if ((right_left >= middle_left && right_left <= middle_right) ||
- (right_right >= middle_left && right_right <= middle_right))
- {
+ (right_right >= middle_left && right_right <= middle_right)) {
/* Check for overlapping top edges */
if ((right_top < middle_top && right_bottom >= middle_top) ||
(middle_top < right_top && middle_bottom >= right_top))
@@ -506,12 +508,13 @@ Bool SynapticsIsSoftButtonAreasValid(int *values)
return TRUE;
}
-static void set_softbutton_areas_option(InputInfoPtr pInfo)
+static void
+set_softbutton_areas_option(InputInfoPtr pInfo)
{
SynapticsPrivate *priv = pInfo->private;
SynapticsParameters *pars = &priv->synpara;
int values[8];
- int in_percent = 0; /* bitmask for which ones are in % */
+ int in_percent = 0; /* bitmask for which ones are in % */
char *option_string;
char *next_num;
char *end_str;
@@ -527,23 +530,22 @@ static void set_softbutton_areas_option(InputInfoPtr pInfo)
next_num = option_string;
- for (i = 0; i < 8 && *next_num != '\0'; i++)
- {
+ for (i = 0; i < 8 && *next_num != '\0'; i++) {
long int value = strtol(next_num, &end_str, 0);
+
if (value > INT_MAX || value < -INT_MAX)
goto fail;
values[i] = value;
- if (next_num != end_str)
- {
- if (end_str && *end_str == '%')
- {
+ if (next_num != end_str) {
+ if (end_str && *end_str == '%') {
in_percent |= 1 << i;
end_str++;
}
next_num = end_str;
- } else
+ }
+ else
goto fail;
}
@@ -553,8 +555,7 @@ static void set_softbutton_areas_option(InputInfoPtr pInfo)
width = priv->maxx - priv->minx;
height = priv->maxy - priv->miny;
- for (i = 0; in_percent && i < 8; i++)
- {
+ for (i = 0; in_percent && i < 8; i++) {
int base, size;
if ((in_percent & (1 << i)) == 0 || values[i] == 0)
@@ -562,7 +563,7 @@ static void set_softbutton_areas_option(InputInfoPtr pInfo)
size = ((i % 4) < 2) ? width : height;
base = ((i % 4) < 2) ? priv->minx : priv->miny;
- values[i] = base + size * values[i]/100.0;
+ values[i] = base + size * values[i] / 100.0;
}
if (!SynapticsIsSoftButtonAreasValid(values))
@@ -573,28 +574,30 @@ static void set_softbutton_areas_option(InputInfoPtr pInfo)
return;
-fail:
- xf86IDrvMsg(pInfo, X_ERROR, "invalid SoftButtonAreas value '%s', keeping defaults\n",
+ fail:
+ xf86IDrvMsg(pInfo, X_ERROR,
+ "invalid SoftButtonAreas value '%s', keeping defaults\n",
option_string);
}
-static void set_default_parameters(InputInfoPtr pInfo)
+static void
+set_default_parameters(InputInfoPtr pInfo)
{
- SynapticsPrivate *priv = pInfo->private; /* read-only */
- pointer opts = pInfo->options; /* read-only */
+ SynapticsPrivate *priv = pInfo->private; /* read-only */
+ pointer opts = pInfo->options; /* read-only */
SynapticsParameters *pars = &priv->synpara; /* modified */
- int horizScrollDelta, vertScrollDelta; /* pixels */
- int tapMove; /* pixels */
- int l, r, t, b; /* left, right, top, bottom */
- int edgeMotionMinSpeed, edgeMotionMaxSpeed; /* pixels/second */
- double accelFactor; /* 1/pixels */
- int fingerLow, fingerHigh, fingerPress; /* pressure */
- int emulateTwoFingerMinZ; /* pressure */
- int emulateTwoFingerMinW; /* width */
- int edgeMotionMinZ, edgeMotionMaxZ; /* pressure */
- int pressureMotionMinZ, pressureMotionMaxZ; /* pressure */
- int palmMinWidth, palmMinZ; /* pressure */
+ int horizScrollDelta, vertScrollDelta; /* pixels */
+ int tapMove; /* pixels */
+ int l, r, t, b; /* left, right, top, bottom */
+ int edgeMotionMinSpeed, edgeMotionMaxSpeed; /* pixels/second */
+ double accelFactor; /* 1/pixels */
+ int fingerLow, fingerHigh, fingerPress; /* pressure */
+ int emulateTwoFingerMinZ; /* pressure */
+ int emulateTwoFingerMinW; /* width */
+ int edgeMotionMinZ, edgeMotionMaxZ; /* pressure */
+ int pressureMotionMinZ, pressureMotionMaxZ; /* pressure */
+ int palmMinWidth, palmMinZ; /* pressure */
int tapButton1, tapButton2, tapButton3;
int clickFinger1, clickFinger2, clickFinger3;
Bool vertEdgeScroll, horizEdgeScroll;
@@ -607,7 +610,9 @@ static void set_default_parameters(InputInfoPtr pInfo)
/* read the parameters */
if (priv->synshm)
- priv->synshm->version = (PACKAGE_VERSION_MAJOR*10000+PACKAGE_VERSION_MINOR*100+PACKAGE_VERSION_PATCHLEVEL);
+ priv->synshm->version =
+ (PACKAGE_VERSION_MAJOR * 10000 + PACKAGE_VERSION_MINOR * 100 +
+ PACKAGE_VERSION_PATCHLEVEL);
/* The synaptics specs specify typical edge widths of 4% on x, and 5.4% on
* y (page 7) [Synaptics TouchPad Interfacing Guide, 510-000080 - A
@@ -640,21 +645,22 @@ static void set_default_parameters(InputInfoPtr pInfo)
range = priv->maxp - priv->minp + 1;
- calculate_tap_hysteresis(priv, range, &fingerLow, &fingerHigh, &fingerPress);
+ calculate_tap_hysteresis(priv, range, &fingerLow, &fingerHigh,
+ &fingerPress);
/* scaling based on defaults and a pressure of 256 */
- emulateTwoFingerMinZ = priv->minp + range * (282.0/256);
- edgeMotionMinZ = priv->minp + range * (30.0/256);
- edgeMotionMaxZ = priv->minp + range * (160.0/256);
- pressureMotionMinZ = priv->minp + range * (30.0/256);
- pressureMotionMaxZ = priv->minp + range * (160.0/256);
- palmMinZ = priv->minp + range * (200.0/256);
+ emulateTwoFingerMinZ = priv->minp + range * (282.0 / 256);
+ edgeMotionMinZ = priv->minp + range * (30.0 / 256);
+ edgeMotionMaxZ = priv->minp + range * (160.0 / 256);
+ pressureMotionMinZ = priv->minp + range * (30.0 / 256);
+ pressureMotionMaxZ = priv->minp + range * (160.0 / 256);
+ palmMinZ = priv->minp + range * (200.0 / 256);
range = priv->maxw - priv->minw + 1;
/* scaling based on defaults below and a tool width of 16 */
- palmMinWidth = priv->minw + range * (10.0/16);
- emulateTwoFingerMinW = priv->minw + range * (7.0/16);
+ palmMinWidth = priv->minw + range * (10.0 / 16);
+ emulateTwoFingerMinW = priv->minw + range * (7.0 / 16);
/* Enable tap if we don't have a phys left button */
tapButton1 = priv->has_left ? 0 : 1;
@@ -687,13 +693,19 @@ static void set_default_parameters(InputInfoPtr pInfo)
pars->top_edge = xf86SetIntOption(opts, "TopEdge", t);
pars->bottom_edge = xf86SetIntOption(opts, "BottomEdge", b);
- pars->area_top_edge = set_percent_option(opts, "AreaTopEdge", height, priv->miny, 0);
- pars->area_bottom_edge = set_percent_option(opts, "AreaBottomEdge", height, priv->miny, 0);
- pars->area_left_edge = set_percent_option(opts, "AreaLeftEdge", width, priv->minx, 0);
- pars->area_right_edge = set_percent_option(opts, "AreaRightEdge", width, priv->minx, 0);
+ pars->area_top_edge =
+ set_percent_option(opts, "AreaTopEdge", height, priv->miny, 0);
+ pars->area_bottom_edge =
+ set_percent_option(opts, "AreaBottomEdge", height, priv->miny, 0);
+ pars->area_left_edge =
+ set_percent_option(opts, "AreaLeftEdge", width, priv->minx, 0);
+ pars->area_right_edge =
+ set_percent_option(opts, "AreaRightEdge", width, priv->minx, 0);
- pars->hyst_x = set_percent_option(opts, "HorizHysteresis", width, 0, horizHyst);
- pars->hyst_y = set_percent_option(opts, "VertHysteresis", height, 0, vertHyst);
+ pars->hyst_x =
+ set_percent_option(opts, "HorizHysteresis", width, 0, horizHyst);
+ pars->hyst_y =
+ set_percent_option(opts, "VertHysteresis", height, 0, vertHyst);
pars->finger_low = xf86SetIntOption(opts, "FingerLow", fingerLow);
pars->finger_high = xf86SetIntOption(opts, "FingerHigh", fingerHigh);
@@ -702,32 +714,51 @@ static void set_default_parameters(InputInfoPtr pInfo)
pars->tap_move = xf86SetIntOption(opts, "MaxTapMove", tapMove);
pars->tap_time_2 = xf86SetIntOption(opts, "MaxDoubleTapTime", 180);
pars->click_time = xf86SetIntOption(opts, "ClickTime", 100);
- pars->clickpad = xf86SetBoolOption(opts, "ClickPad", pars->clickpad); /* Probed */
+ pars->clickpad = xf86SetBoolOption(opts, "ClickPad", pars->clickpad); /* Probed */
pars->fast_taps = xf86SetBoolOption(opts, "FastTaps", FALSE);
/* middle mouse button emulation on a clickpad? nah, you're joking */
middle_button_timeout = pars->clickpad ? 0 : 75;
- pars->emulate_mid_button_time = xf86SetIntOption(opts, "EmulateMidButtonTime", middle_button_timeout);
- pars->emulate_twofinger_z = xf86SetIntOption(opts, "EmulateTwoFingerMinZ", emulateTwoFingerMinZ);
- pars->emulate_twofinger_w = xf86SetIntOption(opts, "EmulateTwoFingerMinW", emulateTwoFingerMinW);
- pars->scroll_dist_vert = xf86SetIntOption(opts, "VertScrollDelta", vertScrollDelta);
- pars->scroll_dist_horiz = xf86SetIntOption(opts, "HorizScrollDelta", horizScrollDelta);
- pars->scroll_edge_vert = xf86SetBoolOption(opts, "VertEdgeScroll", vertEdgeScroll);
- pars->scroll_edge_horiz = xf86SetBoolOption(opts, "HorizEdgeScroll", horizEdgeScroll);
+ pars->emulate_mid_button_time =
+ xf86SetIntOption(opts, "EmulateMidButtonTime", middle_button_timeout);
+ pars->emulate_twofinger_z =
+ xf86SetIntOption(opts, "EmulateTwoFingerMinZ", emulateTwoFingerMinZ);
+ pars->emulate_twofinger_w =
+ xf86SetIntOption(opts, "EmulateTwoFingerMinW", emulateTwoFingerMinW);
+ pars->scroll_dist_vert =
+ xf86SetIntOption(opts, "VertScrollDelta", vertScrollDelta);
+ pars->scroll_dist_horiz =
+ xf86SetIntOption(opts, "HorizScrollDelta", horizScrollDelta);
+ pars->scroll_edge_vert =
+ xf86SetBoolOption(opts, "VertEdgeScroll", vertEdgeScroll);
+ pars->scroll_edge_horiz =
+ xf86SetBoolOption(opts, "HorizEdgeScroll", horizEdgeScroll);
pars->scroll_edge_corner = xf86SetBoolOption(opts, "CornerCoasting", FALSE);
- pars->scroll_twofinger_vert = xf86SetBoolOption(opts, "VertTwoFingerScroll", vertTwoFingerScroll);
- pars->scroll_twofinger_horiz = xf86SetBoolOption(opts, "HorizTwoFingerScroll", horizTwoFingerScroll);
- pars->edge_motion_min_z = xf86SetIntOption(opts, "EdgeMotionMinZ", edgeMotionMinZ);
- pars->edge_motion_max_z = xf86SetIntOption(opts, "EdgeMotionMaxZ", edgeMotionMaxZ);
- pars->edge_motion_min_speed = xf86SetIntOption(opts, "EdgeMotionMinSpeed", edgeMotionMinSpeed);
- pars->edge_motion_max_speed = xf86SetIntOption(opts, "EdgeMotionMaxSpeed", edgeMotionMaxSpeed);
- pars->edge_motion_use_always = xf86SetBoolOption(opts, "EdgeMotionUseAlways", FALSE);
+ pars->scroll_twofinger_vert =
+ xf86SetBoolOption(opts, "VertTwoFingerScroll", vertTwoFingerScroll);
+ pars->scroll_twofinger_horiz =
+ xf86SetBoolOption(opts, "HorizTwoFingerScroll", horizTwoFingerScroll);
+ pars->edge_motion_min_z =
+ xf86SetIntOption(opts, "EdgeMotionMinZ", edgeMotionMinZ);
+ pars->edge_motion_max_z =
+ xf86SetIntOption(opts, "EdgeMotionMaxZ", edgeMotionMaxZ);
+ pars->edge_motion_min_speed =
+ xf86SetIntOption(opts, "EdgeMotionMinSpeed", edgeMotionMinSpeed);
+ pars->edge_motion_max_speed =
+ xf86SetIntOption(opts, "EdgeMotionMaxSpeed", edgeMotionMaxSpeed);
+ pars->edge_motion_use_always =
+ xf86SetBoolOption(opts, "EdgeMotionUseAlways", FALSE);
if (priv->has_scrollbuttons) {
- pars->updown_button_scrolling = xf86SetBoolOption(opts, "UpDownScrolling", TRUE);
- pars->leftright_button_scrolling = xf86SetBoolOption(opts, "LeftRightScrolling", TRUE);
- pars->updown_button_repeat = xf86SetBoolOption(opts, "UpDownScrollRepeat", TRUE);
- pars->leftright_button_repeat = xf86SetBoolOption(opts, "LeftRightScrollRepeat", TRUE);
- }
- pars->scroll_button_repeat = xf86SetIntOption(opts,"ScrollButtonRepeat", 100);
+ pars->updown_button_scrolling =
+ xf86SetBoolOption(opts, "UpDownScrolling", TRUE);
+ pars->leftright_button_scrolling =
+ xf86SetBoolOption(opts, "LeftRightScrolling", TRUE);
+ pars->updown_button_repeat =
+ xf86SetBoolOption(opts, "UpDownScrollRepeat", TRUE);
+ pars->leftright_button_repeat =
+ xf86SetBoolOption(opts, "LeftRightScrollRepeat", TRUE);
+ }
+ pars->scroll_button_repeat =
+ xf86SetIntOption(opts, "ScrollButtonRepeat", 100);
pars->touchpad_off = xf86SetIntOption(opts, "TouchpadOff", 0);
pars->locked_drags = xf86SetBoolOption(opts, "LockedDrags", FALSE);
pars->locked_drag_time = xf86SetIntOption(opts, "LockedDragTimeout", 5000);
@@ -735,21 +766,27 @@ static void set_default_parameters(InputInfoPtr pInfo)
pars->tap_action[RB_TAP] = xf86SetIntOption(opts, "RBCornerButton", 0);
pars->tap_action[LT_TAP] = xf86SetIntOption(opts, "LTCornerButton", 0);
pars->tap_action[LB_TAP] = xf86SetIntOption(opts, "LBCornerButton", 0);
- pars->tap_action[F1_TAP] = xf86SetIntOption(opts, "TapButton1", tapButton1);
- pars->tap_action[F2_TAP] = xf86SetIntOption(opts, "TapButton2", tapButton2);
- pars->tap_action[F3_TAP] = xf86SetIntOption(opts, "TapButton3", tapButton3);
- pars->click_action[F1_CLICK1] = xf86SetIntOption(opts, "ClickFinger1", clickFinger1);
- pars->click_action[F2_CLICK1] = xf86SetIntOption(opts, "ClickFinger2", clickFinger2);
- pars->click_action[F3_CLICK1] = xf86SetIntOption(opts, "ClickFinger3", clickFinger3);
- pars->circular_scrolling = xf86SetBoolOption(opts, "CircularScrolling", FALSE);
- pars->circular_trigger = xf86SetIntOption(opts, "CircScrollTrigger", 0);
- pars->circular_pad = xf86SetBoolOption(opts, "CircularPad", FALSE);
- pars->palm_detect = xf86SetBoolOption(opts, "PalmDetect", FALSE);
- pars->palm_min_width = xf86SetIntOption(opts, "PalmMinWidth", palmMinWidth);
- pars->palm_min_z = xf86SetIntOption(opts, "PalmMinZ", palmMinZ);
+ pars->tap_action[F1_TAP] = xf86SetIntOption(opts, "TapButton1", tapButton1);
+ pars->tap_action[F2_TAP] = xf86SetIntOption(opts, "TapButton2", tapButton2);
+ pars->tap_action[F3_TAP] = xf86SetIntOption(opts, "TapButton3", tapButton3);
+ pars->click_action[F1_CLICK1] =
+ xf86SetIntOption(opts, "ClickFinger1", clickFinger1);
+ pars->click_action[F2_CLICK1] =
+ xf86SetIntOption(opts, "ClickFinger2", clickFinger2);
+ pars->click_action[F3_CLICK1] =
+ xf86SetIntOption(opts, "ClickFinger3", clickFinger3);
+ pars->circular_scrolling =
+ xf86SetBoolOption(opts, "CircularScrolling", FALSE);
+ pars->circular_trigger = xf86SetIntOption(opts, "CircScrollTrigger", 0);
+ pars->circular_pad = xf86SetBoolOption(opts, "CircularPad", FALSE);
+ pars->palm_detect = xf86SetBoolOption(opts, "PalmDetect", FALSE);
+ pars->palm_min_width = xf86SetIntOption(opts, "PalmMinWidth", palmMinWidth);
+ pars->palm_min_z = xf86SetIntOption(opts, "PalmMinZ", palmMinZ);
pars->single_tap_timeout = xf86SetIntOption(opts, "SingleTapTimeout", 180);
- pars->press_motion_min_z = xf86SetIntOption(opts, "PressureMotionMinZ", pressureMotionMinZ);
- pars->press_motion_max_z = xf86SetIntOption(opts, "PressureMotionMaxZ", pressureMotionMaxZ);
+ pars->press_motion_min_z =
+ xf86SetIntOption(opts, "PressureMotionMinZ", pressureMotionMinZ);
+ pars->press_motion_max_z =
+ xf86SetIntOption(opts, "PressureMotionMaxZ", pressureMotionMaxZ);
pars->min_speed = xf86SetRealOption(opts, "MinSpeed", 0.4);
pars->max_speed = xf86SetRealOption(opts, "MaxSpeed", 0.7);
@@ -758,42 +795,49 @@ static void set_default_parameters(InputInfoPtr pInfo)
pars->scroll_dist_circ = xf86SetRealOption(opts, "CircScrollDelta", 0.1);
pars->coasting_speed = xf86SetRealOption(opts, "CoastingSpeed", 20.0);
pars->coasting_friction = xf86SetRealOption(opts, "CoastingFriction", 50);
- pars->press_motion_min_factor = xf86SetRealOption(opts, "PressureMotionMinFactor", 1.0);
- pars->press_motion_max_factor = xf86SetRealOption(opts, "PressureMotionMaxFactor", 1.0);
+ pars->press_motion_min_factor =
+ xf86SetRealOption(opts, "PressureMotionMinFactor", 1.0);
+ pars->press_motion_max_factor =
+ xf86SetRealOption(opts, "PressureMotionMaxFactor", 1.0);
pars->grab_event_device = xf86SetBoolOption(opts, "GrabEventDevice", TRUE);
- pars->tap_and_drag_gesture = xf86SetBoolOption(opts, "TapAndDragGesture", TRUE);
- pars->resolution_horiz = xf86SetIntOption(opts, "HorizResolution", horizResolution);
- pars->resolution_vert = xf86SetIntOption(opts, "VertResolution", vertResolution);
+ pars->tap_and_drag_gesture =
+ xf86SetBoolOption(opts, "TapAndDragGesture", TRUE);
+ pars->resolution_horiz =
+ xf86SetIntOption(opts, "HorizResolution", horizResolution);
+ pars->resolution_vert =
+ xf86SetIntOption(opts, "VertResolution", vertResolution);
/* Warn about (and fix) incorrectly configured TopEdge/BottomEdge parameters */
if (pars->top_edge > pars->bottom_edge) {
- int tmp = pars->top_edge;
- pars->top_edge = pars->bottom_edge;
- pars->bottom_edge = tmp;
- xf86IDrvMsg(pInfo, X_WARNING, "TopEdge is bigger than BottomEdge. Fixing.\n");
+ int tmp = pars->top_edge;
+
+ pars->top_edge = pars->bottom_edge;
+ pars->bottom_edge = tmp;
+ xf86IDrvMsg(pInfo, X_WARNING,
+ "TopEdge is bigger than BottomEdge. Fixing.\n");
}
set_softbutton_areas_option(pInfo);
}
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 14
-static double SynapticsAccelerationProfile(DeviceIntPtr dev,
- DeviceVelocityPtr vel,
- double velocity,
- double thr,
- double acc) {
+static double
+SynapticsAccelerationProfile(DeviceIntPtr dev,
+ DeviceVelocityPtr vel,
+ double velocity, double thr, double acc)
+{
#else
-static float SynapticsAccelerationProfile(DeviceIntPtr dev,
- DeviceVelocityPtr vel,
- float velocity_f,
- float thr_f,
- float acc_f) {
+static float
+SynapticsAccelerationProfile(DeviceIntPtr dev,
+ DeviceVelocityPtr vel,
+ float velocity_f, float thr_f, float acc_f)
+{
double velocity = velocity_f;
double acc = acc_f;
#endif
InputInfoPtr pInfo = dev->public.devicePrivate;
SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private);
- SynapticsParameters* para = &priv->synpara;
+ SynapticsParameters *para = &priv->synpara;
double accelfct;
@@ -808,23 +852,28 @@ static float SynapticsAccelerationProfile(DeviceIntPtr dev,
/* clip acceleration factor */
if (accelfct > para->max_speed * acc)
- accelfct = para->max_speed * acc;
+ accelfct = para->max_speed * acc;
else if (accelfct < para->min_speed)
- accelfct = para->min_speed;
+ accelfct = para->min_speed;
/* modify speed according to pressure */
if (priv->moving_state == MS_TOUCHPAD_RELATIVE) {
- int minZ = para->press_motion_min_z;
- int maxZ = para->press_motion_max_z;
- double minFctr = para->press_motion_min_factor;
- double maxFctr = para->press_motion_max_factor;
- if (priv->hwState->z <= minZ) {
- accelfct *= minFctr;
- } else if (priv->hwState->z >= maxZ) {
- accelfct *= maxFctr;
- } else {
- accelfct *= minFctr + (priv->hwState->z - minZ) * (maxFctr - minFctr) / (maxZ - minZ);
- }
+ int minZ = para->press_motion_min_z;
+ int maxZ = para->press_motion_max_z;
+ double minFctr = para->press_motion_min_factor;
+ double maxFctr = para->press_motion_max_factor;
+
+ if (priv->hwState->z <= minZ) {
+ accelfct *= minFctr;
+ }
+ else if (priv->hwState->z >= maxZ) {
+ accelfct *= maxFctr;
+ }
+ else {
+ accelfct *=
+ minFctr + (priv->hwState->z - minZ) * (maxFctr -
+ minFctr) / (maxZ - minZ);
+ }
}
return accelfct;
@@ -832,7 +881,8 @@ static float SynapticsAccelerationProfile(DeviceIntPtr dev,
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
static int
-NewSynapticsPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags);
+ NewSynapticsPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags);
+
/*
* called by the module loader for initialization
*/
@@ -844,17 +894,17 @@ SynapticsPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
/* Allocate a new InputInfoRec and add it to the head xf86InputDevs. */
pInfo = xf86AllocateInput(drv, 0);
if (!pInfo) {
- return NULL;
+ return NULL;
}
/* initialize the InputInfoRec */
- pInfo->name = dev->identifier;
+ pInfo->name = dev->identifier;
pInfo->reverse_conversion_proc = NULL;
- pInfo->dev = NULL;
- pInfo->private_flags = 0;
- pInfo->flags = XI86_SEND_DRAG_EVENTS;
- pInfo->conf_idev = dev;
- pInfo->always_core_feedback = 0;
+ pInfo->dev = NULL;
+ pInfo->private_flags = 0;
+ pInfo->flags = XI86_SEND_DRAG_EVENTS;
+ pInfo->conf_idev = dev;
+ pInfo->always_core_feedback = 0;
xf86CollectInputOptions(pInfo, NULL, NULL);
@@ -878,25 +928,26 @@ SynapticsPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
/* allocate memory for SynapticsPrivateRec */
priv = calloc(1, sizeof(SynapticsPrivate));
if (!priv)
- return BadAlloc;
+ return BadAlloc;
- pInfo->type_name = XI_TOUCHPAD;
- pInfo->device_control = DeviceControl;
- pInfo->read_input = ReadInput;
- pInfo->control_proc = ControlProc;
- pInfo->switch_mode = SwitchMode;
- pInfo->private = priv;
+ pInfo->type_name = XI_TOUCHPAD;
+ pInfo->device_control = DeviceControl;
+ pInfo->read_input = ReadInput;
+ pInfo->control_proc = ControlProc;
+ pInfo->switch_mode = SwitchMode;
+ pInfo->private = priv;
/* allocate now so we don't allocate in the signal handler */
priv->timer = TimerSet(NULL, 0, 0, NULL, NULL);
if (!priv->timer) {
- free(priv);
- return BadAlloc;
+ free(priv);
+ return BadAlloc;
}
/* may change pInfo->options */
if (!SetDeviceAndProtocol(pInfo)) {
- xf86IDrvMsg(pInfo, X_ERROR, "Synaptics driver unable to detect protocol\n");
+ xf86IDrvMsg(pInfo, X_ERROR,
+ "Synaptics driver unable to detect protocol\n");
goto SetupProc_fail;
}
@@ -905,8 +956,8 @@ SynapticsPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
/* open the touchpad device */
pInfo->fd = xf86OpenSerial(pInfo->options);
if (pInfo->fd == -1) {
- xf86IDrvMsg(pInfo, X_ERROR, "Synaptics driver unable to open device\n");
- goto SetupProc_fail;
+ xf86IDrvMsg(pInfo, X_ERROR, "Synaptics driver unable to open device\n");
+ goto SetupProc_fail;
}
xf86ErrorFVerb(6, "port opened successfully\n");
@@ -932,23 +983,24 @@ SynapticsPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
CalculateScalingCoeffs(priv);
if (!alloc_shm_data(pInfo))
- goto SetupProc_fail;
+ goto SetupProc_fail;
priv->comm.buffer = XisbNew(pInfo->fd, INPUT_BUFFER_SIZE);
if (!QueryHardware(pInfo)) {
- xf86IDrvMsg(pInfo, X_ERROR, "Unable to query/initialize Synaptics hardware.\n");
- goto SetupProc_fail;
+ xf86IDrvMsg(pInfo, X_ERROR,
+ "Unable to query/initialize Synaptics hardware.\n");
+ goto SetupProc_fail;
}
xf86ProcessCommonOptions(pInfo, pInfo->options);
if (pInfo->fd != -1) {
- if (priv->comm.buffer) {
- XisbFree(priv->comm.buffer);
- priv->comm.buffer = NULL;
- }
- xf86CloseSerial(pInfo->fd);
+ if (priv->comm.buffer) {
+ XisbFree(priv->comm.buffer);
+ priv->comm.buffer = NULL;
+ }
+ xf86CloseSerial(pInfo->fd);
}
pInfo->fd = -1;
@@ -956,12 +1008,12 @@ SynapticsPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
SetupProc_fail:
if (pInfo->fd >= 0) {
- xf86CloseSerial(pInfo->fd);
- pInfo->fd = -1;
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
}
if (priv->comm.buffer)
- XisbFree(priv->comm.buffer);
+ XisbFree(priv->comm.buffer);
free_shm_data(priv);
free(priv->proto_data);
free(priv->timer);
@@ -970,15 +1022,14 @@ SynapticsPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
return BadAlloc;
}
-
/*
* Uninitialize the device.
*/
-static void SynapticsUnInit(InputDriverPtr drv,
- InputInfoPtr pInfo,
- int flags)
+static void
+SynapticsUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
{
- SynapticsPrivate *priv = ((SynapticsPrivate *)pInfo->private);
+ SynapticsPrivate *priv = ((SynapticsPrivate *) pInfo->private);
+
if (priv && priv->timer)
free(priv->timer);
if (priv && priv->proto_data)
@@ -996,13 +1047,12 @@ static void SynapticsUnInit(InputDriverPtr drv,
xf86DeleteInput(pInfo, 0);
}
-
/*
* Alter the control parameters for the mouse. Note that all special
* protocol values are handled by dix.
*/
static void
-SynapticsCtrl(DeviceIntPtr device, PtrCtrl *ctrl)
+SynapticsCtrl(DeviceIntPtr device, PtrCtrl * ctrl)
{
}
@@ -1013,19 +1063,19 @@ DeviceControl(DeviceIntPtr dev, int mode)
switch (mode) {
case DEVICE_INIT:
- RetValue = DeviceInit(dev);
- break;
+ RetValue = DeviceInit(dev);
+ break;
case DEVICE_ON:
- RetValue = DeviceOn(dev);
- break;
+ RetValue = DeviceOn(dev);
+ break;
case DEVICE_OFF:
- RetValue = DeviceOff(dev);
- break;
+ RetValue = DeviceOff(dev);
+ break;
case DEVICE_CLOSE:
- RetValue = DeviceClose(dev);
- break;
+ RetValue = DeviceClose(dev);
+ break;
default:
- RetValue = BadValue;
+ RetValue = BadValue;
}
return RetValue;
@@ -1041,8 +1091,8 @@ DeviceOn(DeviceIntPtr dev)
pInfo->fd = xf86OpenSerial(pInfo->options);
if (pInfo->fd == -1) {
- xf86IDrvMsg(pInfo, X_WARNING, "cannot open input device\n");
- return !Success;
+ xf86IDrvMsg(pInfo, X_WARNING, "cannot open input device\n");
+ return !Success;
}
if (priv->proto_ops->DeviceOnHook &&
@@ -1051,16 +1101,15 @@ DeviceOn(DeviceIntPtr dev)
priv->comm.buffer = XisbNew(pInfo->fd, INPUT_BUFFER_SIZE);
if (!priv->comm.buffer) {
- xf86CloseSerial(pInfo->fd);
- pInfo->fd = -1;
- return !Success;
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+ return !Success;
}
xf86FlushInput(pInfo->fd);
/* reinit the pad */
- if (!QueryHardware(pInfo))
- {
+ if (!QueryHardware(pInfo)) {
XisbFree(priv->comm.buffer);
priv->comm.buffer = NULL;
xf86CloseSerial(pInfo->fd);
@@ -1075,7 +1124,7 @@ DeviceOn(DeviceIntPtr dev)
}
static void
-SynapticsReset(SynapticsPrivate *priv)
+SynapticsReset(SynapticsPrivate * priv)
{
SynapticsResetHwState(priv->hwState);
SynapticsResetHwState(priv->local_hw_state);
@@ -1106,7 +1155,6 @@ SynapticsReset(SynapticsPrivate *priv)
priv->prevFingers = 0;
}
-
static Bool
DeviceOff(DeviceIntPtr dev)
{
@@ -1117,19 +1165,19 @@ DeviceOff(DeviceIntPtr dev)
DBG(3, "Synaptics DeviceOff called\n");
if (pInfo->fd != -1) {
- TimerCancel(priv->timer);
- xf86RemoveEnabledDevice(pInfo);
- SynapticsReset(priv);
+ TimerCancel(priv->timer);
+ xf86RemoveEnabledDevice(pInfo);
+ SynapticsReset(priv);
if (priv->proto_ops->DeviceOffHook &&
!priv->proto_ops->DeviceOffHook(pInfo))
rc = !Success;
- if (priv->comm.buffer) {
- XisbFree(priv->comm.buffer);
- priv->comm.buffer = NULL;
- }
- xf86CloseSerial(pInfo->fd);
- pInfo->fd = -1;
+ if (priv->comm.buffer) {
+ XisbFree(priv->comm.buffer);
+ priv->comm.buffer = NULL;
+ }
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
}
dev->public.on = FALSE;
return rc;
@@ -1153,61 +1201,60 @@ DeviceClose(DeviceIntPtr dev)
return RetValue;
}
-static void InitAxesLabels(Atom *labels, int nlabels,
- const SynapticsPrivate *priv)
+static void
+InitAxesLabels(Atom *labels, int nlabels, const SynapticsPrivate * priv)
{
#ifdef HAVE_MULTITOUCH
int i;
#endif
memset(labels, 0, nlabels * sizeof(Atom));
- switch(nlabels)
- {
- default:
+ switch (nlabels) {
+ default:
#ifdef HAVE_SMOOTH_SCROLL
- case 4:
- labels[3] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_VSCROLL);
- case 3:
- labels[2] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_HSCROLL);
+ case 4:
+ labels[3] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_VSCROLL);
+ case 3:
+ labels[2] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_HSCROLL);
#endif
- case 2:
- labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
- case 1:
- labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
- break;
+ case 2:
+ labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+ case 1:
+ labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+ break;
}
#ifdef HAVE_MULTITOUCH
- for (i = 0; i < priv->num_mt_axes; i++)
- {
+ for (i = 0; i < priv->num_mt_axes; i++) {
SynapticsTouchAxisRec *axis = &priv->touch_axes[i];
int axnum = nlabels - priv->num_mt_axes + i;
+
labels[axnum] = XIGetKnownProperty(axis->label);
}
#endif
}
-static void InitButtonLabels(Atom *labels, int nlabels)
+static void
+InitButtonLabels(Atom *labels, int nlabels)
{
memset(labels, 0, nlabels * sizeof(Atom));
- switch(nlabels)
- {
- default:
- case 7:
- labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
- case 6:
- labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
- case 5:
- labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
- case 4:
- labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
- case 3:
- labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
- case 2:
- labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
- case 1:
- labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
- break;
+ switch (nlabels) {
+ default:
+ case 7:
+ labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
+ case 6:
+ labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
+ case 5:
+ labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
+ case 4:
+ labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
+ case 3:
+ labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+ case 2:
+ labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+ case 1:
+ labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+ break;
}
}
@@ -1219,13 +1266,12 @@ DeviceInitTouch(DeviceIntPtr dev, Atom *axes_labels)
SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private);
int i;
- if (priv->has_touch)
- {
- priv->num_slots = priv->max_touches ? priv->max_touches : SYNAPTICS_MAX_TOUCHES;
+ if (priv->has_touch) {
+ priv->num_slots =
+ priv->max_touches ? priv->max_touches : SYNAPTICS_MAX_TOUCHES;
priv->open_slots = malloc(priv->num_slots * sizeof(int));
- if (!priv->open_slots)
- {
+ if (!priv->open_slots) {
xf86IDrvMsg(pInfo, X_ERROR,
"failed to allocate open touch slots array\n");
priv->has_touch = 0;
@@ -1235,8 +1281,8 @@ DeviceInitTouch(DeviceIntPtr dev, Atom *axes_labels)
/* x/y + whatever other MT axes we found */
if (!InitTouchClassDeviceStruct(dev, priv->max_touches,
- XIDependentTouch, 2 + priv->num_mt_axes))
- {
+ XIDependentTouch,
+ 2 + priv->num_mt_axes)) {
xf86IDrvMsg(pInfo, X_ERROR,
"failed to initialize touch class device\n");
priv->has_touch = 0;
@@ -1246,15 +1292,13 @@ DeviceInitTouch(DeviceIntPtr dev, Atom *axes_labels)
return;
}
- for (i = 0; i < priv->num_mt_axes; i++)
- {
+ for (i = 0; i < priv->num_mt_axes; i++) {
SynapticsTouchAxisRec *axis = &priv->touch_axes[i];
- int axnum = 4 + i; /* Skip x, y, and scroll axes */
+ int axnum = 4 + i; /* Skip x, y, and scroll axes */
if (!xf86InitValuatorAxisStruct(dev, axnum, axes_labels[axnum],
axis->min, axis->max, axis->res, 0,
- axis->res, Absolute))
- {
+ axis->res, Absolute)) {
xf86IDrvMsg(pInfo, X_WARNING,
"failed to initialize axis %s, skipping\n",
axis->label);
@@ -1291,8 +1335,7 @@ DeviceInit(DeviceIntPtr dev)
#endif
axes_labels = calloc(num_axes, sizeof(Atom));
- if (!axes_labels)
- {
+ if (!axes_labels) {
xf86IDrvMsg(pInfo, X_ERROR, "failed to allocate axis labels\n");
return !Success;
}
@@ -1303,17 +1346,15 @@ DeviceInit(DeviceIntPtr dev)
DBG(3, "Synaptics DeviceInit called\n");
for (i = 0; i <= SYN_MAX_BUTTONS; i++)
- map[i] = i;
+ map[i] = i;
dev->public.on = FALSE;
- InitPointerDeviceStruct((DevicePtr)dev, map,
- SYN_MAX_BUTTONS,
+ InitPointerDeviceStruct((DevicePtr) dev, map,
+ SYN_MAX_BUTTONS,
btn_labels,
- SynapticsCtrl,
- GetMotionHistorySize(),
- num_axes,
- axes_labels);
+ SynapticsCtrl,
+ GetMotionHistorySize(), num_axes, axes_labels);
/*
* setup dix acceleration to match legacy synaptics settings, and
@@ -1321,77 +1362,76 @@ DeviceInit(DeviceIntPtr dev)
* acceleration.
*/
if (NULL != (pVel = GetDevicePredictableAccelData(dev))) {
- SetDeviceSpecificAccelerationProfile(pVel,
- SynapticsAccelerationProfile);
+ SetDeviceSpecificAccelerationProfile(pVel,
+ SynapticsAccelerationProfile);
- /* float property type */
- float_type = XIGetKnownProperty(XATOM_FLOAT);
+ /* float property type */
+ float_type = XIGetKnownProperty(XATOM_FLOAT);
- /* translate MinAcc to constant deceleration.
- * May be overridden in xf86InitValuatorDefaults */
- tmpf = 1.0 / priv->synpara.min_speed;
+ /* translate MinAcc to constant deceleration.
+ * May be overridden in xf86InitValuatorDefaults */
+ tmpf = 1.0 / priv->synpara.min_speed;
- xf86IDrvMsg(pInfo, X_CONFIG, "(accel) MinSpeed is now constant deceleration "
- "%.1f\n", tmpf);
- prop = XIGetKnownProperty(ACCEL_PROP_CONSTANT_DECELERATION);
- XIChangeDeviceProperty(dev, prop, float_type, 32,
- PropModeReplace, 1, &tmpf, FALSE);
+ xf86IDrvMsg(pInfo, X_CONFIG,
+ "(accel) MinSpeed is now constant deceleration " "%.1f\n",
+ tmpf);
+ prop = XIGetKnownProperty(ACCEL_PROP_CONSTANT_DECELERATION);
+ XIChangeDeviceProperty(dev, prop, float_type, 32,
+ PropModeReplace, 1, &tmpf, FALSE);
- /* adjust accordingly */
- priv->synpara.max_speed /= priv->synpara.min_speed;
- priv->synpara.min_speed = 1.0;
+ /* adjust accordingly */
+ priv->synpara.max_speed /= priv->synpara.min_speed;
+ priv->synpara.min_speed = 1.0;
- /* synaptics seems to report 80 packet/s, but dix scales for
- * 100 packet/s by default. */
- pVel->corr_mul = 12.5f; /*1000[ms]/80[/s] = 12.5 */
+ /* synaptics seems to report 80 packet/s, but dix scales for
+ * 100 packet/s by default. */
+ pVel->corr_mul = 12.5f; /*1000[ms]/80[/s] = 12.5 */
- xf86IDrvMsg(pInfo, X_CONFIG, "MaxSpeed is now %.2f\n",
- priv->synpara.max_speed);
- xf86IDrvMsg(pInfo, X_CONFIG, "AccelFactor is now %.3f\n",
- priv->synpara.accl);
+ xf86IDrvMsg(pInfo, X_CONFIG, "MaxSpeed is now %.2f\n",
+ priv->synpara.max_speed);
+ xf86IDrvMsg(pInfo, X_CONFIG, "AccelFactor is now %.3f\n",
+ priv->synpara.accl);
- prop = XIGetKnownProperty(ACCEL_PROP_PROFILE_NUMBER);
- i = AccelProfileDeviceSpecific;
- XIChangeDeviceProperty(dev, prop, XA_INTEGER, 32,
- PropModeReplace, 1, &i, FALSE);
+ prop = XIGetKnownProperty(ACCEL_PROP_PROFILE_NUMBER);
+ i = AccelProfileDeviceSpecific;
+ XIChangeDeviceProperty(dev, prop, XA_INTEGER, 32,
+ PropModeReplace, 1, &i, FALSE);
}
/* X valuator */
- if (priv->minx < priv->maxx)
- {
+ if (priv->minx < priv->maxx) {
min = priv->minx;
max = priv->maxx;
- } else
- {
+ }
+ else {
min = 0;
max = -1;
}
xf86InitValuatorAxisStruct(dev, 0, axes_labels[0],
- min, max, priv->resx * 1000, 0, priv->resx * 1000
+ min, max, priv->resx * 1000, 0, priv->resx * 1000
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
- , Relative
+ , Relative
#endif
- );
+ );
xf86InitValuatorDefaults(dev, 0);
/* Y valuator */
- if (priv->miny < priv->maxy)
- {
+ if (priv->miny < priv->maxy) {
min = priv->miny;
max = priv->maxy;
- } else
- {
+ }
+ else {
min = 0;
max = -1;
}
xf86InitValuatorAxisStruct(dev, 1, axes_labels[1],
- min, max, priv->resy * 1000, 0, priv->resy * 1000
+ min, max, priv->resy * 1000, 0, priv->resy * 1000
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
- , Relative
+ , Relative
#endif
- );
+ );
xf86InitValuatorDefaults(dev, 1);
#ifdef HAVE_SMOOTH_SCROLL
@@ -1402,8 +1442,7 @@ DeviceInit(DeviceIntPtr dev)
Relative);
priv->scroll_axis_vert = 3;
priv->scroll_events_mask = valuator_mask_new(MAX_VALUATORS);
- if (!priv->scroll_events_mask)
- {
+ if (!priv->scroll_events_mask) {
free(axes_labels);
return !Success;
}
@@ -1428,7 +1467,7 @@ DeviceInit(DeviceIntPtr dev)
priv->local_hw_state = SynapticsHwStateAlloc(priv);
if (!priv->local_hw_state)
- goto fail;
+ goto fail;
priv->comm.hwState = SynapticsHwStateAlloc(priv);
@@ -1440,7 +1479,7 @@ DeviceInit(DeviceIntPtr dev)
return Success;
-fail:
+ fail:
free_shm_data(priv);
free(priv->local_hw_state);
free(priv->hwState);
@@ -1450,15 +1489,14 @@ fail:
return !Success;
}
-
/*
* Convert from absolute X/Y coordinates to a coordinate system where
* -1 corresponds to the left/upper edge and +1 corresponds to the
* right/lower edge.
*/
static void
-relative_coords(SynapticsPrivate *priv, int x, int y,
- double *relX, double *relY)
+relative_coords(SynapticsPrivate * priv, int x, int y,
+ double *relX, double *relY)
{
int minX = priv->synpara.left_edge;
int maxX = priv->synpara.right_edge;
@@ -1468,17 +1506,18 @@ relative_coords(SynapticsPrivate *priv, int x, int y,
double yCenter = (minY + maxY) / 2.0;
if ((maxX - xCenter > 0) && (maxY - yCenter > 0)) {
- *relX = (x - xCenter) / (maxX - xCenter);
- *relY = (y - yCenter) / (maxY - yCenter);
- } else {
- *relX = 0;
- *relY = 0;
+ *relX = (x - xCenter) / (maxX - xCenter);
+ *relY = (y - yCenter) / (maxY - yCenter);
+ }
+ else {
+ *relX = 0;
+ *relY = 0;
}
}
/* return angle of point relative to center */
static double
-angle(SynapticsPrivate *priv, int x, int y)
+angle(SynapticsPrivate * priv, int x, int y)
{
double xCenter = (priv->synpara.left_edge + priv->synpara.right_edge) / 2.0;
double yCenter = (priv->synpara.top_edge + priv->synpara.bottom_edge) / 2.0;
@@ -1491,15 +1530,16 @@ static double
diffa(double a1, double a2)
{
double da = fmod(a2 - a1, 2 * M_PI);
+
if (da < 0)
- da += 2 * M_PI;
+ da += 2 * M_PI;
if (da > M_PI)
- da -= 2 * M_PI;
+ da -= 2 * M_PI;
return da;
}
static edge_type
-circular_edge_detection(SynapticsPrivate *priv, int x, int y)
+circular_edge_detection(SynapticsPrivate * priv, int x, int y)
{
edge_type edge = 0;
double relX, relY, relR;
@@ -1508,38 +1548,38 @@ circular_edge_detection(SynapticsPrivate *priv, int x, int y)
relR = SQR(relX) + SQR(relY);
if (relR > 1) {
- /* we are outside the ellipse enclosed by the edge parameters */
- if (relX > M_SQRT1_2)
- edge |= RIGHT_EDGE;
- else if (relX < -M_SQRT1_2)
- edge |= LEFT_EDGE;
+ /* we are outside the ellipse enclosed by the edge parameters */
+ if (relX > M_SQRT1_2)
+ edge |= RIGHT_EDGE;
+ else if (relX < -M_SQRT1_2)
+ edge |= LEFT_EDGE;
- if (relY < -M_SQRT1_2)
- edge |= TOP_EDGE;
- else if (relY > M_SQRT1_2)
- edge |= BOTTOM_EDGE;
+ if (relY < -M_SQRT1_2)
+ edge |= TOP_EDGE;
+ else if (relY > M_SQRT1_2)
+ edge |= BOTTOM_EDGE;
}
return edge;
}
static edge_type
-edge_detection(SynapticsPrivate *priv, int x, int y)
+edge_detection(SynapticsPrivate * priv, int x, int y)
{
edge_type edge = NO_EDGE;
if (priv->synpara.circular_pad)
- return circular_edge_detection(priv, x, y);
+ return circular_edge_detection(priv, x, y);
if (x > priv->synpara.right_edge)
- edge |= RIGHT_EDGE;
+ edge |= RIGHT_EDGE;
else if (x < priv->synpara.left_edge)
- edge |= LEFT_EDGE;
+ edge |= LEFT_EDGE;
if (y < priv->synpara.top_edge)
- edge |= TOP_EDGE;
+ edge |= TOP_EDGE;
else if (y > priv->synpara.bottom_edge)
- edge |= BOTTOM_EDGE;
+ edge |= BOTTOM_EDGE;
return edge;
}
@@ -1550,25 +1590,28 @@ edge_detection(SynapticsPrivate *priv, int x, int y)
* all set to zero), the function returns TRUE.
*/
static Bool
-is_inside_active_area(SynapticsPrivate *priv, int x, int y)
+is_inside_active_area(SynapticsPrivate * priv, int x, int y)
{
Bool inside_area = TRUE;
- if ((priv->synpara.area_left_edge != 0) && (x < priv->synpara.area_left_edge))
- inside_area = FALSE;
- else if ((priv->synpara.area_right_edge != 0) && (x > priv->synpara.area_right_edge))
- inside_area = FALSE;
+ if ((priv->synpara.area_left_edge != 0) &&
+ (x < priv->synpara.area_left_edge))
+ inside_area = FALSE;
+ else if ((priv->synpara.area_right_edge != 0) &&
+ (x > priv->synpara.area_right_edge))
+ inside_area = FALSE;
if ((priv->synpara.area_top_edge != 0) && (y < priv->synpara.area_top_edge))
- inside_area = FALSE;
- else if ((priv->synpara.area_bottom_edge != 0) && (y > priv->synpara.area_bottom_edge))
- inside_area = FALSE;
+ inside_area = FALSE;
+ else if ((priv->synpara.area_bottom_edge != 0) &&
+ (y > priv->synpara.area_bottom_edge))
+ inside_area = FALSE;
return inside_area;
}
static Bool
-is_inside_button_area(SynapticsParameters *para, int which, int x, int y)
+is_inside_button_area(SynapticsParameters * para, int which, int x, int y)
{
Bool inside_area = TRUE;
@@ -1580,28 +1623,28 @@ is_inside_button_area(SynapticsParameters *para, int which, int x, int y)
if (para->softbutton_areas[which][0] &&
x < para->softbutton_areas[which][0])
- inside_area = FALSE;
+ inside_area = FALSE;
else if (para->softbutton_areas[which][1] &&
x > para->softbutton_areas[which][1])
- inside_area = FALSE;
+ inside_area = FALSE;
else if (para->softbutton_areas[which][2] &&
y < para->softbutton_areas[which][2])
- inside_area = FALSE;
+ inside_area = FALSE;
else if (para->softbutton_areas[which][3] &&
y > para->softbutton_areas[which][3])
- inside_area = FALSE;
+ inside_area = FALSE;
return inside_area;
}
static Bool
-is_inside_rightbutton_area(SynapticsParameters *para, int x, int y)
+is_inside_rightbutton_area(SynapticsParameters * para, int x, int y)
{
return is_inside_button_area(para, 0, x, y);
}
static Bool
-is_inside_middlebutton_area(SynapticsParameters *para, int x, int y)
+is_inside_middlebutton_area(SynapticsParameters * para, int x, int y)
{
return is_inside_button_area(para, 1, x, y);
}
@@ -1634,16 +1677,16 @@ static int
clamp(int val, int min, int max)
{
if (val < min)
- return min;
+ return min;
else if (val < max)
- return val;
+ return val;
else
- return max;
+ return max;
}
static Bool
-SynapticsGetHwState(InputInfoPtr pInfo, SynapticsPrivate *priv,
- struct SynapticsHwState *hw)
+SynapticsGetHwState(InputInfoPtr pInfo, SynapticsPrivate * priv,
+ struct SynapticsHwState *hw)
{
return priv->proto_ops->ReadHwState(pInfo, &priv->comm, hw);
}
@@ -1662,31 +1705,32 @@ ReadInput(InputInfoPtr pInfo)
SynapticsResetTouchHwState(hw, FALSE);
while (SynapticsGetHwState(pInfo, priv, hw)) {
- /* Semi-mt device touch slots do not track touches. When there is a
- * change in the number of touches, we must disregard the temporary
- * motion changes. */
- if (priv->has_semi_mt && hw->numFingers != priv->hwState->numFingers) {
- hw->cumulative_dx = priv->hwState->cumulative_dx;
- hw->cumulative_dy = priv->hwState->cumulative_dy;
- }
+ /* Semi-mt device touch slots do not track touches. When there is a
+ * change in the number of touches, we must disregard the temporary
+ * motion changes. */
+ if (priv->has_semi_mt && hw->numFingers != priv->hwState->numFingers) {
+ hw->cumulative_dx = priv->hwState->cumulative_dx;
+ hw->cumulative_dy = priv->hwState->cumulative_dy;
+ }
- /* timer may cause actual events to lag behind (#48777) */
- if (priv->hwState->millis > hw->millis)
- hw->millis = priv->hwState->millis;
+ /* timer may cause actual events to lag behind (#48777) */
+ if (priv->hwState->millis > hw->millis)
+ hw->millis = priv->hwState->millis;
- SynapticsCopyHwState(priv->hwState, hw);
- delay = HandleState(pInfo, hw, hw->millis, FALSE);
- newDelay = TRUE;
+ SynapticsCopyHwState(priv->hwState, hw);
+ delay = HandleState(pInfo, hw, hw->millis, FALSE);
+ newDelay = TRUE;
}
if (newDelay) {
- priv->timer_time = GetTimeInMillis();
- priv->timer = TimerSet(priv->timer, 0, delay, timerFunc, pInfo);
+ priv->timer_time = GetTimeInMillis();
+ priv->timer = TimerSet(priv->timer, 0, delay, timerFunc, pInfo);
}
}
static int
-HandleMidButtonEmulation(SynapticsPrivate *priv, struct SynapticsHwState *hw, CARD32 now, int *delay)
+HandleMidButtonEmulation(SynapticsPrivate * priv, struct SynapticsHwState *hw,
+ CARD32 now, int *delay)
{
SynapticsParameters *para = &priv->synpara;
Bool done = FALSE;
@@ -1697,83 +1741,95 @@ HandleMidButtonEmulation(SynapticsPrivate *priv, struct SynapticsHwState *hw, CA
return mid;
while (!done) {
- switch (priv->mid_emu_state) {
- case MBE_LEFT_CLICK:
- case MBE_RIGHT_CLICK:
- case MBE_OFF:
- priv->button_delay_millis = now;
- if (hw->left) {
- priv->mid_emu_state = MBE_LEFT;
- } else if (hw->right) {
- priv->mid_emu_state = MBE_RIGHT;
- } else {
- done = TRUE;
- }
- break;
- case MBE_LEFT:
- timeleft = TIME_DIFF(priv->button_delay_millis + para->emulate_mid_button_time,
- now);
- if (timeleft > 0)
- *delay = MIN(*delay, timeleft);
+ switch (priv->mid_emu_state) {
+ case MBE_LEFT_CLICK:
+ case MBE_RIGHT_CLICK:
+ case MBE_OFF:
+ priv->button_delay_millis = now;
+ if (hw->left) {
+ priv->mid_emu_state = MBE_LEFT;
+ }
+ else if (hw->right) {
+ priv->mid_emu_state = MBE_RIGHT;
+ }
+ else {
+ done = TRUE;
+ }
+ break;
+ case MBE_LEFT:
+ timeleft =
+ TIME_DIFF(priv->button_delay_millis +
+ para->emulate_mid_button_time, now);
+ if (timeleft > 0)
+ *delay = MIN(*delay, timeleft);
/* timeout, but within the same ReadInput cycle! */
if ((timeleft <= 0) && !hw->left) {
- priv->mid_emu_state = MBE_LEFT_CLICK;
- done = TRUE;
- } else if ((!hw->left) || (timeleft <= 0)) {
- hw->left = TRUE;
- priv->mid_emu_state = MBE_TIMEOUT;
- done = TRUE;
- } else if (hw->right) {
- priv->mid_emu_state = MBE_MID;
- } else {
- hw->left = FALSE;
- done = TRUE;
- }
- break;
- case MBE_RIGHT:
- timeleft = TIME_DIFF(priv->button_delay_millis + para->emulate_mid_button_time,
- now);
- if (timeleft > 0)
- *delay = MIN(*delay, timeleft);
-
- /* timeout, but within the same ReadInput cycle! */
+ priv->mid_emu_state = MBE_LEFT_CLICK;
+ done = TRUE;
+ }
+ else if ((!hw->left) || (timeleft <= 0)) {
+ hw->left = TRUE;
+ priv->mid_emu_state = MBE_TIMEOUT;
+ done = TRUE;
+ }
+ else if (hw->right) {
+ priv->mid_emu_state = MBE_MID;
+ }
+ else {
+ hw->left = FALSE;
+ done = TRUE;
+ }
+ break;
+ case MBE_RIGHT:
+ timeleft =
+ TIME_DIFF(priv->button_delay_millis +
+ para->emulate_mid_button_time, now);
+ if (timeleft > 0)
+ *delay = MIN(*delay, timeleft);
+
+ /* timeout, but within the same ReadInput cycle! */
if ((timeleft <= 0) && !hw->right) {
- priv->mid_emu_state = MBE_RIGHT_CLICK;
- done = TRUE;
- } else if (!hw->right || (timeleft <= 0)) {
- hw->right = TRUE;
- priv->mid_emu_state = MBE_TIMEOUT;
- done = TRUE;
- } else if (hw->left) {
- priv->mid_emu_state = MBE_MID;
- } else {
- hw->right = FALSE;
- done = TRUE;
- }
- break;
- case MBE_MID:
- if (!hw->left && !hw->right) {
- priv->mid_emu_state = MBE_OFF;
- } else {
- mid = TRUE;
- hw->left = hw->right = FALSE;
- done = TRUE;
- }
- break;
- case MBE_TIMEOUT:
- if (!hw->left && !hw->right) {
- priv->mid_emu_state = MBE_OFF;
- } else {
- done = TRUE;
- }
- }
+ priv->mid_emu_state = MBE_RIGHT_CLICK;
+ done = TRUE;
+ }
+ else if (!hw->right || (timeleft <= 0)) {
+ hw->right = TRUE;
+ priv->mid_emu_state = MBE_TIMEOUT;
+ done = TRUE;
+ }
+ else if (hw->left) {
+ priv->mid_emu_state = MBE_MID;
+ }
+ else {
+ hw->right = FALSE;
+ done = TRUE;
+ }
+ break;
+ case MBE_MID:
+ if (!hw->left && !hw->right) {
+ priv->mid_emu_state = MBE_OFF;
+ }
+ else {
+ mid = TRUE;
+ hw->left = hw->right = FALSE;
+ done = TRUE;
+ }
+ break;
+ case MBE_TIMEOUT:
+ if (!hw->left && !hw->right) {
+ priv->mid_emu_state = MBE_OFF;
+ }
+ else {
+ done = TRUE;
+ }
+ }
}
return mid;
}
static enum FingerState
-SynapticsDetectFinger(SynapticsPrivate *priv, struct SynapticsHwState *hw)
+SynapticsDetectFinger(SynapticsPrivate * priv, struct SynapticsHwState *hw)
{
SynapticsParameters *para = &priv->synpara;
enum FingerState finger;
@@ -1790,10 +1846,10 @@ SynapticsDetectFinger(SynapticsPrivate *priv, struct SynapticsHwState *hw)
else if (hw->z > para->finger_high && priv->finger_state == FS_UNTOUCHED)
finger = FS_TOUCHED;
else
- finger = priv->finger_state;
+ finger = priv->finger_state;
if (!para->palm_detect)
- return finger;
+ return finger;
/* palm detection */
@@ -1801,24 +1857,24 @@ SynapticsDetectFinger(SynapticsPrivate *priv, struct SynapticsHwState *hw)
return FS_BLOCKED;
if (hw->x == 0 || priv->finger_state == FS_UNTOUCHED)
- priv->avg_width = 0;
+ priv->avg_width = 0;
else
- priv->avg_width += (hw->fingerWidth - priv->avg_width + 1) / 2;
+ priv->avg_width += (hw->fingerWidth - priv->avg_width + 1) / 2;
if (finger != FS_UNTOUCHED && priv->finger_state == FS_UNTOUCHED) {
- int safe_width = MAX(hw->fingerWidth, priv->avg_width);
-
- if (hw->numFingers > 1 || /* more than one finger -> not a palm */
- ((safe_width < 6) && (priv->prev_z < para->finger_high)) || /* thin finger, distinct touch -> not a palm */
- ((safe_width < 7) && (priv->prev_z < para->finger_high / 2)))/* thin finger, distinct touch -> not a palm */
- {
- /* leave finger value as is */
- } else if (hw->z > priv->prev_z + 1) /* z not stable, may be a palm */
- finger = FS_UNTOUCHED;
- else if (hw->z < priv->prev_z - 5) /* z not stable, may be a palm */
- finger = FS_UNTOUCHED;
- else if (hw->fingerWidth > para->palm_min_width) /* finger width too large -> probably palm */
- finger = FS_UNTOUCHED;
+ int safe_width = MAX(hw->fingerWidth, priv->avg_width);
+
+ if (hw->numFingers > 1 || /* more than one finger -> not a palm */
+ ((safe_width < 6) && (priv->prev_z < para->finger_high)) || /* thin finger, distinct touch -> not a palm */
+ ((safe_width < 7) && (priv->prev_z < para->finger_high / 2))) { /* thin finger, distinct touch -> not a palm */
+ /* leave finger value as is */
+ }
+ else if (hw->z > priv->prev_z + 1) /* z not stable, may be a palm */
+ finger = FS_UNTOUCHED;
+ else if (hw->z < priv->prev_z - 5) /* z not stable, may be a palm */
+ finger = FS_UNTOUCHED;
+ else if (hw->fingerWidth > para->palm_min_width) /* finger width too large -> probably palm */
+ finger = FS_UNTOUCHED;
}
priv->prev_z = hw->z;
@@ -1826,48 +1882,48 @@ SynapticsDetectFinger(SynapticsPrivate *priv, struct SynapticsHwState *hw)
}
static void
-SelectTapButton(SynapticsPrivate *priv, edge_type edge)
+SelectTapButton(SynapticsPrivate * priv, edge_type edge)
{
TapEvent tap;
if (priv->synpara.touchpad_off == 2) {
- priv->tap_button = 0;
- return;
+ priv->tap_button = 0;
+ return;
}
switch (priv->tap_max_fingers) {
case 1:
- switch (edge) {
- case RIGHT_TOP_EDGE:
- DBG(7, "right top edge\n");
- tap = RT_TAP;
- break;
- case RIGHT_BOTTOM_EDGE:
- DBG(7, "right bottom edge\n");
- tap = RB_TAP;
- break;
- case LEFT_TOP_EDGE:
- DBG(7, "left top edge\n");
- tap = LT_TAP;
- break;
- case LEFT_BOTTOM_EDGE:
- DBG(7, "left bottom edge\n");
- tap = LB_TAP;
- break;
- default:
- DBG(7, "no edge\n");
- tap = F1_TAP;
- break;
- }
- break;
+ switch (edge) {
+ case RIGHT_TOP_EDGE:
+ DBG(7, "right top edge\n");
+ tap = RT_TAP;
+ break;
+ case RIGHT_BOTTOM_EDGE:
+ DBG(7, "right bottom edge\n");
+ tap = RB_TAP;
+ break;
+ case LEFT_TOP_EDGE:
+ DBG(7, "left top edge\n");
+ tap = LT_TAP;
+ break;
+ case LEFT_BOTTOM_EDGE:
+ DBG(7, "left bottom edge\n");
+ tap = LB_TAP;
+ break;
+ default:
+ DBG(7, "no edge\n");
+ tap = F1_TAP;
+ break;
+ }
+ break;
case 2:
- DBG(7, "two finger tap\n");
- tap = F2_TAP;
- break;
+ DBG(7, "two finger tap\n");
+ tap = F2_TAP;
+ break;
case 3:
- DBG(7, "three finger tap\n");
- tap = F3_TAP;
- break;
+ DBG(7, "three finger tap\n");
+ tap = F3_TAP;
+ break;
default:
priv->tap_button = 0;
return;
@@ -1878,58 +1934,62 @@ SelectTapButton(SynapticsPrivate *priv, edge_type edge)
}
static void
-SetTapState(SynapticsPrivate *priv, enum TapState tap_state, CARD32 millis)
+SetTapState(SynapticsPrivate * priv, enum TapState tap_state, CARD32 millis)
{
SynapticsParameters *para = &priv->synpara;
- DBG(3, "SetTapState - %d -> %d (millis:%u)\n", priv->tap_state, tap_state, millis);
+
+ DBG(3, "SetTapState - %d -> %d (millis:%u)\n", priv->tap_state, tap_state,
+ millis);
switch (tap_state) {
case TS_START:
- priv->tap_button_state = TBS_BUTTON_UP;
- priv->tap_max_fingers = 0;
- break;
+ priv->tap_button_state = TBS_BUTTON_UP;
+ priv->tap_max_fingers = 0;
+ break;
case TS_1:
- priv->tap_button_state = TBS_BUTTON_UP;
- break;
+ priv->tap_button_state = TBS_BUTTON_UP;
+ break;
case TS_2A:
- if (para->fast_taps)
- priv->tap_button_state = TBS_BUTTON_DOWN;
- else
- priv->tap_button_state = TBS_BUTTON_UP;
- break;
+ if (para->fast_taps)
+ priv->tap_button_state = TBS_BUTTON_DOWN;
+ else
+ priv->tap_button_state = TBS_BUTTON_UP;
+ break;
case TS_2B:
- priv->tap_button_state = TBS_BUTTON_UP;
- break;
+ priv->tap_button_state = TBS_BUTTON_UP;
+ break;
case TS_3:
- priv->tap_button_state = TBS_BUTTON_DOWN;
- break;
+ priv->tap_button_state = TBS_BUTTON_DOWN;
+ break;
case TS_SINGLETAP:
- if (para->fast_taps)
- priv->tap_button_state = TBS_BUTTON_UP;
- else
- priv->tap_button_state = TBS_BUTTON_DOWN;
- priv->touch_on.millis = millis;
- break;
+ if (para->fast_taps)
+ priv->tap_button_state = TBS_BUTTON_UP;
+ else
+ priv->tap_button_state = TBS_BUTTON_DOWN;
+ priv->touch_on.millis = millis;
+ break;
default:
- break;
+ break;
}
priv->tap_state = tap_state;
}
static void
-SetMovingState(SynapticsPrivate *priv, enum MovingState moving_state, CARD32 millis)
+SetMovingState(SynapticsPrivate * priv, enum MovingState moving_state,
+ CARD32 millis)
{
- DBG(7, "SetMovingState - %d -> %d center at %d/%d (millis:%u)\n", priv->moving_state,
- moving_state,priv->hwState->x, priv->hwState->y, millis);
+ DBG(7, "SetMovingState - %d -> %d center at %d/%d (millis:%u)\n",
+ priv->moving_state, moving_state, priv->hwState->x, priv->hwState->y,
+ millis);
if (moving_state == MS_TRACKSTICK) {
- priv->trackstick_neutral_x = priv->hwState->x;
- priv->trackstick_neutral_y = priv->hwState->y;
+ priv->trackstick_neutral_x = priv->hwState->x;
+ priv->trackstick_neutral_y = priv->hwState->y;
}
priv->moving_state = moving_state;
}
static int
-GetTimeOut(SynapticsPrivate *priv)
+GetTimeOut(SynapticsPrivate * priv)
{
SynapticsParameters *para = &priv->synpara;
@@ -1937,24 +1997,24 @@ GetTimeOut(SynapticsPrivate *priv)
case TS_1:
case TS_3:
case TS_5:
- return para->tap_time;
+ return para->tap_time;
case TS_SINGLETAP:
- return para->click_time;
+ return para->click_time;
case TS_2A:
- return para->single_tap_timeout;
+ return para->single_tap_timeout;
case TS_2B:
- return para->tap_time_2;
+ return para->tap_time_2;
case TS_4:
- return para->locked_drag_time;
+ return para->locked_drag_time;
default:
- return -1; /* No timeout */
+ return -1; /* No timeout */
}
}
static int
-HandleTapProcessing(SynapticsPrivate *priv, struct SynapticsHwState *hw,
- CARD32 now, enum FingerState finger,
- Bool inside_active_area)
+HandleTapProcessing(SynapticsPrivate * priv, struct SynapticsHwState *hw,
+ CARD32 now, enum FingerState finger,
+ Bool inside_active_area)
{
SynapticsParameters *para = &priv->synpara;
Bool touch, release, is_timeout, move, press;
@@ -1963,26 +2023,29 @@ HandleTapProcessing(SynapticsPrivate *priv, struct SynapticsHwState *hw,
int delay = 1000000000;
if (priv->finger_state == FS_BLOCKED)
- return delay;
+ return delay;
touch = finger >= FS_TOUCHED && priv->finger_state == FS_UNTOUCHED;
release = finger == FS_UNTOUCHED && priv->finger_state >= FS_TOUCHED;
move = (finger >= FS_TOUCHED &&
- (priv->tap_max_fingers <= ((priv->horiz_scroll_twofinger_on || priv->vert_scroll_twofinger_on)? 2 : 1)) &&
- ((abs(hw->x - priv->touch_on.x) >= para->tap_move) ||
- (abs(hw->y - priv->touch_on.y) >= para->tap_move)));
+ (priv->tap_max_fingers <=
+ ((priv->horiz_scroll_twofinger_on ||
+ priv->vert_scroll_twofinger_on) ? 2 : 1)) &&
+ ((abs(hw->x - priv->touch_on.x) >= para->tap_move) ||
+ (abs(hw->y - priv->touch_on.y) >= para->tap_move)));
press = (hw->left || hw->right || hw->middle);
if (touch) {
- priv->touch_on.x = hw->x;
- priv->touch_on.y = hw->y;
- priv->touch_on.millis = now;
- } else if (release) {
- priv->touch_on.millis = now;
+ priv->touch_on.x = hw->x;
+ priv->touch_on.y = hw->y;
+ priv->touch_on.millis = now;
+ }
+ else if (release) {
+ priv->touch_on.millis = now;
}
if (hw->z > para->finger_high)
- if (priv->tap_max_fingers < hw->numFingers)
- priv->tap_max_fingers = hw->numFingers;
+ if (priv->tap_max_fingers < hw->numFingers)
+ priv->tap_max_fingers = hw->numFingers;
timeout = GetTimeOut(priv);
timeleft = TIME_DIFF(priv->touch_on.millis + timeout, now);
is_timeout = timeleft <= 0;
@@ -1990,150 +2053,161 @@ HandleTapProcessing(SynapticsPrivate *priv, struct SynapticsHwState *hw,
restart:
switch (priv->tap_state) {
case TS_START:
- if (touch)
- SetTapState(priv, TS_1, now);
- break;
+ if (touch)
+ SetTapState(priv, TS_1, now);
+ break;
case TS_1:
- if (para->clickpad && press) {
- SetTapState(priv, TS_CLICKPAD_MOVE, now);
- goto restart;
- }
- if (move) {
- SetMovingState(priv, MS_TOUCHPAD_RELATIVE, now);
- SetTapState(priv, TS_MOVE, now);
- goto restart;
- } else if (is_timeout) {
- if (finger == FS_TOUCHED) {
- SetMovingState(priv, MS_TOUCHPAD_RELATIVE, now);
- } else if (finger == FS_PRESSED) {
- SetMovingState(priv, MS_TRACKSTICK, now);
- }
- SetTapState(priv, TS_MOVE, now);
- goto restart;
- } else if (release) {
- edge = edge_detection(priv, priv->touch_on.x, priv->touch_on.y);
- SelectTapButton(priv, edge);
- /* Disable taps outside of the active area */
- if (!inside_active_area) {
- priv->tap_button = 0;
- }
- SetTapState(priv, TS_2A, now);
- }
- break;
+ if (para->clickpad && press) {
+ SetTapState(priv, TS_CLICKPAD_MOVE, now);
+ goto restart;
+ }
+ if (move) {
+ SetMovingState(priv, MS_TOUCHPAD_RELATIVE, now);
+ SetTapState(priv, TS_MOVE, now);
+ goto restart;
+ }
+ else if (is_timeout) {
+ if (finger == FS_TOUCHED) {
+ SetMovingState(priv, MS_TOUCHPAD_RELATIVE, now);
+ }
+ else if (finger == FS_PRESSED) {
+ SetMovingState(priv, MS_TRACKSTICK, now);
+ }
+ SetTapState(priv, TS_MOVE, now);
+ goto restart;
+ }
+ else if (release) {
+ edge = edge_detection(priv, priv->touch_on.x, priv->touch_on.y);
+ SelectTapButton(priv, edge);
+ /* Disable taps outside of the active area */
+ if (!inside_active_area) {
+ priv->tap_button = 0;
+ }
+ SetTapState(priv, TS_2A, now);
+ }
+ break;
case TS_MOVE:
- if (para->clickpad && press) {
- SetTapState(priv, TS_CLICKPAD_MOVE, now);
- goto restart;
- }
- if (move && priv->moving_state == MS_TRACKSTICK) {
- SetMovingState(priv, MS_TOUCHPAD_RELATIVE, now);
- }
- if (release) {
- SetMovingState(priv, MS_FALSE, now);
- SetTapState(priv, TS_START, now);
- }
- break;
+ if (para->clickpad && press) {
+ SetTapState(priv, TS_CLICKPAD_MOVE, now);
+ goto restart;
+ }
+ if (move && priv->moving_state == MS_TRACKSTICK) {
+ SetMovingState(priv, MS_TOUCHPAD_RELATIVE, now);
+ }
+ if (release) {
+ SetMovingState(priv, MS_FALSE, now);
+ SetTapState(priv, TS_START, now);
+ }
+ break;
case TS_2A:
- if (touch)
- SetTapState(priv, TS_3, now);
- else if (is_timeout)
- SetTapState(priv, TS_SINGLETAP, now);
- break;
+ if (touch)
+ SetTapState(priv, TS_3, now);
+ else if (is_timeout)
+ SetTapState(priv, TS_SINGLETAP, now);
+ break;
case TS_2B:
- if (touch) {
- SetTapState(priv, TS_3, now);
- } else if (is_timeout) {
- SetTapState(priv, TS_START, now);
- priv->tap_button_state = TBS_BUTTON_DOWN_UP;
- }
- break;
+ if (touch) {
+ SetTapState(priv, TS_3, now);
+ }
+ else if (is_timeout) {
+ SetTapState(priv, TS_START, now);
+ priv->tap_button_state = TBS_BUTTON_DOWN_UP;
+ }
+ break;
case TS_SINGLETAP:
- if (touch)
- SetTapState(priv, TS_1, now);
- else if (is_timeout)
- SetTapState(priv, TS_START, now);
- break;
+ if (touch)
+ SetTapState(priv, TS_1, now);
+ else if (is_timeout)
+ SetTapState(priv, TS_START, now);
+ break;
case TS_3:
- if (move) {
- if (para->tap_and_drag_gesture) {
- SetMovingState(priv, MS_TOUCHPAD_RELATIVE, now);
- SetTapState(priv, TS_DRAG, now);
- } else {
- SetTapState(priv, TS_1, now);
- }
- goto restart;
- } else if (is_timeout) {
- if (para->tap_and_drag_gesture) {
- if (finger == FS_TOUCHED) {
- SetMovingState(priv, MS_TOUCHPAD_RELATIVE, now);
- } else if (finger == FS_PRESSED) {
- SetMovingState(priv, MS_TRACKSTICK, now);
- }
- SetTapState(priv, TS_DRAG, now);
- } else {
- SetTapState(priv, TS_1, now);
- }
- goto restart;
- } else if (release) {
- SetTapState(priv, TS_2B, now);
- }
- break;
+ if (move) {
+ if (para->tap_and_drag_gesture) {
+ SetMovingState(priv, MS_TOUCHPAD_RELATIVE, now);
+ SetTapState(priv, TS_DRAG, now);
+ }
+ else {
+ SetTapState(priv, TS_1, now);
+ }
+ goto restart;
+ }
+ else if (is_timeout) {
+ if (para->tap_and_drag_gesture) {
+ if (finger == FS_TOUCHED) {
+ SetMovingState(priv, MS_TOUCHPAD_RELATIVE, now);
+ }
+ else if (finger == FS_PRESSED) {
+ SetMovingState(priv, MS_TRACKSTICK, now);
+ }
+ SetTapState(priv, TS_DRAG, now);
+ }
+ else {
+ SetTapState(priv, TS_1, now);
+ }
+ goto restart;
+ }
+ else if (release) {
+ SetTapState(priv, TS_2B, now);
+ }
+ break;
case TS_DRAG:
- if (para->clickpad && press) {
- SetTapState(priv, TS_CLICKPAD_MOVE, now);
- goto restart;
- }
- if (move)
- SetMovingState(priv, MS_TOUCHPAD_RELATIVE, now);
- if (release) {
- SetMovingState(priv, MS_FALSE, now);
- if (para->locked_drags) {
- SetTapState(priv, TS_4, now);
- } else {
- SetTapState(priv, TS_START, now);
- }
- }
- break;
+ if (para->clickpad && press) {
+ SetTapState(priv, TS_CLICKPAD_MOVE, now);
+ goto restart;
+ }
+ if (move)
+ SetMovingState(priv, MS_TOUCHPAD_RELATIVE, now);
+ if (release) {
+ SetMovingState(priv, MS_FALSE, now);
+ if (para->locked_drags) {
+ SetTapState(priv, TS_4, now);
+ }
+ else {
+ SetTapState(priv, TS_START, now);
+ }
+ }
+ break;
case TS_4:
- if (is_timeout) {
- SetTapState(priv, TS_START, now);
- goto restart;
- }
- if (touch)
- SetTapState(priv, TS_5, now);
- break;
+ if (is_timeout) {
+ SetTapState(priv, TS_START, now);
+ goto restart;
+ }
+ if (touch)
+ SetTapState(priv, TS_5, now);
+ break;
case TS_5:
- if (is_timeout || move) {
- SetTapState(priv, TS_DRAG, now);
- goto restart;
- } else if (release) {
- SetMovingState(priv, MS_FALSE, now);
- SetTapState(priv, TS_START, now);
- }
- break;
+ if (is_timeout || move) {
+ SetTapState(priv, TS_DRAG, now);
+ goto restart;
+ }
+ else if (release) {
+ SetMovingState(priv, MS_FALSE, now);
+ SetTapState(priv, TS_START, now);
+ }
+ break;
case TS_CLICKPAD_MOVE:
- /* Disable scrolling once a button is pressed on a clickpad */
- priv->vert_scroll_edge_on = FALSE;
- priv->horiz_scroll_edge_on = FALSE;
- priv->vert_scroll_twofinger_on = FALSE;
- priv->horiz_scroll_twofinger_on = FALSE;
+ /* Disable scrolling once a button is pressed on a clickpad */
+ priv->vert_scroll_edge_on = FALSE;
+ priv->horiz_scroll_edge_on = FALSE;
+ priv->vert_scroll_twofinger_on = FALSE;
+ priv->horiz_scroll_twofinger_on = FALSE;
/* Assume one touch is only for holding the clickpad button down */
- if (hw->numFingers > 1)
- hw->numFingers--;
- SetMovingState(priv, MS_TOUCHPAD_RELATIVE, now);
- if (!press) {
- SetMovingState(priv, MS_FALSE, now);
- SetTapState(priv, TS_MOVE, now);
- priv->count_packet_finger = 0;
- }
- break;
+ if (hw->numFingers > 1)
+ hw->numFingers--;
+ SetMovingState(priv, MS_TOUCHPAD_RELATIVE, now);
+ if (!press) {
+ SetMovingState(priv, MS_FALSE, now);
+ SetTapState(priv, TS_MOVE, now);
+ priv->count_packet_finger = 0;
+ }
+ break;
}
timeout = GetTimeOut(priv);
if (timeout >= 0) {
- timeleft = TIME_DIFF(priv->touch_on.millis + timeout, now);
- delay = clamp(timeleft, 1, delay);
+ timeleft = TIME_DIFF(priv->touch_on.millis + timeout, now);
+ delay = clamp(timeleft, 1, delay);
}
return delay;
}
@@ -2142,9 +2216,10 @@ HandleTapProcessing(SynapticsPrivate *priv, struct SynapticsHwState *hw,
#define HIST_DELTA(a, b, e) ((HIST((a)).e) - (HIST((b)).e))
static void
-store_history(SynapticsPrivate *priv, int x, int y, CARD32 millis)
+store_history(SynapticsPrivate * priv, int x, int y, CARD32 millis)
{
int idx = (priv->hist_index + 1) % SYNAPTICS_MOVE_HISTORY;
+
priv->move_hist[idx].x = x;
priv->move_hist[idx].y = y;
priv->move_hist[idx].millis = millis;
@@ -2172,21 +2247,27 @@ estimate_delta(double x0, double x1, double x2, double x3)
* @param margin the margin to center in which no change is applied
* @return the new center (which might coincide with the previous)
*/
-static int hysteresis(int in, int center, int margin) {
+static int
+hysteresis(int in, int center, int margin)
+{
int diff = in - center;
+
if (abs(diff) <= margin) {
- diff = 0;
- } else if (diff > margin) {
- diff -= margin;
- } else if (diff < -margin) {
- diff += margin;
+ diff = 0;
+ }
+ else if (diff > margin) {
+ diff -= margin;
+ }
+ else if (diff < -margin) {
+ diff += margin;
}
return center + diff;
}
static void
-get_delta_for_trackstick(SynapticsPrivate *priv, const struct SynapticsHwState *hw,
- double *dx, double *dy)
+get_delta_for_trackstick(SynapticsPrivate * priv,
+ const struct SynapticsHwState *hw, double *dx,
+ double *dy)
{
SynapticsParameters *para = &priv->synpara;
double dtime = (hw->millis - HIST(0).millis) / 1000.0;
@@ -2199,7 +2280,7 @@ get_delta_for_trackstick(SynapticsPrivate *priv, const struct SynapticsHwState *
}
static void
-get_edge_speed(SynapticsPrivate *priv, const struct SynapticsHwState *hw,
+get_edge_speed(SynapticsPrivate * priv, const struct SynapticsHwState *hw,
edge_type edge, int *x_edge_speed, int *y_edge_speed)
{
SynapticsParameters *para = &priv->synpara;
@@ -2212,35 +2293,41 @@ get_edge_speed(SynapticsPrivate *priv, const struct SynapticsHwState *hw,
if (hw->z <= minZ) {
edge_speed = minSpd;
- } else if (hw->z >= maxZ) {
+ }
+ else if (hw->z >= maxZ) {
edge_speed = maxSpd;
- } else {
- edge_speed = minSpd + (hw->z - minZ) * (maxSpd - minSpd) / (maxZ - minZ);
+ }
+ else {
+ edge_speed =
+ minSpd + (hw->z - minZ) * (maxSpd - minSpd) / (maxZ - minZ);
}
if (!priv->synpara.circular_pad) {
/* on rectangular pad */
if (edge & RIGHT_EDGE) {
*x_edge_speed = edge_speed;
- } else if (edge & LEFT_EDGE) {
+ }
+ else if (edge & LEFT_EDGE) {
*x_edge_speed = -edge_speed;
}
if (edge & TOP_EDGE) {
*y_edge_speed = -edge_speed;
- } else if (edge & BOTTOM_EDGE) {
+ }
+ else if (edge & BOTTOM_EDGE) {
*y_edge_speed = edge_speed;
}
- } else if (edge) {
+ }
+ else if (edge) {
/* at edge of circular pad */
double relX, relY;
relative_coords(priv, hw->x, hw->y, &relX, &relY);
- *x_edge_speed = (int)(edge_speed * relX);
- *y_edge_speed = (int)(edge_speed * relY);
+ *x_edge_speed = (int) (edge_speed * relX);
+ *y_edge_speed = (int) (edge_speed * relY);
}
}
static void
-get_delta(SynapticsPrivate *priv, const struct SynapticsHwState *hw,
+get_delta(SynapticsPrivate * priv, const struct SynapticsHwState *hw,
edge_type edge, double *dx, double *dy)
{
SynapticsParameters *para = &priv->synpara;
@@ -2278,8 +2365,8 @@ get_delta(SynapticsPrivate *priv, const struct SynapticsHwState *hw,
* Compute relative motion ('deltas') including edge motion xor trackstick.
*/
static int
-ComputeDeltas(SynapticsPrivate *priv, const struct SynapticsHwState *hw,
- edge_type edge, int *dxP, int *dyP, Bool inside_area)
+ComputeDeltas(SynapticsPrivate * priv, const struct SynapticsHwState *hw,
+ edge_type edge, int *dxP, int *dyP, Bool inside_area)
{
enum MovingState moving_state;
double dx, dy;
@@ -2289,27 +2376,26 @@ ComputeDeltas(SynapticsPrivate *priv, const struct SynapticsHwState *hw,
moving_state = priv->moving_state;
if (moving_state == MS_FALSE) {
- switch (priv->tap_state) {
- case TS_MOVE:
- case TS_DRAG:
- moving_state = MS_TOUCHPAD_RELATIVE;
- break;
- case TS_1:
- case TS_3:
- case TS_5:
- moving_state = MS_TOUCHPAD_RELATIVE;
- break;
- default:
- break;
- }
+ switch (priv->tap_state) {
+ case TS_MOVE:
+ case TS_DRAG:
+ moving_state = MS_TOUCHPAD_RELATIVE;
+ break;
+ case TS_1:
+ case TS_3:
+ case TS_5:
+ moving_state = MS_TOUCHPAD_RELATIVE;
+ break;
+ default:
+ break;
+ }
}
if (!inside_area || !moving_state || priv->finger_state == FS_BLOCKED ||
- priv->vert_scroll_edge_on || priv->horiz_scroll_edge_on ||
- priv->vert_scroll_twofinger_on || priv->horiz_scroll_twofinger_on ||
- priv->circ_scroll_on || priv->prevFingers != hw->numFingers ||
- (moving_state == MS_TOUCHPAD_RELATIVE && hw->numFingers != 1))
- {
+ priv->vert_scroll_edge_on || priv->horiz_scroll_edge_on ||
+ priv->vert_scroll_twofinger_on || priv->horiz_scroll_twofinger_on ||
+ priv->circ_scroll_on || priv->prevFingers != hw->numFingers ||
+ (moving_state == MS_TOUCHPAD_RELATIVE && hw->numFingers != 1)) {
/* reset packet counter. */
priv->count_packet_finger = 0;
goto out;
@@ -2321,14 +2407,14 @@ ComputeDeltas(SynapticsPrivate *priv, const struct SynapticsHwState *hw,
delay = MIN(delay, POLL_MS);
if (priv->count_packet_finger <= 1)
- goto out; /* skip the lot */
+ goto out; /* skip the lot */
if (priv->moving_state == MS_TRACKSTICK)
get_delta_for_trackstick(priv, hw, &dx, &dy);
else if (moving_state == MS_TOUCHPAD_RELATIVE)
get_delta(priv, hw, edge, &dx, &dy);
-out:
+ out:
priv->prevFingers = hw->numFingers;
*dxP = dx;
@@ -2338,24 +2424,25 @@ out:
}
static double
-estimate_delta_circ(SynapticsPrivate *priv)
+estimate_delta_circ(SynapticsPrivate * priv)
{
- double a1 = angle(priv, HIST(3).x, HIST(3).y);
- double a2 = angle(priv, HIST(2).x, HIST(2).y);
- double a3 = angle(priv, HIST(1).x, HIST(1).y);
- double a4 = angle(priv, HIST(0).x, HIST(0).y);
- double d1 = diffa(a2, a1);
- double d2 = d1 + diffa(a3, a2);
- double d3 = d2 + diffa(a4, a3);
- return estimate_delta(d3, d2, d1, 0);
+ double a1 = angle(priv, HIST(3).x, HIST(3).y);
+ double a2 = angle(priv, HIST(2).x, HIST(2).y);
+ double a3 = angle(priv, HIST(1).x, HIST(1).y);
+ double a4 = angle(priv, HIST(0).x, HIST(0).y);
+ double d1 = diffa(a2, a1);
+ double d2 = d1 + diffa(a3, a2);
+ double d3 = d2 + diffa(a4, a3);
+
+ return estimate_delta(d3, d2, d1, 0);
}
/* vert and horiz are to know which direction to start coasting
* circ is true if the user had been circular scrolling.
*/
static void
-start_coasting(SynapticsPrivate *priv, struct SynapticsHwState *hw,
- Bool vert, Bool horiz, Bool circ)
+start_coasting(SynapticsPrivate * priv, struct SynapticsHwState *hw,
+ Bool vert, Bool horiz, Bool circ)
{
SynapticsParameters *para = &priv->synpara;
@@ -2363,49 +2450,60 @@ start_coasting(SynapticsPrivate *priv, struct SynapticsHwState *hw,
priv->scroll.coast_delta_x = 0.0;
if ((priv->scroll.packets_this_scroll > 3) && (para->coasting_speed > 0.0)) {
- double pkt_time = HIST_DELTA(0, 3, millis) / 1000.0;
- if (vert && !circ) {
- double dy = estimate_delta(HIST(0).y, HIST(1).y, HIST(2).y, HIST(3).y);
- if (pkt_time > 0) {
- double scrolls_per_sec = dy / pkt_time;
- if (fabs(scrolls_per_sec) >= para->coasting_speed) {
- priv->scroll.coast_speed_y = scrolls_per_sec;
- priv->scroll.coast_delta_y = (hw->y - priv->scroll.last_y);
- }
- }
- }
- if (horiz && !circ){
- double dx = estimate_delta(HIST(0).x, HIST(1).x, HIST(2).x, HIST(3).x);
- if (pkt_time > 0) {
- double scrolls_per_sec = dx / pkt_time;
- if (fabs(scrolls_per_sec) >= para->coasting_speed) {
- priv->scroll.coast_speed_x = scrolls_per_sec;
- priv->scroll.coast_delta_x = (hw->x - priv->scroll.last_x);
- }
- }
- }
- if (circ) {
- double da = estimate_delta_circ(priv);
- if (pkt_time > 0) {
- double scrolls_per_sec = da / pkt_time;
- if (fabs(scrolls_per_sec) >= para->coasting_speed) {
- if (vert) {
- priv->scroll.coast_speed_y = scrolls_per_sec;
- priv->scroll.coast_delta_y = diffa(priv->scroll.last_a, angle(priv, hw->x, hw->y));
- }
- else if (horiz) {
- priv->scroll.coast_speed_x = scrolls_per_sec;
- priv->scroll.coast_delta_x = diffa(priv->scroll.last_a, angle(priv, hw->x, hw->y));
- }
- }
- }
- }
+ double pkt_time = HIST_DELTA(0, 3, millis) / 1000.0;
+
+ if (vert && !circ) {
+ double dy =
+ estimate_delta(HIST(0).y, HIST(1).y, HIST(2).y, HIST(3).y);
+ if (pkt_time > 0) {
+ double scrolls_per_sec = dy / pkt_time;
+
+ if (fabs(scrolls_per_sec) >= para->coasting_speed) {
+ priv->scroll.coast_speed_y = scrolls_per_sec;
+ priv->scroll.coast_delta_y = (hw->y - priv->scroll.last_y);
+ }
+ }
+ }
+ if (horiz && !circ) {
+ double dx =
+ estimate_delta(HIST(0).x, HIST(1).x, HIST(2).x, HIST(3).x);
+ if (pkt_time > 0) {
+ double scrolls_per_sec = dx / pkt_time;
+
+ if (fabs(scrolls_per_sec) >= para->coasting_speed) {
+ priv->scroll.coast_speed_x = scrolls_per_sec;
+ priv->scroll.coast_delta_x = (hw->x - priv->scroll.last_x);
+ }
+ }
+ }
+ if (circ) {
+ double da = estimate_delta_circ(priv);
+
+ if (pkt_time > 0) {
+ double scrolls_per_sec = da / pkt_time;
+
+ if (fabs(scrolls_per_sec) >= para->coasting_speed) {
+ if (vert) {
+ priv->scroll.coast_speed_y = scrolls_per_sec;
+ priv->scroll.coast_delta_y =
+ diffa(priv->scroll.last_a,
+ angle(priv, hw->x, hw->y));
+ }
+ else if (horiz) {
+ priv->scroll.coast_speed_x = scrolls_per_sec;
+ priv->scroll.coast_delta_x =
+ diffa(priv->scroll.last_a,
+ angle(priv, hw->x, hw->y));
+ }
+ }
+ }
+ }
}
priv->scroll.packets_this_scroll = 0;
}
static void
-stop_coasting(SynapticsPrivate *priv)
+stop_coasting(SynapticsPrivate * priv)
{
priv->scroll.coast_speed_x = 0;
priv->scroll.coast_speed_y = 0;
@@ -2413,241 +2511,262 @@ stop_coasting(SynapticsPrivate *priv)
}
static int
-HandleScrolling(SynapticsPrivate *priv, struct SynapticsHwState *hw,
- edge_type edge, Bool finger)
+HandleScrolling(SynapticsPrivate * priv, struct SynapticsHwState *hw,
+ edge_type edge, Bool finger)
{
SynapticsParameters *para = &priv->synpara;
int delay = 1000000000;
if ((priv->synpara.touchpad_off == 2) || (priv->finger_state == FS_BLOCKED)) {
- stop_coasting(priv);
- priv->circ_scroll_on = FALSE;
- priv->vert_scroll_edge_on = FALSE;
- priv->horiz_scroll_edge_on = FALSE;
- priv->vert_scroll_twofinger_on = FALSE;
- priv->horiz_scroll_twofinger_on = FALSE;
- return delay;
+ stop_coasting(priv);
+ priv->circ_scroll_on = FALSE;
+ priv->vert_scroll_edge_on = FALSE;
+ priv->horiz_scroll_edge_on = FALSE;
+ priv->vert_scroll_twofinger_on = FALSE;
+ priv->horiz_scroll_twofinger_on = FALSE;
+ return delay;
}
/* scroll detection */
if (finger && priv->finger_state == FS_UNTOUCHED) {
- stop_coasting(priv);
+ stop_coasting(priv);
priv->scroll.delta_y = 0;
priv->scroll.delta_x = 0;
- if (para->circular_scrolling) {
- if ((para->circular_trigger == 0 && edge) ||
- (para->circular_trigger == 1 && edge & TOP_EDGE) ||
- (para->circular_trigger == 2 && edge & TOP_EDGE && edge & RIGHT_EDGE) ||
- (para->circular_trigger == 3 && edge & RIGHT_EDGE) ||
- (para->circular_trigger == 4 && edge & RIGHT_EDGE && edge & BOTTOM_EDGE) ||
- (para->circular_trigger == 5 && edge & BOTTOM_EDGE) ||
- (para->circular_trigger == 6 && edge & BOTTOM_EDGE && edge & LEFT_EDGE) ||
- (para->circular_trigger == 7 && edge & LEFT_EDGE) ||
- (para->circular_trigger == 8 && edge & LEFT_EDGE && edge & TOP_EDGE)) {
- priv->circ_scroll_on = TRUE;
- priv->circ_scroll_vert = TRUE;
- priv->scroll.last_a = angle(priv, hw->x, hw->y);
- DBG(7, "circular scroll detected on edge\n");
- }
- }
+ if (para->circular_scrolling) {
+ if ((para->circular_trigger == 0 && edge) ||
+ (para->circular_trigger == 1 && edge & TOP_EDGE) ||
+ (para->circular_trigger == 2 && edge & TOP_EDGE &&
+ edge & RIGHT_EDGE) || (para->circular_trigger == 3 &&
+ edge & RIGHT_EDGE) ||
+ (para->circular_trigger == 4 && edge & RIGHT_EDGE &&
+ edge & BOTTOM_EDGE) || (para->circular_trigger == 5 &&
+ edge & BOTTOM_EDGE) ||
+ (para->circular_trigger == 6 && edge & BOTTOM_EDGE &&
+ edge & LEFT_EDGE) || (para->circular_trigger == 7 &&
+ edge & LEFT_EDGE) ||
+ (para->circular_trigger == 8 && edge & LEFT_EDGE &&
+ edge & TOP_EDGE)) {
+ priv->circ_scroll_on = TRUE;
+ priv->circ_scroll_vert = TRUE;
+ priv->scroll.last_a = angle(priv, hw->x, hw->y);
+ DBG(7, "circular scroll detected on edge\n");
+ }
+ }
}
if (!priv->circ_scroll_on) {
- if (finger) {
- if (hw->numFingers == 2) {
- if (!priv->vert_scroll_twofinger_on &&
- (para->scroll_twofinger_vert) && (para->scroll_dist_vert != 0)) {
- stop_coasting(priv);
- priv->vert_scroll_twofinger_on = TRUE;
- priv->vert_scroll_edge_on = FALSE;
- priv->scroll.last_y = hw->y;
- DBG(7, "vert two-finger scroll detected\n");
- }
- if (!priv->horiz_scroll_twofinger_on &&
- (para->scroll_twofinger_horiz) && (para->scroll_dist_horiz != 0)) {
- stop_coasting(priv);
- priv->horiz_scroll_twofinger_on = TRUE;
- priv->horiz_scroll_edge_on = FALSE;
- priv->scroll.last_x = hw->x;
- DBG(7, "horiz two-finger scroll detected\n");
- }
- }
- }
- if (finger && priv->finger_state == FS_UNTOUCHED) {
- if (!priv->vert_scroll_twofinger_on && !priv->horiz_scroll_twofinger_on) {
- if ((para->scroll_edge_vert) && (para->scroll_dist_vert != 0) &&
- (edge & RIGHT_EDGE)) {
- priv->vert_scroll_edge_on = TRUE;
- priv->scroll.last_y = hw->y;
- DBG(7, "vert edge scroll detected on right edge\n");
- }
- if ((para->scroll_edge_horiz) && (para->scroll_dist_horiz != 0) &&
- (edge & BOTTOM_EDGE)) {
- priv->horiz_scroll_edge_on = TRUE;
- priv->scroll.last_x = hw->x;
- DBG(7, "horiz edge scroll detected on bottom edge\n");
- }
- }
- }
+ if (finger) {
+ if (hw->numFingers == 2) {
+ if (!priv->vert_scroll_twofinger_on &&
+ (para->scroll_twofinger_vert) &&
+ (para->scroll_dist_vert != 0)) {
+ stop_coasting(priv);
+ priv->vert_scroll_twofinger_on = TRUE;
+ priv->vert_scroll_edge_on = FALSE;
+ priv->scroll.last_y = hw->y;
+ DBG(7, "vert two-finger scroll detected\n");
+ }
+ if (!priv->horiz_scroll_twofinger_on &&
+ (para->scroll_twofinger_horiz) &&
+ (para->scroll_dist_horiz != 0)) {
+ stop_coasting(priv);
+ priv->horiz_scroll_twofinger_on = TRUE;
+ priv->horiz_scroll_edge_on = FALSE;
+ priv->scroll.last_x = hw->x;
+ DBG(7, "horiz two-finger scroll detected\n");
+ }
+ }
+ }
+ if (finger && priv->finger_state == FS_UNTOUCHED) {
+ if (!priv->vert_scroll_twofinger_on &&
+ !priv->horiz_scroll_twofinger_on) {
+ if ((para->scroll_edge_vert) && (para->scroll_dist_vert != 0) &&
+ (edge & RIGHT_EDGE)) {
+ priv->vert_scroll_edge_on = TRUE;
+ priv->scroll.last_y = hw->y;
+ DBG(7, "vert edge scroll detected on right edge\n");
+ }
+ if ((para->scroll_edge_horiz) && (para->scroll_dist_horiz != 0)
+ && (edge & BOTTOM_EDGE)) {
+ priv->horiz_scroll_edge_on = TRUE;
+ priv->scroll.last_x = hw->x;
+ DBG(7, "horiz edge scroll detected on bottom edge\n");
+ }
+ }
+ }
}
{
- Bool oldv = priv->vert_scroll_twofinger_on || priv->vert_scroll_edge_on ||
- (priv->circ_scroll_on && priv->circ_scroll_vert);
-
- Bool oldh = priv->horiz_scroll_twofinger_on || priv->horiz_scroll_edge_on ||
- (priv->circ_scroll_on && !priv->circ_scroll_vert);
-
- Bool oldc = priv->circ_scroll_on;
-
- if (priv->circ_scroll_on && !finger) {
- /* circular scroll locks in until finger is raised */
- DBG(7, "cicular scroll off\n");
- priv->circ_scroll_on = FALSE;
- }
-
- if (!finger || hw->numFingers != 2) {
- if (priv->vert_scroll_twofinger_on) {
- DBG(7, "vert two-finger scroll off\n");
- priv->vert_scroll_twofinger_on = FALSE;
- }
- if (priv->horiz_scroll_twofinger_on) {
- DBG(7, "horiz two-finger scroll off\n");
- priv->horiz_scroll_twofinger_on = FALSE;
- }
- }
-
- if (priv->vert_scroll_edge_on && (!(edge & RIGHT_EDGE) || !finger)) {
- DBG(7, "vert edge scroll off\n");
- priv->vert_scroll_edge_on = FALSE;
- }
- if (priv->horiz_scroll_edge_on && (!(edge & BOTTOM_EDGE) || !finger)) {
- DBG(7, "horiz edge scroll off\n");
- priv->horiz_scroll_edge_on = FALSE;
- }
- /* If we were corner edge scrolling (coasting),
- * but no longer in corner or raised a finger, then stop coasting. */
- if (para->scroll_edge_corner && (priv->scroll.coast_speed_x || priv->scroll.coast_speed_y)) {
- Bool is_in_corner =
- ((edge & RIGHT_EDGE) && (edge & (TOP_EDGE | BOTTOM_EDGE))) ||
- ((edge & BOTTOM_EDGE) && (edge & (LEFT_EDGE | RIGHT_EDGE))) ;
- if (!is_in_corner || !finger) {
- DBG(7, "corner edge scroll off\n");
- stop_coasting(priv);
- }
- }
- /* if we were scrolling, but couldn't corner edge scroll,
- * and are no longer scrolling, then start coasting */
- oldv = oldv && !(priv->vert_scroll_twofinger_on || priv->vert_scroll_edge_on ||
- (priv->circ_scroll_on && priv->circ_scroll_vert));
-
- oldh = oldh && !(priv->horiz_scroll_twofinger_on || priv->horiz_scroll_edge_on ||
- (priv->circ_scroll_on && !priv->circ_scroll_vert));
-
- oldc = oldc && !priv->circ_scroll_on;
-
- if ((oldv || oldh) && !para->scroll_edge_corner) {
- start_coasting(priv, hw, oldv, oldh, oldc);
- }
+ Bool oldv = priv->vert_scroll_twofinger_on || priv->vert_scroll_edge_on
+ || (priv->circ_scroll_on && priv->circ_scroll_vert);
+
+ Bool oldh = priv->horiz_scroll_twofinger_on ||
+ priv->horiz_scroll_edge_on || (priv->circ_scroll_on &&
+ !priv->circ_scroll_vert);
+
+ Bool oldc = priv->circ_scroll_on;
+
+ if (priv->circ_scroll_on && !finger) {
+ /* circular scroll locks in until finger is raised */
+ DBG(7, "cicular scroll off\n");
+ priv->circ_scroll_on = FALSE;
+ }
+
+ if (!finger || hw->numFingers != 2) {
+ if (priv->vert_scroll_twofinger_on) {
+ DBG(7, "vert two-finger scroll off\n");
+ priv->vert_scroll_twofinger_on = FALSE;
+ }
+ if (priv->horiz_scroll_twofinger_on) {
+ DBG(7, "horiz two-finger scroll off\n");
+ priv->horiz_scroll_twofinger_on = FALSE;
+ }
+ }
+
+ if (priv->vert_scroll_edge_on && (!(edge & RIGHT_EDGE) || !finger)) {
+ DBG(7, "vert edge scroll off\n");
+ priv->vert_scroll_edge_on = FALSE;
+ }
+ if (priv->horiz_scroll_edge_on && (!(edge & BOTTOM_EDGE) || !finger)) {
+ DBG(7, "horiz edge scroll off\n");
+ priv->horiz_scroll_edge_on = FALSE;
+ }
+ /* If we were corner edge scrolling (coasting),
+ * but no longer in corner or raised a finger, then stop coasting. */
+ if (para->scroll_edge_corner &&
+ (priv->scroll.coast_speed_x || priv->scroll.coast_speed_y)) {
+ Bool is_in_corner = ((edge & RIGHT_EDGE) &&
+ (edge & (TOP_EDGE | BOTTOM_EDGE))) ||
+ ((edge & BOTTOM_EDGE) && (edge & (LEFT_EDGE | RIGHT_EDGE)));
+ if (!is_in_corner || !finger) {
+ DBG(7, "corner edge scroll off\n");
+ stop_coasting(priv);
+ }
+ }
+ /* if we were scrolling, but couldn't corner edge scroll,
+ * and are no longer scrolling, then start coasting */
+ oldv = oldv && !(priv->vert_scroll_twofinger_on ||
+ priv->vert_scroll_edge_on || (priv->circ_scroll_on &&
+ priv->circ_scroll_vert));
+
+ oldh = oldh && !(priv->horiz_scroll_twofinger_on ||
+ priv->horiz_scroll_edge_on || (priv->circ_scroll_on &&
+ !priv->
+ circ_scroll_vert));
+
+ oldc = oldc && !priv->circ_scroll_on;
+
+ if ((oldv || oldh) && !para->scroll_edge_corner) {
+ start_coasting(priv, hw, oldv, oldh, oldc);
+ }
}
/* if hitting a corner (top right or bottom right) while vertical
* scrolling is active, consider starting corner edge scrolling or
* switching over to circular scrolling smoothly */
if (priv->vert_scroll_edge_on && !priv->horiz_scroll_edge_on &&
- (edge & RIGHT_EDGE) && (edge & (TOP_EDGE | BOTTOM_EDGE))) {
- if (para->scroll_edge_corner) {
- if (priv->scroll.coast_speed_y == 0) {
- /* FYI: We can generate multiple start_coasting requests if
- * we're in the corner, but we were moving so slowly when we
- * got here that we didn't actually start coasting. */
- DBG(7, "corner edge scroll on\n");
- start_coasting(priv, hw, TRUE, FALSE, FALSE);
- }
- } else if (para->circular_scrolling) {
- priv->vert_scroll_edge_on = FALSE;
- priv->circ_scroll_on = TRUE;
- priv->circ_scroll_vert = TRUE;
- priv->scroll.last_a = angle(priv, hw->x, hw->y);
- DBG(7, "switching to circular scrolling\n");
- }
+ (edge & RIGHT_EDGE) && (edge & (TOP_EDGE | BOTTOM_EDGE))) {
+ if (para->scroll_edge_corner) {
+ if (priv->scroll.coast_speed_y == 0) {
+ /* FYI: We can generate multiple start_coasting requests if
+ * we're in the corner, but we were moving so slowly when we
+ * got here that we didn't actually start coasting. */
+ DBG(7, "corner edge scroll on\n");
+ start_coasting(priv, hw, TRUE, FALSE, FALSE);
+ }
+ }
+ else if (para->circular_scrolling) {
+ priv->vert_scroll_edge_on = FALSE;
+ priv->circ_scroll_on = TRUE;
+ priv->circ_scroll_vert = TRUE;
+ priv->scroll.last_a = angle(priv, hw->x, hw->y);
+ DBG(7, "switching to circular scrolling\n");
+ }
}
/* Same treatment for horizontal scrolling */
if (priv->horiz_scroll_edge_on && !priv->vert_scroll_edge_on &&
- (edge & BOTTOM_EDGE) && (edge & (LEFT_EDGE | RIGHT_EDGE))) {
- if (para->scroll_edge_corner) {
- if (priv->scroll.coast_speed_x == 0) {
- /* FYI: We can generate multiple start_coasting requests if
- * we're in the corner, but we were moving so slowly when we
- * got here that we didn't actually start coasting. */
- DBG(7, "corner edge scroll on\n");
- start_coasting(priv, hw, FALSE, TRUE, FALSE);
- }
- } else if (para->circular_scrolling) {
- priv->horiz_scroll_edge_on = FALSE;
- priv->circ_scroll_on = TRUE;
- priv->circ_scroll_vert = FALSE;
- priv->scroll.last_a = angle(priv, hw->x, hw->y);
- DBG(7, "switching to circular scrolling\n");
- }
+ (edge & BOTTOM_EDGE) && (edge & (LEFT_EDGE | RIGHT_EDGE))) {
+ if (para->scroll_edge_corner) {
+ if (priv->scroll.coast_speed_x == 0) {
+ /* FYI: We can generate multiple start_coasting requests if
+ * we're in the corner, but we were moving so slowly when we
+ * got here that we didn't actually start coasting. */
+ DBG(7, "corner edge scroll on\n");
+ start_coasting(priv, hw, FALSE, TRUE, FALSE);
+ }
+ }
+ else if (para->circular_scrolling) {
+ priv->horiz_scroll_edge_on = FALSE;
+ priv->circ_scroll_on = TRUE;
+ priv->circ_scroll_vert = FALSE;
+ priv->scroll.last_a = angle(priv, hw->x, hw->y);
+ DBG(7, "switching to circular scrolling\n");
+ }
}
if (priv->vert_scroll_edge_on || priv->horiz_scroll_edge_on ||
- priv->vert_scroll_twofinger_on || priv->horiz_scroll_twofinger_on ||
- priv->circ_scroll_on) {
- priv->scroll.packets_this_scroll++;
+ priv->vert_scroll_twofinger_on || priv->horiz_scroll_twofinger_on ||
+ priv->circ_scroll_on) {
+ priv->scroll.packets_this_scroll++;
}
if (priv->vert_scroll_edge_on || priv->vert_scroll_twofinger_on) {
- /* + = down, - = up */
- if (para->scroll_dist_vert != 0 && hw->y != priv->scroll.last_y) {
- priv->scroll.delta_y += (hw->y - priv->scroll.last_y);
- priv->scroll.last_y = hw->y;
- }
+ /* + = down, - = up */
+ if (para->scroll_dist_vert != 0 && hw->y != priv->scroll.last_y) {
+ priv->scroll.delta_y += (hw->y - priv->scroll.last_y);
+ priv->scroll.last_y = hw->y;
+ }
}
if (priv->horiz_scroll_edge_on || priv->horiz_scroll_twofinger_on) {
- /* + = right, - = left */
- if (para->scroll_dist_horiz != 0 && hw->x != priv->scroll.last_x) {
- priv->scroll.delta_x += (hw->x - priv->scroll.last_x);
- priv->scroll.last_x = hw->x;
- }
+ /* + = right, - = left */
+ if (para->scroll_dist_horiz != 0 && hw->x != priv->scroll.last_x) {
+ priv->scroll.delta_x += (hw->x - priv->scroll.last_x);
+ priv->scroll.last_x = hw->x;
+ }
}
if (priv->circ_scroll_on) {
- /* + = counter clockwise, - = clockwise */
- double delta = para->scroll_dist_circ;
- double diff = diffa(priv->scroll.last_a, angle(priv, hw->x, hw->y));
- if (delta >= 0.005 && diff != 0.0) {
- if (priv->circ_scroll_vert)
- priv->scroll.delta_y -= diff / delta * para->scroll_dist_vert;
- else
- priv->scroll.delta_x -= diff / delta * para->scroll_dist_horiz;
- priv->scroll.last_a = angle(priv, hw->x, hw->y);
+ /* + = counter clockwise, - = clockwise */
+ double delta = para->scroll_dist_circ;
+ double diff = diffa(priv->scroll.last_a, angle(priv, hw->x, hw->y));
+
+ if (delta >= 0.005 && diff != 0.0) {
+ if (priv->circ_scroll_vert)
+ priv->scroll.delta_y -= diff / delta * para->scroll_dist_vert;
+ else
+ priv->scroll.delta_x -= diff / delta * para->scroll_dist_horiz;
+ priv->scroll.last_a = angle(priv, hw->x, hw->y);
}
}
if (priv->scroll.coast_speed_y) {
- double dtime = (hw->millis - priv->scroll.last_millis) / 1000.0;
- double ddy = para->coasting_friction * dtime * abs(para->scroll_dist_vert);
-
- priv->scroll.delta_y += priv->scroll.coast_speed_y * dtime;
- delay = MIN(delay, POLL_MS);
- if (abs(priv->scroll.coast_speed_y) < ddy) {
- priv->scroll.coast_speed_y = 0;
- priv->scroll.packets_this_scroll = 0;
- } else {
- priv->scroll.coast_speed_y += (priv->scroll.coast_speed_y < 0 ? ddy : -ddy);
- }
+ double dtime = (hw->millis - priv->scroll.last_millis) / 1000.0;
+ double ddy =
+ para->coasting_friction * dtime * abs(para->scroll_dist_vert);
+
+ priv->scroll.delta_y += priv->scroll.coast_speed_y * dtime;
+ delay = MIN(delay, POLL_MS);
+ if (abs(priv->scroll.coast_speed_y) < ddy) {
+ priv->scroll.coast_speed_y = 0;
+ priv->scroll.packets_this_scroll = 0;
+ }
+ else {
+ priv->scroll.coast_speed_y +=
+ (priv->scroll.coast_speed_y < 0 ? ddy : -ddy);
+ }
}
if (priv->scroll.coast_speed_x) {
- double dtime = (hw->millis - priv->scroll.last_millis) / 1000.0;
- double ddx = para->coasting_friction * dtime * abs(para->scroll_dist_horiz);
- priv->scroll.delta_x += priv->scroll.coast_speed_x * dtime;
- delay = MIN(delay, POLL_MS);
- if (abs(priv->scroll.coast_speed_x) < ddx) {
- priv->scroll.coast_speed_x = 0;
- priv->scroll.packets_this_scroll = 0;
- } else {
- priv->scroll.coast_speed_x += (priv->scroll.coast_speed_x < 0 ? ddx : -ddx);
- }
+ double dtime = (hw->millis - priv->scroll.last_millis) / 1000.0;
+ double ddx =
+ para->coasting_friction * dtime * abs(para->scroll_dist_horiz);
+ priv->scroll.delta_x += priv->scroll.coast_speed_x * dtime;
+ delay = MIN(delay, POLL_MS);
+ if (abs(priv->scroll.coast_speed_x) < ddx) {
+ priv->scroll.coast_speed_x = 0;
+ priv->scroll.packets_this_scroll = 0;
+ }
+ else {
+ priv->scroll.coast_speed_x +=
+ (priv->scroll.coast_speed_x < 0 ? ddx : -ddx);
+ }
}
return delay;
@@ -2658,12 +2777,14 @@ HandleScrolling(SynapticsPrivate *priv, struct SynapticsHwState *hw,
* ClickFinger action.
*/
static int
-clickpad_guess_clickfingers(SynapticsPrivate *priv, struct SynapticsHwState *hw)
+clickpad_guess_clickfingers(SynapticsPrivate * priv,
+ struct SynapticsHwState *hw)
{
int nfingers = 0;
+
#if HAVE_MULTITOUCH
- char close_point[SYNAPTICS_MAX_TOUCHES] = {0}; /* 1 for each point close
- to another one */
+ char close_point[SYNAPTICS_MAX_TOUCHES] = { 0 }; /* 1 for each point close
+ to another one */
int i, j;
for (i = 0; i < hw->num_mt_mask - 1; i++) {
@@ -2710,9 +2831,8 @@ clickpad_guess_clickfingers(SynapticsPrivate *priv, struct SynapticsHwState *hw)
return nfingers;
}
-
static void
-handle_clickfinger(SynapticsPrivate *priv, struct SynapticsHwState *hw)
+handle_clickfinger(SynapticsPrivate * priv, struct SynapticsHwState *hw)
{
SynapticsParameters *para = &priv->synpara;
int action = 0;
@@ -2727,33 +2847,32 @@ handle_clickfinger(SynapticsPrivate *priv, struct SynapticsHwState *hw)
if (para->clickpad)
nfingers = clickpad_guess_clickfingers(priv, hw);
- switch(nfingers) {
- 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 (nfingers) {
+ 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 | BTN_EMULATED_FLAG;
- break;
- case 2:
- hw->left = 0;
- hw->middle = 1 | BTN_EMULATED_FLAG;
- break;
- case 3:
- hw->left = 0;
- hw->right = 1 | BTN_EMULATED_FLAG;
- break;
+ switch (action) {
+ case 1:
+ hw->left = 1 | BTN_EMULATED_FLAG;
+ break;
+ case 2:
+ hw->left = 0;
+ hw->middle = 1 | BTN_EMULATED_FLAG;
+ break;
+ case 3:
+ hw->left = 0;
+ hw->right = 1 | BTN_EMULATED_FLAG;
+ break;
}
}
-
/* Update the hardware state in shared memory. This is read-only these days,
* nothing in the driver reads back from SHM. SHM configuration is a thing of the past.
*/
@@ -2765,7 +2884,7 @@ update_shm(const InputInfoPtr pInfo, const struct SynapticsHwState *hw)
SynapticsSHM *shm = priv->synshm;
if (!shm)
- return;
+ return;
shm->x = hw->x;
shm->y = hw->y;
@@ -2777,7 +2896,7 @@ update_shm(const InputInfoPtr pInfo, const struct SynapticsHwState *hw)
shm->up = hw->up;
shm->down = hw->down;
for (i = 0; i < 8; i++)
- shm->multi[i] = hw->multi[i];
+ shm->multi[i] = hw->multi[i];
shm->middle = hw->middle;
}
@@ -2787,34 +2906,35 @@ update_shm(const InputInfoPtr pInfo, const struct SynapticsHwState *hw)
* function (or scrolling into).
*/
static Bool
-adjust_state_from_scrollbuttons(const InputInfoPtr pInfo, struct SynapticsHwState *hw)
+adjust_state_from_scrollbuttons(const InputInfoPtr pInfo,
+ struct SynapticsHwState *hw)
{
SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private);
SynapticsParameters *para = &priv->synpara;
Bool double_click = FALSE;
if (!para->updown_button_scrolling) {
- if (hw->down) { /* map down button to middle button */
- hw->middle = TRUE;
- }
+ if (hw->down) { /* map down button to middle button */
+ hw->middle = TRUE;
+ }
- if (hw->up) { /* up button generates double click */
- if (!priv->prev_up)
- double_click = TRUE;
- }
- priv->prev_up = hw->up;
+ if (hw->up) { /* up button generates double click */
+ if (!priv->prev_up)
+ double_click = TRUE;
+ }
+ priv->prev_up = hw->up;
- /* reset up/down button events */
- hw->up = hw->down = FALSE;
+ /* reset up/down button events */
+ hw->up = hw->down = FALSE;
}
/* Left/right button scrolling, or middle clicks */
if (!para->leftright_button_scrolling) {
- if (hw->multi[2] || hw->multi[3])
- hw->middle = TRUE;
+ if (hw->multi[2] || hw->multi[3])
+ hw->middle = TRUE;
- /* reset left/right button events */
- hw->multi[2] = hw->multi[3] = FALSE;
+ /* reset left/right button events */
+ hw->multi[2] = hw->multi[3] = FALSE;
}
return double_click;
@@ -2836,15 +2956,12 @@ update_hw_button_state(const InputInfoPtr pInfo, struct SynapticsHwState *hw,
/* If this is a clickpad and the user clicks in a soft button area, press
* the soft button instead. */
- if (para->clickpad && hw->left && !hw->right && !hw->middle)
- {
- if (is_inside_rightbutton_area(para, hw->x, hw->y))
- {
+ if (para->clickpad && hw->left && !hw->right && !hw->middle) {
+ if (is_inside_rightbutton_area(para, hw->x, hw->y)) {
hw->left = 0;
hw->right = 1;
}
- else if (is_inside_middlebutton_area(para, hw->x, hw->y))
- {
+ else if (is_inside_middlebutton_area(para, hw->x, hw->y)) {
hw->left = 0;
hw->middle = 1;
}
@@ -2853,15 +2970,15 @@ update_hw_button_state(const InputInfoPtr pInfo, struct SynapticsHwState *hw,
/* Fingers emulate other buttons. ClickFinger can only be
triggered on transition, when left is pressed
*/
- if(hw->left && !old->left && !old->middle && !old->right &&
- hw->numFingers >= 1) {
+ if (hw->left && !old->left && !old->middle && !old->right &&
+ hw->numFingers >= 1) {
handle_clickfinger(priv, hw);
}
/* Two finger emulation */
if (hw->numFingers == 1 && hw->z >= para->emulate_twofinger_z &&
hw->fingerWidth >= para->emulate_twofinger_w) {
- hw->numFingers = 2;
+ hw->numFingers = 2;
}
}
@@ -2872,7 +2989,6 @@ post_button_click(const InputInfoPtr pInfo, const int button)
xf86PostButtonEvent(pInfo->dev, FALSE, button, FALSE, 0, 0);
}
-
static void
post_scroll_events(const InputInfoPtr pInfo)
{
@@ -2881,18 +2997,14 @@ post_scroll_events(const InputInfoPtr pInfo)
#ifdef HAVE_SMOOTH_SCROLL
valuator_mask_zero(priv->scroll_events_mask);
- if (priv->scroll.delta_y != 0.0)
- {
+ if (priv->scroll.delta_y != 0.0) {
valuator_mask_set_double(priv->scroll_events_mask,
- priv->scroll_axis_vert,
- priv->scroll.delta_y);
+ priv->scroll_axis_vert, priv->scroll.delta_y);
priv->scroll.delta_y = 0;
}
- if (priv->scroll.delta_x != 0.0)
- {
+ if (priv->scroll.delta_x != 0.0) {
valuator_mask_set_double(priv->scroll_events_mask,
- priv->scroll_axis_horiz,
- priv->scroll.delta_x);
+ priv->scroll_axis_horiz, priv->scroll.delta_x);
priv->scroll.delta_x = 0;
}
if (valuator_mask_num_valuators(priv->scroll_events_mask))
@@ -2902,26 +3014,22 @@ post_scroll_events(const InputInfoPtr pInfo)
/* smooth scrolling uses the dist as increment */
- while (priv->scroll.delta_y <= -para->scroll_dist_vert)
- {
+ while (priv->scroll.delta_y <= -para->scroll_dist_vert) {
post_button_click(pInfo, 4);
priv->scroll.delta_y += para->scroll_dist_vert;
}
- while (priv->scroll.delta_y >= para->scroll_dist_vert)
- {
+ while (priv->scroll.delta_y >= para->scroll_dist_vert) {
post_button_click(pInfo, 5);
priv->scroll.delta_y -= para->scroll_dist_vert;
}
- while (priv->scroll.delta_x <= -para->scroll_dist_horiz)
- {
+ while (priv->scroll.delta_x <= -para->scroll_dist_horiz) {
post_button_click(pInfo, 6);
priv->scroll.delta_x += para->scroll_dist_horiz;
}
- while (priv->scroll.delta_x >= para->scroll_dist_horiz)
- {
+ while (priv->scroll.delta_x >= para->scroll_dist_horiz) {
post_button_click(pInfo, 7);
priv->scroll.delta_x -= para->scroll_dist_horiz;
}
@@ -2931,7 +3039,7 @@ post_scroll_events(const InputInfoPtr pInfo)
static inline int
repeat_scrollbuttons(const InputInfoPtr pInfo,
const struct SynapticsHwState *hw,
- int buttons, CARD32 now, int delay)
+ int buttons, CARD32 now, int delay)
{
SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private);
SynapticsParameters *para = &priv->synpara;
@@ -2946,41 +3054,43 @@ repeat_scrollbuttons(const InputInfoPtr pInfo,
/* Handle auto repeat buttons */
repeat_delay = clamp(para->scroll_button_repeat, SBR_MIN, SBR_MAX);
if (((hw->up || hw->down) && para->updown_button_repeat &&
- para->updown_button_scrolling) ||
- ((hw->multi[2] || hw->multi[3]) && para->leftright_button_repeat &&
- para->leftright_button_scrolling)) {
- priv->repeatButtons = buttons & rep_buttons;
- if (!priv->nextRepeat) {
- priv->nextRepeat = now + repeat_delay * 2;
- }
- } else {
- priv->repeatButtons = 0;
- priv->nextRepeat = 0;
+ para->updown_button_scrolling) ||
+ ((hw->multi[2] || hw->multi[3]) && para->leftright_button_repeat &&
+ para->leftright_button_scrolling)) {
+ priv->repeatButtons = buttons & rep_buttons;
+ if (!priv->nextRepeat) {
+ priv->nextRepeat = now + repeat_delay * 2;
+ }
+ }
+ else {
+ priv->repeatButtons = 0;
+ priv->nextRepeat = 0;
}
if (priv->repeatButtons) {
- timeleft = TIME_DIFF(priv->nextRepeat, now);
- if (timeleft > 0)
- delay = MIN(delay, timeleft);
- if (timeleft <= 0) {
- int change, id;
- change = priv->repeatButtons;
- while (change) {
- id = ffs(change);
- change &= ~(1 << (id - 1));
- if (id == 4)
- priv->scroll.delta_y -= para->scroll_dist_vert;
- else if (id == 5)
- priv->scroll.delta_y += para->scroll_dist_vert;
- else if (id == 6)
- priv->scroll.delta_x -= para->scroll_dist_horiz;
- else if (id == 7)
- priv->scroll.delta_x += para->scroll_dist_horiz;
- }
-
- priv->nextRepeat = now + repeat_delay;
- delay = MIN(delay, repeat_delay);
- }
+ timeleft = TIME_DIFF(priv->nextRepeat, now);
+ if (timeleft > 0)
+ delay = MIN(delay, timeleft);
+ if (timeleft <= 0) {
+ int change, id;
+
+ change = priv->repeatButtons;
+ while (change) {
+ id = ffs(change);
+ change &= ~(1 << (id - 1));
+ if (id == 4)
+ priv->scroll.delta_y -= para->scroll_dist_vert;
+ else if (id == 5)
+ priv->scroll.delta_y += para->scroll_dist_vert;
+ else if (id == 6)
+ priv->scroll.delta_x -= para->scroll_dist_horiz;
+ else if (id == 7)
+ priv->scroll.delta_x += para->scroll_dist_horiz;
+ }
+
+ priv->nextRepeat = now + repeat_delay;
+ delay = MIN(delay, repeat_delay);
+ }
}
return delay;
@@ -2991,22 +3101,19 @@ static void
UpdateTouchState(InputInfoPtr pInfo, struct SynapticsHwState *hw)
{
#ifdef HAVE_MULTITOUCH
- SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
+ SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
int i;
- for (i = 0; i < hw->num_mt_mask; i++)
- {
- if (hw->slot_state[i] == SLOTSTATE_OPEN)
- {
+ for (i = 0; i < hw->num_mt_mask; i++) {
+ if (hw->slot_state[i] == SLOTSTATE_OPEN) {
priv->open_slots[priv->num_active_touches] = i;
priv->num_active_touches++;
- } else if (hw->slot_state[i] == SLOTSTATE_CLOSE)
- {
+ }
+ else if (hw->slot_state[i] == SLOTSTATE_CLOSE) {
Bool found = FALSE;
int j;
- for (j = 0; j < priv->num_active_touches - 1; j++)
- {
+ for (j = 0; j < priv->num_active_touches - 1; j++) {
if (priv->open_slots[j] == i)
found = TRUE;
@@ -3026,7 +3133,7 @@ static void
HandleTouches(InputInfoPtr pInfo, struct SynapticsHwState *hw)
{
#ifdef HAVE_MULTITOUCH
- SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;
+ SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
SynapticsParameters *para = &priv->synpara;
int new_active_touches = priv->num_active_touches;
int min_touches = 2;
@@ -3040,8 +3147,7 @@ HandleTouches(InputInfoPtr pInfo, struct SynapticsHwState *hw)
min_touches = 3;
/* Count new number of active touches */
- for (i = 0; i < hw->num_mt_mask; i++)
- {
+ for (i = 0; i < hw->num_mt_mask; i++) {
if (hw->slot_state[i] == SLOTSTATE_OPEN)
new_active_touches++;
else if (hw->slot_state[i] == SLOTSTATE_CLOSE)
@@ -3052,32 +3158,30 @@ HandleTouches(InputInfoPtr pInfo, struct SynapticsHwState *hw)
goto out;
if (priv->num_active_touches < min_touches &&
- new_active_touches < min_touches)
- {
+ new_active_touches < min_touches) {
/* We stayed below number of touches needed to send events */
goto out;
- } else if (priv->num_active_touches >= min_touches &&
- new_active_touches < min_touches)
- {
+ }
+ else if (priv->num_active_touches >= min_touches &&
+ new_active_touches < min_touches) {
/* We are transitioning to less than the number of touches needed to
* send events. End all currently open touches. */
- for (i = 0; i < priv->num_active_touches; i++)
- {
+ for (i = 0; i < priv->num_active_touches; i++) {
int slot = priv->open_slots[i];
+
xf86PostTouchEvent(pInfo->dev, slot, XI_TouchEnd, 0,
hw->mt_mask[slot]);
}
/* Don't send any more events */
goto out;
- } else if (priv->num_active_touches < min_touches &&
- new_active_touches >= min_touches)
- {
+ }
+ else if (priv->num_active_touches < min_touches &&
+ new_active_touches >= min_touches) {
/* We are transitioning to more than the number of touches needed to
* send events. Begin all already open touches. */
restart_touches = TRUE;
- for (i = 0; i < priv->num_active_touches; i++)
- {
+ for (i = 0; i < priv->num_active_touches; i++) {
int slot = priv->open_slots[i];
xf86PostTouchEvent(pInfo->dev, slot, XI_TouchBegin, 0,
@@ -3088,12 +3192,10 @@ HandleTouches(InputInfoPtr pInfo, struct SynapticsHwState *hw)
/* Send touch begin events for all new touches */
for (i = 0; i < hw->num_mt_mask; i++)
if (hw->slot_state[i] == SLOTSTATE_OPEN)
- xf86PostTouchEvent(pInfo->dev, i, XI_TouchBegin, 0,
- hw->mt_mask[i]);
+ xf86PostTouchEvent(pInfo->dev, i, XI_TouchBegin, 0, hw->mt_mask[i]);
/* Send touch update/end events for all the rest */
- for (i = 0; i < priv->num_active_touches; i++)
- {
+ for (i = 0; i < priv->num_active_touches; i++) {
int slot = priv->open_slots[i];
/* Don't send update event if we just reopened the touch above */
@@ -3105,13 +3207,13 @@ HandleTouches(InputInfoPtr pInfo, struct SynapticsHwState *hw)
hw->mt_mask[slot]);
}
-out:
+ out:
UpdateTouchState(pInfo, hw);
#endif
}
static void
-filter_jitter(SynapticsPrivate *priv, int *x, int *y)
+filter_jitter(SynapticsPrivate * priv, int *x, int *y)
{
SynapticsParameters *para = &priv->synpara;
@@ -3159,16 +3261,14 @@ HandleState(InputInfoPtr pInfo, struct SynapticsHwState *hw, CARD32 now,
update_shm(pInfo, hw);
/* If touchpad is switched off, we skip the whole thing and return delay */
- if (para->touchpad_off == 1)
- {
- UpdateTouchState(pInfo, hw);
- return delay;
+ if (para->touchpad_off == 1) {
+ UpdateTouchState(pInfo, hw);
+ return delay;
}
/* If a physical button is pressed on a clickpad, use cumulative relative
* touch movements for motion */
- if (para->clickpad && (hw->left || hw->right || hw->middle))
- {
+ if (para->clickpad && (hw->left || hw->right || hw->middle)) {
hw->x = hw->cumulative_dx;
hw->y = hw->cumulative_dy;
}
@@ -3183,120 +3283,119 @@ HandleState(InputInfoPtr pInfo, struct SynapticsHwState *hw, CARD32 now,
/* now we know that these _coordinates_ aren't in the area.
invalid are: x, y, z, numFingers, fingerWidth
valid are: millis, left/right/middle/up/down/etc.
- */
- if (!inside_active_area)
- {
- reset_hw_state(hw);
+ */
+ if (!inside_active_area) {
+ reset_hw_state(hw);
- /* FIXME: if finger accidentally moves into the area and doesn't
- * really release, the finger should remain down. */
+ /* FIXME: if finger accidentally moves into the area and doesn't
+ * really release, the finger should remain down. */
}
/* these two just update hw->left, right, etc. */
update_hw_button_state(pInfo, hw, priv->old_hw_state, now, &delay);
if (priv->has_scrollbuttons)
- double_click = adjust_state_from_scrollbuttons(pInfo, hw);
+ double_click = adjust_state_from_scrollbuttons(pInfo, hw);
/* no edge or finger detection outside of area */
if (inside_active_area) {
- edge = edge_detection(priv, hw->x, hw->y);
- if (!from_timer)
- finger = SynapticsDetectFinger(priv, hw);
- else
- finger = priv->finger_state;
+ edge = edge_detection(priv, hw->x, hw->y);
+ if (!from_timer)
+ finger = SynapticsDetectFinger(priv, hw);
+ else
+ finger = priv->finger_state;
}
/* tap and drag detection. Needs to be performed even if the finger is in
* the dead area to reset the state. */
timeleft = HandleTapProcessing(priv, hw, now, finger, inside_active_area);
if (timeleft > 0)
- delay = MIN(delay, timeleft);
-
- if (inside_active_area)
- {
- /* Don't bother about scrolling in the dead area of the touchpad. */
- timeleft = HandleScrolling(priv, hw, edge, (finger >= FS_TOUCHED));
- if (timeleft > 0)
- delay = MIN(delay, timeleft);
+ delay = MIN(delay, timeleft);
- /*
- * Compensate for unequal x/y resolution. This needs to be done after
- * calculations that require unadjusted coordinates, for example edge
- * detection.
- */
- ScaleCoordinates(priv, hw);
+ if (inside_active_area) {
+ /* Don't bother about scrolling in the dead area of the touchpad. */
+ timeleft = HandleScrolling(priv, hw, edge, (finger >= FS_TOUCHED));
+ if (timeleft > 0)
+ delay = MIN(delay, timeleft);
+
+ /*
+ * Compensate for unequal x/y resolution. This needs to be done after
+ * calculations that require unadjusted coordinates, for example edge
+ * detection.
+ */
+ ScaleCoordinates(priv, hw);
}
dx = dy = 0;
if (!priv->absolute_events) {
- timeleft = ComputeDeltas(priv, hw, edge, &dx, &dy, inside_active_area);
- delay = MIN(delay, timeleft);
+ timeleft = ComputeDeltas(priv, hw, edge, &dx, &dy, inside_active_area);
+ delay = MIN(delay, timeleft);
}
-
- buttons = ((hw->left ? 0x01 : 0) |
- (hw->middle ? 0x02 : 0) |
- (hw->right ? 0x04 : 0) |
- (hw->up ? 0x08 : 0) |
- (hw->down ? 0x10 : 0) |
- (hw->multi[2] ? 0x20 : 0) |
- (hw->multi[3] ? 0x40 : 0));
+ buttons = ((hw->left ? 0x01 : 0) |
+ (hw->middle ? 0x02 : 0) |
+ (hw->right ? 0x04 : 0) |
+ (hw->up ? 0x08 : 0) |
+ (hw->down ? 0x10 : 0) |
+ (hw->multi[2] ? 0x20 : 0) | (hw->multi[3] ? 0x40 : 0));
if (priv->tap_button > 0) {
- int tap_mask = 1 << (priv->tap_button - 1);
- if (priv->tap_button_state == TBS_BUTTON_DOWN_UP) {
- if (tap_mask != (priv->lastButtons & tap_mask)) {
- xf86PostButtonEvent(pInfo->dev, FALSE, priv->tap_button, TRUE, 0, 0);
- priv->lastButtons |= tap_mask;
- }
- priv->tap_button_state = TBS_BUTTON_UP;
- }
- if (priv->tap_button_state == TBS_BUTTON_DOWN)
- buttons |= tap_mask;
+ int tap_mask = 1 << (priv->tap_button - 1);
+
+ if (priv->tap_button_state == TBS_BUTTON_DOWN_UP) {
+ if (tap_mask != (priv->lastButtons & tap_mask)) {
+ xf86PostButtonEvent(pInfo->dev, FALSE, priv->tap_button, TRUE,
+ 0, 0);
+ priv->lastButtons |= tap_mask;
+ }
+ priv->tap_button_state = TBS_BUTTON_UP;
+ }
+ if (priv->tap_button_state == TBS_BUTTON_DOWN)
+ buttons |= tap_mask;
}
/* Post events */
if (finger >= FS_TOUCHED) {
if (priv->absolute_events && inside_active_area) {
xf86PostMotionEvent(pInfo->dev, 1, 0, 2, hw->x, hw->y);
- } else if (dx || dy) {
+ }
+ else if (dx || dy) {
xf86PostMotionEvent(pInfo->dev, 0, 0, 2, dx, dy);
}
}
- if (priv->mid_emu_state == MBE_LEFT_CLICK)
- {
- post_button_click(pInfo, 1);
- priv->mid_emu_state = MBE_OFF;
- } else if (priv->mid_emu_state == MBE_RIGHT_CLICK)
- {
- post_button_click(pInfo, 3);
- priv->mid_emu_state = MBE_OFF;
+ if (priv->mid_emu_state == MBE_LEFT_CLICK) {
+ post_button_click(pInfo, 1);
+ priv->mid_emu_state = MBE_OFF;
+ }
+ else if (priv->mid_emu_state == MBE_RIGHT_CLICK) {
+ post_button_click(pInfo, 3);
+ priv->mid_emu_state = MBE_OFF;
}
change = buttons ^ priv->lastButtons;
while (change) {
- id = ffs(change); /* number of first set bit 1..32 is returned */
- change &= ~(1 << (id - 1));
- xf86PostButtonEvent(pInfo->dev, FALSE, id, (buttons & (1 << (id - 1))), 0, 0);
+ id = ffs(change); /* number of first set bit 1..32 is returned */
+ change &= ~(1 << (id - 1));
+ xf86PostButtonEvent(pInfo->dev, FALSE, id, (buttons & (1 << (id - 1))),
+ 0, 0);
}
if (priv->has_scrollbuttons)
- delay = repeat_scrollbuttons(pInfo, hw, buttons, now, delay);
+ delay = repeat_scrollbuttons(pInfo, hw, buttons, now, delay);
/* Process scroll events only if coordinates are
* in the Synaptics Area
*/
if (inside_active_area &&
(priv->scroll.delta_x != 0.0 || priv->scroll.delta_y != 0.0)) {
- post_scroll_events(pInfo);
- priv->scroll.last_millis = hw->millis;
+ post_scroll_events(pInfo);
+ priv->scroll.last_millis = hw->millis;
}
if (double_click) {
- post_button_click(pInfo, 1);
- post_button_click(pInfo, 1);
+ post_button_click(pInfo, 1);
+ post_button_click(pInfo, 1);
}
HandleTouches(pInfo, hw);
@@ -3307,7 +3406,7 @@ HandleState(InputInfoPtr pInfo, struct SynapticsHwState *hw, CARD32 now,
/* generate a history of the absolute positions */
if (inside_active_area)
- store_history(priv, hw->x, hw->y, hw->millis);
+ store_history(priv, hw->x, hw->y, hw->millis);
/* Save logical state for transition comparisons */
SynapticsCopyHwState(priv->old_hw_state, hw);
@@ -3322,7 +3421,6 @@ ControlProc(InputInfoPtr pInfo, xDeviceCtl * control)
return Success;
}
-
static int
SwitchMode(ClientPtr client, DeviceIntPtr dev, int mode)
{
@@ -3353,7 +3451,7 @@ ReadDevDimensions(InputInfoPtr pInfo)
SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
if (priv->proto_ops->ReadDevDimensions)
- priv->proto_ops->ReadDevDimensions(pInfo);
+ priv->proto_ops->ReadDevDimensions(pInfo);
SanitizeDimensions(pInfo);
}
@@ -3366,8 +3464,8 @@ QueryHardware(InputInfoPtr pInfo)
priv->comm.protoBufTail = 0;
if (!priv->proto_ops->QueryHardware(pInfo)) {
- xf86IDrvMsg(pInfo, X_PROBED, "no supported touchpad found\n");
- if (priv->proto_ops->DeviceOffHook)
+ xf86IDrvMsg(pInfo, X_PROBED, "no supported touchpad found\n");
+ if (priv->proto_ops->DeviceOffHook)
priv->proto_ops->DeviceOffHook(pInfo);
return FALSE;
}
@@ -3376,7 +3474,7 @@ QueryHardware(InputInfoPtr pInfo)
}
static void
-ScaleCoordinates(SynapticsPrivate *priv, struct SynapticsHwState *hw)
+ScaleCoordinates(SynapticsPrivate * priv, struct SynapticsHwState *hw)
{
int xCenter = (priv->synpara.left_edge + priv->synpara.right_edge) / 2;
int yCenter = (priv->synpara.top_edge + priv->synpara.bottom_edge) / 2;
@@ -3386,18 +3484,20 @@ ScaleCoordinates(SynapticsPrivate *priv, struct SynapticsHwState *hw)
}
void
-CalculateScalingCoeffs(SynapticsPrivate *priv)
+CalculateScalingCoeffs(SynapticsPrivate * priv)
{
int vertRes = priv->synpara.resolution_vert;
int horizRes = priv->synpara.resolution_horiz;
if ((horizRes > vertRes) && (horizRes > 0)) {
- priv->horiz_coeff = vertRes / (double)horizRes;
+ priv->horiz_coeff = vertRes / (double) horizRes;
priv->vert_coeff = 1;
- } else if ((horizRes < vertRes) && (vertRes > 0)) {
+ }
+ else if ((horizRes < vertRes) && (vertRes > 0)) {
priv->horiz_coeff = 1;
- priv->vert_coeff = horizRes / (double)vertRes;
- } else {
+ priv->vert_coeff = horizRes / (double) vertRes;
+ }
+ else {
priv->horiz_coeff = 1;
priv->vert_coeff = 1;
}
diff --git a/src/synapticsstr.h b/src/synapticsstr.h
index 14ae362..57ed4ba 100644
--- a/src/synapticsstr.h
+++ b/src/synapticsstr.h
@@ -26,14 +26,14 @@
#include <xserver-properties.h>
#ifdef DBG
-# undef DBG
+#undef DBG
#endif
#ifdef DEBUG
#define DBG(verb, ...) \
xf86MsgVerb(X_INFO, verb, __VA_ARGS__)
#else
-#define DBG(verb, msg, ...) /* */
+#define DBG(verb, msg, ...) /* */
#endif
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
@@ -51,14 +51,12 @@
#define SYNAPTICS_MOVE_HISTORY 5
#define SYNAPTICS_MAX_TOUCHES 10
-typedef struct _SynapticsMoveHist
-{
+typedef struct _SynapticsMoveHist {
int x, y;
CARD32 millis;
} SynapticsMoveHistRec;
-typedef struct _SynapticsTouchAxis
-{
+typedef struct _SynapticsTouchAxis {
const char *label;
int min;
int max;
@@ -67,7 +65,7 @@ typedef struct _SynapticsTouchAxis
enum FingerState { /* Note! The order matters. Compared with < operator. */
FS_BLOCKED = -1,
- FS_UNTOUCHED = 0, /* this is 0 so it's the initialized value. */
+ FS_UNTOUCHED = 0, /* this is 0 so it's the initialized value. */
FS_TOUCHED = 1,
FS_PRESSED = 2,
};
@@ -75,39 +73,39 @@ enum FingerState { /* Note! The order matters. Compared with < oper
enum MovingState {
MS_FALSE,
MS_TOUCHPAD_RELATIVE,
- MS_TRACKSTICK /* trackstick is always relative */
+ MS_TRACKSTICK /* trackstick is always relative */
};
enum MidButtonEmulation {
- MBE_OFF, /* No button pressed */
- MBE_LEFT, /* Left button pressed, waiting for right button or timeout */
- MBE_RIGHT, /* Right button pressed, waiting for left button or timeout */
- MBE_MID, /* Left and right buttons pressed, waiting for both buttons
- to be released */
- MBE_TIMEOUT, /* Waiting for both buttons to be released. */
- MBE_LEFT_CLICK, /* Emulate left button click. */
- MBE_RIGHT_CLICK, /* Emulate right button click. */
+ MBE_OFF, /* No button pressed */
+ MBE_LEFT, /* Left button pressed, waiting for right button or timeout */
+ MBE_RIGHT, /* Right button pressed, waiting for left button or timeout */
+ MBE_MID, /* Left and right buttons pressed, waiting for both buttons
+ to be released */
+ MBE_TIMEOUT, /* Waiting for both buttons to be released. */
+ MBE_LEFT_CLICK, /* Emulate left button click. */
+ MBE_RIGHT_CLICK, /* Emulate right button click. */
};
/* See docs/tapndrag.dia for a state machine diagram */
enum TapState {
- TS_START, /* No tap/drag in progress */
- TS_1, /* After first touch */
- TS_MOVE, /* Pointer movement enabled */
- TS_2A, /* After first release */
- TS_2B, /* After second/third/... release */
- TS_SINGLETAP, /* After timeout after first release */
- TS_3, /* After second touch */
- TS_DRAG, /* Pointer drag enabled */
- TS_4, /* After release when "locked drags" enabled */
- TS_5, /* After touch when "locked drags" enabled */
- TS_CLICKPAD_MOVE, /* After left button press on a clickpad */
+ TS_START, /* No tap/drag in progress */
+ TS_1, /* After first touch */
+ TS_MOVE, /* Pointer movement enabled */
+ TS_2A, /* After first release */
+ TS_2B, /* After second/third/... release */
+ TS_SINGLETAP, /* After timeout after first release */
+ TS_3, /* After second touch */
+ TS_DRAG, /* Pointer drag enabled */
+ TS_4, /* After release when "locked drags" enabled */
+ TS_5, /* After touch when "locked drags" enabled */
+ TS_CLICKPAD_MOVE, /* After left button press on a clickpad */
};
enum TapButtonState {
- TBS_BUTTON_UP, /* "Virtual tap button" is up */
- TBS_BUTTON_DOWN, /* "Virtual tap button" is down */
- TBS_BUTTON_DOWN_UP /* Send button down event + set up state */
+ TBS_BUTTON_UP, /* "Virtual tap button" is up */
+ TBS_BUTTON_DOWN, /* "Virtual tap button" is down */
+ TBS_BUTTON_DOWN_UP /* Send button down event + set up state */
};
enum TouchpadModel {
@@ -118,180 +116,177 @@ enum TouchpadModel {
MODEL_ELANTECH
};
-typedef struct _SynapticsParameters
-{
+typedef struct _SynapticsParameters {
/* Parameter data */
- int left_edge, right_edge, top_edge, bottom_edge; /* edge coordinates absolute */
- int finger_low, finger_high, finger_press; /* finger detection values in Z-values */
+ int left_edge, right_edge, top_edge, bottom_edge; /* edge coordinates absolute */
+ int finger_low, finger_high, finger_press; /* finger detection values in Z-values */
int tap_time;
- int tap_move; /* max. tapping time and movement in packets and coord. */
- int single_tap_timeout; /* timeout to recognize a single tap */
- int tap_time_2; /* max. tapping time for double taps */
- int click_time; /* The duration of a single click */
- Bool clickpad; /* Device is a has integrated buttons */
- Bool fast_taps; /* Faster reaction to single taps */
- int emulate_mid_button_time; /* Max time between left and right button presses to
- emulate a middle button press. */
- int emulate_twofinger_z; /* pressure threshold to emulate two finger touch (for Alps) */
- int emulate_twofinger_w; /* Finger width threshold to emulate two finger touch */
- int scroll_dist_vert; /* Scrolling distance in absolute coordinates */
- int scroll_dist_horiz; /* Scrolling distance in absolute coordinates */
- Bool scroll_edge_vert; /* Enable/disable vertical scrolling on right edge */
- Bool scroll_edge_horiz; /* Enable/disable horizontal scrolling on left edge */
- Bool scroll_edge_corner; /* Enable/disable continuous edge scrolling when in the corner */
- Bool scroll_twofinger_vert; /* Enable/disable vertical two-finger scrolling */
- Bool scroll_twofinger_horiz; /* Enable/disable horizontal two-finger scrolling */
- double min_speed, max_speed, accl; /* movement parameters */
- double trackstick_speed; /* trackstick mode speed */
- int edge_motion_min_z; /* finger pressure at which minimum edge motion speed is set */
- int edge_motion_max_z; /* finger pressure at which maximum edge motion speed is set */
- int edge_motion_min_speed; /* slowest setting for edge motion speed */
- int edge_motion_max_speed; /* fastest setting for edge motion speed */
- Bool edge_motion_use_always; /* If false, edge motion is used only when dragging */
-
- Bool updown_button_scrolling; /* Up/Down-Button scrolling or middle/double-click */
- Bool leftright_button_scrolling; /* Left/right-button scrolling, or two lots of middle button */
- Bool updown_button_repeat; /* If up/down button being used to scroll, auto-repeat?*/
- Bool leftright_button_repeat; /* If left/right button being used to scroll, auto-repeat? */
- int scroll_button_repeat; /* time, in milliseconds, between scroll events being
- * sent when holding down scroll buttons */
- int touchpad_off; /* Switches the touchpad off
- * 0 : Not off
- * 1 : Off
- * 2 : Only tapping and scrolling off
- */
- 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 */
- Bool circular_pad; /* Edge has an oval or circular shape */
- Bool palm_detect; /* Enable Palm Detection */
- int palm_min_width; /* Palm detection width */
- int palm_min_z; /* Palm detection depth */
- double coasting_speed; /* Coasting threshold scrolling speed */
- double coasting_friction; /* Number of scrolls per second per second to change coasting speed */
- int press_motion_min_z; /* finger pressure at which minimum pressure motion factor is applied */
- int press_motion_max_z; /* finger pressure at which maximum pressure motion factor is applied */
- double press_motion_min_factor; /* factor applied on speed when finger pressure is at minimum */
- double press_motion_max_factor; /* factor applied on speed when finger pressure is at minimum */
- Bool grab_event_device; /* grab event device for exclusive use? */
- Bool tap_and_drag_gesture; /* Switches the tap-and-drag gesture on/off */
- unsigned int resolution_horiz; /* horizontal resolution of touchpad in units/mm */
- unsigned int resolution_vert; /* vertical resolution of touchpad in units/mm */
- int area_left_edge, area_right_edge, area_top_edge, area_bottom_edge; /* area coordinates absolute */
- int softbutton_areas[2][4]; /* soft button area coordinates, 0 => right, 1 => middle button */
- int hyst_x, hyst_y; /* x and y width of hysteresis box */
+ int tap_move; /* max. tapping time and movement in packets and coord. */
+ int single_tap_timeout; /* timeout to recognize a single tap */
+ int tap_time_2; /* max. tapping time for double taps */
+ int click_time; /* The duration of a single click */
+ Bool clickpad; /* Device is a has integrated buttons */
+ Bool fast_taps; /* Faster reaction to single taps */
+ int emulate_mid_button_time; /* Max time between left and right button presses to
+ emulate a middle button press. */
+ int emulate_twofinger_z; /* pressure threshold to emulate two finger touch (for Alps) */
+ int emulate_twofinger_w; /* Finger width threshold to emulate two finger touch */
+ int scroll_dist_vert; /* Scrolling distance in absolute coordinates */
+ int scroll_dist_horiz; /* Scrolling distance in absolute coordinates */
+ Bool scroll_edge_vert; /* Enable/disable vertical scrolling on right edge */
+ Bool scroll_edge_horiz; /* Enable/disable horizontal scrolling on left edge */
+ Bool scroll_edge_corner; /* Enable/disable continuous edge scrolling when in the corner */
+ Bool scroll_twofinger_vert; /* Enable/disable vertical two-finger scrolling */
+ Bool scroll_twofinger_horiz; /* Enable/disable horizontal two-finger scrolling */
+ double min_speed, max_speed, accl; /* movement parameters */
+ double trackstick_speed; /* trackstick mode speed */
+ int edge_motion_min_z; /* finger pressure at which minimum edge motion speed is set */
+ int edge_motion_max_z; /* finger pressure at which maximum edge motion speed is set */
+ int edge_motion_min_speed; /* slowest setting for edge motion speed */
+ int edge_motion_max_speed; /* fastest setting for edge motion speed */
+ Bool edge_motion_use_always; /* If false, edge motion is used only when dragging */
+
+ Bool updown_button_scrolling; /* Up/Down-Button scrolling or middle/double-click */
+ Bool leftright_button_scrolling; /* Left/right-button scrolling, or two lots of middle button */
+ Bool updown_button_repeat; /* If up/down button being used to scroll, auto-repeat? */
+ Bool leftright_button_repeat; /* If left/right button being used to scroll, auto-repeat? */
+ int scroll_button_repeat; /* time, in milliseconds, between scroll events being
+ * sent when holding down scroll buttons */
+ int touchpad_off; /* Switches the touchpad off
+ * 0 : Not off
+ * 1 : Off
+ * 2 : Only tapping and scrolling off
+ */
+ 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 */
+ Bool circular_pad; /* Edge has an oval or circular shape */
+ Bool palm_detect; /* Enable Palm Detection */
+ int palm_min_width; /* Palm detection width */
+ int palm_min_z; /* Palm detection depth */
+ double coasting_speed; /* Coasting threshold scrolling speed */
+ double coasting_friction; /* Number of scrolls per second per second to change coasting speed */
+ int press_motion_min_z; /* finger pressure at which minimum pressure motion factor is applied */
+ int press_motion_max_z; /* finger pressure at which maximum pressure motion factor is applied */
+ double press_motion_min_factor; /* factor applied on speed when finger pressure is at minimum */
+ double press_motion_max_factor; /* factor applied on speed when finger pressure is at minimum */
+ Bool grab_event_device; /* grab event device for exclusive use? */
+ Bool tap_and_drag_gesture; /* Switches the tap-and-drag gesture on/off */
+ unsigned int resolution_horiz; /* horizontal resolution of touchpad in units/mm */
+ unsigned int resolution_vert; /* vertical resolution of touchpad in units/mm */
+ int area_left_edge, area_right_edge, area_top_edge, area_bottom_edge; /* area coordinates absolute */
+ int softbutton_areas[2][4]; /* soft button area coordinates, 0 => right, 1 => middle button */
+ int hyst_x, hyst_y; /* x and y width of hysteresis box */
} SynapticsParameters;
-
-struct _SynapticsPrivateRec
-{
- SynapticsParameters synpara; /* Default parameter settings, read from
- the X config file */
- SynapticsSHM *synshm; /* Current parameter settings. Will point to
- shared memory if shm_config is true */
- struct SynapticsProtocolOperations* proto_ops;
- void *proto_data; /* protocol-specific data */
+struct _SynapticsPrivateRec {
+ SynapticsParameters synpara; /* Default parameter settings, read from
+ the X config file */
+ SynapticsSHM *synshm; /* Current parameter settings. Will point to
+ shared memory if shm_config is true */
+ struct SynapticsProtocolOperations *proto_ops;
+ void *proto_data; /* protocol-specific data */
struct SynapticsHwState *hwState;
- struct SynapticsHwState *old_hw_state; /* previous logical hw state */
+ struct SynapticsHwState *old_hw_state; /* previous logical hw state */
- const char *device; /* device node */
- Bool shm_config; /* True when shared memory area allocated */
+ const char *device; /* device node */
+ Bool shm_config; /* True when shared memory area allocated */
- CARD32 timer_time; /* when timer last fired */
- OsTimerPtr timer; /* for up/down-button repeat, tap processing, etc */
+ CARD32 timer_time; /* when timer last fired */
+ OsTimerPtr timer; /* for up/down-button repeat, tap processing, etc */
struct CommData comm;
- struct SynapticsHwState *local_hw_state; /* used in place of local hw state variables */
+ struct SynapticsHwState *local_hw_state; /* used in place of local hw state variables */
- Bool absolute_events; /* post absolute motion events instead of relative */
- SynapticsMoveHistRec move_hist[SYNAPTICS_MOVE_HISTORY]; /* movement history */
- int hist_index; /* Last added entry in move_hist[] */
- int hyst_center_x; /* center x of hysteresis*/
- int hyst_center_y; /* center y of hysteresis*/
+ Bool absolute_events; /* post absolute motion events instead of relative */
+ SynapticsMoveHistRec move_hist[SYNAPTICS_MOVE_HISTORY]; /* movement history */
+ int hist_index; /* Last added entry in move_hist[] */
+ int hyst_center_x; /* center x of hysteresis */
+ int hyst_center_y; /* center y of hysteresis */
struct {
- int last_x; /* last x-scroll position */
- int last_y; /* last y-scroll position */
- double delta_x; /* accumulated horiz scroll delta */
- double delta_y; /* accumulated vert scroll delta */
- double last_a; /* last angle-scroll position */
- CARD32 last_millis; /* time last scroll event posted */
- double coast_speed_x; /* Horizontal coasting speed */
- double coast_speed_y; /* Vertical coasting speed */
- double coast_delta_x; /* Accumulated horizontal coast delta */
- double coast_delta_y; /* Accumulated vertical coast delta */
- int packets_this_scroll; /* Events received for this scroll */
+ int last_x; /* last x-scroll position */
+ int last_y; /* last y-scroll position */
+ double delta_x; /* accumulated horiz scroll delta */
+ double delta_y; /* accumulated vert scroll delta */
+ double last_a; /* last angle-scroll position */
+ CARD32 last_millis; /* time last scroll event posted */
+ double coast_speed_x; /* Horizontal coasting speed */
+ double coast_speed_y; /* Vertical coasting speed */
+ double coast_delta_x; /* Accumulated horizontal coast delta */
+ double coast_delta_y; /* Accumulated vertical coast delta */
+ int packets_this_scroll; /* Events received for this scroll */
} scroll;
- int count_packet_finger; /* packet counter with finger on the touchpad */
- int button_delay_millis; /* button delay for 3rd button emulation */
- Bool prev_up; /* Previous up button value, for double click emulation */
- enum FingerState finger_state; /* previous finger state */
- CARD32 last_motion_millis; /* time of the last motion */
-
- enum TapState tap_state; /* State of tap processing */
- int tap_max_fingers; /* Max number of fingers seen since entering start state */
- int tap_button; /* Which button started the tap processing */
- enum TapButtonState tap_button_state; /* Current tap action */
- SynapticsMoveHistRec touch_on; /* data when the touchpad is touched/released */
-
- enum MovingState moving_state; /* previous moving state */
- Bool vert_scroll_edge_on; /* Keeps track of currently active scroll modes */
- Bool horiz_scroll_edge_on; /* Keeps track of currently active scroll modes */
- Bool vert_scroll_twofinger_on; /* Keeps track of currently active scroll modes */
- Bool horiz_scroll_twofinger_on; /* Keeps track of currently active scroll modes */
- Bool circ_scroll_on; /* Keeps track of currently active scroll modes */
- Bool circ_scroll_vert; /* True: Generate vertical scroll events
- False: Generate horizontal events */
- int trackstick_neutral_x; /* neutral x position for trackstick mode */
- int trackstick_neutral_y; /* neutral y position for trackstick mode */
- double frac_x, frac_y; /* absolute -> relative fraction */
- enum MidButtonEmulation mid_emu_state; /* emulated 3rd button */
- int repeatButtons; /* buttons for repeat */
- int nextRepeat; /* Time when to trigger next auto repeat event */
- int lastButtons; /* last state of the buttons */
- int prev_z; /* previous z value, for palm detection */
- int prevFingers; /* previous numFingers, for transition detection */
- int avg_width; /* weighted average of previous fingerWidth values */
- double horiz_coeff; /* normalization factor for x coordintes */
- double vert_coeff; /* normalization factor for y coordintes */
-
- int minx, maxx, miny, maxy; /* min/max dimensions as detected */
- int minp, maxp, minw, maxw; /* min/max pressure and finger width as detected */
- int resx, resy; /* resolution of coordinates as detected in units/mm */
- Bool has_left; /* left button detected for this device */
- Bool has_right; /* right button detected for this device */
- Bool has_middle; /* middle button detected for this device */
- Bool has_double; /* double click detected for this device */
- Bool has_triple; /* triple click detected for this device */
- Bool has_pressure; /* device reports pressure */
- Bool has_width; /* device reports finger width */
- Bool has_scrollbuttons; /* device has physical scrollbuttons */
- Bool has_semi_mt; /* device is only semi-multitouch capable */
-
- enum TouchpadModel model; /* The detected model */
- unsigned short id_vendor; /* vendor id */
- unsigned short id_product; /* product id */
+ int count_packet_finger; /* packet counter with finger on the touchpad */
+ int button_delay_millis; /* button delay for 3rd button emulation */
+ Bool prev_up; /* Previous up button value, for double click emulation */
+ enum FingerState finger_state; /* previous finger state */
+ CARD32 last_motion_millis; /* time of the last motion */
+
+ enum TapState tap_state; /* State of tap processing */
+ int tap_max_fingers; /* Max number of fingers seen since entering start state */
+ int tap_button; /* Which button started the tap processing */
+ enum TapButtonState tap_button_state; /* Current tap action */
+ SynapticsMoveHistRec touch_on; /* data when the touchpad is touched/released */
+
+ enum MovingState moving_state; /* previous moving state */
+ Bool vert_scroll_edge_on; /* Keeps track of currently active scroll modes */
+ Bool horiz_scroll_edge_on; /* Keeps track of currently active scroll modes */
+ Bool vert_scroll_twofinger_on; /* Keeps track of currently active scroll modes */
+ Bool horiz_scroll_twofinger_on; /* Keeps track of currently active scroll modes */
+ Bool circ_scroll_on; /* Keeps track of currently active scroll modes */
+ Bool circ_scroll_vert; /* True: Generate vertical scroll events
+ False: Generate horizontal events */
+ int trackstick_neutral_x; /* neutral x position for trackstick mode */
+ int trackstick_neutral_y; /* neutral y position for trackstick mode */
+ double frac_x, frac_y; /* absolute -> relative fraction */
+ enum MidButtonEmulation mid_emu_state; /* emulated 3rd button */
+ int repeatButtons; /* buttons for repeat */
+ int nextRepeat; /* Time when to trigger next auto repeat event */
+ int lastButtons; /* last state of the buttons */
+ int prev_z; /* previous z value, for palm detection */
+ int prevFingers; /* previous numFingers, for transition detection */
+ int avg_width; /* weighted average of previous fingerWidth values */
+ double horiz_coeff; /* normalization factor for x coordintes */
+ double vert_coeff; /* normalization factor for y coordintes */
+
+ int minx, maxx, miny, maxy; /* min/max dimensions as detected */
+ int minp, maxp, minw, maxw; /* min/max pressure and finger width as detected */
+ int resx, resy; /* resolution of coordinates as detected in units/mm */
+ Bool has_left; /* left button detected for this device */
+ Bool has_right; /* right button detected for this device */
+ Bool has_middle; /* middle button detected for this device */
+ Bool has_double; /* double click detected for this device */
+ Bool has_triple; /* triple click detected for this device */
+ Bool has_pressure; /* device reports pressure */
+ Bool has_width; /* device reports finger width */
+ Bool has_scrollbuttons; /* device has physical scrollbuttons */
+ Bool has_semi_mt; /* device is only semi-multitouch capable */
+
+ enum TouchpadModel model; /* The detected model */
+ unsigned short id_vendor; /* vendor id */
+ unsigned short id_product; /* product id */
#ifdef HAVE_SMOOTH_SCROLL
- int scroll_axis_horiz; /* Horizontal smooth-scrolling axis */
- int scroll_axis_vert; /* Vertical smooth-scrolling axis */
+ int scroll_axis_horiz; /* Horizontal smooth-scrolling axis */
+ int scroll_axis_vert; /* Vertical smooth-scrolling axis */
ValuatorMask *scroll_events_mask; /* ValuatorMask for smooth-scrolling */
#endif
#ifdef HAVE_MULTITOUCH
- Bool has_touch; /* Device has multitouch capabilities */
- int max_touches; /* Number of touches supported */
- int num_mt_axes; /* Number of multitouch axes other than X, Y */
+ Bool has_touch; /* Device has multitouch capabilities */
+ int max_touches; /* Number of touches supported */
+ int num_mt_axes; /* Number of multitouch axes other than X, Y */
SynapticsTouchAxisRec *touch_axes; /* Touch axis information other than X, Y */
- int num_slots; /* Number of touch slots allocated */
- int *open_slots; /* Array of currently open touch slots */
- int num_active_touches; /* Number of active touches on device */
+ int num_slots; /* Number of touch slots allocated */
+ int *open_slots; /* Array of currently open touch slots */
+ int num_active_touches; /* Number of active touches on device */
#endif
};
-#endif /* _SYNAPTICSSTR_H_ */
+#endif /* _SYNAPTICSSTR_H_ */
diff --git a/src/synproto.c b/src/synproto.c
index 8e67800..d6e8c65 100644
--- a/src/synproto.c
+++ b/src/synproto.c
@@ -21,14 +21,13 @@
* DEALINGS IN THE SOFTWARE.
*/
-
#include "synproto.h"
#include "synaptics.h"
#include "synapticsstr.h"
#ifdef HAVE_MULTITOUCH
static int
-HwStateAllocTouch(struct SynapticsHwState *hw, SynapticsPrivate *priv)
+HwStateAllocTouch(struct SynapticsHwState *hw, SynapticsPrivate * priv)
{
int num_vals;
int i = 0;
@@ -38,12 +37,11 @@ HwStateAllocTouch(struct SynapticsHwState *hw, SynapticsPrivate *priv)
if (!hw->mt_mask)
goto fail;
- num_vals = 2; /* x and y */
- num_vals += 2; /* scroll axes */
+ num_vals = 2; /* x and y */
+ num_vals += 2; /* scroll axes */
num_vals += priv->num_mt_axes;
- for (; i < hw->num_mt_mask; i++)
- {
+ for (; i < hw->num_mt_mask; i++) {
hw->mt_mask[i] = valuator_mask_new(num_vals);
if (!hw->mt_mask[i])
goto fail;
@@ -55,7 +53,7 @@ HwStateAllocTouch(struct SynapticsHwState *hw, SynapticsPrivate *priv)
return Success;
-fail:
+ fail:
for (i--; i >= 0; i--)
valuator_mask_free(&hw->mt_mask[i]);
free(hw->mt_mask);
@@ -65,7 +63,7 @@ fail:
#endif
struct SynapticsHwState *
-SynapticsHwStateAlloc(SynapticsPrivate *priv)
+SynapticsHwStateAlloc(SynapticsPrivate * priv)
{
struct SynapticsHwState *hw;
@@ -74,8 +72,7 @@ SynapticsHwStateAlloc(SynapticsPrivate *priv)
return NULL;
#ifdef HAVE_MULTITOUCH
- if (HwStateAllocTouch(hw, priv) != Success)
- {
+ if (HwStateAllocTouch(hw, priv) != Success) {
free(hw);
return NULL;
}
@@ -162,25 +159,24 @@ SynapticsResetTouchHwState(struct SynapticsHwState *hw, Bool set_slot_empty)
#ifdef HAVE_MULTITOUCH
int i;
- for (i = 0; i < hw->num_mt_mask; i++)
- {
+ for (i = 0; i < hw->num_mt_mask; i++) {
int j;
/* Leave x and y valuators in case we need to restart touch */
for (j = 2; j < valuator_mask_num_valuators(hw->mt_mask[i]); j++)
valuator_mask_unset(hw->mt_mask[i], j);
- switch (hw->slot_state[i])
- {
- case SLOTSTATE_OPEN:
- case SLOTSTATE_OPEN_EMPTY:
- case SLOTSTATE_UPDATE:
- hw->slot_state[i] = set_slot_empty ? SLOTSTATE_EMPTY : SLOTSTATE_OPEN_EMPTY;
- break;
-
- default:
- hw->slot_state[i] = SLOTSTATE_EMPTY;
- break;
+ switch (hw->slot_state[i]) {
+ case SLOTSTATE_OPEN:
+ case SLOTSTATE_OPEN_EMPTY:
+ case SLOTSTATE_UPDATE:
+ hw->slot_state[i] =
+ set_slot_empty ? SLOTSTATE_EMPTY : SLOTSTATE_OPEN_EMPTY;
+ break;
+
+ default:
+ hw->slot_state[i] = SLOTSTATE_EMPTY;
+ break;
}
}
#endif
diff --git a/src/synproto.h b/src/synproto.h
index 413579d..a099fce 100644
--- a/src/synproto.h
+++ b/src/synproto.h
@@ -37,8 +37,7 @@
struct _SynapticsPrivateRec;
typedef struct _SynapticsPrivateRec SynapticsPrivate;
-enum SynapticsSlotState
-{
+enum SynapticsSlotState {
SLOTSTATE_EMPTY = 0,
SLOTSTATE_OPEN,
SLOTSTATE_CLOSE,
@@ -53,12 +52,12 @@ enum SynapticsSlotState
* A structure to describe the state of the touchpad hardware (buttons and pad)
*/
struct SynapticsHwState {
- CARD32 millis; /* Timestamp in milliseconds */
- int x; /* X position of finger */
- int y; /* Y position of finger */
- int z; /* Finger pressure */
- int cumulative_dx; /* Cumulative delta X for clickpad dragging */
- int cumulative_dy; /* Cumulative delta Y for clickpad dragging */
+ CARD32 millis; /* Timestamp in milliseconds */
+ int x; /* X position of finger */
+ int y; /* Y position of finger */
+ int z; /* Finger pressure */
+ int cumulative_dx; /* Cumulative delta X for clickpad dragging */
+ int cumulative_dy; /* Cumulative delta Y for clickpad dragging */
int numFingers;
int fingerWidth;
@@ -68,7 +67,7 @@ struct SynapticsHwState {
Bool down;
Bool multi[8];
- Bool middle; /* Some ALPS touchpads have a middle button */
+ Bool middle; /* Some ALPS touchpads have a middle button */
#ifdef HAVE_MULTITOUCH
int num_mt_mask;
@@ -79,10 +78,10 @@ struct SynapticsHwState {
struct CommData {
XISBuffer *buffer;
- unsigned char protoBuf[6]; /* Buffer for Packet */
- unsigned char lastByte; /* Last read byte. Use for reset sequence detection. */
- int outOfSync; /* How many consecutive incorrect packets we
- have received */
+ unsigned char protoBuf[6]; /* Buffer for Packet */
+ unsigned char lastByte; /* Last read byte. Use for reset sequence detection. */
+ int outOfSync; /* How many consecutive incorrect packets we
+ have received */
int protoBufTail;
/* Used for keeping track of partial HwState updates. */
@@ -95,33 +94,36 @@ struct CommData {
struct _SynapticsParameters;
struct SynapticsProtocolOperations {
- Bool (*DeviceOnHook)(InputInfoPtr pInfo, struct _SynapticsParameters *para);
- Bool (*DeviceOffHook)(InputInfoPtr pInfo);
- Bool (*QueryHardware)(InputInfoPtr pInfo);
- Bool (*ReadHwState)(InputInfoPtr pInfo,
- struct CommData *comm, struct SynapticsHwState *hwRet);
- Bool (*AutoDevProbe)(InputInfoPtr pInfo, const char *device);
- void (*ReadDevDimensions)(InputInfoPtr pInfo);
+ Bool (*DeviceOnHook) (InputInfoPtr pInfo,
+ struct _SynapticsParameters * para);
+ Bool (*DeviceOffHook) (InputInfoPtr pInfo);
+ Bool (*QueryHardware) (InputInfoPtr pInfo);
+ Bool (*ReadHwState) (InputInfoPtr pInfo,
+ struct CommData * comm,
+ struct SynapticsHwState * hwRet);
+ Bool (*AutoDevProbe) (InputInfoPtr pInfo, const char *device);
+ void (*ReadDevDimensions) (InputInfoPtr pInfo);
};
#ifdef BUILD_PS2COMM
extern struct SynapticsProtocolOperations psaux_proto_operations;
extern struct SynapticsProtocolOperations alps_proto_operations;
-#endif /* BUILD_PS2COMM */
+#endif /* BUILD_PS2COMM */
#ifdef BUILD_EVENTCOMM
extern struct SynapticsProtocolOperations event_proto_operations;
-#endif /* BUILD_EVENTCOMM */
+#endif /* BUILD_EVENTCOMM */
#ifdef BUILD_PSMCOMM
extern struct SynapticsProtocolOperations psm_proto_operations;
-#endif /* BUILD_PSMCOMM */
+#endif /* BUILD_PSMCOMM */
-extern struct SynapticsHwState *SynapticsHwStateAlloc(SynapticsPrivate *priv);
+extern struct SynapticsHwState *SynapticsHwStateAlloc(SynapticsPrivate * priv);
extern void SynapticsHwStateFree(struct SynapticsHwState **hw);
extern void SynapticsCopyHwState(struct SynapticsHwState *dst,
const struct SynapticsHwState *src);
extern void SynapticsResetHwState(struct SynapticsHwState *hw);
-extern void SynapticsResetTouchHwState(struct SynapticsHwState *hw, Bool force_empty);
+extern void SynapticsResetTouchHwState(struct SynapticsHwState *hw,
+ Bool force_empty);
extern Bool SynapticsIsSoftButtonAreasValid(int *values);
-#endif /* _SYNPROTO_H_ */
+#endif /* _SYNPROTO_H_ */