profile[profileNum].mapName[31] = 0;
profile[profileNum].preferredSlot = CONTROLLER1;
- for(int i=BUTTON_FIRST; i<BUTTON_LAST; i++)
+ for(int i=BUTTON_FIRST; i<=BUTTON_LAST; i++)
profile[profileNum].map[i] = '*';
mapNameList->addItem(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;
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);
}
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)
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
}
}
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] = {
//
void SaveProfiles(void)
{
+ numberOfProfilesSave = numberOfProfiles;
memcpy(&profileBackup, &profile, sizeof(Profile) * MAX_PROFILES);
}
void RestoreProfiles(void)
{
memcpy(&profile, &profileBackup, sizeof(Profile) * MAX_PROFILES);
+ numberOfProfiles = numberOfProfilesSave;
}