diff options
author | Henrik Rydberg <rydberg@euromail.se> | 2008-11-06 14:03:42 +0100 |
---|---|---|
committer | Henrik Rydberg <rydberg@euromail.se> | 2008-11-06 14:03:42 +0100 |
commit | a773c79d6d767ddfe574ad513ab0276bdd13a717 (patch) | |
tree | 8d879fe396dab810bf5632c9777c3931c08eb396 /src/multitouch.c | |
parent | 030a3c8a38a81ea882fa0a3b0bfce61ded50a20d (diff) | |
download | xorg-input-kobomultitouch-a773c79d6d767ddfe574ad513ab0276bdd13a717.tar.gz xorg-input-kobomultitouch-a773c79d6d767ddfe574ad513ab0276bdd13a717.tar.bz2 xorg-input-kobomultitouch-a773c79d6d767ddfe574ad513ab0276bdd13a717.zip |
Driver stages in place - should one support multiple
device instances by moving the private alloc to init/close?
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/multitouch.c')
-rw-r--r-- | src/multitouch.c | 123 |
1 files changed, 101 insertions, 22 deletions
diff --git a/src/multitouch.c b/src/multitouch.c index 6818e7c..9fb6d82 100644 --- a/src/multitouch.c +++ b/src/multitouch.c @@ -21,47 +21,125 @@ * **************************************************************************/ -#include "capabilities.h" +#include "mtouch.h" + +//////////////////////////////////////////////////////////////////////////// + +static int device_init(LocalDevicePtr local) +{ + struct MTouch *mt = local->private; + local->fd = xf86OpenSerial(local->options); + if (local->fd < 0) { + xf86Msg(X_ERROR, "multitouch: cannot configure device\n"); + return local->fd; + } + if (configure_mtouch(mt, local->fd)) + return -1; + xf86CloseSerial(local->fd); + return 0; +} + +//////////////////////////////////////////////////////////////////////////// + +static int device_on(LocalDevicePtr local) +{ + struct MTouch *mt = local->private; + local->fd = xf86OpenSerial(local->options); + if (local->fd < 0) { + xf86Msg(X_ERROR, "multitouch: cannot open device\n"); + return local->fd; + } + if (init_mtouch(mt)) + return -1; + return 0; +} + +//////////////////////////////////////////////////////////////////////////// + +static void device_off(LocalDevicePtr local) +{ + if(local->fd >= 0) + xf86CloseSerial(local->fd); +} + +//////////////////////////////////////////////////////////////////////////// + +static void device_close(LocalDevicePtr local) +{ +} + +//////////////////////////////////////////////////////////////////////////// + +/* called for each full received packet from the touchpad */ +static void read_input(LocalDevicePtr local) +{ + struct MTouch *mt = local->private; + + xf86Msg(X_INFO, "read_input called\n"); + + if (local->fd >= 0) { + while (!read_hwdata(&mt->hw, local->fd)) { + // do all the good stuff here + } + } +} + +//////////////////////////////////////////////////////////////////////////// + +static Bool device_control(DeviceIntPtr dev, int mode) +{ + LocalDevicePtr local = dev->public.devicePrivate; + switch (mode) { + case DEVICE_INIT: + xf86Msg(X_INFO, "device control: init\n"); + if (device_init(local)) + return !Success; + return Success; + case DEVICE_ON: + xf86Msg(X_INFO, "device control: on\n"); + if (device_on(local)) + return !Success; + return Success; + case DEVICE_OFF: + xf86Msg(X_INFO, "device control: off\n"); + device_off(local); + return Success; + case DEVICE_CLOSE: + xf86Msg(X_INFO, "device control: close\n"); + device_close(local); + return Success; + default: + xf86Msg(X_INFO, "device control: default\n"); + return BadValue; + } +} + //////////////////////////////////////////////////////////////////////////// static InputInfoPtr preinit(InputDriverPtr drv, IDevPtr dev, int flags) { + struct MTouch *mt; InputInfoPtr local = xf86AllocateInput(drv, 0); if (!local) goto error; + mt = xcalloc(1, sizeof(struct MTouch)); + if (!mt) + goto error; local->name = dev->identifier; local->type_name = XI_TOUCHPAD; - local->device_control = 0;//DeviceControl; - local->read_input = 0;//ReadInput; - local->control_proc = 0;//ControlProc; - local->close_proc = 0;//CloseProc; - local->switch_mode = 0;//SwitchMode; - local->conversion_proc = 0;//ConvertProc; - local->reverse_conversion_proc = NULL; - local->dev = NULL; - local->private = 0;//priv; + local->device_control = device_control; + local->read_input = read_input; + local->private = mt; local->private_flags = 0; local->flags = XI86_POINTER_CAPABLE | XI86_SEND_DRAG_EVENTS; local->conf_idev = dev; - //local->motion_history_proc = xf86GetMotionEvents; - //local->history_size = 0; local->always_core_feedback = 0; xf86CollectInputOptions(local, NULL, NULL); xf86OptionListReport(local->options); - local->fd = xf86OpenSerial(local->options); - if (local->fd < 0) { - xf86Msg(X_ERROR, "multitouch: cannot open device\n"); - goto error; - } - struct Capabilities cap; - read_capabilities(&cap, local->fd); - output_capabilities(&cap); - xf86CloseSerial(local->fd); - local->fd = -1; local->flags |= XI86_CONFIGURED; error: return local; @@ -69,6 +147,7 @@ static InputInfoPtr preinit(InputDriverPtr drv, IDevPtr dev, int flags) static void uninit(InputDriverPtr drv, InputInfoPtr local, int flags) { + xfree(local->private); xf86DeleteInput(local, 0); } |