summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Tissoires <tissoire@cena.fr>2009-12-19 12:20:50 +0100
committerBenjamin Tissoires <tissoire@cena.fr>2010-03-15 19:05:33 +0100
commit6b4dc3b451eb2f217e02620563db642054362df4 (patch)
treefad80644d9a7591da072ad03d2430ea4dffbb6d9
parent45d6d0184b04e77e36dbac0fcdb11aef53593d6f (diff)
Adding to evdev the virtual subdevices that manage the multitouch part
This patch introduces in the evdev driver the sub-devices that will be used in multitouch. Note that they are not used right now. Signed-off-by: Benjamin Tissoires <tissoire@cena.fr>
-rw-r--r--src/evdev.c114
-rw-r--r--src/evdev.h3
2 files changed, 109 insertions, 8 deletions
diff --git a/src/evdev.c b/src/evdev.c
index cfe40c9..376ae3a 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -190,6 +190,12 @@ EvdevGetMajorMinor(InputInfoPtr pInfo)
return st.st_rdev;
}
+static BOOL
+EvdevIsCoreDevice(InputInfoPtr pInfo) {
+ EvdevPtr pEvdev = pInfo->private;
+ return pEvdev->core_device == pInfo;
+}
+
/**
* Return TRUE if one of the devices we know about has the same min/maj
* number.
@@ -730,6 +736,14 @@ EvdevProcessEvent(InputInfoPtr pInfo, struct input_event *ev)
/* just a magic number to reduce the number of reads */
#define NUM_EVENTS 16
+/**
+ * Empty callback for subdevice.
+ */
+static void
+EvdevSubdevReadInput(InputInfoPtr pInfo) {
+ return;
+}
+
static void
EvdevReadInput(InputInfoPtr pInfo)
{
@@ -1535,6 +1549,27 @@ EvdevInit(DeviceIntPtr device)
}
/**
+ * For the subdev: Init all extras (wheel emulation, etc.) and grab the device.
+ */
+static int
+EvdevSubdevOn(DeviceIntPtr device)
+{
+ InputInfoPtr pInfo;
+ EvdevPtr pEvdev;
+
+ pInfo = device->public.devicePrivate;
+ pEvdev = pInfo->private;
+
+ xf86AddEnabledDevice(pInfo);
+ EvdevMBEmuOn(pInfo);
+ pEvdev->flags |= EVDEV_INITIALIZED;
+ device->public.on = TRUE;
+
+ return Success;
+}
+
+
+/**
* Init all extras (wheel emulation, etc.) and grab the device.
*/
static int
@@ -1597,19 +1632,28 @@ EvdevProc(DeviceIntPtr device, int what)
return EvdevInit(device);
case DEVICE_ON:
- return EvdevOn(device);
+ if (EvdevIsCoreDevice(pInfo))
+ return EvdevOn(device);
+ else
+ return EvdevSubdevOn(device);
case DEVICE_OFF:
if (pEvdev->flags & EVDEV_INITIALIZED)
EvdevMBEmuFinalize(pInfo);
- if (pInfo->fd != -1)
- {
- if (pEvdev->grabDevice && ioctl(pInfo->fd, EVIOCGRAB, (void *)0))
- xf86Msg(X_WARNING, "%s: Release failed (%s)\n", pInfo->name,
- strerror(errno));
+ if (EvdevIsCoreDevice(pInfo)) {
+ if (pInfo->fd != -1) {
+ if (pEvdev->grabDevice && ioctl(pInfo->fd, EVIOCGRAB, (void *)0))
+ xf86Msg(X_WARNING, "%s: Release failed (%s)\n", pInfo->name,
+ strerror(errno));
+ xf86RemoveEnabledDevice(pInfo);
+ close(pInfo->fd);
+ pInfo->fd = -1;
+ }
+ } else {
+ /* subdevice: removing it in the list of the core device */
+ EvdevPtr g_pEvdev;
+ g_pEvdev = pEvdev->core_device->private;
xf86RemoveEnabledDevice(pInfo);
- close(pInfo->fd);
- pInfo->fd = -1;
}
pEvdev->min_maj = 0;
pEvdev->flags &= ~EVDEV_INITIALIZED;
@@ -1618,11 +1662,13 @@ EvdevProc(DeviceIntPtr device, int what)
case DEVICE_CLOSE:
xf86Msg(X_INFO, "%s: Close\n", pInfo->name);
+ if (EvdevIsCoreDevice(pInfo)) { /* core mt only */
if (pInfo->fd != -1) {
close(pInfo->fd);
pInfo->fd = -1;
}
EvdevRemoveDevice(pInfo);
+ }
pEvdev->min_maj = 0;
break;
}
@@ -2008,16 +2054,64 @@ EvdevSetCalibration(InputInfoPtr pInfo, int num_calibration, int calibration[4])
}
static InputInfoPtr
+EvdevSubdevPreInit(InputInfoPtr pInfo, InputDriverPtr drv, IDevPtr dev, int flags)
+{
+ EvdevPtr pEvdev;
+
+ /* Initialise the InputInfoRec. */
+ pInfo->name = dev->identifier;
+ pInfo->flags = 0;
+ pInfo->type_name = "UNKNOWN";
+ pInfo->device_control = EvdevProc;
+ pInfo->history_size = 0;
+ pInfo->control_proc = NULL;
+ pInfo->close_proc = NULL;
+ pInfo->read_input = EvdevSubdevReadInput;
+ pInfo->switch_mode = NULL;
+ pInfo->conversion_proc = NULL;
+ pInfo->reverse_conversion_proc = NULL;
+ pInfo->dev = NULL;
+ pInfo->private_flags = 0;
+ pInfo->always_core_feedback = NULL;
+ pInfo->conf_idev = dev;
+
+ pEvdev = xcalloc(sizeof(EvdevRec), 1);
+ if (!pEvdev)
+ return pInfo;
+
+ pInfo->private = pEvdev;
+
+ xf86CollectInputOptions(pInfo, evdevDefaults, NULL);
+ xf86ProcessCommonOptions(pInfo, pInfo->options);
+
+ xf86Msg(X_INFO, "%s: Evdev subdevice found\n", dev->identifier);
+
+ pInfo->flags |= XI86_CONFIGURED;
+ pEvdev->num_multitouch = 1;
+
+ return pInfo;
+}
+
+static InputInfoPtr
EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
{
InputInfoPtr pInfo;
const char *device, *str;
int num_calibration = 0, calibration[4] = { 0, 0, 0, 0 };
EvdevPtr pEvdev;
+ char *type;
if (!(pInfo = xf86AllocateInput(drv, 0)))
return NULL;
+ /* If Type == Object, this is a subdevice for an object to use */
+ type = xf86CheckStrOption(dev->commonOptions, "Type", NULL);
+
+ xf86Msg(X_INFO, "%s: Evdev Type %s found\n", dev->identifier, type);
+
+ if (type != NULL && strcmp(type, "Object") == 0)
+ return EvdevSubdevPreInit(pInfo, drv, dev, flags);
+
/* Initialise the InputInfoRec. */
pInfo->name = dev->identifier;
pInfo->flags = 0;
@@ -2043,6 +2137,10 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
xf86CollectInputOptions(pInfo, evdevDefaults, NULL);
xf86ProcessCommonOptions(pInfo, pInfo->options);
+ /* mt initializations. */
+ pEvdev->core_device = pInfo;
+ pEvdev->num_multitouch = 0;
+
/*
* We initialize pEvdev->tool to 1 so that device that doesn't use
* proximity will still report events.
diff --git a/src/evdev.h b/src/evdev.h
index 9d9b1c6..cb9c3d3 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -216,6 +216,9 @@ typedef struct {
/* to store the trackingID given by the reading of the input. */
int current_id;
+
+ /* the reference of the main mt device. */
+ InputInfoPtr core_device;
} EvdevRec, *EvdevPtr;
/* Event posting functions */