X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui%2Fprofile.cpp;h=434d01d8ac0918d7d183cb96ab816a3fae99de94;hb=3b0e8e7d6be25106bcfa0ee0c78faed597e9a2c6;hp=114b98c9059cb59e520a08fb87de1c2897a9286f;hpb=62587015fb12ec54b1702bfa17077e4b8af44b19;p=virtualjaguar diff --git a/src/gui/profile.cpp b/src/gui/profile.cpp index 114b98c..434d01d 100644 --- a/src/gui/profile.cpp +++ b/src/gui/profile.cpp @@ -357,15 +357,20 @@ One more stab at this... */ void AutoConnectProfiles(void) { - int foundProfiles[MAX_PROFILES]; +// int foundProfiles[MAX_PROFILES]; controller1Profile = -1; controller2Profile = -1; 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,23 @@ void AutoConnectProfiles(void) } } + // Connect the keyboard device (lowest priority) + // N.B.: The keyboard is always mapped to profile #0, so we can locate it + // easily. :-) + 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);