From: Shamus Hammons Date: Fri, 10 Oct 2014 03:42:52 +0000 (-0500) Subject: Hotfix for bug #28. X-Git-Tag: 2.1.2~1 X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?p=virtualjaguar;a=commitdiff_plain;h=77430278bc7300a9ad84bdc2e40615c1d510dc78 Hotfix for bug #28. --- diff --git a/src/gui/controllertab.cpp b/src/gui/controllertab.cpp index 89a678f..bd73c2b 100644 --- a/src/gui/controllertab.cpp +++ b/src/gui/controllertab.cpp @@ -226,17 +226,28 @@ void ControllerTab::AddMapName(void) profile[profileNum].mapName[31] = 0; profile[profileNum].preferredSlot = CONTROLLER1; - for(int i=BUTTON_FIRST; iaddItem(text, profileNum); +#if 0 mapNameList->setCurrentIndex(mapNameList->count() - 1); +#else + int selection = mapNameList->count() - 1; + mapNameList->setCurrentIndex(selection); + ChangeMapName(selection); + // We just added a new mapping, so enable the delete button! + deleteMapName->setDisabled(false); +#endif } void ControllerTab::DeleteMapName(void) { - QMessageBox::StandardButton retVal = QMessageBox::question(this, tr("Remove Mapping"), tr("Are you sure you want to remove this mapping?"), QMessageBox::No | QMessageBox::Yes, QMessageBox::No); + QString msg = QString("Map name: %1\n\nAre you sure you want to remove this mapping?").arg(profile[profileNum].mapName); + +// QMessageBox::StandardButton retVal = QMessageBox::question(this, tr("Remove Mapping"), tr("Are you sure you want to remove this mapping?"), QMessageBox::No | QMessageBox::Yes, QMessageBox::No); + QMessageBox::StandardButton retVal = QMessageBox::question(this, tr("Remove Mapping"), msg, QMessageBox::No | QMessageBox::Yes, QMessageBox::No); if (retVal == QMessageBox::No) return; @@ -245,5 +256,11 @@ void ControllerTab::DeleteMapName(void) int profileToRemove = profileNum; mapNameList->removeItem(index); DeleteProfile(profileToRemove); + // We need to reload the profile that we move to after deleting the current + // one... + ChangeMapName(mapNameList->currentIndex()); + // If we get down to one profile left for the device, we need to make sure + // that the user can't delete it! + deleteMapName->setDisabled(mapNameList->count() == 1 ? true : false); } diff --git a/src/gui/controllerwidget.cpp b/src/gui/controllerwidget.cpp index f268c00..f7ea8d0 100644 --- a/src/gui/controllerwidget.cpp +++ b/src/gui/controllerwidget.cpp @@ -117,6 +117,10 @@ void ControllerWidget::paintEvent(QPaintEvent * /*event*/) painter.setPen(colorPen); painter.drawLine(line); +//#define DEBUG_CWPAINT +#ifdef DEBUG_CWPAINT +printf("------------------------------\n"); +#endif for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++) { if (keyToHighlight == i) @@ -132,33 +136,63 @@ void ControllerWidget::paintEvent(QPaintEvent * /*event*/) painter.setFont(font); } +#ifdef DEBUG_CWPAINT +printf("key %02i: ", i); +#endif + if (keys[i] < 0x80) +#ifdef DEBUG_CWPAINT +{ +printf("Drawing a key < 0x80 [keys[i]=%X, keyname=%s]...\n", keys[i], keyName1[keys[i] - 0x20]); +#endif DrawBorderedText(painter, buttonPos[i][0], buttonPos[i][1], QString(keyName1[keys[i] - 0x20])); +#ifdef DEBUG_CWPAINT +} +#endif else if ((keys[i] & 0xFFFFFF00) == 0x01000000) { +#ifdef DEBUG_CWPAINT +printf("Drawing a key with bit 48 set...\n"); +#endif DrawBorderedText(painter, buttonPos[i][0], buttonPos[i][1], QString(keyName2[keys[i] & 0x3F])); } #if 1 else if (keys[i] & JOY_BUTTON) { +#ifdef DEBUG_CWPAINT +printf("Drawing a joystick button...\n"); +#endif DrawBorderedText(painter, buttonPos[i][0], buttonPos[i][1], QString("JB%1").arg(keys[i] & JOY_BUTTON_MASK)); } else if (keys[i] & JOY_HAT) { +#ifdef DEBUG_CWPAINT +printf("Drawing a joystick hat...\n"); +#endif DrawBorderedText(painter, buttonPos[i][0], buttonPos[i][1], QString("j%1").arg(hatName[keys[i] & JOY_BUTTON_MASK])); } else if (keys[i] & JOY_AXIS) { +#ifdef DEBUG_CWPAINT +printf("Drawing a joystick axis...\n"); +#endif DrawBorderedText(painter, buttonPos[i][0], buttonPos[i][1], QString("JA%1%2").arg((keys[i] & JOY_AXISNUM_MASK) >> 1).arg(axisName[keys[i] & JOY_AXISDIR_MASK])); } #endif else +#ifdef DEBUG_CWPAINT +{ +printf("Drawing ???...\n"); +#endif DrawBorderedText(painter, buttonPos[i][0], buttonPos[i][1], QString("???")); +#ifdef DEBUG_CWPAINT +} +#endif } } diff --git a/src/gui/profile.cpp b/src/gui/profile.cpp index 434d01d..cbb12f4 100644 --- a/src/gui/profile.cpp +++ b/src/gui/profile.cpp @@ -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; }