diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2010-10-25 14:34:28 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2010-11-18 11:36:15 +1000 |
commit | 0a088df6b2f5cac05a00c4f461274b83feb1a9a8 (patch) | |
tree | c2b1404a72a368475d61664b631dea4aaee06293 | |
parent | fedd52ba781da1960ada0a96b85293afe2509a4a (diff) |
Adjust to new Input ABI 12.
New PreInit prototype and a couple of other minor changes.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
-rw-r--r-- | src/bsd_mouse.c | 4 | ||||
-rw-r--r-- | src/hurd_mouse.c | 2 | ||||
-rw-r--r-- | src/mouse.c | 87 | ||||
-rw-r--r-- | src/mouse.h | 7 | ||||
-rw-r--r-- | src/sun_mouse.c | 2 |
5 files changed, 76 insertions, 26 deletions
diff --git a/src/bsd_mouse.c b/src/bsd_mouse.c index 94d4382..8a57226 100644 --- a/src/bsd_mouse.c +++ b/src/bsd_mouse.c @@ -458,7 +458,7 @@ wsconsPreInit(InputInfoPtr pInfo, const char *protocol, int flags) xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol); /* Collect the options, and process the common options. */ - xf86CollectInputOptions(pInfo, NULL, NULL); + COLLECT_INPUT_OPTIONS(pInfo, NULL); xf86ProcessCommonOptions(pInfo, pInfo->options); /* Check if the device can be opened. */ @@ -653,7 +653,7 @@ usbPreInit(InputInfoPtr pInfo, const char *protocol, int flags) xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol); /* Collect the options, and process the common options. */ - xf86CollectInputOptions(pInfo, NULL, NULL); + COLLECT_INPUT_OPTIONS(pInfo, NULL); xf86ProcessCommonOptions(pInfo, pInfo->options); /* Check if the device can be opened. */ diff --git a/src/hurd_mouse.c b/src/hurd_mouse.c index e0ed126..e5c7186 100644 --- a/src/hurd_mouse.c +++ b/src/hurd_mouse.c @@ -144,7 +144,7 @@ OsMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags) xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol); /* Collect the options, and process the common options. */ - xf86CollectInputOptions(pInfo, NULL, NULL); + COLLECT_INPUT_OPTIONS(pInfo, NULL); xf86ProcessCommonOptions(pInfo, pInfo->options); /* Check if the device can be opened. */ diff --git a/src/mouse.c b/src/mouse.c index 7088abc..d2377ad 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -112,7 +112,11 @@ typedef struct _DragLockRec { } DragLockRec, *DragLockPtr; +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12 static InputInfoPtr MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags); +#else +static int MousePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags); +#endif static int MouseProc(DeviceIntPtr device, int what); static void MouseCtrl(DeviceIntPtr device, PtrCtrl *ctrl); @@ -842,10 +846,48 @@ MousePickProtocol(InputInfoPtr pInfo, const char* device, return protocol; } +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12 +static int NewMousePreInit(InputDriverPtr drv, InputInfoPtr pInfo, + int flags); + static InputInfoPtr MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags) { InputInfoPtr pInfo; + + if (!(pInfo = xf86AllocateInput(drv, 0))) + return NULL; + + pInfo->name = dev->identifier; + pInfo->flags = XI86_SEND_DRAG_EVENTS; + pInfo->conf_idev = dev; + pInfo->close_proc = NULL; + pInfo->private_flags = 0; + pInfo->always_core_feedback = NULL; + + if (NewMousePreInit(drv, pInfo, flags) == Success) + { + /* Check if SendDragEvents has been disabled. */ + if (!xf86SetBoolOption(dev->commonOptions, "SendDragEvents", TRUE)) + pInfo->flags &= ~XI86_SEND_DRAG_EVENTS; + + pInfo->flags |= XI86_CONFIGURED; + + return pInfo; + } + + xf86DeleteInput(pInfo, 0); + + return NULL; +} + +static int +NewMousePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) +#else +static int +MousePreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags) +#endif +{ MouseDevPtr pMse; mousePrivPtr mPriv; MessageType protocolFrom = X_DEFAULT; @@ -854,44 +896,34 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags) MouseProtocolID protocolID; MouseProtocolPtr pProto; int i; - - if (!InitProtocols()) - return NULL; + int rc = Success; - if (!(pInfo = xf86AllocateInput(drv, 0))) - return NULL; + if (!InitProtocols()) + return BadAlloc; /* Initialise the InputInfoRec. */ - pInfo->name = dev->identifier; pInfo->type_name = XI_MOUSE; - pInfo->flags = XI86_SEND_DRAG_EVENTS; pInfo->device_control = MouseProc; pInfo->read_input = MouseReadInput; pInfo->control_proc = NULL; - pInfo->close_proc = NULL; pInfo->switch_mode = NULL; pInfo->fd = -1; pInfo->dev = NULL; - pInfo->private_flags = 0; - pInfo->always_core_feedback = NULL; - pInfo->conf_idev = dev; /* Allocate the MouseDevRec and initialise it. */ if (!(pMse = calloc(sizeof(MouseDevRec), 1))) + { + rc = BadAlloc; goto out; + } pInfo->private = pMse; pMse->Ctrl = MouseCtrl; pMse->PostEvent = MousePostEvent; pMse->CommonOptions = MouseCommonOptions; - /* Check if SendDragEvents has been disabled. */ - if (!xf86SetBoolOption(dev->commonOptions, "SendDragEvents", TRUE)) { - pInfo->flags &= ~XI86_SEND_DRAG_EVENTS; - } - /* Find the protocol type. */ - protocol = xf86SetStrOption(dev->commonOptions, "Protocol", NULL); + protocol = xf86SetStrOption(pInfo->options, "Protocol", NULL); if (protocol) { protocolFrom = X_CONFIG; } else if (osInfo->DefaultProtocol) { @@ -900,10 +932,11 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags) } if (!protocol) { xf86Msg(X_ERROR, "%s: No Protocol specified\n", pInfo->name); + rc = BadValue; goto out; } - device = xf86SetStrOption(dev->commonOptions, "Device", NULL); + device = xf86SetStrOption(pInfo->options, "Device", NULL); /* Default Mapping: 1 2 3 8 9 10 11 ... */ for (i = 0; i < MSE_MAXBUTTONS; i++) @@ -916,18 +949,25 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags) xf86Msg(protocolFrom, "%s: Protocol: \"%s\"\n", pInfo->name, protocol); if (!(pProto = GetProtocol(protocolID))) + { + rc = BadValue; goto out; + } pMse->protocolID = protocolID; pMse->oldProtocolID = protocolID; /* hack */ pMse->autoProbe = FALSE; /* Collect the options, and process the common options. */ +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12 /* need some special handling here. xf86CollectInputOptions will reset * pInfo->options if the second argument is not-null. To re-merge the * previously set arguments, pass the original pInfo->options in. */ xf86CollectInputOptions(pInfo, pProto->defaults, pInfo->options); +#else + COLLECT_INPUT_OPTIONS(pInfo, pProto->defaults); +#endif xf86ProcessCommonOptions(pInfo, pInfo->options); /* Check if the device can be opened. */ @@ -941,6 +981,7 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags) free(pMse->mousePriv); free(pMse); pInfo->private = NULL; + rc = BadValue; goto out; } } @@ -948,7 +989,11 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags) pInfo->fd = -1; if (!(mPriv = (pointer) calloc(sizeof(mousePrivRec), 1))) + { + rc = BadAlloc; goto out; + } + pMse->mousePriv = mPriv; pMse->CommonOptions(pInfo); pMse->checkMovements = checkForErraticMovements; @@ -958,11 +1003,9 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags) MouseHWOptions(pInfo); MouseSerialOptions(pInfo); - - pInfo->flags |= XI86_CONFIGURED; out: - return pInfo; + return rc; } @@ -2523,7 +2566,7 @@ initMouseHW(InputInfoPtr pInfo) usleep(100000); /* Set the parameters up for the MM series protocol. */ options = pInfo->options; - xf86CollectInputOptions(pInfo, mmDefaults, NULL); + COLLECT_INPUT_OPTIONS(pInfo, mmDefaults); xf86SetSerial(pInfo->fd, pInfo->options); pInfo->options = options; diff --git a/src/mouse.h b/src/mouse.h index 8c02ba1..9f5b47e 100644 --- a/src/mouse.h +++ b/src/mouse.h @@ -32,6 +32,13 @@ #include "xf86Xinput.h" +#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12 +#define COLLECT_INPUT_OPTIONS(pInfo, options) xf86CollectInputOptions((pInfo), (options), NULL) +#else +#define COLLECT_INPUT_OPTIONS(pInfo, options) xf86CollectInputOptions((pInfo), (options)) +#endif + + /* Mouse interface classes */ #define MSE_NONE 0x00 #define MSE_SERIAL 0x01 /* serial port */ diff --git a/src/sun_mouse.c b/src/sun_mouse.c index 95b45bc..2799947 100644 --- a/src/sun_mouse.c +++ b/src/sun_mouse.c @@ -216,7 +216,7 @@ vuidPreInit(InputInfoPtr pInfo, const char *protocol, int flags) xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol); /* Collect the options, and process the common options. */ - xf86CollectInputOptions(pInfo, NULL, NULL); + COLLECT_INPUT_OPTIONS(pInfo, NULL); xf86ProcessCommonOptions(pInfo, pInfo->options); pVuidMse->buffer = (unsigned char *)&pVuidMse->event; |