diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2010-10-25 12:13:00 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2010-10-26 06:32:34 +1000 |
commit | a1eb66c75a180e87424be2b7af92db2fd493d19b (patch) | |
tree | c6a5b748689eaf751f9b6fb363b261e95cd223df | |
parent | 805b3771bfad089fea78f7c509cf9c17336f6946 (diff) |
De-duplicate Option "Device" handling.
Move the warning messages and the OS-specific autoprobing calls into a new
function. This will change the order log messages appear in but functional
changes should be identical.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | src/mouse.c | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/src/mouse.c b/src/mouse.c index 341f07f..d098f9d 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -796,13 +796,31 @@ InitProtocols(void) return TRUE; } +static const char* +MouseFindDevice(InputInfoPtr pInfo, const char* protocol) +{ + const char *device; + + if (!osInfo->FindDevice) + return NULL; + + xf86Msg(X_WARNING, "%s: No Device specified, looking for one...\n", pInfo->name); + device = osInfo->FindDevice(pInfo, protocol, 0); + if (!device) + xf86Msg(X_ERROR, "%s: Cannot find which device to use.\n", pInfo->name); + else + xf86Msg(X_PROBED, "%s: Device: \"%s\"\n", pInfo->name, device); + + return device; +} + static InputInfoPtr MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags) { InputInfoPtr pInfo; MouseDevPtr pMse; mousePrivPtr mPriv; - MessageType protocolFrom = X_DEFAULT, deviceFrom = X_CONFIG; + MessageType protocolFrom = X_DEFAULT; const char *protocol, *osProt = NULL; const char *device; MouseProtocolID protocolID; @@ -857,6 +875,8 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags) return pInfo; } + device = xf86SetStrOption(dev->commonOptions, "Device", NULL); + /* Default Mapping: 1 2 3 8 9 10 11 ... */ for (i = 0; i < MSE_MAXBUTTONS; i++) pMse->buttonMap[i] = 1 << (i > 2 && i < MSE_MAXBUTTONS-4 ? i+4 : i); @@ -882,16 +902,8 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags) * and call its PreInit. */ if (osInfo->CheckProtocol && osInfo->CheckProtocol(protocol)) { - if (!xf86CheckStrOption(dev->commonOptions, "Device", NULL) && - osInfo->FindDevice) { - xf86Msg(X_WARNING, "%s: No Device specified, " - "looking for one...\n", pInfo->name); - if (!osInfo->FindDevice(pInfo, protocol, 0)) { - xf86Msg(X_ERROR, "%s: Cannot find which device " - "to use.\n", pInfo->name); - } else - deviceFrom = X_PROBED; - } + if (!device) + MouseFindDevice(pInfo, protocol); if (osInfo->PreInit) { osInfo->PreInit(pInfo, protocol, 0); } @@ -912,24 +924,10 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags) } } while (!detected); - - if (!xf86CheckStrOption(dev->commonOptions, "Device", NULL) && - osInfo->FindDevice) { - xf86Msg(X_WARNING, "%s: No Device specified, looking for one...\n", - pInfo->name); - if (!osInfo->FindDevice(pInfo, protocol, 0)) { - xf86Msg(X_ERROR, "%s: Cannot find which device to use.\n", - pInfo->name); - } else { - deviceFrom = X_PROBED; - xf86MarkOptionUsedByName(dev->commonOptions, "Device"); - } - } - device = xf86CheckStrOption(dev->commonOptions, "Device", NULL); - if (device) - xf86Msg(deviceFrom, "%s: Device: \"%s\"\n", pInfo->name, device); - + if (!device) + MouseFindDevice(pInfo, protocol); + xf86Msg(protocolFrom, "%s: Protocol: \"%s\"\n", pInfo->name, protocol); if (!(pProto = GetProtocol(protocolID))) return pInfo; |