]> Shamusworld >> Repos - virtualjaguar/blobdiff - src/gui/profile.cpp
Minor update to debugger; added autoupdating to CPU/MEM windows.
[virtualjaguar] / src / gui / profile.cpp
index 854d8cb038b05408e886b6a51af9ebf66c736494..5f1ca13035be6d23b1e2202ff99b83ff10f1bb7a 100644 (file)
@@ -30,7 +30,7 @@
 //
 
 #include "profile.h"
-#include <QtGui>
+#include <QtWidgets>
 #include "gamepad.h"
 #include "log.h"
 #include "settings.h"
@@ -49,6 +49,7 @@ int gamepadIDSlot2;
 int numberOfProfiles;
 int numberOfDevices;
 char deviceNames[MAX_DEVICES][128];
+static int numberOfProfilesSave;
 
 // This is so that new devices have something reasonable to show for default
 uint32_t defaultMap[21] = {
@@ -68,6 +69,7 @@ int FindProfileForDevice(int deviceNum, int preferred, int * found);
 //
 void SaveProfiles(void)
 {
+       numberOfProfilesSave = numberOfProfiles;
        memcpy(&profileBackup, &profile, sizeof(Profile) * MAX_PROFILES);
 }
 
@@ -75,6 +77,7 @@ void SaveProfiles(void)
 void RestoreProfiles(void)
 {
        memcpy(&profile, &profileBackup, sizeof(Profile) * MAX_PROFILES);
+       numberOfProfiles = numberOfProfilesSave;
 }
 
 
@@ -94,7 +97,7 @@ void ReadProfiles(QSettings * set)
        for(int i=1; i<numberOfDevices; i++)
        {
                set->setArrayIndex(i - 1);
-               strcpy(deviceNames[i], set->value("deviceName").toString().toAscii().data());
+               strcpy(deviceNames[i], set->value("deviceName").toString().toUtf8().data());
 #ifdef DEBUG_PROFILES
 printf("Read device name: %s\n", deviceNames[i]);
 #endif
@@ -110,7 +113,7 @@ printf("Number of profiles: %u\n", numberOfProfiles);
        {
                set->setArrayIndex(i);
                profile[i].device = set->value("deviceNum").toInt();
-               strcpy(profile[i].mapName, set->value("mapName").toString().toAscii().data());
+               strcpy(profile[i].mapName, set->value("mapName").toString().toUtf8().data());
                profile[i].preferredSlot = set->value("preferredSlot").toInt();
 
                for(int j=0; j<21; j++)
@@ -357,7 +360,7 @@ One more stab at this...
 */
 void AutoConnectProfiles(void)
 {
-       int foundProfiles[MAX_PROFILES];
+//     int foundProfiles[MAX_PROFILES];
        controller1Profile = -1;
        controller2Profile = -1;
        gamepadIDSlot1 = -1;
@@ -368,7 +371,12 @@ void AutoConnectProfiles(void)
        // add it in.
        if (Gamepad::numJoysticks == 0)
        {
-               ConnectProfileToDevice(0);
+#ifdef DEBUG_PROFILES
+printf("AutoConnect: Setting up keyboard...\n");
+#endif
+//NO!          ConnectProfileToDevice(0);
+#warning "!!! Need to set up scanning for multiple keyboard profiles !!!"
+               ConnectProfileToController(0, 0);
                return;
        }
 
@@ -379,6 +387,9 @@ void AutoConnectProfiles(void)
        {
                int deviceNum = FindDeviceNumberForName(Gamepad::GetJoystickName(i));
 //             bool p1Overwriteable = 
+#ifdef DEBUG_PROFILES
+printf("AutoConnect: Attempting to set up profile for device '%s' (%i)\n", Gamepad::GetJoystickName(i), deviceNum);
+#endif
 
                for(int j=0; j<numberOfProfiles; j++)
                {
@@ -443,7 +454,12 @@ 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;
+#ifdef DEBUG_PROFILES
+printf("AutoConnect: Attempting to connect keyboard... (gamepadIDSlot1/2 = %i/%i)\n", gamepadIDSlot1, gamepadIDSlot2);
+#endif
 
        if ((slot == CONTROLLER1) && (gamepadIDSlot1 == -1))
                controller1Profile = 0;
@@ -457,12 +473,16 @@ void AutoConnectProfiles(void)
                        controller2Profile = 0;
        }
 
+#ifdef DEBUG_PROFILES
+printf("AutoConnect: Profiles found: [%i, %i]\n", controller1Profile, controller2Profile);
+#endif
        // Finally, attempt to connect profiles to controllers
        ConnectProfileToController(controller1Profile, 0);
        ConnectProfileToController(controller2Profile, 1);
 }
 
 
+//unused...
 int ConnectProfileToDevice(int deviceNum, int gamepadID/*= -1*/)
 {
 //     bool found1 = false;