diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2011-03-20 09:46:26 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-03-28 16:21:20 +1000 |
commit | 2122ad2f17c0efed016d41178e2da9d3eeba84fd (patch) | |
tree | 7b859c720cd625ffd9ae851964336a5db5fda5e6 /src | |
parent | 7b2d245ee1ecc3793f29dbf2761ef1ab73a577e5 (diff) |
eventcomm: rewrite event_query_info to something more sane
Instead of passing in a magic struct and set fields in that struct, pass in
the fd that we query and return the queried value. Let the caller deal with
the information accordingly.
And document the lot.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Cyril Brulebois <kibi@debian.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/eventcomm.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/eventcomm.c b/src/eventcomm.c index 30146af..287f9de 100644 --- a/src/eventcomm.c +++ b/src/eventcomm.c @@ -158,23 +158,34 @@ static model_lookup_t model_lookup_table[] = { {0x0, 0x0, 0x0} }; -static void -event_query_info(InputInfoPtr pInfo) +/** + * Check for the vendor/product id on the file descriptor and compare + * with the built-in model LUT. This information is used in synaptics.c to + * initialize model-specific dimensions. + * + * @param fd The file descriptor to a event device. + * @param[out] model_out The type of touchpad model detected. + * + * @return TRUE on success or FALSE otherwise. + */ +static Bool +event_query_model(int fd, enum TouchpadModel *model_out) { - SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private; short id[4]; int rc; model_lookup_t *model_lookup; - SYSCALL(rc = ioctl(pInfo->fd, EVIOCGID, id)); + SYSCALL(rc = ioctl(fd, EVIOCGID, id)); if (rc < 0) - return; + return FALSE; for(model_lookup = model_lookup_table; model_lookup->vendor; model_lookup++) { if(model_lookup->vendor == id[ID_VENDOR] && (model_lookup->product == id[ID_PRODUCT] || model_lookup->product == PRODUCT_ANY)) - priv->model = model_lookup->model; + *model_out = model_lookup->model; } + + return TRUE; } /* Query device for axis ranges */ @@ -462,7 +473,7 @@ EventReadDevDimensions(InputInfoPtr pInfo) if (event_query_is_touchpad(pInfo->fd, (need_grab) ? *need_grab : TRUE)) event_query_axis_ranges(pInfo); - event_query_info(pInfo); + event_query_model(pInfo->fd, &priv->model); } static Bool |