nJoy: Fixed bugs in settings saving and loading

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2069 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson 2009-02-02 03:16:59 +00:00
parent 2199b15ca6
commit eb91942fd6
4 changed files with 33 additions and 22 deletions

View File

@ -216,9 +216,6 @@ void Config::Load(bool ChangePad, bool ChangeSaveByID)
the current amount of connected PadMapping */
if(PadMapping[i].ID >= SDL_NumJoysticks()) continue;
//PanicAlert("%i %i",PadMapping[i].ID, SDL_NumJoysticks());
//PanicAlert("%s", joyinfo[PadMapping[i].ID].Name);
// Create a section name
SectionName = joyinfo[PadMapping[i].ID].Name;
}

View File

@ -272,20 +272,19 @@ void ConfigBox::DoSave(bool ChangePad, int Slot)
ToBlank();
}
// OnSaveById
// On changing the SaveById option we update all pages
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void ConfigBox::OnSaveById()
{
// Save current settings
DoSave(false, notebookpage);
// Update the setting and load the settings
// Update the SaveByID setting and load the settings
g_Config.bSaveByID = m_CBSaveByID[notebookpage]->IsChecked();
g_Config.Load(false, true);
// Update GUI and PadMapping[]
UpdateGUI(notebookpage);
SaveButtonMapping(notebookpage);
// Update the GUI from the now updated PadMapping[]
UpdateGUIAll(-1);
}
// Change Joystick
@ -328,14 +327,12 @@ void ConfigBox::PadClose(int Close) // Close for slot 1, 2, 3 or 4
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void ConfigBox::NotebookPageChanged(wxNotebookEvent& event)
{
//int oldnotebookpage = notebookpage;
notebookpage = event.GetSelection();
//int OldId = PadMapping[oldnotebookpage].ID;
//int NewId = PadMapping[notebookpage].ID;
// Save current settings now, don't wait for OK
if(ControlsCreated && !g_Config.bSaveByID) DoSave(false, notebookpage);
// Update the global variable
notebookpage = event.GetSelection();
// Check if it has changed. If it has save the old Id and load the new Id
//if(OldId != NewId && NumGoodPads > 0) DoChangeJoystick();
// Update GUI
if(ControlsCreated) UpdateGUI(notebookpage);
}
@ -383,9 +380,24 @@ void ConfigBox::SaveButtonMappingAll(int Slot)
{
for (int i = 0; i < 4; i++)
if (joyinfo[PadMapping[i].ID].Name == joyinfo[PadMapping[Slot].ID].Name)
SaveButtonMapping(i, false);
SaveButtonMapping(i, false, Slot);
}
void ConfigBox::UpdateGUIAll(int Slot)
{
if(Slot == -1)
{
for (int i = 0; i < 4; i++) UpdateGUI(i);
}
else
{
for (int i = 0; i < 4; i++)
if (joyinfo[PadMapping[i].ID].Name == joyinfo[PadMapping[Slot].ID].Name)
UpdateGUI(i);
}
}
void ConfigBox::ChangeSettings( wxCommandEvent& event )
{
switch(event.GetId())
@ -404,10 +416,9 @@ void ConfigBox::ChangeSettings( wxCommandEvent& event )
SizeWindow();
break;
case IDC_CONTROLTYPE:
case IDC_TRIGGERTYPE:
SaveButtonMapping(notebookpage);
UpdateGUI(notebookpage);
case IDC_CONTROLTYPE:
case IDC_TRIGGERTYPE:
//UpdateGUI(notebookpage);
break;
case IDC_JOYNAME:
@ -426,6 +437,7 @@ void ConfigBox::ChangeSettings( wxCommandEvent& event )
// Update all slots that use this device
if(g_Config.bSaveByID) SaveButtonMappingAll(notebookpage);
if(g_Config.bSaveByID) UpdateGUIAll(notebookpage);
}
///////////////////////////////

View File

@ -320,6 +320,7 @@ class ConfigBox : public wxDialog
void UpdateGUIKeys(int controller);
void SaveButtonMapping(int controller, bool DontChangeId = false, int FromSlot = -1);
void SaveButtonMappingAll(int Slot);
void UpdateGUIAll(int Slot);
void ToBlank(bool ToBlank = true);
void OnSaveById();

View File

@ -80,7 +80,7 @@ void ConfigBox::UpdateGUIKeys(int controller)
m_CoBDiagonal[controller]->SetValue(wxString::FromAscii(PadMapping[controller].SDiagonal.c_str()));
m_CBS_to_C[controller]->SetValue(PadMapping[controller].bSquareToCircle);
//LogMsg("bSquareToCircle: %i\n", PadMapping[controller].bSquareToCircle);
//LogMsg("m_TriggerType[%i] = %i\n", controller, PadMapping[controller].triggertype);
// Update D-Pad
if(PadMapping[controller].controllertype == CTL_DPAD_HAT)
@ -141,7 +141,8 @@ void ConfigBox::SaveButtonMapping(int controller, bool DontChangeId, int FromSlo
m_JoyButtonZ[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[CTL_Z_TRIGGER] = value; tmp.clear();
m_JoyButtonStart[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[CTL_START] = value; tmp.clear();
//LogMsg("SaveButtonMapping: Key:%i From:%i To:%i\n", m_TriggerType[FromSlot]->GetSelection(), FromSlot, controller);
//LogMsg("PadMapping[%i].triggertype = %i, m_TriggerType[%i]->GetSelection() = %i\n",
// controller, PadMapping[controller].triggertype, FromSlot, m_TriggerType[FromSlot]->GetSelection());
// The halfpress button
m_JoyButtonHalfpress[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].halfpress = value; tmp.clear();