From 0d7e70c5e34e691b15365901951700f43242065f Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Mon, 6 Oct 2014 09:47:15 -0500 Subject: [PATCH] Made keyboard handling a bit more sane. What this means is that now, if there are no gamepads plugged in, it will add the keyboard as a device plugged into slot #0 (CONTROLLER1). Also, if you have any devices plugged in it will also honor whatever choice you have made WRT the keyboard and attempt to connect it to whichever preferred slot you have set it to. Assuming testing goes OK, this will be the 2.1.1 release. :-D --- src/gui/profile.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/gui/profile.cpp b/src/gui/profile.cpp index 114b98c..854d8cb 100644 --- a/src/gui/profile.cpp +++ b/src/gui/profile.cpp @@ -363,9 +363,14 @@ void AutoConnectProfiles(void) gamepadIDSlot1 = -1; gamepadIDSlot2 = -1; - // Connect keyboard devices first... (N.B.: this leaves gampadIDSlot1 at -1, - // so it can be overridden by plugged-in gamepads.) - ConnectProfileToDevice(0); + // Connect the keyboard automagically only if no gamepads are plugged in. + // Otherwise, check after all other devices have been checked, then try to + // add it in. + if (Gamepad::numJoysticks == 0) + { + ConnectProfileToDevice(0); + return; + } // Connect the profiles that prefer a slot, if any. // N.B.: Conflicts are detected, but ignored. 1st controller to grab a @@ -437,6 +442,21 @@ void AutoConnectProfiles(void) } } + // Connect the keyboard device (lowest priority) + int slot = profile[0].preferredSlot; + + if ((slot == CONTROLLER1) && (gamepadIDSlot1 == -1)) + controller1Profile = 0; + else if ((slot == CONTROLLER2) && (gamepadIDSlot2 == -1)) + controller2Profile = 0; + else if (slot == (CONTROLLER1 | CONTROLLER2)) + { + if (gamepadIDSlot1 == -1) + controller1Profile = 0; + else if (gamepadIDSlot2 == -1) + controller2Profile = 0; + } + // Finally, attempt to connect profiles to controllers ConnectProfileToController(controller1Profile, 0); ConnectProfileToController(controller2Profile, 1); -- 2.37.2