diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2010-09-01 13:42:37 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2010-09-01 13:42:37 +1000 |
commit | f0623c56b91d1444ceb0f18a3b090a06bd6817a9 (patch) | |
tree | 0c255d76b9e34ae31447c31d2e928bc1c062c248 | |
parent | 1a9495a74c41d956751177807602383ce4549c37 (diff) | |
parent | 81ad2e389d11691d5c2687d83150e8e9033cfe76 (diff) |
Merge branch 'input-api'
Conflicts:
src/properties.c
-rw-r--r-- | src/alpscomm.c | 12 | ||||
-rw-r--r-- | src/eventcomm.c | 92 | ||||
-rw-r--r-- | src/properties.c | 86 | ||||
-rw-r--r-- | src/ps2comm.c | 46 | ||||
-rw-r--r-- | src/psmcomm.c | 24 | ||||
-rw-r--r-- | src/synaptics.c | 378 | ||||
-rw-r--r-- | src/synapticsstr.h | 2 | ||||
-rw-r--r-- | src/synproto.h | 12 |
8 files changed, 338 insertions, 314 deletions
diff --git a/src/alpscomm.c b/src/alpscomm.c index a5a4344..84d2136 100644 --- a/src/alpscomm.c +++ b/src/alpscomm.c @@ -87,9 +87,9 @@ ALPS_initialize(int fd) } static Bool -ALPSQueryHardware(LocalDevicePtr local) +ALPSQueryHardware(InputInfoPtr pInfo) { - ALPS_initialize(local->fd); + ALPS_initialize(pInfo->fd); return TRUE; } @@ -103,7 +103,7 @@ ALPS_packet_ok(struct CommData *comm) } static Bool -ALPS_get_packet(struct CommData *comm, LocalDevicePtr local) +ALPS_get_packet(struct CommData *comm, InputInfoPtr pInfo) { int c; @@ -205,14 +205,14 @@ ALPS_process_packet(unsigned char *packet, struct SynapticsHwState *hw) } static Bool -ALPSReadHwState(LocalDevicePtr local, +ALPSReadHwState(InputInfoPtr pInfo, struct SynapticsProtocolOperations *proto_ops, struct CommData *comm, struct SynapticsHwState *hwRet) { unsigned char *buf = comm->protoBuf; struct SynapticsHwState *hw = &(comm->hwState); - if (!ALPS_get_packet(comm, local)) + if (!ALPS_get_packet(comm, pInfo)) return FALSE; ALPS_process_packet(buf, hw); @@ -222,7 +222,7 @@ ALPSReadHwState(LocalDevicePtr local, } static Bool -ALPSAutoDevProbe(LocalDevicePtr local) +ALPSAutoDevProbe(InputInfoPtr pInfo) { return FALSE; } diff --git a/src/eventcomm.c b/src/eventcomm.c index faa66ab..85dfd09 100644 --- a/src/eventcomm.c +++ b/src/eventcomm.c @@ -56,9 +56,9 @@ ****************************************************************************/ static void -EventDeviceOnHook(LocalDevicePtr local, SynapticsParameters *para) +EventDeviceOnHook(InputInfoPtr pInfo, SynapticsParameters *para) { - SynapticsPrivate *priv = (SynapticsPrivate *)local->private; + SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private; BOOL *need_grab; if (!priv->proto_data) @@ -69,10 +69,10 @@ EventDeviceOnHook(LocalDevicePtr local, SynapticsParameters *para) 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(local->fd, EVIOCGRAB, (pointer)1)); + SYSCALL(ret = ioctl(pInfo->fd, EVIOCGRAB, (pointer)1)); if (ret < 0) { xf86Msg(X_WARNING, "%s can't grab event device, errno=%d\n", - local->name, errno); + pInfo->name, errno); } } @@ -148,14 +148,14 @@ static model_lookup_t model_lookup_table[] = { }; static void -event_query_info(LocalDevicePtr local) +event_query_info(InputInfoPtr pInfo) { - SynapticsPrivate *priv = (SynapticsPrivate *)local->private; + SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private; short id[4]; int rc; model_lookup_t *model_lookup; - SYSCALL(rc = ioctl(local->fd, EVIOCGID, id)); + SYSCALL(rc = ioctl(pInfo->fd, EVIOCGID, id)); if (rc < 0) return; @@ -168,19 +168,19 @@ event_query_info(LocalDevicePtr local) /* Query device for axis ranges */ static void -event_query_axis_ranges(LocalDevicePtr local) +event_query_axis_ranges(InputInfoPtr pInfo) { - SynapticsPrivate *priv = (SynapticsPrivate *)local->private; + SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private; struct input_absinfo abs = {0}; unsigned long absbits[NBITS(ABS_MAX)] = {0}; unsigned long keybits[NBITS(KEY_MAX)] = {0}; char buf[256]; int rc; - SYSCALL(rc = ioctl(local->fd, EVIOCGABS(ABS_X), &abs)); + SYSCALL(rc = ioctl(pInfo->fd, EVIOCGABS(ABS_X), &abs)); if (rc >= 0) { - xf86Msg(X_PROBED, "%s: x-axis range %d - %d\n", local->name, + xf86Msg(X_PROBED, "%s: x-axis range %d - %d\n", pInfo->name, abs.minimum, abs.maximum); priv->minx = abs.minimum; priv->maxx = abs.maximum; @@ -188,13 +188,13 @@ event_query_axis_ranges(LocalDevicePtr local) priv->resx = abs.resolution; #endif } else - xf86Msg(X_ERROR, "%s: failed to query axis range (%s)\n", local->name, + xf86Msg(X_ERROR, "%s: failed to query axis range (%s)\n", pInfo->name, strerror(errno)); - SYSCALL(rc = ioctl(local->fd, EVIOCGABS(ABS_Y), &abs)); + SYSCALL(rc = ioctl(pInfo->fd, EVIOCGABS(ABS_Y), &abs)); if (rc >= 0) { - xf86Msg(X_PROBED, "%s: y-axis range %d - %d\n", local->name, + xf86Msg(X_PROBED, "%s: y-axis range %d - %d\n", pInfo->name, abs.minimum, abs.maximum); priv->miny = abs.minimum; priv->maxy = abs.maximum; @@ -202,27 +202,27 @@ event_query_axis_ranges(LocalDevicePtr local) priv->resy = abs.resolution; #endif } else - xf86Msg(X_ERROR, "%s: failed to query axis range (%s)\n", local->name, + xf86Msg(X_ERROR, "%s: failed to query axis range (%s)\n", pInfo->name, strerror(errno)); priv->has_pressure = FALSE; priv->has_width = FALSE; - SYSCALL(rc = ioctl(local->fd, EVIOCGBIT(EV_ABS, sizeof(absbits)), absbits)); + 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); } else - xf86Msg(X_ERROR, "%s: failed to query ABS bits (%s)\n", local->name, + xf86Msg(X_ERROR, "%s: failed to query ABS bits (%s)\n", pInfo->name, strerror(errno)); if (priv->has_pressure) { - SYSCALL(rc = ioctl(local->fd, EVIOCGABS(ABS_PRESSURE), &abs)); + SYSCALL(rc = ioctl(pInfo->fd, EVIOCGABS(ABS_PRESSURE), &abs)); if (rc >= 0) { - xf86Msg(X_PROBED, "%s: pressure range %d - %d\n", local->name, + xf86Msg(X_PROBED, "%s: pressure range %d - %d\n", pInfo->name, abs.minimum, abs.maximum); priv->minp = abs.minimum; priv->maxp = abs.maximum; @@ -230,21 +230,21 @@ event_query_axis_ranges(LocalDevicePtr local) } else xf86Msg(X_INFO, "%s: device does not report pressure, will use touch data.\n", - local->name); + pInfo->name); if (priv->has_width) { - SYSCALL(rc = ioctl(local->fd, EVIOCGABS(ABS_TOOL_WIDTH), &abs)); + SYSCALL(rc = ioctl(pInfo->fd, EVIOCGABS(ABS_TOOL_WIDTH), &abs)); if (rc >= 0) { - xf86Msg(X_PROBED, "%s: finger width range %d - %d\n", local->name, + xf86Msg(X_PROBED, "%s: finger width range %d - %d\n", pInfo->name, abs.minimum, abs.maximum); priv->minw = abs.minimum; priv->maxw = abs.maximum; } } - SYSCALL(rc = ioctl(local->fd, EVIOCGBIT(EV_KEY, sizeof(keybits)), keybits)); + SYSCALL(rc = ioctl(pInfo->fd, EVIOCGBIT(EV_KEY, sizeof(keybits)), keybits)); if (rc >= 0) { buf[0] = 0; @@ -268,56 +268,56 @@ event_query_axis_ranges(LocalDevicePtr local) strcat(buf, " scroll-buttons"); } - xf86Msg(X_PROBED, "%s: buttons:%s\n", local->name, buf); + xf86Msg(X_PROBED, "%s: buttons:%s\n", pInfo->name, buf); } } static Bool -EventQueryHardware(LocalDevicePtr local) +EventQueryHardware(InputInfoPtr pInfo) { - SynapticsPrivate *priv = (SynapticsPrivate *)local->private; + SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private; BOOL *need_grab = (BOOL*)priv->proto_data; - if (!event_query_is_touchpad(local->fd, (need_grab) ? *need_grab : TRUE)) + if (!event_query_is_touchpad(pInfo->fd, (need_grab) ? *need_grab : TRUE)) return FALSE; - xf86Msg(X_PROBED, "%s: touchpad found\n", local->name); + xf86Msg(X_PROBED, "%s: touchpad found\n", pInfo->name); return TRUE; } static Bool -SynapticsReadEvent(LocalDevicePtr local, struct input_event *ev) +SynapticsReadEvent(InputInfoPtr pInfo, struct input_event *ev) { int rc = TRUE; ssize_t len; - len = read(local->fd, ev, sizeof(*ev)); + len = read(pInfo->fd, ev, sizeof(*ev)); 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", local->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.", local->name); + xf86MsgVerb(X_NONE, 0, "%s: Read error, invalid number of bytes.", pInfo->name); rc = FALSE; } return rc; } static Bool -EventReadHwState(LocalDevicePtr local, +EventReadHwState(InputInfoPtr pInfo, struct SynapticsProtocolOperations *proto_ops, struct CommData *comm, struct SynapticsHwState *hwRet) { struct input_event ev; Bool v; struct SynapticsHwState *hw = &(comm->hwState); - SynapticsPrivate *priv = (SynapticsPrivate *)local->private; + SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private; SynapticsParameters *para = &priv->synpara; - while (SynapticsReadEvent(local, &ev)) { + while (SynapticsReadEvent(pInfo, &ev)) { switch (ev.type) { case EV_SYN: switch (ev.code) { @@ -420,18 +420,18 @@ static int EventDevOnly(const struct dirent *dir) { * Probe the open device for dimensions. */ static void -EventReadDevDimensions(LocalDevicePtr local) +EventReadDevDimensions(InputInfoPtr pInfo) { - SynapticsPrivate *priv = (SynapticsPrivate *)local->private; + SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private; BOOL *need_grab = (BOOL*)priv->proto_data; - if (event_query_is_touchpad(local->fd, (need_grab) ? *need_grab : TRUE)) - event_query_axis_ranges(local); - event_query_info(local); + if (event_query_is_touchpad(pInfo->fd, (need_grab) ? *need_grab : TRUE)) + event_query_axis_ranges(pInfo); + event_query_info(pInfo); } static Bool -EventAutoDevProbe(LocalDevicePtr local) +EventAutoDevProbe(InputInfoPtr pInfo) { /* We are trying to find the right eventX device or fall back to the psaux protocol and the given device from XF86Config */ @@ -446,7 +446,7 @@ EventAutoDevProbe(LocalDevicePtr local) } else if (i == 0) { xf86Msg(X_ERROR, "%s The /dev/input/event* device nodes seem to be missing\n", - local->name); + pInfo->name); free(namelist); return FALSE; } @@ -464,9 +464,9 @@ EventAutoDevProbe(LocalDevicePtr local) if (event_query_is_touchpad(fd, TRUE)) { touchpad_found = TRUE; xf86Msg(X_PROBED, "%s auto-dev sets device to %s\n", - local->name, fname); - local->options = - xf86ReplaceStrOption(local->options, "Device", fname); + pInfo->name, fname); + pInfo->options = + xf86ReplaceStrOption(pInfo->options, "Device", fname); } SYSCALL(close(fd)); } @@ -475,7 +475,7 @@ EventAutoDevProbe(LocalDevicePtr local) free(namelist); if (!touchpad_found) { - xf86Msg(X_ERROR, "%s no synaptics event device found\n", local->name); + xf86Msg(X_ERROR, "%s no synaptics event device found\n", pInfo->name); return FALSE; } return TRUE; diff --git a/src/properties.c b/src/properties.c index ee9a5a6..5400928 100644 --- a/src/properties.c +++ b/src/properties.c @@ -132,9 +132,9 @@ InitFloatAtom(DeviceIntPtr dev, char *name, int nvalues, float *values) } void -InitDeviceProperties(LocalDevicePtr local) +InitDeviceProperties(InputInfoPtr pInfo) { - SynapticsPrivate *priv = (SynapticsPrivate *) local->private; + 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 */ @@ -146,7 +146,7 @@ InitDeviceProperties(LocalDevicePtr local) if (!float_type) { xf86Msg(X_ERROR, "%s: Failed to init float atom. " - "Disabling property support.\n", local->name); + "Disabling property support.\n", pInfo->name); return; } } @@ -156,109 +156,109 @@ InitDeviceProperties(LocalDevicePtr local) values[2] = para->top_edge; values[3] = para->bottom_edge; - prop_edges = InitAtom(local->dev, SYNAPTICS_PROP_EDGES, 32, 4, values); + prop_edges = InitAtom(pInfo->dev, SYNAPTICS_PROP_EDGES, 32, 4, values); values[0] = para->finger_low; values[1] = para->finger_high; values[2] = para->finger_press; - prop_finger = InitAtom(local->dev, SYNAPTICS_PROP_FINGER, 32, 3, values); - prop_tap_time = InitAtom(local->dev, SYNAPTICS_PROP_TAP_TIME, 32, 1, ¶->tap_time); - prop_tap_move = InitAtom(local->dev, SYNAPTICS_PROP_TAP_MOVE, 32, 1, ¶->tap_move); + prop_finger = InitAtom(pInfo->dev, SYNAPTICS_PROP_FINGER, 32, 3, values); + prop_tap_time = InitAtom(pInfo->dev, SYNAPTICS_PROP_TAP_TIME, 32, 1, ¶->tap_time); + prop_tap_move = InitAtom(pInfo->dev, SYNAPTICS_PROP_TAP_MOVE, 32, 1, ¶->tap_move); values[0] = para->single_tap_timeout; values[1] = para->tap_time_2; values[2] = para->click_time; - prop_tap_durations = InitAtom(local->dev, SYNAPTICS_PROP_TAP_DURATIONS, 32, 3, values); - prop_tap_fast = InitAtom(local->dev, SYNAPTICS_PROP_TAP_FAST, 8, 1, ¶->fast_taps); - prop_middle_timeout = InitAtom(local->dev, SYNAPTICS_PROP_MIDDLE_TIMEOUT, + prop_tap_durations = InitAtom(pInfo->dev, SYNAPTICS_PROP_TAP_DURATIONS, 32, 3, values); + prop_tap_fast = InitAtom(pInfo->dev, SYNAPTICS_PROP_TAP_FAST, 8, 1, ¶->fast_taps); + prop_middle_timeout = InitAtom(pInfo->dev, SYNAPTICS_PROP_MIDDLE_TIMEOUT, 32, 1, ¶->emulate_mid_button_time); - prop_twofinger_pressure = InitAtom(local->dev, SYNAPTICS_PROP_TWOFINGER_PRESSURE, + prop_twofinger_pressure = InitAtom(pInfo->dev, SYNAPTICS_PROP_TWOFINGER_PRESSURE, 32, 1, ¶->emulate_twofinger_z); - prop_twofinger_width = InitAtom(local->dev, SYNAPTICS_PROP_TWOFINGER_WIDTH, + prop_twofinger_width = InitAtom(pInfo->dev, SYNAPTICS_PROP_TWOFINGER_WIDTH, 32, 1, ¶->emulate_twofinger_w); values[0] = para->scroll_dist_vert; values[1] = para->scroll_dist_horiz; - prop_scrolldist = InitAtom(local->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(local->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(local->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; fvalues[2] = para->accl; fvalues[3] = para->trackstick_speed; - prop_speed = InitFloatAtom(local->dev, SYNAPTICS_PROP_SPEED, 4, fvalues); + prop_speed = InitFloatAtom(pInfo->dev, SYNAPTICS_PROP_SPEED, 4, fvalues); values[0] = para->edge_motion_min_z; values[1] = para->edge_motion_max_z; - prop_edgemotion_pressure = InitAtom(local->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(local->dev, SYNAPTICS_PROP_EDGEMOTION_SPEED, 32, 2, values); - prop_edgemotion_always = InitAtom(local->dev, SYNAPTICS_PROP_EDGEMOTION, 8, 1, ¶->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, ¶->edge_motion_use_always); if (priv->has_scrollbuttons) { values[0] = para->updown_button_scrolling; values[1] = para->leftright_button_scrolling; - prop_buttonscroll = InitAtom(local->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(local->dev, SYNAPTICS_PROP_BUTTONSCROLLING_REPEAT, 8, 2, values); - prop_buttonscroll_time = InitAtom(local->dev, SYNAPTICS_PROP_BUTTONSCROLLING_TIME, 32, 1, ¶->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, ¶->scroll_button_repeat); } - prop_off = InitAtom(local->dev, SYNAPTICS_PROP_OFF, 8, 1, ¶->touchpad_off); - prop_lockdrags = InitAtom(local->dev, SYNAPTICS_PROP_LOCKED_DRAGS, 8, 1, ¶->locked_drags); - prop_lockdrags_time = InitAtom(local->dev, SYNAPTICS_PROP_LOCKED_DRAGS_TIMEOUT, 32, 1, ¶->locked_drag_time); + prop_off = InitAtom(pInfo->dev, SYNAPTICS_PROP_OFF, 8, 1, ¶->touchpad_off); + prop_lockdrags = InitAtom(pInfo->dev, SYNAPTICS_PROP_LOCKED_DRAGS, 8, 1, ¶->locked_drags); + prop_lockdrags_time = InitAtom(pInfo->dev, SYNAPTICS_PROP_LOCKED_DRAGS_TIMEOUT, 32, 1, ¶->locked_drag_time); memcpy(values, para->tap_action, MAX_TAP * sizeof(int)); - prop_tapaction = InitAtom(local->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(local->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(local->dev, SYNAPTICS_PROP_CIRCULAR_SCROLLING, 8, 1, ¶->circular_scrolling); + prop_circscroll = InitAtom(pInfo->dev, SYNAPTICS_PROP_CIRCULAR_SCROLLING, 8, 1, ¶->circular_scrolling); fvalues[0] = para->scroll_dist_circ; - prop_circscroll_dist = InitFloatAtom(local->dev, SYNAPTICS_PROP_CIRCULAR_SCROLLING_DIST, 1, fvalues); + prop_circscroll_dist = InitFloatAtom(pInfo->dev, SYNAPTICS_PROP_CIRCULAR_SCROLLING_DIST, 1, fvalues); - prop_circscroll_trigger = InitAtom(local->dev, SYNAPTICS_PROP_CIRCULAR_SCROLLING_TRIGGER, 8, 1, ¶->circular_trigger); - prop_circpad = InitAtom(local->dev, SYNAPTICS_PROP_CIRCULAR_PAD, 8, 1, ¶->circular_pad); - prop_palm = InitAtom(local->dev, SYNAPTICS_PROP_PALM_DETECT, 8, 1, ¶->palm_detect); + prop_circscroll_trigger = InitAtom(pInfo->dev, SYNAPTICS_PROP_CIRCULAR_SCROLLING_TRIGGER, 8, 1, ¶->circular_trigger); + prop_circpad = InitAtom(pInfo->dev, SYNAPTICS_PROP_CIRCULAR_PAD, 8, 1, ¶->circular_pad); + prop_palm = InitAtom(pInfo->dev, SYNAPTICS_PROP_PALM_DETECT, 8, 1, ¶->palm_detect); values[0] = para->palm_min_width; values[1] = para->palm_min_z; - prop_palm_dim = InitAtom(local->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(local->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 = InitAtom(local->dev, SYNAPTICS_PROP_PRESSURE_MOTION, 32, 2, values); + prop_pressuremotion = InitAtom(pInfo->dev, SYNAPTICS_PROP_PRESSURE_MOTION, 32, 2, values); fvalues[0] = para->press_motion_min_factor; fvalues[1] = para->press_motion_max_factor; - prop_pressuremotion_factor = InitFloatAtom(local->dev, SYNAPTICS_PROP_PRESSURE_MOTION_FACTOR, 2, fvalues); + prop_pressuremotion_factor = InitFloatAtom(pInfo->dev, SYNAPTICS_PROP_PRESSURE_MOTION_FACTOR, 2, fvalues); - prop_grab = InitAtom(local->dev, SYNAPTICS_PROP_GRAB, 8, 1, ¶->grab_event_device); + prop_grab = InitAtom(pInfo->dev, SYNAPTICS_PROP_GRAB, 8, 1, ¶->grab_event_device); values[0] = para->tap_and_drag_gesture; - prop_gestures = InitAtom(local->dev, SYNAPTICS_PROP_GESTURES, 8, 1, values); + prop_gestures = InitAtom(pInfo->dev, SYNAPTICS_PROP_GESTURES, 8, 1, values); values[0] = priv->has_left; values[1] = priv->has_middle; @@ -267,25 +267,25 @@ InitDeviceProperties(LocalDevicePtr local) values[4] = priv->has_triple; values[5] = priv->has_pressure; values[6] = priv->has_width; - prop_capabilities = InitAtom(local->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(local->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; values[2] = para->area_top_edge; values[3] = para->area_bottom_edge; - prop_area = InitAtom(local->dev, SYNAPTICS_PROP_AREA, 32, 4, values); + prop_area = InitAtom(pInfo->dev, SYNAPTICS_PROP_AREA, 32, 4, values); } int SetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop, BOOL checkonly) { - LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; - SynapticsPrivate *priv = (SynapticsPrivate *) local->private; + InputInfoPtr pInfo = dev->public.devicePrivate; + SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private; SynapticsParameters *para = &priv->synpara; SynapticsParameters tmp; diff --git a/src/ps2comm.c b/src/ps2comm.c index 4b844c6..4e372b3 100644 --- a/src/ps2comm.c +++ b/src/ps2comm.c @@ -377,17 +377,17 @@ ps2_print_ident(const struct SynapticsHwInfo *synhw) } static void -PS2DeviceOffHook(LocalDevicePtr local) +PS2DeviceOffHook(InputInfoPtr pInfo) { - ps2_synaptics_reset(local->fd); - ps2_synaptics_enable_device(local->fd); + ps2_synaptics_reset(pInfo->fd); + ps2_synaptics_enable_device(pInfo->fd); } static Bool -PS2QueryHardware(LocalDevicePtr local) +PS2QueryHardware(InputInfoPtr pInfo) { int mode; - SynapticsPrivate *priv = (SynapticsPrivate *)local->private; + SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private; struct SynapticsHwInfo *synhw; if (!priv->proto_data) @@ -395,21 +395,21 @@ PS2QueryHardware(LocalDevicePtr local) synhw = (struct SynapticsHwInfo*)priv->proto_data; /* is the synaptics touchpad active? */ - if (!ps2_query_is_synaptics(local->fd, synhw)) + if (!ps2_query_is_synaptics(pInfo->fd, synhw)) return FALSE; - xf86Msg(X_PROBED, "%s synaptics touchpad found\n", local->name); + xf86Msg(X_PROBED, "%s synaptics touchpad found\n", pInfo->name); - if (!ps2_synaptics_reset(local->fd)) - xf86Msg(X_ERROR, "%s reset failed\n", local->name); + if (!ps2_synaptics_reset(pInfo->fd)) + xf86Msg(X_ERROR, "%s reset failed\n", pInfo->name); - if (!ps2_synaptics_identify(local->fd, synhw)) + if (!ps2_synaptics_identify(pInfo->fd, synhw)) return FALSE; - if (!ps2_synaptics_model_id(local->fd, synhw)) + if (!ps2_synaptics_model_id(pInfo->fd, synhw)) return FALSE; - if (!ps2_synaptics_capability(local->fd, synhw)) + if (!ps2_synaptics_capability(pInfo->fd, synhw)) return FALSE; mode = SYN_BIT_ABSOLUTE_MODE | SYN_BIT_HIGH_RATE; @@ -417,10 +417,10 @@ PS2QueryHardware(LocalDevicePtr local) mode |= SYN_BIT_DISABLE_GESTURE; if (SYN_CAP_EXTENDED(synhw)) mode |= SYN_BIT_W_MODE; - if (!ps2_synaptics_set_mode(local->fd, mode)) + if (!ps2_synaptics_set_mode(pInfo->fd, mode)) return FALSE; - ps2_synaptics_enable_device(local->fd); + ps2_synaptics_enable_device(pInfo->fd); ps2_print_ident(synhw); @@ -460,7 +460,7 @@ ps2_packet_ok(struct SynapticsHwInfo *synhw, struct CommData *comm) } static Bool -ps2_synaptics_get_packet(LocalDevicePtr local, struct SynapticsHwInfo *synhw, +ps2_synaptics_get_packet(InputInfoPtr pInfo, struct SynapticsHwInfo *synhw, struct SynapticsProtocolOperations *proto_ops, struct CommData *comm) { @@ -473,9 +473,9 @@ ps2_synaptics_get_packet(LocalDevicePtr local, struct SynapticsHwInfo *synhw, /* test if there is a reset sequence received */ if ((c == 0x00) && (comm->lastByte == 0xAA)) { - if (xf86WaitForInput(local->fd, 50000) == 0) { + if (xf86WaitForInput(pInfo->fd, 50000) == 0) { DBG(7, "Reset received\n"); - proto_ops->QueryHardware(local); + proto_ops->QueryHardware(pInfo); } else DBG(3, "faked reset received\n"); } @@ -501,7 +501,7 @@ ps2_synaptics_get_packet(LocalDevicePtr local, struct SynapticsHwInfo *synhw, if (comm->outOfSync > MAX_UNSYNC_PACKETS) { comm->outOfSync = 0; DBG(3, "Synaptics synchronization lost too long -> reset touchpad.\n"); - proto_ops->QueryHardware(local); /* including a reset */ + proto_ops->QueryHardware(pInfo); /* including a reset */ continue; } } @@ -521,13 +521,13 @@ ps2_synaptics_get_packet(LocalDevicePtr local, struct SynapticsHwInfo *synhw, } static Bool -PS2ReadHwState(LocalDevicePtr local, +PS2ReadHwState(InputInfoPtr pInfo, struct SynapticsProtocolOperations *proto_ops, struct CommData *comm, struct SynapticsHwState *hwRet) { unsigned char *buf = comm->protoBuf; struct SynapticsHwState *hw = &(comm->hwState); - SynapticsPrivate *priv = (SynapticsPrivate *)local->private; + SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private; SynapticsParameters *para = &priv->synpara; struct SynapticsHwInfo *synhw; int newabs; @@ -538,13 +538,13 @@ PS2ReadHwState(LocalDevicePtr local, { xf86Msg(X_ERROR, "%s: PS2ReadHwState, synhw is NULL. This is a bug.\n", - local->name); + pInfo->name); return FALSE; } newabs = SYN_MODEL_NEWABS(synhw); - if (!ps2_synaptics_get_packet(local, synhw, proto_ops, comm)) + if (!ps2_synaptics_get_packet(pInfo, synhw, proto_ops, comm)) return FALSE; /* Handle normal packets */ @@ -661,7 +661,7 @@ PS2ReadHwState(LocalDevicePtr local, } static Bool -PS2AutoDevProbe(LocalDevicePtr local) +PS2AutoDevProbe(InputInfoPtr pInfo) { return FALSE; } diff --git a/src/psmcomm.c b/src/psmcomm.c index 50ddd8f..66e8d1e 100644 --- a/src/psmcomm.c +++ b/src/psmcomm.c @@ -79,7 +79,7 @@ psm_synaptics_identify(int fd, synapticshw_t *ident) #define PSM_LEVEL_NATIVE 2 static Bool -PSMQueryIsSynaptics(LocalDevicePtr local) +PSMQueryIsSynaptics(InputInfoPtr pInfo) { int ret; int level = PSM_LEVEL_NATIVE; @@ -89,14 +89,14 @@ PSMQueryIsSynaptics(LocalDevicePtr local) * Otherwise HWINFO will not return the right id * And we will need native mode anyway ... */ - SYSCALL(ret = ioctl(local->fd, MOUSE_SETLEVEL, &level)); + SYSCALL(ret = ioctl(pInfo->fd, MOUSE_SETLEVEL, &level)); if (ret != 0) { - xf86Msg(X_ERROR, "%s Can't set native mode\n", local->name); + xf86Msg(X_ERROR, "%s Can't set native mode\n", pInfo->name); return FALSE; } - SYSCALL(ret = ioctl(local->fd, MOUSE_GETHWINFO, &mhw)); + SYSCALL(ret = ioctl(pInfo->fd, MOUSE_GETHWINFO, &mhw)); if (ret != 0) { - xf86Msg(X_ERROR, "%s Can't get hardware info\n", local->name); + xf86Msg(X_ERROR, "%s Can't get hardware info\n", pInfo->name); return FALSE; } @@ -104,7 +104,7 @@ PSMQueryIsSynaptics(LocalDevicePtr local) return TRUE; } else { xf86Msg(X_ERROR, "%s Found no Synaptics, found Mouse model %d instead\n", - local->name, mhw.model); + pInfo->name, mhw.model); return FALSE; } } @@ -134,13 +134,13 @@ convert_hw_info(const synapticshw_t *psm_ident, struct SynapticsHwInfo *synhw) } static Bool -PSMQueryHardware(LocalDevicePtr local) +PSMQueryHardware(InputInfoPtr pInfo) { synapticshw_t psm_ident; struct SynapticsHwInfo *synhw; SynapticsPrivate *priv; - priv = (SynapticsPrivate *)local->private; + priv = (SynapticsPrivate *)pInfo->private; if(!priv->proto_data) priv->proto_data = calloc(1, sizeof(struct SynapticsHwInfo)); @@ -150,9 +150,9 @@ PSMQueryHardware(LocalDevicePtr local) if (!PSMQueryIsSynaptics(local)) return FALSE; - xf86Msg(X_PROBED, "%s synaptics touchpad found\n", local->name); + xf86Msg(X_PROBED, "%s synaptics touchpad found\n", pInfo->name); - if (!psm_synaptics_identify(local->fd, &psm_ident)) + if (!psm_synaptics_identify(pInfo->fd, &psm_ident)) return FALSE; convert_hw_info(&psm_ident, synhw); @@ -163,14 +163,14 @@ PSMQueryHardware(LocalDevicePtr local) } static Bool -PSMReadHwState(LocalDevicePtr local, +PSMReadHwState(InputInfoPtr pInfo, struct SynapticsProtocolOperations *proto_ops, struct CommData *comm, struct SynapticsHwState *hwRet) { return psaux_proto_operations.ReadHwState(local, proto_ops, comm, hwRet); } -static Bool PSMAutoDevProbe(LocalDevicePtr local) +static Bool PSMAutoDevProbe(InputInfoPtr pInfo) { return FALSE; } diff --git a/src/synaptics.c b/src/synaptics.c index 53c3685..eae48d2 100644 --- a/src/synaptics.c +++ b/src/synaptics.c @@ -80,6 +80,12 @@ #include <ptrveloc.h> #endif +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12 +/* removed from server, purge when dropping support for server 1.10 */ +#define XI86_CONFIGURED 0x02 +#define XI86_SEND_DRAG_EVENTS 0x08 +#endif + typedef enum { NO_EDGE = 0, BOTTOM_EDGE = 1, @@ -111,25 +117,29 @@ typedef enum { /***************************************************************************** * Forward declaration ****************************************************************************/ +#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); +#endif static void SynapticsUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags); static Bool DeviceControl(DeviceIntPtr, int); -static void ReadInput(LocalDevicePtr); -static int HandleState(LocalDevicePtr, struct SynapticsHwState*); -static int ControlProc(LocalDevicePtr, xDeviceCtl*); -static void CloseProc(LocalDevicePtr); +static void ReadInput(InputInfoPtr); +static int HandleState(InputInfoPtr, struct SynapticsHwState*); +static int ControlProc(InputInfoPtr, xDeviceCtl*); +static void CloseProc(InputInfoPtr); static int SwitchMode(ClientPtr, DeviceIntPtr, int); -static Bool ConvertProc(LocalDevicePtr, int, int, int, int, int, int, int, int, int*, int*); +static Bool ConvertProc(InputInfoPtr, int, int, int, int, int, int, int, int, int*, int*); static Bool DeviceInit(DeviceIntPtr); static Bool DeviceOn(DeviceIntPtr); static Bool DeviceOff(DeviceIntPtr); static Bool DeviceClose(DeviceIntPtr); -static Bool QueryHardware(LocalDevicePtr); -static void ReadDevDimensions(LocalDevicePtr); +static Bool QueryHardware(InputInfoPtr); +static void ReadDevDimensions(InputInfoPtr); static void ScaleCoordinates(SynapticsPrivate *priv, struct SynapticsHwState *hw); static void CalculateScalingCoeffs(SynapticsPrivate *priv); -void InitDeviceProperties(LocalDevicePtr local); +void InitDeviceProperties(InputInfoPtr pInfo); int SetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop, BOOL checkonly); @@ -183,9 +193,9 @@ _X_EXPORT XF86ModuleData synapticsModuleData = { * men, or possibly apes. */ void -SynapticsDefaultDimensions(LocalDevicePtr local) +SynapticsDefaultDimensions(InputInfoPtr pInfo) { - SynapticsPrivate *priv = (SynapticsPrivate *)local->private; + SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private; if (priv->minx >= priv->maxx) { @@ -195,7 +205,7 @@ SynapticsDefaultDimensions(LocalDevicePtr local) xf86Msg(X_PROBED, "%s: invalid x-axis range. defaulting to %d - %d\n", - local->name, priv->minx, priv->maxx); + pInfo->name, priv->minx, priv->maxx); } if (priv->miny >= priv->maxy) @@ -206,7 +216,7 @@ SynapticsDefaultDimensions(LocalDevicePtr local) xf86Msg(X_PROBED, "%s: invalid y-axis range. defaulting to %d - %d\n", - local->name, priv->miny, priv->maxy); + pInfo->name, priv->miny, priv->maxy); } if (priv->minp >= priv->maxp) @@ -216,7 +226,7 @@ SynapticsDefaultDimensions(LocalDevicePtr local) xf86Msg(X_PROBED, "%s: invalid pressure range. defaulting to %d - %d\n", - local->name, priv->minp, priv->maxp); + pInfo->name, priv->minp, priv->maxp); } if (priv->minw >= priv->maxw) @@ -226,23 +236,23 @@ SynapticsDefaultDimensions(LocalDevicePtr local) xf86Msg(X_PROBED, "%s: invalid finger width range. defaulting to %d - %d\n", - local->name, priv->minw, priv->maxw); + pInfo->name, priv->minw, priv->maxw); } } static void -SetDeviceAndProtocol(LocalDevicePtr local) +SetDeviceAndProtocol(InputInfoPtr pInfo) { char *str_par, *device; - SynapticsPrivate *priv = local->private; + SynapticsPrivate *priv = pInfo->private; enum SynapticsProtocol proto = SYN_PROTO_PSAUX; - device = xf86FindOptionValue(local->options, "Device"); + device = xf86FindOptionValue(pInfo->options, "Device"); if (!device) { - device = xf86FindOptionValue(local->options, "Path"); + device = xf86FindOptionValue(pInfo->options, "Path"); if (device) { - local->options = - xf86ReplaceStrOption(local->options, "Device", device); + pInfo->options = + xf86ReplaceStrOption(pInfo->options, "Device", device); } } if (device && strstr(device, "/dev/input/event")) { @@ -250,7 +260,7 @@ SetDeviceAndProtocol(LocalDevicePtr local) proto = SYN_PROTO_EVENT; #endif } else { - str_par = xf86FindOptionValue(local->options, "Protocol"); + str_par = xf86FindOptionValue(pInfo->options, "Protocol"); if (str_par && !strcmp(str_par, "psaux")) { /* Already set up */ #ifdef BUILD_EVENTCOMM @@ -265,7 +275,7 @@ SetDeviceAndProtocol(LocalDevicePtr local) proto = SYN_PROTO_ALPS; } else { /* default to auto-dev */ #ifdef BUILD_EVENTCOMM - if (event_proto_operations.AutoDevProbe(local)) + if (event_proto_operations.AutoDevProbe(pInfo)) proto = SYN_PROTO_EVENT; #endif } @@ -296,10 +306,10 @@ SetDeviceAndProtocol(LocalDevicePtr local) * The function will allocate shared memory if priv->shm_config is TRUE. */ static Bool -alloc_param_data(LocalDevicePtr local) +alloc_param_data(InputInfoPtr pInfo) { int shmid; - SynapticsPrivate *priv = local->private; + SynapticsPrivate *priv = pInfo->private; if (priv->synshm) return TRUE; /* Already allocated */ @@ -309,11 +319,11 @@ alloc_param_data(LocalDevicePtr local) shmctl(shmid, IPC_RMID, NULL); if ((shmid = shmget(SHM_SYNAPTICS, sizeof(SynapticsSHM), 0774 | IPC_CREAT)) == -1) { - xf86Msg(X_ERROR, "%s error shmget\n", local->name); + xf86Msg(X_ERROR, "%s error shmget\n", pInfo->name); return FALSE; } if ((priv->synshm = (SynapticsSHM*)shmat(shmid, NULL, 0)) == NULL) { - xf86Msg(X_ERROR, "%s error shmat\n", local->name); + xf86Msg(X_ERROR, "%s error shmat\n", pInfo->name); return FALSE; } } else { @@ -402,10 +412,10 @@ static int set_percent_option(pointer options, const char* optname, return result; } -static void set_default_parameters(LocalDevicePtr local) +static void set_default_parameters(InputInfoPtr pInfo) { - SynapticsPrivate *priv = local->private; /* read-only */ - pointer opts = local->options; /* read-only */ + SynapticsPrivate *priv = pInfo->private; /* read-only */ + pointer opts = pInfo->options; /* read-only */ SynapticsParameters *pars = &priv->synpara; /* modified */ int horizScrollDelta, vertScrollDelta; /* pixels */ @@ -441,7 +451,7 @@ static void set_default_parameters(LocalDevicePtr local) * If the range was autodetected, apply these edge widths to all four * sides. */ - SynapticsDefaultDimensions(local); + SynapticsDefaultDimensions(pInfo); width = abs(priv->maxx - priv->minx); height = abs(priv->maxy - priv->miny); @@ -590,7 +600,7 @@ static void set_default_parameters(LocalDevicePtr local) pars->top_edge = pars->bottom_edge; pars->bottom_edge = tmp; xf86Msg(X_WARNING, "%s: TopEdge is bigger than BottomEdge. Fixing.\n", - local->name); + pInfo->name); } } @@ -599,8 +609,8 @@ static float SynapticsAccelerationProfile(DeviceIntPtr dev, float velocity, float thr, float acc) { - LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; - SynapticsPrivate *priv = (SynapticsPrivate *) (local->private); + InputInfoPtr pInfo = dev->public.devicePrivate; + SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private); SynapticsParameters* para = &priv->synpara; double accelfct; @@ -638,64 +648,78 @@ static float SynapticsAccelerationProfile(DeviceIntPtr dev, return accelfct; } +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12 +static int +NewSynapticsPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags); /* * called by the module loader for initialization */ static InputInfoPtr SynapticsPreInit(InputDriverPtr drv, IDevPtr dev, int flags) { - LocalDevicePtr local; + InputInfoPtr pInfo; + + /* Allocate a new InputInfoRec and add it to the head xf86InputDevs. */ + pInfo = xf86AllocateInput(drv, 0); + if (!pInfo) { + return NULL; + } + + /* initialize the InputInfoRec */ + 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; + + if (NewSynapticsPreInit(drv, pInfo, flags) != Success) + return NULL; + + return pInfo; +} + +static int +NewSynapticsPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) +#else +static int +SynapticsPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) +#endif +{ SynapticsPrivate *priv; + xf86Msg(X_INFO, "Synaptics touchpad driver version %s\n", PACKAGE_VERSION); + /* allocate memory for SynapticsPrivateRec */ priv = calloc(1, sizeof(SynapticsPrivate)); if (!priv) - return NULL; + return BadAlloc; + + pInfo->type_name = XI_TOUCHPAD; + pInfo->device_control = DeviceControl; + pInfo->read_input = ReadInput; + pInfo->control_proc = ControlProc; + pInfo->close_proc = CloseProc; + pInfo->switch_mode = SwitchMode; + pInfo->conversion_proc = ConvertProc; + pInfo->private = priv; + + xf86OptionListReport(pInfo->options); /* 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 NULL; + return BadAlloc; } - /* Allocate a new InputInfoRec and add it to the head xf86InputDevs. */ - local = xf86AllocateInput(drv, 0); - if (!local) { - free(priv->timer); - free(priv); - return NULL; - } - - /* initialize the InputInfoRec */ - local->name = dev->identifier; - local->type_name = XI_TOUCHPAD; - local->device_control = DeviceControl; - local->read_input = ReadInput; - local->control_proc = ControlProc; - local->close_proc = CloseProc; - local->switch_mode = SwitchMode; - local->conversion_proc = ConvertProc; - local->reverse_conversion_proc = NULL; - local->dev = NULL; - local->private = priv; - local->private_flags = 0; - local->flags = XI86_POINTER_CAPABLE | XI86_SEND_DRAG_EVENTS; - local->conf_idev = dev; - local->always_core_feedback = 0; - - xf86Msg(X_INFO, "Synaptics touchpad driver version %s\n", PACKAGE_VERSION); - - xf86CollectInputOptions(local, NULL, NULL); - - xf86OptionListReport(local->options); - - /* may change local->options */ - SetDeviceAndProtocol(local); + /* may change pInfo->options */ + SetDeviceAndProtocol(pInfo); /* open the touchpad device */ - local->fd = xf86OpenSerial(local->options); - if (local->fd == -1) { + pInfo->fd = xf86OpenSerial(pInfo->options); + if (pInfo->fd == -1) { xf86Msg(X_ERROR, "Synaptics driver unable to open device\n"); goto SetupProc_fail; } @@ -711,43 +735,43 @@ SynapticsPreInit(InputDriverPtr drv, IDevPtr dev, int flags) priv->touch_on.millis = 0; /* read hardware dimensions */ - ReadDevDimensions(local); + ReadDevDimensions(pInfo); /* install shared memory or normal memory for parameters */ - priv->shm_config = xf86SetBoolOption(local->options, "SHMConfig", FALSE); + priv->shm_config = xf86SetBoolOption(pInfo->options, "SHMConfig", FALSE); - set_default_parameters(local); + set_default_parameters(pInfo); CalculateScalingCoeffs(priv); - if (!alloc_param_data(local)) + if (!alloc_param_data(pInfo)) goto SetupProc_fail; - priv->comm.buffer = XisbNew(local->fd, INPUT_BUFFER_SIZE); + priv->comm.buffer = XisbNew(pInfo->fd, INPUT_BUFFER_SIZE); - if (!QueryHardware(local)) { - xf86Msg(X_ERROR, "%s Unable to query/initialize Synaptics hardware.\n", local->name); + if (!QueryHardware(pInfo)) { + xf86Msg(X_ERROR, "%s Unable to query/initialize Synaptics hardware.\n", pInfo->name); goto SetupProc_fail; } - xf86ProcessCommonOptions(local, local->options); - local->flags |= XI86_CONFIGURED; + xf86ProcessCommonOptions(pInfo, pInfo->options); + pInfo->flags |= XI86_CONFIGURED; - if (local->fd != -1) { + if (pInfo->fd != -1) { if (priv->comm.buffer) { XisbFree(priv->comm.buffer); priv->comm.buffer = NULL; } - xf86CloseSerial(local->fd); + xf86CloseSerial(pInfo->fd); } - local->fd = -1; + pInfo->fd = -1; - return local; + return Success; SetupProc_fail: - if (local->fd >= 0) { - xf86CloseSerial(local->fd); - local->fd = -1; + if (pInfo->fd >= 0) { + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; } if (priv->comm.buffer) @@ -756,8 +780,8 @@ SynapticsPreInit(InputDriverPtr drv, IDevPtr dev, int flags) free(priv->proto_data); free(priv->timer); free(priv); - local->private = NULL; - return local; + pInfo->private = NULL; + return BadAlloc; } @@ -765,17 +789,17 @@ SynapticsPreInit(InputDriverPtr drv, IDevPtr dev, int flags) * Uninitialize the device. */ static void SynapticsUnInit(InputDriverPtr drv, - InputInfoPtr local, + InputInfoPtr pInfo, int flags) { - SynapticsPrivate *priv = ((SynapticsPrivate *)local->private); + SynapticsPrivate *priv = ((SynapticsPrivate *)pInfo->private); if (priv && priv->timer) free(priv->timer); if (priv && priv->proto_data) free(priv->proto_data); - free(local->private); - local->private = NULL; - xf86DeleteInput(local, 0); + free(pInfo->private); + pInfo->private = NULL; + xf86DeleteInput(pInfo, 0); } @@ -816,41 +840,41 @@ DeviceControl(DeviceIntPtr dev, int mode) static Bool DeviceOn(DeviceIntPtr dev) { - LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; - SynapticsPrivate *priv = (SynapticsPrivate *) (local->private); + InputInfoPtr pInfo = dev->public.devicePrivate; + SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private); DBG(3, "Synaptics DeviceOn called\n"); - SetDeviceAndProtocol(local); - local->fd = xf86OpenSerial(local->options); - if (local->fd == -1) { - xf86Msg(X_WARNING, "%s: cannot open input device\n", local->name); + SetDeviceAndProtocol(pInfo); + pInfo->fd = xf86OpenSerial(pInfo->options); + if (pInfo->fd == -1) { + xf86Msg(X_WARNING, "%s: cannot open input device\n", pInfo->name); return !Success; } if (priv->proto_ops->DeviceOnHook) - priv->proto_ops->DeviceOnHook(local, &priv->synpara); + priv->proto_ops->DeviceOnHook(pInfo, &priv->synpara); - priv->comm.buffer = XisbNew(local->fd, INPUT_BUFFER_SIZE); + priv->comm.buffer = XisbNew(pInfo->fd, INPUT_BUFFER_SIZE); if (!priv->comm.buffer) { - xf86CloseSerial(local->fd); - local->fd = -1; + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; return !Success; } - xf86FlushInput(local->fd); + xf86FlushInput(pInfo->fd); /* reinit the pad */ - if (!QueryHardware(local)) + if (!QueryHardware(pInfo)) { XisbFree(priv->comm.buffer); priv->comm.buffer = NULL; - xf86CloseSerial(local->fd); - local->fd = -1; + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; return !Success; } - xf86AddEnabledDevice(local); + xf86AddEnabledDevice(pInfo); dev->public.on = TRUE; return Success; @@ -859,22 +883,22 @@ DeviceOn(DeviceIntPtr dev) static Bool DeviceOff(DeviceIntPtr dev) { - LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; - SynapticsPrivate *priv = (SynapticsPrivate *) (local->private); + InputInfoPtr pInfo = dev->public.devicePrivate; + SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private); DBG(3, "Synaptics DeviceOff called\n"); - if (local->fd != -1) { + if (pInfo->fd != -1) { TimerCancel(priv->timer); - xf86RemoveEnabledDevice(local); + xf86RemoveEnabledDevice(pInfo); if (priv->proto_ops->DeviceOffHook) - priv->proto_ops->DeviceOffHook(local); + priv->proto_ops->DeviceOffHook(pInfo); if (priv->comm.buffer) { XisbFree(priv->comm.buffer); priv->comm.buffer = NULL; } - xf86CloseSerial(local->fd); - local->fd = -1; + xf86CloseSerial(pInfo->fd); + pInfo->fd = -1; } dev->public.on = FALSE; return Success; @@ -884,8 +908,8 @@ static Bool DeviceClose(DeviceIntPtr dev) { Bool RetValue; - LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; - SynapticsPrivate *priv = (SynapticsPrivate *) local->private; + InputInfoPtr pInfo = dev->public.devicePrivate; + SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private; RetValue = DeviceOff(dev); TimerFree(priv->timer); @@ -937,8 +961,8 @@ static void InitButtonLabels(Atom *labels, int nlabels) static Bool DeviceInit(DeviceIntPtr dev) { - LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate; - SynapticsPrivate *priv = (SynapticsPrivate *) (local->private); + InputInfoPtr pInfo = dev->public.devicePrivate; + SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private); Atom float_type, prop; float tmpf; unsigned char map[SYN_MAX_BUTTONS + 1]; @@ -1051,11 +1075,11 @@ DeviceInit(DeviceIntPtr dev) min, max, priv->resy * 1000, 0, priv->resy * 1000); xf86InitValuatorDefaults(dev, 1); - if (!alloc_param_data(local)) + if (!alloc_param_data(pInfo)) return !Success; - InitDeviceProperties(local); - XIRegisterPropertyHandler(local->dev, SetProperty, NULL, NULL); + InitDeviceProperties(pInfo); + XIRegisterPropertyHandler(pInfo->dev, SetProperty, NULL, NULL); return Success; } @@ -1180,8 +1204,8 @@ is_inside_active_area(SynapticsPrivate *priv, int x, int y) static CARD32 timerFunc(OsTimerPtr timer, CARD32 now, pointer arg) { - LocalDevicePtr local = (LocalDevicePtr) (arg); - SynapticsPrivate *priv = (SynapticsPrivate *) (local->private); + InputInfoPtr pInfo = arg; + SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private); struct SynapticsHwState hw; int delay; int sigstate; @@ -1191,7 +1215,7 @@ timerFunc(OsTimerPtr timer, CARD32 now, pointer arg) hw = priv->hwState; hw.millis = now; - delay = HandleState(local, &hw); + delay = HandleState(pInfo, &hw); /* * Workaround for wraparound bug in the TimerSet function. This bug is already @@ -1202,7 +1226,7 @@ timerFunc(OsTimerPtr timer, CARD32 now, pointer arg) if (wakeUpTime <= now) wakeUpTime = 0xffffffffL; - priv->timer = TimerSet(priv->timer, TimerAbsolute, wakeUpTime, timerFunc, local); + priv->timer = TimerSet(priv->timer, TimerAbsolute, wakeUpTime, timerFunc, pInfo); xf86UnblockSIGIO(sigstate); @@ -1221,10 +1245,10 @@ clamp(int val, int min, int max) } static Bool -SynapticsGetHwState(LocalDevicePtr local, SynapticsPrivate *priv, +SynapticsGetHwState(InputInfoPtr pInfo, SynapticsPrivate *priv, struct SynapticsHwState *hw) { - return priv->proto_ops->ReadHwState(local, priv->proto_ops, + return priv->proto_ops->ReadHwState(pInfo, priv->proto_ops, &priv->comm, hw); } @@ -1232,22 +1256,22 @@ SynapticsGetHwState(LocalDevicePtr local, SynapticsPrivate *priv, * called for each full received packet from the touchpad */ static void -ReadInput(LocalDevicePtr local) +ReadInput(InputInfoPtr pInfo) { - SynapticsPrivate *priv = (SynapticsPrivate *) (local->private); + SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private); struct SynapticsHwState hw; int delay = 0; Bool newDelay = FALSE; - while (SynapticsGetHwState(local, priv, &hw)) { + while (SynapticsGetHwState(pInfo, priv, &hw)) { hw.millis = GetTimeInMillis(); priv->hwState = hw; - delay = HandleState(local, &hw); + delay = HandleState(pInfo, &hw); newDelay = TRUE; } if (newDelay) - priv->timer = TimerSet(priv->timer, 0, delay, timerFunc, local); + priv->timer = TimerSet(priv->timer, 0, delay, timerFunc, pInfo); } static int @@ -2158,10 +2182,10 @@ handle_clickfinger(SynapticsParameters *para, struct SynapticsHwState *hw) * nothing in the driver reads back from SHM. SHM configuration is a thing of the past. */ static void -update_shm(const LocalDevicePtr local, const struct SynapticsHwState *hw) +update_shm(const InputInfoPtr pInfo, const struct SynapticsHwState *hw) { int i; - SynapticsPrivate *priv = (SynapticsPrivate *) (local->private); + SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private); SynapticsSHM *shm = priv->synshm; if (!shm) @@ -2187,9 +2211,9 @@ update_shm(const LocalDevicePtr local, const struct SynapticsHwState *hw) * function (or scrolling into). */ static Bool -adjust_state_from_scrollbuttons(const LocalDevicePtr local, struct SynapticsHwState *hw) +adjust_state_from_scrollbuttons(const InputInfoPtr pInfo, struct SynapticsHwState *hw) { - SynapticsPrivate *priv = (SynapticsPrivate *) (local->private); + SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private); SynapticsParameters *para = &priv->synpara; Bool double_click = FALSE; @@ -2221,9 +2245,9 @@ adjust_state_from_scrollbuttons(const LocalDevicePtr local, struct SynapticsHwSt } static void -update_hw_button_state(const LocalDevicePtr local, struct SynapticsHwState *hw, int *delay) +update_hw_button_state(const InputInfoPtr pInfo, struct SynapticsHwState *hw, int *delay) { - SynapticsPrivate *priv = (SynapticsPrivate *) (local->private); + SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private); SynapticsParameters *para = &priv->synpara; /* Treat the first two multi buttons as up/down for now. */ @@ -2246,35 +2270,35 @@ update_hw_button_state(const LocalDevicePtr local, struct SynapticsHwState *hw, } static void -post_button_click(const LocalDevicePtr local, const int button) +post_button_click(const InputInfoPtr pInfo, const int button) { - xf86PostButtonEvent(local->dev, FALSE, button, TRUE, 0, 0); - xf86PostButtonEvent(local->dev, FALSE, button, FALSE, 0, 0); + xf86PostButtonEvent(pInfo->dev, FALSE, button, TRUE, 0, 0); + xf86PostButtonEvent(pInfo->dev, FALSE, button, FALSE, 0, 0); } static void -post_scroll_events(const LocalDevicePtr local, struct ScrollData scroll) +post_scroll_events(const InputInfoPtr pInfo, struct ScrollData scroll) { while (scroll.up-- > 0) - post_button_click(local, 4); + post_button_click(pInfo, 4); while (scroll.down-- > 0) - post_button_click(local, 5); + post_button_click(pInfo, 5); while (scroll.left-- > 0) - post_button_click(local, 6); + post_button_click(pInfo, 6); while (scroll.right-- > 0) - post_button_click(local, 7); + post_button_click(pInfo, 7); } static inline int -repeat_scrollbuttons(const LocalDevicePtr local, +repeat_scrollbuttons(const InputInfoPtr pInfo, const struct SynapticsHwState *hw, int buttons, int delay) { - SynapticsPrivate *priv = (SynapticsPrivate *) (local->private); + SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private); SynapticsParameters *para = &priv->synpara; int repeat_delay, timeleft; int rep_buttons = ((para->updown_button_repeat ? 0x18 : 0) | @@ -2305,8 +2329,8 @@ repeat_scrollbuttons(const LocalDevicePtr local, while (change) { id = ffs(change); change &= ~(1 << (id - 1)); - xf86PostButtonEvent(local->dev, FALSE, id, FALSE, 0, 0); - xf86PostButtonEvent(local->dev, FALSE, id, TRUE, 0, 0); + xf86PostButtonEvent(pInfo->dev, FALSE, id, FALSE, 0, 0); + xf86PostButtonEvent(pInfo->dev, FALSE, id, TRUE, 0, 0); } priv->nextRepeat = hw->millis + repeat_delay; @@ -2324,9 +2348,9 @@ repeat_scrollbuttons(const LocalDevicePtr local, * occurs. */ static int -HandleState(LocalDevicePtr local, struct SynapticsHwState *hw) +HandleState(InputInfoPtr pInfo, struct SynapticsHwState *hw) { - SynapticsPrivate *priv = (SynapticsPrivate *) (local->private); + SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private); SynapticsParameters *para = &priv->synpara; int finger; int dx, dy, buttons, id; @@ -2338,7 +2362,7 @@ HandleState(LocalDevicePtr local, struct SynapticsHwState *hw) int timeleft; Bool inside_active_area; - update_shm(local, hw); + update_shm(pInfo, hw); /* If touchpad is switched off, we skip the whole thing and return delay */ if (para->touchpad_off == 1) @@ -2367,9 +2391,9 @@ HandleState(LocalDevicePtr local, struct SynapticsHwState *hw) } /* these two just update hw->left, right, etc. */ - update_hw_button_state(local, hw, &delay); + update_hw_button_state(pInfo, hw, &delay); if (priv->has_scrollbuttons) - double_click = adjust_state_from_scrollbuttons(local, hw); + double_click = adjust_state_from_scrollbuttons(pInfo, hw); /* no edge or finger detection outside of area */ if (inside_active_area) { @@ -2414,7 +2438,7 @@ HandleState(LocalDevicePtr local, struct SynapticsHwState *hw) 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(local->dev, FALSE, priv->tap_button, TRUE, 0, 0); + xf86PostButtonEvent(pInfo->dev, FALSE, priv->tap_button, TRUE, 0, 0); priv->lastButtons |= tap_mask; } priv->tap_button_state = TBS_BUTTON_UP; @@ -2425,15 +2449,15 @@ HandleState(LocalDevicePtr local, struct SynapticsHwState *hw) /* Post events */ if (dx || dy) - xf86PostMotionEvent(local->dev, 0, 0, 2, dx, dy); + xf86PostMotionEvent(pInfo->dev, 0, 0, 2, dx, dy); if (priv->mid_emu_state == MBE_LEFT_CLICK) { - post_button_click(local, 1); + post_button_click(pInfo, 1); priv->mid_emu_state = MBE_OFF; } else if (priv->mid_emu_state == MBE_RIGHT_CLICK) { - post_button_click(local, 3); + post_button_click(pInfo, 3); priv->mid_emu_state = MBE_OFF; } @@ -2441,22 +2465,22 @@ HandleState(LocalDevicePtr local, struct SynapticsHwState *hw) while (change) { id = ffs(change); /* number of first set bit 1..32 is returned */ change &= ~(1 << (id - 1)); - xf86PostButtonEvent(local->dev, FALSE, id, (buttons & (1 << (id - 1))), 0, 0); + xf86PostButtonEvent(pInfo->dev, FALSE, id, (buttons & (1 << (id - 1))), 0, 0); } /* Process scroll events only if coordinates are * in the Synaptics Area */ if (inside_active_area) - post_scroll_events(local, scroll); + post_scroll_events(pInfo, scroll); if (double_click) { - post_button_click(local, 1); - post_button_click(local, 1); + post_button_click(pInfo, 1); + post_button_click(pInfo, 1); } if (priv->has_scrollbuttons) - delay = repeat_scrollbuttons(local, hw, buttons, delay); + delay = repeat_scrollbuttons(pInfo, hw, buttons, delay); /* Save old values of some state variables */ priv->finger_state = finger; @@ -2470,7 +2494,7 @@ HandleState(LocalDevicePtr local, struct SynapticsHwState *hw) } static int -ControlProc(LocalDevicePtr local, xDeviceCtl * control) +ControlProc(InputInfoPtr pInfo, xDeviceCtl * control) { DBG(3, "Control Proc called\n"); return Success; @@ -2478,7 +2502,7 @@ ControlProc(LocalDevicePtr local, xDeviceCtl * control) static void -CloseProc(LocalDevicePtr local) +CloseProc(InputInfoPtr pInfo) { DBG(3, "Close Proc called\n"); } @@ -2491,7 +2515,7 @@ SwitchMode(ClientPtr client, DeviceIntPtr dev, int mode) } static Bool -ConvertProc(LocalDevicePtr local, +ConvertProc(InputInfoPtr pInfo, int first, int num, int v0, @@ -2514,25 +2538,25 @@ ConvertProc(LocalDevicePtr local, static void -ReadDevDimensions(LocalDevicePtr local) +ReadDevDimensions(InputInfoPtr pInfo) { - SynapticsPrivate *priv = (SynapticsPrivate *) local->private; + SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private; if (priv->proto_ops->ReadDevDimensions) - priv->proto_ops->ReadDevDimensions(local); + priv->proto_ops->ReadDevDimensions(pInfo); } static Bool -QueryHardware(LocalDevicePtr local) +QueryHardware(InputInfoPtr pInfo) { - SynapticsPrivate *priv = (SynapticsPrivate *) local->private; + SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private; priv->comm.protoBufTail = 0; - if (!priv->proto_ops->QueryHardware(local)) { - xf86Msg(X_PROBED, "%s: no supported touchpad found\n", local->name); + if (!priv->proto_ops->QueryHardware(pInfo)) { + xf86Msg(X_PROBED, "%s: no supported touchpad found\n", pInfo->name); if (priv->proto_ops->DeviceOffHook) - priv->proto_ops->DeviceOffHook(local); + priv->proto_ops->DeviceOffHook(pInfo); return FALSE; } diff --git a/src/synapticsstr.h b/src/synapticsstr.h index 658721c..9dc0a19 100644 --- a/src/synapticsstr.h +++ b/src/synapticsstr.h @@ -240,6 +240,6 @@ typedef struct _SynapticsPrivateRec } SynapticsPrivate; -extern void SynapticsDefaultDimensions(LocalDevicePtr local); +extern void SynapticsDefaultDimensions(InputInfoPtr pInfo); #endif /* _SYNAPTICSSTR_H_ */ diff --git a/src/synproto.h b/src/synproto.h index c851271..96ddf3e 100644 --- a/src/synproto.h +++ b/src/synproto.h @@ -83,14 +83,14 @@ struct SynapticsHwInfo; struct CommData; struct SynapticsProtocolOperations { - void (*DeviceOnHook)(LocalDevicePtr local, struct _SynapticsParameters *para); - void (*DeviceOffHook)(LocalDevicePtr local); - Bool (*QueryHardware)(LocalDevicePtr local); - Bool (*ReadHwState)(LocalDevicePtr local, + void (*DeviceOnHook)(InputInfoPtr pInfo, struct _SynapticsParameters *para); + void (*DeviceOffHook)(InputInfoPtr pInfo); + Bool (*QueryHardware)(InputInfoPtr pInfo); + Bool (*ReadHwState)(InputInfoPtr pInfo, struct SynapticsProtocolOperations *proto_ops, struct CommData *comm, struct SynapticsHwState *hwRet); - Bool (*AutoDevProbe)(LocalDevicePtr local); - void (*ReadDevDimensions)(LocalDevicePtr local); + Bool (*AutoDevProbe)(InputInfoPtr pInfo); + void (*ReadDevDimensions)(InputInfoPtr pInfo); }; extern struct SynapticsProtocolOperations psaux_proto_operations; |