From 43d9edd31e31b33b9da4a50d8ab05004881c8d5a Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 14 Sep 2006 19:09:02 -0400 Subject: [PATCH] Attempt to add the 'mouse' driver in more situations. Always add a mouse driver instance configured to send core events, unless a core pointer already exists using either the mouse or void drivers. This handles the laptop case where the config file only specifies, say, synaptics, which causes the touchpad to work but not the pointing stick. We don't double-instantiate the mouse driver to avoid the mouse moving twice as fast, and we skip this logic when the user asked for a void core pointer since that probably means they want to run with no pointer at all. --- hw/xfree86/common/xf86Config.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index fe55c8cc4..dbe158efc 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -1450,12 +1450,13 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) IDevPtr corePointer = NULL, coreKeyboard = NULL; Bool foundPointer = FALSE, foundKeyboard = FALSE; const char *pointerMsg = NULL, *keyboardMsg = NULL; - IDevPtr indp; + IDevPtr indp, i; IDevRec Pointer, Keyboard; XF86ConfInputPtr confInput; XF86ConfInputRec defPtr, defKbd; int count = 0; MessageType from = X_DEFAULT; + int found = 0; /* * First check if a core pointer or core keyboard have been specified @@ -1607,6 +1608,35 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) return FALSE; } + /* + * always synthesize a 'mouse' section configured to send core + * events, unless a 'void' section is found, in which case the user + * probably wants to run footless. + */ + for (i = servlayoutp->inputs; i->driver; i++) { + if (!strcmp(i->driver, "void") || !strcmp(i->driver, "mouse")) { + found = 1; break; + } + } + if (!found) { + xf86Msg(X_INFO, "No default mouse found, adding one\n"); + bzero(&defPtr, sizeof(defPtr)); + defPtr.inp_identifier = ""; + defPtr.inp_driver = "mouse"; + confInput = &defPtr; + foundPointer = configInput(&Pointer, confInput, from); + if (foundPointer) { + count++; + indp = xnfrealloc(servlayoutp->inputs, + (count + 1) * sizeof(IDevRec)); + indp[count - 1] = Pointer; + indp[count - 1].extraOptions = + xf86addNewOption(NULL, "AlwaysCore", NULL); + indp[count].identifier = NULL; + servlayoutp->inputs = indp; + } + } + confInput = NULL; /* 1. Check for the -keyboard command line option. */