Commit 05e22a58 authored by Peter Hutterer's avatar Peter Hutterer

Pre-probe the device (eventcomm only).

For auto-dev, we'd probe the device node and get the axis ranges. If we
specify the device however we didn't retrieve the axis ranges and thus got
stuck with the defaults - losing out on automatic edge and accel calculation.

This is an issue if the device is hotplugged, as HAL will specify the device
node.

This patch adds another hook to synproto_operations to pre-probe the device.
This hook is only used by eventcomm and opens the FD, queries the axis range
and closes the FD again.
parent db7dc108
......@@ -262,5 +262,6 @@ struct SynapticsProtocolOperations alps_proto_operations = {
ALPSDeviceOffHook,
ALPSQueryHardware,
ALPSReadHwState,
ALPSAutoDevProbe
ALPSAutoDevProbe,
NULL /* ProbeDevice */
};
......@@ -305,6 +305,31 @@ static int EventDevOnly(const struct dirent *dir) {
return strncmp(EVENT_DEV_NAME, dir->d_name, 5) == 0;
}
/**
* Probe the given device name for axis ranges, if appropriate.
*/
static Bool
EventProbeDevice(LocalDevicePtr local, char* device)
{
int fd;
SYSCALL(fd = open(device, O_RDONLY));
if (fd < 0)
goto out;
if (!event_query_is_touchpad(fd))
goto out;
event_query_axis_ranges(fd, local);
out:
if (fd >= 0)
SYSCALL(close(fd));
/* Always return TRUE, PreInit will complain for us if necessary */
return TRUE;
}
static Bool
EventAutoDevProbe(LocalDevicePtr local)
{
......@@ -361,5 +386,6 @@ struct SynapticsProtocolOperations event_proto_operations = {
EventDeviceOffHook,
EventQueryHardware,
EventReadHwState,
EventAutoDevProbe
EventAutoDevProbe,
EventProbeDevice
};
......@@ -758,5 +758,6 @@ struct SynapticsProtocolOperations psaux_proto_operations = {
PS2DeviceOffHook,
PS2QueryHardware,
PS2ReadHwState,
PS2AutoDevProbe
PS2AutoDevProbe,
NULL /* ProbeDevice */
};
......@@ -177,5 +177,6 @@ struct SynapticsProtocolOperations psm_proto_operations = {
PSMDeviceOffHook,
PSMQueryHardware,
PSMReadHwState,
PSMAutoDevProbe
PSMAutoDevProbe,
NULL /* ProbeDevice */
};
......@@ -181,8 +181,9 @@ SetDeviceAndProtocol(LocalDevicePtr local)
}
if (device && strstr(device, "/dev/input/event")) {
#ifdef BUILD_EVENTCOMM
/* trust the device name if we've been given one */
proto = SYN_PROTO_EVENT;
if (event_proto_operations.ProbeDevice &&
event_proto_operations.ProbeDevice(local, device))
proto = SYN_PROTO_EVENT;
#endif
} else {
str_par = xf86FindOptionValue(local->options, "Protocol");
......
......@@ -96,6 +96,7 @@ struct SynapticsProtocolOperations {
struct SynapticsProtocolOperations *proto_ops,
struct CommData *comm, struct SynapticsHwState *hwRet);
Bool (*AutoDevProbe)(LocalDevicePtr local);
Bool (*ProbeDevice)(LocalDevicePtr local, char* name);
};
extern struct SynapticsProtocolOperations psaux_proto_operations;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment