nJoy: Escape key stops waiting for input when configuring the pad, changed the display of a disabled button from -1 to ""
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1946 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
6f4cbb89f9
commit
969f34bbd0
|
@ -160,6 +160,7 @@ int Config::CheckForDuplicateJoypads(bool OK)
|
|||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void Config::Save(bool CheckedForDuplicates)
|
||||
{
|
||||
// Load ini file
|
||||
IniFile file;
|
||||
file.Load("nJoy.ini");
|
||||
|
||||
|
@ -296,7 +297,7 @@ void Config::Load(bool config)
|
|||
file.Get(SectionName.c_str(), "sub_y", &joysticks[i].axis[CTL_SUB_Y], 3);
|
||||
|
||||
file.Get(SectionName.c_str(), "deadzone", &joysticks[i].deadzone, 9);
|
||||
file.Get(SectionName.c_str(), "halfpress", &joysticks[i].halfpress, 6);
|
||||
file.Get(SectionName.c_str(), "halfpress", &joysticks[i].halfpress, -1);
|
||||
file.Get(SectionName.c_str(), "controllertype", &joysticks[i].controllertype, 0);
|
||||
file.Get(SectionName.c_str(), "TriggerType", &joysticks[i].triggertype, 0);
|
||||
file.Get(SectionName.c_str(), "eventnum", &joysticks[i].eventnum, 0);
|
||||
|
|
|
@ -192,8 +192,8 @@ void ConfigBox::OKClick(wxCommandEvent& event)
|
|||
if (Tmp == wxOK) return; else if (Tmp == wxNO) g_Config.bSaveByIDNotice = false;
|
||||
}
|
||||
|
||||
for(int i=0; i<4 ;i++) SaveButtonMapping(i); // Update joysticks array
|
||||
g_Config.Save(true); // Save settings
|
||||
for(int i = 0; i < 4; i++) SaveButtonMapping(i); // Update joysticks array
|
||||
DoSave(false, true); // Save settings
|
||||
g_Config.Load(); // Reload settings
|
||||
Close(); // Call OnClose()
|
||||
}
|
||||
|
@ -209,6 +209,106 @@ void ConfigBox::CancelClick(wxCommandEvent& event)
|
|||
Close(); // Call OnClose()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////
|
||||
// Save Settings
|
||||
/* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
|
||||
Saving is currently done when:
|
||||
|
||||
1. Closing the configuration window
|
||||
2. Changing the gamepad
|
||||
3. When the gamepad is enabled or disbled */
|
||||
|
||||
void ConfigBox::DoSave(bool ChangePad, bool CheckedForDuplicates)
|
||||
{
|
||||
// Replace "" with "-1" before we are saving
|
||||
ToBlank(false);
|
||||
|
||||
if(ChangePad)
|
||||
{
|
||||
// Since we are selecting the pad to save to by the Id we can't update it when we change the pad
|
||||
for(int i = 0; i < 4; i++) SaveButtonMapping(i, true);
|
||||
g_Config.Save(CheckedForDuplicates);
|
||||
// Now we can update the ID
|
||||
joysticks[notebookpage].ID = m_Joyname[notebookpage]->GetSelection();
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = 0; i < 4; i++) SaveButtonMapping(i);
|
||||
g_Config.Save(CheckedForDuplicates);
|
||||
}
|
||||
|
||||
// Then change it back
|
||||
ToBlank();
|
||||
}
|
||||
|
||||
// Enable or disable joystick and update the GUI
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ConfigBox::EnableDisable(wxCommandEvent& event)
|
||||
{
|
||||
// We will enable this device
|
||||
joysticks[notebookpage].enabled = !joysticks[notebookpage].enabled;
|
||||
|
||||
// Update the GUI
|
||||
UpdateGUI(notebookpage);
|
||||
}
|
||||
|
||||
// Change Joystick
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
/* Function: When changing the joystick we save and load the settings and update the joysticks
|
||||
and joystate array */
|
||||
void ConfigBox::DoChangeJoystick()
|
||||
{
|
||||
// Before changing the pad we save potential changes (to support SaveByID)
|
||||
DoSave(true);
|
||||
|
||||
// Load the settings for the new Id
|
||||
g_Config.Load(true);
|
||||
UpdateGUI(notebookpage); // Update the GUI
|
||||
|
||||
// Remap the controller
|
||||
if (joysticks[notebookpage].enabled)
|
||||
{
|
||||
//Console::Print("Id: %i\n", joysticks[notebookpage].ID);
|
||||
if (SDL_JoystickOpened(joysticks[notebookpage].ID)) SDL_JoystickClose(joystate[notebookpage].joy);
|
||||
joystate[notebookpage].joy = SDL_JoystickOpen(joysticks[notebookpage].ID);
|
||||
}
|
||||
}
|
||||
void ConfigBox::ChangeJoystick(wxCommandEvent& event)
|
||||
{
|
||||
DoChangeJoystick();
|
||||
}
|
||||
|
||||
// Notebook page changed
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ConfigBox::NotebookPageChanged(wxNotebookEvent& event)
|
||||
{
|
||||
int oldnotebookpage = notebookpage;
|
||||
notebookpage = event.GetSelection();
|
||||
int OldId = joysticks[oldnotebookpage].ID;
|
||||
int NewId = joysticks[notebookpage].ID;
|
||||
|
||||
// Check if it has changed. If it has save the old Id and load the new Id
|
||||
if(OldId != NewId)
|
||||
DoChangeJoystick();
|
||||
}
|
||||
|
||||
// Replace the harder to understand -1 with "" for the sake of user friendliness
|
||||
void ConfigBox::ToBlank(bool ToBlank)
|
||||
{
|
||||
if(ToBlank)
|
||||
{
|
||||
for(int i = IDB_ANALOG_MAIN_X; i <= IDB_BUTTONHALFPRESS; i++)
|
||||
if(GetButtonText(i) == "-1") SetButtonText(i, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = IDB_ANALOG_MAIN_X; i <= IDB_BUTTONHALFPRESS; i++)
|
||||
if(GetButtonText(i) == "") SetButtonText(i, "-1");
|
||||
}
|
||||
}
|
||||
//////////////////////////////////
|
||||
|
||||
|
||||
|
@ -246,27 +346,13 @@ void ConfigBox::ChangeSettings( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
// Enable or disable joystick and update the GUI
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ConfigBox::EnableDisable(wxCommandEvent& event)
|
||||
{
|
||||
// First save the settings as they are now, disabled controls will not be saved later
|
||||
g_Config.Save();
|
||||
|
||||
// Update the enable / disable status
|
||||
UpdateGUI(notebookpage);
|
||||
|
||||
// Update the status
|
||||
SaveButtonMapping(notebookpage);
|
||||
}
|
||||
|
||||
// Update GUI
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
// Called from: UpdateGUIKeys(), ChangeControllertype()
|
||||
// Called from: ChangeControllertype()
|
||||
void ConfigBox::UpdateGUI(int _notebookpage)
|
||||
{
|
||||
// Update the enable / disable status
|
||||
joysticks[_notebookpage].enabled = m_Joyattach[_notebookpage]->GetValue();
|
||||
// Update the GUI from joysticks[]
|
||||
UpdateGUIKeys(_notebookpage);
|
||||
|
||||
// Controller type settings
|
||||
bool Hat = (joysticks[_notebookpage].controllertype == CTL_DPAD_HAT);
|
||||
|
@ -291,8 +377,6 @@ void ConfigBox::UpdateGUI(int _notebookpage)
|
|||
m_bJoyDpadDown[_notebookpage]->SetToolTip(Hat ?
|
||||
wxT("Select a hat by pressing the hat in any direction") : wxT(""));
|
||||
|
||||
m_TriggerType[_notebookpage]->Enable(AnalogTrigger);
|
||||
|
||||
// General settings
|
||||
m_CBSaveByID[_notebookpage]->SetValue(g_Config.bSaveByID.at(_notebookpage));
|
||||
m_CBSaveByIDNotice[_notebookpage]->SetValue(g_Config.bSaveByIDNotice);
|
||||
|
@ -302,62 +386,28 @@ void ConfigBox::UpdateGUI(int _notebookpage)
|
|||
m_CoBDiagonal[_notebookpage]->SetValue(wxString::FromAscii(g_Config.SDiagonal.at(_notebookpage).c_str()));
|
||||
m_CBS_to_C[_notebookpage]->SetValue(g_Config.bSquareToCircle.at(_notebookpage));
|
||||
|
||||
// Disabled pages
|
||||
bool Enabled = joysticks[_notebookpage].enabled;
|
||||
// There is no FindItem in linux so this doesn't work
|
||||
#ifdef _WIN32
|
||||
// Enable or disable all buttons
|
||||
for(int i = IDB_ANALOG_MAIN_X; i < (IDB_ANALOG_MAIN_X + 13 + 4); i++)
|
||||
{
|
||||
m_Controller[_notebookpage]->FindItem(i)->Enable(joysticks[_notebookpage].enabled);
|
||||
}
|
||||
|
||||
for(int i = IDB_ANALOG_MAIN_X; i <= IDB_BUTTONHALFPRESS; i++)
|
||||
m_Controller[_notebookpage]->FindItem(i)->Enable(Enabled);
|
||||
// Controller type settings
|
||||
m_Controller[_notebookpage]->FindItem(IDC_DEADZONE)->Enable(joysticks[_notebookpage].enabled);
|
||||
m_Controller[_notebookpage]->FindItem(IDC_DEADZONE)->Enable(Enabled);
|
||||
m_Controller[_notebookpage]->FindItem(IDC_CONTROLTYPE)->Enable(Enabled);
|
||||
m_Controller[_notebookpage]->FindItem(IDC_TRIGGERTYPE)->Enable(Enabled && AnalogTrigger);
|
||||
m_Controller[_notebookpage]->FindItem(IDCB_MAINSTICK_DIAGONAL)->Enable(Enabled);
|
||||
m_Controller[_notebookpage]->FindItem(IDCB_MAINSTICK_S_TO_C)->Enable(Enabled);
|
||||
#endif
|
||||
|
||||
// Replace the harder to understand -1 with "" for the sake of user friendliness
|
||||
ToBlank();
|
||||
|
||||
// Repaint the background
|
||||
m_Controller[_notebookpage]->Refresh();
|
||||
}
|
||||
|
||||
|
||||
// Notebook page changed
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ConfigBox::NotebookPageChanged(wxNotebookEvent& event)
|
||||
{
|
||||
notebookpage = event.GetSelection();
|
||||
}
|
||||
|
||||
|
||||
// Change Joystick
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
/* Function: When changing the joystick we save and load the settings and update the joysticks
|
||||
and joystate array */
|
||||
void ConfigBox::ChangeJoystick(wxCommandEvent& event)
|
||||
{
|
||||
// Before chaning the pad we save potential changes (to support SaveByID)
|
||||
int TmpID = joysticks[notebookpage].ID; // Don't update the ID before saving
|
||||
SaveButtonMapping(notebookpage); // Update the ID among other things
|
||||
joysticks[notebookpage].ID = TmpID;
|
||||
g_Config.Save();
|
||||
|
||||
// Update the physical device ID for the virtual device
|
||||
joysticks[notebookpage].ID = m_Joyname[notebookpage]->GetSelection();
|
||||
|
||||
// Load device settings to support SaveByID
|
||||
g_Config.Load(true); // Then load the current
|
||||
UpdateGUIKeys(notebookpage); // Update joystick dialog items
|
||||
UpdateGUI(notebookpage); // Update other dialog items
|
||||
|
||||
// Remap the controller
|
||||
if (joysticks[notebookpage].enabled)
|
||||
{
|
||||
//Console::Print("Id: %i\n", joysticks[notebookpage].ID);
|
||||
|
||||
if (SDL_JoystickOpened(joysticks[notebookpage].ID)) SDL_JoystickClose(joystate[notebookpage].joy);
|
||||
joystate[notebookpage].joy = SDL_JoystickOpen(joysticks[notebookpage].ID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Populate the config window
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ConfigBox::OnPaint( wxPaintEvent &event )
|
||||
|
@ -632,7 +682,7 @@ void ConfigBox::CreateGUIControls()
|
|||
m_TriggerType[i] = new wxComboBox(m_Controller[i], IDC_TRIGGERTYPE, wxAS_TriggerType[0], wxDefaultPosition, wxDefaultSize, wxAS_TriggerType, wxCB_READONLY);
|
||||
|
||||
// Populate general settings 2 (controller typ)
|
||||
m_gGenSettings[i] = new wxStaticBoxSizer( wxVERTICAL, m_Controller[i], wxT("D-Pad and Analog Trigger"));
|
||||
m_gGenSettings[i] = new wxStaticBoxSizer( wxVERTICAL, m_Controller[i], wxT("D-Pad and Trigger"));
|
||||
m_gGBGenSettings[i] = new wxGridBagSizer(0, 0);
|
||||
m_gGBGenSettings[i]->Add(m_TSControltype[i], wxGBPosition(0, 0), wxGBSpan(1, 1), (wxTOP), 4);
|
||||
m_gGBGenSettings[i]->Add(m_ControlType[i], wxGBPosition(0, 1), wxGBSpan(1, 1), (wxBOTTOM | wxLEFT), 2);
|
||||
|
@ -653,15 +703,15 @@ void ConfigBox::CreateGUIControls()
|
|||
m_gGenSettingsID[i]->Add(m_sSaveByID[i], 0, wxEXPAND | wxALL, 3);
|
||||
m_gGenSettingsID[i]->Add(m_CBShowAdvanced[i], 0, wxEXPAND | wxALL, 3);
|
||||
|
||||
// Create tooltips
|
||||
// Create tooltips
|
||||
m_ControlType[i]->SetToolTip(wxT(
|
||||
"Use a 'hat' on your gamepad or configure a custom button for each direction."
|
||||
));
|
||||
));
|
||||
m_TriggerType[i]->SetToolTip(wxT(
|
||||
"This is for the analog trigger settings. You can look under 'Trigger values' in the advanced settings to see"
|
||||
" which of these modes work for your gamepad. If it works correctly the unpressed to pressed range should be"
|
||||
" 0 to 255."
|
||||
));
|
||||
));
|
||||
m_CBSaveByID[i]->SetToolTip(wxString::Format(wxT(
|
||||
"Map these settings to the selected controller device instead of to the"
|
||||
"\nselected controller number (%i). This may be a more convenient way"
|
||||
|
@ -725,6 +775,10 @@ void ConfigBox::CreateGUIControls()
|
|||
|
||||
// The checkbox
|
||||
m_CBS_to_C[i] = new wxCheckBox(m_Controller[i], IDCB_MAINSTICK_S_TO_C, wxT("Square-to-circle"));
|
||||
m_CBS_to_C[i]->SetToolTip(wxT(
|
||||
"This will convert a square stick radius to a circle stick radius like the one that the actual GameCube pad produce."
|
||||
" That is also the input the games expect to see."
|
||||
));
|
||||
|
||||
m_gStatusInSettings[i]->Add(m_CBS_to_C[i], 0, (wxALL), 4);
|
||||
m_gStatusInSettings[i]->Add(m_gStatusInSettingsH[i], 0, (wxLEFT | wxRIGHT | wxBOTTOM), 4);
|
||||
|
@ -779,7 +833,7 @@ void ConfigBox::CreateGUIControls()
|
|||
}
|
||||
|
||||
// Set dialog items from saved values
|
||||
UpdateGUIKeys(i);
|
||||
//UpdateGUIKeys(i);
|
||||
|
||||
// Update GUI
|
||||
UpdateGUI(i);
|
||||
|
|
|
@ -225,31 +225,34 @@ class ConfigBox : public wxDialog
|
|||
// Keys objects
|
||||
// -----------------------------
|
||||
|
||||
// Text controls
|
||||
ID_SHOULDER_L = 2000,
|
||||
ID_SHOULDER_R,
|
||||
|
||||
ID_BUTTON_A,
|
||||
ID_BUTTON_B,
|
||||
ID_BUTTON_X,
|
||||
ID_BUTTON_Y,
|
||||
ID_BUTTON_Z,
|
||||
ID_BUTTONSTART,
|
||||
ID_BUTTONHALFPRESS,
|
||||
|
||||
ID_ANALOG_MAIN_X,
|
||||
// -------------------------------------
|
||||
// Text controls that hold the mapped key value
|
||||
// ----------
|
||||
ID_ANALOG_MAIN_X = 2000,
|
||||
ID_ANALOG_MAIN_Y,
|
||||
ID_ANALOG_SUB_X,
|
||||
ID_ANALOG_SUB_Y,
|
||||
ID_SHOULDER_L,
|
||||
ID_SHOULDER_R,
|
||||
|
||||
ID_DPAD_UP,
|
||||
ID_DPAD_DOWN,
|
||||
ID_DPAD_LEFT,
|
||||
ID_DPAD_RIGHT,
|
||||
|
||||
ID_BUTTON_A,
|
||||
ID_BUTTON_B,
|
||||
ID_BUTTON_X,
|
||||
ID_BUTTON_Y,
|
||||
ID_BUTTON_Z,
|
||||
ID_BUTTONSTART,
|
||||
|
||||
ID_BUTTONHALFPRESS,
|
||||
// ------------------ Keep this order
|
||||
|
||||
// -------------------------------------
|
||||
// Buttons controls (it's important that they are kept in this order)
|
||||
// ------
|
||||
// --------
|
||||
IDB_ANALOG_MAIN_X = 3000,
|
||||
IDB_ANALOG_MAIN_Y,
|
||||
IDB_ANALOG_SUB_X,
|
||||
|
@ -272,18 +275,20 @@ class ConfigBox : public wxDialog
|
|||
IDB_BUTTONHALFPRESS,
|
||||
// ------------------ Keep this order
|
||||
|
||||
// Text controls
|
||||
// Statis text controls that hold the button label
|
||||
IDT_ANALOG_MAIN_X = 4000,
|
||||
IDT_ANALOG_MAIN_Y,
|
||||
IDT_ANALOG_SUB_X,
|
||||
IDT_ANALOG_SUB_Y,
|
||||
|
||||
IDT_DPAD_UP,
|
||||
IDT_DPAD_DOWN,
|
||||
IDT_DPAD_LEFT,
|
||||
IDT_DPAD_RIGHT,
|
||||
IDT_DEADZONE,
|
||||
IDT_BUTTONHALFPRESS,
|
||||
IDT_DPADTYPE, IDT_TRIGGERTYPE,
|
||||
IDT_ANALOG_SUB_X,
|
||||
IDT_ANALOG_SUB_Y,
|
||||
|
||||
IDT_DPADTYPE, IDT_TRIGGERTYPE,
|
||||
IDT_WEBSITE,
|
||||
IDT_DEBUGGING, IDT_DEBUGGING2,
|
||||
// ============
|
||||
|
@ -295,8 +300,9 @@ class ConfigBox : public wxDialog
|
|||
void AboutClick(wxCommandEvent& event);
|
||||
void OKClick(wxCommandEvent& event);
|
||||
void CancelClick(wxCommandEvent& event);
|
||||
void DoSave(bool ChangePad = false, bool CheckedForDuplicates = false);
|
||||
|
||||
void ChangeJoystick(wxCommandEvent& event);
|
||||
void ChangeJoystick(wxCommandEvent& event); void DoChangeJoystick();
|
||||
void ChangeControllertype(wxCommandEvent& event);
|
||||
void EnableDisable(wxCommandEvent& event); void UpdateGUI(int _notebookpage);
|
||||
|
||||
|
@ -310,7 +316,8 @@ class ConfigBox : public wxDialog
|
|||
void PadGetStatus(); void Update();
|
||||
|
||||
void UpdateGUIKeys(int controller);
|
||||
void SaveButtonMapping(int controller);
|
||||
void SaveButtonMapping(int controller, bool DontChangeId = false);
|
||||
void ToBlank(bool ToBlank = true);
|
||||
|
||||
void NotebookPageChanged(wxNotebookEvent& event);
|
||||
|
||||
|
@ -321,6 +328,7 @@ class ConfigBox : public wxDialog
|
|||
void OnPaint(wxPaintEvent &event);
|
||||
|
||||
void SetButtonText(int id, char text[128]);
|
||||
wxString GetButtonText(int id);
|
||||
void OnKeyDown(wxKeyEvent& event);
|
||||
};
|
||||
|
||||
|
|
|
@ -52,8 +52,12 @@ void ConfigBox::UpdateGUIKeys(int controller)
|
|||
// http://wiki.wxwidgets.org/Converting_everything_to_and_from_wxString
|
||||
wxString tmp;
|
||||
|
||||
// Update selected gamepad
|
||||
m_Joyname[controller]->SetSelection(joysticks[controller].ID);
|
||||
|
||||
// Update the enabled checkbox
|
||||
m_Joyattach[controller]->SetValue(joysticks[controller].enabled);
|
||||
|
||||
tmp << joysticks[controller].buttons[CTL_L_SHOULDER]; m_JoyShoulderL[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << joysticks[controller].buttons[CTL_R_SHOULDER]; m_JoyShoulderR[controller]->SetValue(tmp); tmp.clear();
|
||||
|
||||
|
@ -70,19 +74,13 @@ void ConfigBox::UpdateGUIKeys(int controller)
|
|||
tmp << joysticks[controller].axis[CTL_MAIN_Y]; m_JoyAnalogMainY[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << joysticks[controller].axis[CTL_SUB_X]; m_JoyAnalogSubX[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << joysticks[controller].axis[CTL_SUB_Y]; m_JoyAnalogSubY[controller]->SetValue(tmp); tmp.clear();
|
||||
|
||||
if(joysticks[controller].enabled)
|
||||
m_Joyattach[controller]->SetValue(TRUE);
|
||||
else
|
||||
m_Joyattach[controller]->SetValue(FALSE);
|
||||
|
||||
// Update the deadzone and controller type controls
|
||||
m_ControlType[controller]->SetSelection(joysticks[controller].controllertype);
|
||||
m_TriggerType[controller]->SetSelection(joysticks[controller].triggertype);
|
||||
m_Deadzone[controller]->SetSelection(joysticks[controller].deadzone);
|
||||
|
||||
UpdateGUI(controller);
|
||||
|
||||
// Update D-Pad
|
||||
if(joysticks[controller].controllertype == CTL_DPAD_HAT)
|
||||
{
|
||||
tmp << joysticks[controller].dpad; m_JoyDpadUp[controller]->SetValue(tmp); tmp.clear();
|
||||
|
@ -93,20 +91,33 @@ void ConfigBox::UpdateGUIKeys(int controller)
|
|||
tmp << joysticks[controller].dpad2[CTL_D_PAD_DOWN]; m_JoyDpadDown[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << joysticks[controller].dpad2[CTL_D_PAD_LEFT]; m_JoyDpadLeft[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << joysticks[controller].dpad2[CTL_D_PAD_RIGHT]; m_JoyDpadRight[controller]->SetValue(tmp); tmp.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Populate the joysticks array with the dialog items settings, for example
|
||||
selected joystick, enabled or disabled status and so on */
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ConfigBox::SaveButtonMapping(int controller)
|
||||
void ConfigBox::SaveButtonMapping(int controller, bool DontChangeId)
|
||||
{
|
||||
// Temporary storage
|
||||
wxString tmp;
|
||||
long value;
|
||||
|
||||
// The controller ID
|
||||
joysticks[controller].ID = m_Joyname[controller]->GetSelection();
|
||||
// Replace "" with "-1"
|
||||
ToBlank(false);
|
||||
|
||||
// Set enabled or disable status and other settings
|
||||
if(!DontChangeId) joysticks[controller].ID = m_Joyname[controller]->GetSelection();
|
||||
joysticks[controller].enabled = m_Joyattach[controller]->GetValue();
|
||||
joysticks[controller].controllertype = m_ControlType[controller]->GetSelection();
|
||||
joysticks[controller].triggertype = m_TriggerType[controller]->GetSelection();
|
||||
joysticks[controller].deadzone = m_Deadzone[controller]->GetSelection();
|
||||
|
||||
// The analog buttons
|
||||
m_JoyAnalogMainX[controller]->GetValue().ToLong(&value); joysticks[controller].axis[CTL_MAIN_X] = value; tmp.clear();
|
||||
m_JoyAnalogMainY[controller]->GetValue().ToLong(&value); joysticks[controller].axis[CTL_MAIN_Y] = value; tmp.clear();
|
||||
m_JoyAnalogSubX[controller]->GetValue().ToLong(&value); joysticks[controller].axis[CTL_SUB_X] = value; tmp.clear();
|
||||
m_JoyAnalogSubY[controller]->GetValue().ToLong(&value); joysticks[controller].axis[CTL_SUB_Y] = value; tmp.clear();
|
||||
|
||||
// The shoulder buttons
|
||||
m_JoyShoulderL[controller]->GetValue().ToLong(&value); joysticks[controller].buttons[CTL_L_SHOULDER] = value;
|
||||
|
@ -120,9 +131,10 @@ void ConfigBox::SaveButtonMapping(int controller)
|
|||
m_JoyButtonZ[controller]->GetValue().ToLong(&value); joysticks[controller].buttons[CTL_Z_TRIGGER] = value; tmp.clear();
|
||||
m_JoyButtonStart[controller]->GetValue().ToLong(&value); joysticks[controller].buttons[CTL_START] = value; tmp.clear();
|
||||
|
||||
// The halfpress button
|
||||
m_JoyButtonHalfpress[controller]->GetValue().ToLong(&value); joysticks[controller].halfpress = value; tmp.clear();
|
||||
|
||||
// Digital pad type
|
||||
// The digital pad
|
||||
if(joysticks[controller].controllertype == CTL_DPAD_HAT)
|
||||
{
|
||||
m_JoyDpadUp[controller]->GetValue().ToLong(&value); joysticks[controller].dpad = value; tmp.clear();
|
||||
|
@ -135,16 +147,8 @@ void ConfigBox::SaveButtonMapping(int controller)
|
|||
m_JoyDpadRight[controller]->GetValue().ToLong(&value); joysticks[controller].dpad2[CTL_D_PAD_RIGHT] = value; tmp.clear();
|
||||
}
|
||||
|
||||
m_JoyAnalogMainX[controller]->GetValue().ToLong(&value); joysticks[controller].axis[CTL_MAIN_X] = value; tmp.clear();
|
||||
m_JoyAnalogMainY[controller]->GetValue().ToLong(&value); joysticks[controller].axis[CTL_MAIN_Y] = value; tmp.clear();
|
||||
m_JoyAnalogSubX[controller]->GetValue().ToLong(&value); joysticks[controller].axis[CTL_SUB_X] = value; tmp.clear();
|
||||
m_JoyAnalogSubY[controller]->GetValue().ToLong(&value); joysticks[controller].axis[CTL_SUB_Y] = value; tmp.clear();
|
||||
|
||||
// Set enabled or disable status and other settings
|
||||
joysticks[controller].enabled = m_Joyattach[controller]->GetValue();
|
||||
joysticks[controller].controllertype = m_ControlType[controller]->GetSelection();
|
||||
joysticks[controller].triggertype = m_TriggerType[controller]->GetSelection();
|
||||
joysticks[controller].deadzone = m_Deadzone[controller]->GetSelection();
|
||||
// Replace "-1" with ""
|
||||
ToBlank();
|
||||
}
|
||||
|
||||
|
||||
|
@ -166,47 +170,61 @@ void ConfigBox::SetButtonText(int id, char text[128])
|
|||
|
||||
switch(id)
|
||||
{
|
||||
case IDB_DPAD_RIGHT:
|
||||
m_JoyDpadRight[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_DPAD_UP:
|
||||
m_JoyDpadUp[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_DPAD_DOWN:
|
||||
m_JoyDpadDown[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_DPAD_LEFT:
|
||||
m_JoyDpadLeft[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_DPAD_RIGHT: m_JoyDpadRight[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_DPAD_UP: m_JoyDpadUp[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_DPAD_DOWN: m_JoyDpadDown[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_DPAD_LEFT: m_JoyDpadLeft[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
|
||||
case IDB_ANALOG_MAIN_X:
|
||||
m_JoyAnalogMainX[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_ANALOG_MAIN_Y:
|
||||
m_JoyAnalogMainY[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_ANALOG_SUB_X:
|
||||
m_JoyAnalogSubX[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_ANALOG_SUB_Y:
|
||||
m_JoyAnalogSubY[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_ANALOG_MAIN_X: m_JoyAnalogMainX[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_ANALOG_MAIN_Y: m_JoyAnalogMainY[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_ANALOG_SUB_X: m_JoyAnalogSubX[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_ANALOG_SUB_Y: m_JoyAnalogSubY[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
|
||||
case IDB_SHOULDER_L:
|
||||
m_JoyShoulderL[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_SHOULDER_R:
|
||||
m_JoyShoulderR[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_SHOULDER_L: m_JoyShoulderL[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_SHOULDER_R: m_JoyShoulderR[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
|
||||
case IDB_BUTTON_A:
|
||||
m_JoyButtonA[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_BUTTON_B:
|
||||
m_JoyButtonB[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_BUTTON_X:
|
||||
m_JoyButtonX[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_BUTTON_Y:
|
||||
m_JoyButtonY[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_BUTTON_Z:
|
||||
m_JoyButtonZ[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_BUTTONSTART:
|
||||
m_JoyButtonStart[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_BUTTON_A: m_JoyButtonA[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_BUTTON_B: m_JoyButtonB[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_BUTTON_X: m_JoyButtonX[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_BUTTON_Y: m_JoyButtonY[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_BUTTON_Z: m_JoyButtonZ[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_BUTTONSTART: m_JoyButtonStart[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
|
||||
case IDB_BUTTONHALFPRESS:
|
||||
m_JoyButtonHalfpress[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
case IDB_BUTTONHALFPRESS: m_JoyButtonHalfpress[controller]->SetValue(wxString::FromAscii(text)); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
// Get the text in the textbox for the buttons
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
wxString ConfigBox::GetButtonText(int id)
|
||||
{
|
||||
int controller = notebookpage;
|
||||
|
||||
switch(id)
|
||||
{
|
||||
case IDB_DPAD_RIGHT: return m_JoyDpadRight[controller]->GetValue();
|
||||
case IDB_DPAD_UP: return m_JoyDpadUp[controller]->GetValue(); break;
|
||||
case IDB_DPAD_DOWN: return m_JoyDpadDown[controller]->GetValue(); break;
|
||||
case IDB_DPAD_LEFT: return m_JoyDpadLeft[controller]->GetValue(); break;
|
||||
|
||||
case IDB_ANALOG_MAIN_X: return m_JoyAnalogMainX[controller]->GetValue(); break;
|
||||
case IDB_ANALOG_MAIN_Y: return m_JoyAnalogMainY[controller]->GetValue(); break;
|
||||
case IDB_ANALOG_SUB_X: return m_JoyAnalogSubX[controller]->GetValue(); break;
|
||||
case IDB_ANALOG_SUB_Y: return m_JoyAnalogSubY[controller]->GetValue(); break;
|
||||
|
||||
case IDB_SHOULDER_L: return m_JoyShoulderL[controller]->GetValue(); break;
|
||||
case IDB_SHOULDER_R: return m_JoyShoulderR[controller]->GetValue(); break;
|
||||
|
||||
case IDB_BUTTON_A: return m_JoyButtonA[controller]->GetValue(); break;
|
||||
case IDB_BUTTON_B: return m_JoyButtonB[controller]->GetValue(); break;
|
||||
case IDB_BUTTON_X: return m_JoyButtonX[controller]->GetValue(); break;
|
||||
case IDB_BUTTON_Y: return m_JoyButtonY[controller]->GetValue(); break;
|
||||
case IDB_BUTTON_Z: return m_JoyButtonZ[controller]->GetValue(); break;
|
||||
case IDB_BUTTONSTART: return m_JoyButtonStart[controller]->GetValue(); break;
|
||||
|
||||
case IDB_BUTTONHALFPRESS: return m_JoyButtonHalfpress[controller]->GetValue(); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,6 +330,10 @@ void ConfigBox::DoGetButtons(int GetId)
|
|||
#endif
|
||||
}
|
||||
|
||||
// ===============================================
|
||||
// Check for buttons
|
||||
// ----------------
|
||||
|
||||
// If there is a timer but we should not create a new one
|
||||
else
|
||||
{
|
||||
|
@ -370,7 +392,8 @@ void ConfigBox::DoGetButtons(int GetId)
|
|||
pressed = g_Pressed;
|
||||
type = CTL_BUTTON;
|
||||
Succeed = true;
|
||||
g_Pressed = 0;
|
||||
g_Pressed = 0;
|
||||
if(pressed == WXK_ESCAPE) pressed = -1; // Check for the exape key
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -379,41 +402,42 @@ void ConfigBox::DoGetButtons(int GetId)
|
|||
Stop = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// ========================= Check for keys
|
||||
|
||||
// Count each time
|
||||
GetButtonWaitingTimer++;
|
||||
// ===============================================
|
||||
// Process results
|
||||
// ----------------
|
||||
|
||||
// This is run every second
|
||||
if(GetButtonWaitingTimer % TimesPerSecond == 0)
|
||||
{
|
||||
//Console::Print("Second\n\n");
|
||||
// Count each time
|
||||
GetButtonWaitingTimer++;
|
||||
|
||||
// Current time
|
||||
int TmpTime = Seconds - (GetButtonWaitingTimer / TimesPerSecond);
|
||||
// This is run every second
|
||||
if(GetButtonWaitingTimer % TimesPerSecond == 0)
|
||||
{
|
||||
// Current time
|
||||
int TmpTime = Seconds - (GetButtonWaitingTimer / TimesPerSecond);
|
||||
|
||||
// Update text
|
||||
sprintf(format, "[%d]", TmpTime);
|
||||
SetButtonText(GetId, format);
|
||||
}
|
||||
// Update text
|
||||
sprintf(format, "[%d]", TmpTime);
|
||||
SetButtonText(GetId, format);
|
||||
}
|
||||
|
||||
// Time's up
|
||||
if( (GetButtonWaitingTimer / TimesPerSecond) >= Seconds )
|
||||
{
|
||||
Stop = true;
|
||||
// Time's up
|
||||
if( (GetButtonWaitingTimer / TimesPerSecond) >= Seconds )
|
||||
{
|
||||
Stop = true;
|
||||
// Leave a blank mapping
|
||||
SetButtonText(GetId, "-1");
|
||||
}
|
||||
|
||||
// Leave a blank mapping
|
||||
SetButtonText(GetId, "");
|
||||
}
|
||||
|
||||
// If we got a button
|
||||
if(Succeed)
|
||||
{
|
||||
Stop = true;
|
||||
|
||||
// Write the number of the pressed button to the text box
|
||||
sprintf(format, "%d", pressed);
|
||||
SetButtonText(GetId, format);
|
||||
}
|
||||
// If we got a button
|
||||
if(Succeed)
|
||||
{
|
||||
Stop = true;
|
||||
// Write the number of the pressed button to the text box
|
||||
sprintf(format, "%d", pressed);
|
||||
SetButtonText(GetId, format);
|
||||
}
|
||||
|
||||
// Stop the timer
|
||||
|
@ -421,12 +445,16 @@ void ConfigBox::DoGetButtons(int GetId)
|
|||
{
|
||||
m_ButtonMappingTimer->Stop();
|
||||
GetButtonWaitingTimer = 0;
|
||||
|
||||
// Update the button mapping and GUI
|
||||
SaveButtonMapping(Controller);
|
||||
UpdateGUI(Controller);
|
||||
}
|
||||
|
||||
// If we got a bad button
|
||||
if(g_Pressed == -1)
|
||||
{
|
||||
SetButtonText(GetId, ""); // Update text
|
||||
SetButtonText(GetId, "-1"); // Update text
|
||||
|
||||
// Notify the user
|
||||
wxMessageBox(wxString::Format(wxT(
|
||||
|
@ -434,13 +462,11 @@ void ConfigBox::DoGetButtons(int GetId)
|
|||
" select another key with a higher key code."), pressed)
|
||||
, wxT("Notice"), wxICON_INFORMATION);
|
||||
}
|
||||
// ======================== Process results
|
||||
|
||||
// We don't need this gamepad handle any more
|
||||
if(SDL_JoystickOpened(joysticks[Controller].ID)) SDL_JoystickClose(joy);
|
||||
|
||||
// Update the button mapping
|
||||
SaveButtonMapping(Controller);
|
||||
|
||||
// Debugging
|
||||
//Console::Print("IsRunning: %i\n", m_ButtonMappingTimer->IsRunning());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue