nJoy: Improvements to the configuration, the SaveById option should now be simpler and better

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1977 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson
2009-01-21 18:09:31 +00:00
parent 1b12bc38ac
commit 7f9dc55fbc
9 changed files with 439 additions and 435 deletions

View File

@ -50,7 +50,7 @@ bool StrangeHack = true;
void ConfigBox::PadGetStatus()
{
// Return if it's not detected
if(joysticks[notebookpage].ID >= SDL_NumJoysticks())
if(PadMapping[notebookpage].ID >= SDL_NumJoysticks())
{
m_TStatusIn[notebookpage]->SetLabel(wxT("Not connected"));
m_TStatusOut[notebookpage]->SetLabel(wxT("Not connected"));
@ -59,7 +59,7 @@ void ConfigBox::PadGetStatus()
}
// Return if it's not enabled
if (!joysticks[notebookpage].enabled)
if (!PadMapping[notebookpage].enabled)
{
m_TStatusIn[notebookpage]->SetLabel(wxT("Not enabled"));
m_TStatusOut[notebookpage]->SetLabel(wxT("Not enabled"));
@ -68,8 +68,8 @@ void ConfigBox::PadGetStatus()
}
// Get physical device status
int PhysicalDevice = joysticks[notebookpage].ID;
int TriggerType = joysticks[notebookpage].triggertype;
int PhysicalDevice = PadMapping[notebookpage].ID;
int TriggerType = PadMapping[notebookpage].triggertype;
// Get pad status
GetJoyState(notebookpage);
@ -78,8 +78,8 @@ void ConfigBox::PadGetStatus()
// Analog stick
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// Set Deadzones perhaps out of function
//int deadzone = (int)(((float)(128.00/100.00)) * (float)(joysticks[_numPAD].deadzone+1));
//int deadzone2 = (int)(((float)(-128.00/100.00)) * (float)(joysticks[_numPAD].deadzone+1));
//int deadzone = (int)(((float)(128.00/100.00)) * (float)(PadMapping[_numPAD].deadzone+1));
//int deadzone2 = (int)(((float)(-128.00/100.00)) * (float)(PadMapping[_numPAD].deadzone+1));
// Get original values
int main_x = joystate[notebookpage].axis[CTL_MAIN_X];
@ -89,7 +89,7 @@ void ConfigBox::PadGetStatus()
// Get adjusted values
int main_x_after = main_x, main_y_after = main_y;
if(g_Config.bSquareToCircle.at(notebookpage))
if(PadMapping[notebookpage].bSquareToCircle)
{
std::vector<int> main_xy = Pad_Square_to_Circle(main_x, main_y, notebookpage);
main_x_after = main_xy.at(0);
@ -143,7 +143,7 @@ void ConfigBox::PadGetStatus()
int TriggerRight = joystate[notebookpage].axis[CTL_R_SHOULDER];
// Convert the triggers values
if (joysticks[notebookpage].triggertype == CTL_TRIGGER_SDL)
if (PadMapping[notebookpage].triggertype == CTL_TRIGGER_SDL)
{
TriggerLeft = Pad_Convert(TriggerLeft);
TriggerRight = Pad_Convert(TriggerRight);
@ -169,19 +169,19 @@ void ConfigBox::PadGetStatus()
std::string ShowStatus(int VirtualController)
{
// Check if it's enabled
if (!joysticks[VirtualController].enabled) return "Disabled";
if (!PadMapping[VirtualController].enabled) return StringFromFormat("%i disabled", VirtualController);
// Save the physical device
int PhysicalDevice = joysticks[VirtualController].ID;
int PhysicalDevice = PadMapping[VirtualController].ID;
// Make local shortcut
SDL_Joystick *joy = joystate[VirtualController].joy;
// Make shortcuts for all pads
SDL_Joystick *joy0 = joystate[joysticks[0].ID].joy;
SDL_Joystick *joy1 = joystate[joysticks[1].ID].joy;
SDL_Joystick *joy2 = joystate[joysticks[2].ID].joy;
SDL_Joystick *joy3 = joystate[joysticks[3].ID].joy;
SDL_Joystick *joy0 = joystate[PadMapping[0].ID].joy;
SDL_Joystick *joy1 = joystate[PadMapping[1].ID].joy;
SDL_Joystick *joy2 = joystate[PadMapping[2].ID].joy;
SDL_Joystick *joy3 = joystate[PadMapping[3].ID].joy;
// Temporary storage
std::string StrAxes, StrHats, StrBut;
@ -193,10 +193,6 @@ std::string ShowStatus(int VirtualController)
int Hats = joyinfo[PhysicalDevice].NumHats;
int Buttons = joyinfo[PhysicalDevice].NumButtons;
// More status
int controllertype = joysticks[VirtualController].controllertype;
int triggertype = joysticks[VirtualController].triggertype;
// Update the internal values
SDL_JoystickUpdate();
@ -218,20 +214,25 @@ std::string ShowStatus(int VirtualController)
}
return StringFromFormat(
"joysticks.ID: %i %i %i %i\n"
"joysticks.controllertype, triggertype: %i %i\n"
"PadMapping\n"
"ID: %i %i %i %i\n"
"Controllertype: %i %i %i %i\n"
"SquareToCircle: %i %i %i %i\n\n"
"Handles: %i %i %i %i\n"
"XInput: %i %i %i\n"
"Axes: %s\n"
"Hats: %s\n"
"But: %s\n"
"Device: Ax: %i Balls:%i But:%i Hats:%i",
joysticks[0].ID, joysticks[1].ID, joysticks[2].ID, joysticks[3].ID,
controllertype, triggertype,
PadMapping[0].ID, PadMapping[1].ID, PadMapping[2].ID, PadMapping[3].ID,
PadMapping[0].controllertype, PadMapping[1].controllertype, PadMapping[2].controllertype, PadMapping[3].controllertype,
PadMapping[0].bSquareToCircle, PadMapping[1].bSquareToCircle, PadMapping[2].bSquareToCircle, PadMapping[3].bSquareToCircle,
joy0, joy1, joy2, joy3,
#ifdef _WIN32
XInput::IsConnected(0), XInput::GetXI(0, XI_TRIGGER_L), XInput::GetXI(0, XI_TRIGGER_R),
#endif
#ifdef _WIN32
XInput::IsConnected(0), XInput::GetXI(0, XI_TRIGGER_L), XInput::GetXI(0, XI_TRIGGER_R),
#endif
StrAxes.c_str(), StrHats.c_str(), StrBut.c_str(),
Axes, Balls, Hats, Buttons
);

View File

@ -40,7 +40,7 @@
#include "Images/controller.xpm"
extern CONTROLLER_INFO *joyinfo;
//extern CONTROLLER_MAPPING joysticks[4];
//extern CONTROLLER_MAPPING PadMapping[4];
extern bool emulator_running;
// D-Pad type
@ -70,17 +70,20 @@ BEGIN_EVENT_TABLE(ConfigBox,wxDialog)
EVT_NOTEBOOK_PAGE_CHANGED(ID_NOTEBOOK, ConfigBox::NotebookPageChanged)
// Change and enable or disable gamepad
EVT_COMBOBOX(IDC_JOYNAME, ConfigBox::ChangeJoystick)
EVT_CHECKBOX(IDC_JOYATTACH, ConfigBox::EnableDisable)
EVT_COMBOBOX(IDC_JOYNAME, ConfigBox::ChangeSettings)
EVT_CHECKBOX(IDC_JOYATTACH, ConfigBox::ChangeSettings)
// Settings
// Other settings
EVT_CHECKBOX(IDC_SAVEBYID, ConfigBox::ChangeSettings)
EVT_CHECKBOX(IDC_SAVEBYIDNOTICE, ConfigBox::ChangeSettings)
EVT_CHECKBOX(IDC_SHOWADVANCED, ConfigBox::ChangeSettings)
EVT_COMBOBOX(IDCB_MAINSTICK_DIAGONAL, ConfigBox::ChangeSettings)
EVT_COMBOBOX(IDC_CONTROLTYPE, ConfigBox::ChangeSettings)
EVT_COMBOBOX(IDC_TRIGGERTYPE, ConfigBox::ChangeSettings)
EVT_COMBOBOX(IDC_DEADZONE, ConfigBox::ChangeSettings)
// Advanced settings
EVT_COMBOBOX(IDCB_MAINSTICK_DIAGONAL, ConfigBox::ChangeSettings)
EVT_CHECKBOX(IDCB_MAINSTICK_S_TO_C, ConfigBox::ChangeSettings)
EVT_COMBOBOX(IDC_CONTROLTYPE, ConfigBox::ChangeControllertype)
EVT_COMBOBOX(IDC_TRIGGERTYPE, ConfigBox::ChangeControllertype)
EVT_BUTTON(IDB_SHOULDER_L, ConfigBox::GetButtons)
EVT_BUTTON(IDB_SHOULDER_R, ConfigBox::GetButtons)
@ -113,6 +116,9 @@ ConfigBox::ConfigBox(wxWindow *parent, wxWindowID id, const wxString &title,
// Define values
notebookpage = 0;
g_Pressed = 0;
Debugging = false;
m_TCDebugging = NULL;
ControlsCreated = false;
// Create controls
CreateGUIControls();
@ -185,16 +191,9 @@ void ConfigBox::OKClick(wxCommandEvent& event)
{
if (event.GetId() == ID_OK)
{
// Check for duplicate joypads
if(g_Config.bSaveByIDNotice)
{
int Tmp = g_Config.CheckForDuplicateJoypads(true);
if (Tmp == wxOK) return; else if (Tmp == wxNO) g_Config.bSaveByIDNotice = false;
}
for(int i = 0; i < 4; i++) SaveButtonMapping(i); // Update joysticks array
DoSave(false, true); // Save settings
g_Config.Load(); // Reload settings
DoSave(); // Save settings
g_Config.Load(); // Reload settings to PadMapping
if(Debugging) PanicAlert("Done");
Close(); // Call OnClose()
}
}
@ -205,11 +204,34 @@ void ConfigBox::CancelClick(wxCommandEvent& event)
{
if (event.GetId() == ID_CANCEL)
{
g_Config.Load(); // Reload settings
// Forget all potential changes to PadMapping by loading the last saved settings
g_Config.Load();
Close(); // Call OnClose()
}
}
// Debugging
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void ConfigBox::LogMsg(const char* format, ...)
{
if(Debugging)
{
const int MaxMsgSize = 1024*2;
char buffer[MaxMsgSize];
va_list args;
va_start(args, format);
CharArrayFromFormatV(buffer, MaxMsgSize, format, args);
va_end(args);
// Add timestamp
std::string StrTmp = buffer;
//StrTmp += Common::Timer::GetTimeFormatted();
if(m_TCDebugging) m_TCDebugging->AppendText(StrTmp.c_str());
}
}
//////////////////////////////////////
// Save Settings
@ -219,9 +241,10 @@ void ConfigBox::CancelClick(wxCommandEvent& event)
1. Closing the configuration window
2. Changing the gamepad
3. When the gamepad is enabled or disbled */
void ConfigBox::DoSave(bool ChangePad, bool CheckedForDuplicates)
3. When the gamepad is enabled or disbled
4. When we change saving mode (by Id or by slot)
*/
void ConfigBox::DoSave(bool ChangePad, int Slot)
{
// Replace "" with "-1" before we are saving
ToBlank(false);
@ -230,55 +253,64 @@ void ConfigBox::DoSave(bool ChangePad, bool CheckedForDuplicates)
{
// 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);
//LogMsg("Old Id: %s | %i %i\n", joyinfo[PadMapping[notebookpage].ID].Name.c_str(), notebookpage, Slot);
g_Config.Save(Slot);
// Now we can update the ID
joysticks[notebookpage].ID = m_Joyname[notebookpage]->GetSelection();
PadMapping[notebookpage].ID = m_Joyname[notebookpage]->GetSelection();
//LogMsg("New Id: %s\n", joyinfo[PadMapping[notebookpage].ID].Name.c_str());
}
else
{
for(int i = 0; i < 4; i++) SaveButtonMapping(i);
g_Config.Save(CheckedForDuplicates);
g_Config.Save(Slot);
}
// Then change it back
ToBlank();
}
// Enable or disable joystick and update the GUI
// OnSaveById
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void ConfigBox::EnableDisable(wxCommandEvent& event)
void ConfigBox::OnSaveById()
{
// We will enable this device
joysticks[notebookpage].enabled = !joysticks[notebookpage].enabled;
// Save current settings
DoSave(false, notebookpage);
// Update the GUI
// Update the 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);
}
// Change Joystick
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/* Function: When changing the joystick we save and load the settings and update the joysticks
/* Function: When changing the joystick we save and load the settings and update the PadMapping
and joystate array */
void ConfigBox::DoChangeJoystick()
{
// Before changing the pad we save potential changes (to support SaveByID)
// Close the current pad
if (PadMapping[notebookpage].enabled) PadClose(notebookpage);
// Before changing the pad we save potential changes to the current pad (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);
}
// Open the new pad
if (PadMapping[notebookpage].enabled) PadOpen(notebookpage);
}
void ConfigBox::ChangeJoystick(wxCommandEvent& event)
void ConfigBox::PadOpen(int Open) // Open for slot 1, 2, 3 or 4
{
DoChangeJoystick();
joystate[Open].joy = SDL_JoystickOpen(PadMapping[Open].ID);
}
void ConfigBox::PadClose(int Close) // Close for slot 1, 2, 3 or 4
{
if (SDL_JoystickOpened(PadMapping[Close].ID)) SDL_JoystickClose(joystate[Close].joy);
}
// Notebook page changed
@ -287,13 +319,14 @@ void ConfigBox::NotebookPageChanged(wxNotebookEvent& event)
{
int oldnotebookpage = notebookpage;
notebookpage = event.GetSelection();
int OldId = joysticks[oldnotebookpage].ID;
int NewId = joysticks[notebookpage].ID;
int OldId = PadMapping[oldnotebookpage].ID;
int NewId = PadMapping[notebookpage].ID;
// Check if it has changed. If it has save the old Id and load the new Id
if(OldId != NewId)
DoChangeJoystick();
if(OldId != NewId) DoChangeJoystick();
// Update GUI
if(ControlsCreated) UpdateGUI(notebookpage);
}
// Replace the harder to understand -1 with "" for the sake of user friendliness
@ -318,18 +351,26 @@ void ConfigBox::ToBlank(bool ToBlank)
//////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
// Change settings
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void ConfigBox::UpdateAllSlots(int Slot)
{
for (int i = 0; i < 4; i++)
{
if (joyinfo[PadMapping[i].ID].Name == joyinfo[PadMapping[Slot].ID].Name)
SaveButtonMapping(i, false, Slot);
//LogMsg("%i: %s\n", i, joyinfo[PadMapping[i].ID].Name.c_str());
UpdateGUI(i);
};
}
void ConfigBox::ChangeSettings( wxCommandEvent& event )
{
switch(event.GetId())
{
case IDC_SAVEBYID:
g_Config.bSaveByID.at(notebookpage) = m_CBSaveByID[notebookpage]->IsChecked();
break;
case IDC_SAVEBYIDNOTICE:
g_Config.bSaveByIDNotice = m_CBSaveByIDNotice[notebookpage]->IsChecked();
break;
OnSaveById();
break;
case IDC_SHOWADVANCED:
g_Config.bShowAdvanced = m_CBShowAdvanced[notebookpage]->IsChecked();
@ -341,35 +382,52 @@ void ConfigBox::ChangeSettings( wxCommandEvent& event )
SizeWindow();
break;
case IDCB_MAINSTICK_DIAGONAL:
g_Config.SDiagonal.at(notebookpage) = m_CoBDiagonal[notebookpage]->GetLabel().mb_str();
case IDC_CONTROLTYPE:
case IDC_TRIGGERTYPE:
SaveButtonMapping(notebookpage);
UpdateGUI(notebookpage);
break;
case IDCB_MAINSTICK_S_TO_C:
g_Config.bSquareToCircle.at(notebookpage) = m_CBS_to_C[notebookpage]->IsChecked();
case IDC_JOYNAME:
DoChangeJoystick();
break;
case IDC_JOYATTACH:
// We will enable this device
int Enable = PadMapping[notebookpage].enabled = !PadMapping[notebookpage].enabled;
// Close or open pad handle
if(Enable) PadOpen(notebookpage); else PadClose(notebookpage);
// Update the GUI
UpdateGUI(notebookpage);
return; // Don't save this for all slots
}
// Update all slots that use this device
if(g_Config.bSaveByID) UpdateAllSlots(notebookpage);
}
///////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
// Update GUI
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// Called from: ChangeControllertype()
// Called from: CreateGUIControls(), ChangeControllertype()
void ConfigBox::UpdateGUI(int _notebookpage)
{
// Update the GUI from joysticks[]
// Update the GUI from PadMapping[]
UpdateGUIKeys(_notebookpage);
// Controller type settings
bool Hat = (joysticks[_notebookpage].controllertype == CTL_DPAD_HAT);
// Collect status
bool Hat = (PadMapping[_notebookpage].controllertype == CTL_DPAD_HAT);
long Left, Right;
m_JoyShoulderL[_notebookpage]->GetValue().ToLong(&Left);
m_JoyShoulderR[_notebookpage]->GetValue().ToLong(&Right);
bool AnalogTrigger = (Left >= 1000 || Right >= 1000);
#ifdef _WIN32
bool XInput = XInput::IsConnected(0);
#endif
#ifdef _WIN32
bool XInput = XInput::IsConnected(0);
#endif
// Hat type selection
m_JoyDpadUp[_notebookpage]->Show(!Hat);
m_JoyDpadLeft[_notebookpage]->Show(!Hat);
m_JoyDpadRight[_notebookpage]->Show(!Hat);
@ -387,23 +445,13 @@ void ConfigBox::UpdateGUI(int _notebookpage)
wxT("Select a hat by pressing the hat in any direction") : wxT(""));
// General settings
m_CBSaveByID[_notebookpage]->SetValue(g_Config.bSaveByID.at(_notebookpage));
m_CBSaveByIDNotice[_notebookpage]->SetValue(g_Config.bSaveByIDNotice);
m_CBSaveByID[_notebookpage]->SetValue(g_Config.bSaveByID);
m_CBShowAdvanced[_notebookpage]->SetValue(g_Config.bShowAdvanced);
// Controller type values
#ifdef _WIN32
if (!XInput) m_TriggerType[_notebookpage]->SetSelection(CTL_TRIGGER_SDL);
#else
m_TriggerType[_notebookpage]->SetSelection(CTL_TRIGGER_SDL);
#endif
// Advanced settings
m_CoBDiagonal[_notebookpage]->SetValue(wxString::FromAscii(g_Config.SDiagonal.at(_notebookpage).c_str()));
m_CBS_to_C[_notebookpage]->SetValue(g_Config.bSquareToCircle.at(_notebookpage));
LogMsg("Update: %i\n", g_Config.bSaveByID);
// Disabled pages
bool Enabled = joysticks[_notebookpage].enabled;
bool Enabled = PadMapping[_notebookpage].enabled;
// There is no FindItem in linux so this doesn't work
#ifdef _WIN32
// Enable or disable all buttons
@ -423,8 +471,10 @@ void ConfigBox::UpdateGUI(int _notebookpage)
// Repaint the background
m_Controller[_notebookpage]->Refresh();
}
///////////////////////////////
// Populate the config window
// Paint the background
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void ConfigBox::OnPaint( wxPaintEvent &event )
{
@ -432,7 +482,7 @@ void ConfigBox::OnPaint( wxPaintEvent &event )
wxPaintDC dcWin(m_pKeys[notebookpage]);
PrepareDC( dcWin );
if(joysticks[notebookpage].enabled)
if(PadMapping[notebookpage].enabled)
dcWin.DrawBitmap( WxStaticBitmap1_BITMAP, 94, 0, true );
else
dcWin.DrawBitmap( WxStaticBitmap1_BITMAPGray, 94, 0, true );
@ -497,7 +547,7 @@ void ConfigBox::CreateGUIControls()
{
for(int x = 0; x < SDL_NumJoysticks(); x++)
{
arrayStringFor_Joyname.Add(wxString::FromAscii(joyinfo[x].Name));
arrayStringFor_Joyname.Add(wxString::FromAscii(joyinfo[x].Name.c_str()));
}
}
else
@ -709,14 +759,10 @@ void ConfigBox::CreateGUIControls()
// Create objects for general settings 3
m_gGenSettingsID[i] = new wxStaticBoxSizer( wxVERTICAL, m_Controller[i], wxT("Settings") );
m_CBSaveByID[i] = new wxCheckBox(m_Controller[i], IDC_SAVEBYID, wxT("Save by ID"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_CBSaveByIDNotice[i] = new wxCheckBox(m_Controller[i], IDC_SAVEBYIDNOTICE, wxT("Notify"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_CBShowAdvanced[i] = new wxCheckBox(m_Controller[i], IDC_SHOWADVANCED, wxT("Show advanced settings"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
// Populate general settings 3
m_sSaveByID[i] = new wxBoxSizer(wxHORIZONTAL);
m_sSaveByID[i]->Add(m_CBSaveByID[i], 0, wxEXPAND | wxALL, 0);
m_sSaveByID[i]->Add(m_CBSaveByIDNotice[i], 0, wxEXPAND | wxLEFT, 2);
m_gGenSettingsID[i]->Add(m_sSaveByID[i], 0, wxEXPAND | wxALL, 3);
m_gGenSettingsID[i]->Add(m_CBSaveByID[i], 0, wxEXPAND | wxALL, 3);
m_gGenSettingsID[i]->Add(m_CBShowAdvanced[i], 0, wxEXPAND | wxALL, 3);
// Create tooltips
@ -728,13 +774,10 @@ void ConfigBox::CreateGUIControls()
));
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"
"\nselected slot (1, 2, 3 or 4). This may be a more convenient way"
"\nto save your settings if you have multiple controllers.")
, i+1
));
m_CBSaveByIDNotice[i]->SetToolTip(wxString::Format(wxT(
"Show a notification message if you have selected this option for multiple identical joypads.")
));
));
// Populate settings
m_sSettings[i] = new wxBoxSizer ( wxHORIZONTAL );
@ -846,9 +889,6 @@ void ConfigBox::CreateGUIControls()
m_ControlType[i]->Enable(false);
}
// Set dialog items from saved values
//UpdateGUIKeys(i);
// Update GUI
UpdateGUI(i);
} // end of loop
@ -875,15 +915,23 @@ void ConfigBox::CreateGUIControls()
// --------------------------------------------------------------------
// Debugging
// -----------------------------
//m_pStatusBar = new wxStaticText(this, IDT_DEBUGGING, wxT("Debugging"), wxPoint(150, 100), wxDefaultSize);
//m_pStatusBar2 = new wxStaticText(this, IDT_DEBUGGING2, wxT("Debugging2"), wxPoint(150, 200), wxDefaultSize);
/*m_pStatusBar = new wxStaticText(this, IDT_DEBUGGING, wxT("Debugging"), wxPoint(135, 100), wxDefaultSize);
//m_pStatusBar2 = new wxStaticText(this, IDT_DEBUGGING2, wxT("Debugging2"), wxPoint(125, 200), wxDefaultSize);
//m_pStatusBar->SetLabel(wxString::Format("Debugging text"));
m_TCDebugging = new wxTextCtrl(this, IDT_DEBUGGING3, _T(""), wxDefaultPosition, wxSize(400, 400),
wxTE_RICH | wxTE_MULTILINE | wxTE_DONTWRAP | wxNO_BORDER);
wxBoxSizer * m_LogSizer = new wxBoxSizer(wxVERTICAL);
m_LogSizer->Add(m_TCDebugging, 0, wxEXPAND | (wxALL), 0);
m_MainSizer->Add(m_LogSizer, 0, wxEXPAND | ( wxLEFT | wxRIGHT | wxBOTTOM), 5);*/
// --------------------------------------------------------------------
// Set window size
// -----------------------------
SizeWindow();
Center();
// All done
ControlsCreated = true;
}
void ConfigBox::SizeWindow()

View File

@ -69,6 +69,9 @@ class ConfigBox : public wxDialog
// Debugging
wxStaticText* m_pStatusBar, * m_pStatusBar2;
wxTextCtrl* m_TCDebugging;
bool Debugging;
void LogMsg(const char* format, ...);
// Status window
int BoxW, BoxH;
@ -107,10 +110,9 @@ class ConfigBox : public wxDialog
wxBoxSizer* m_sSettings[4]; // General settings 2
wxStaticBoxSizer *m_gGenSettings[4];
wxBoxSizer *m_sSaveByID[4];
wxStaticBoxSizer *m_gGenSettingsID[4];
wxGridBagSizer * m_gGBGenSettings[4];
wxCheckBox *m_CBSaveByID[4], *m_CBSaveByIDNotice[4], *m_CBShowAdvanced[4];
wxCheckBox *m_CBSaveByID[4], *m_CBShowAdvanced[4];
wxStaticText *m_TSControltype[4], *m_TSTriggerType[4];
wxStaticBoxSizer *m_gStatusIn[4], *m_gStatusInSettings[4]; // Advanced settings
@ -185,7 +187,8 @@ class ConfigBox : public wxDialog
wxStaticBitmap *m_controllerimage[4],
*m_bmpSquare[4], *m_bmpDot[4], *m_bmpSquareOut[4], *m_bmpDotOut[4];
int notebookpage;
int notebookpage; bool ControlsCreated;
private:
enum
{
@ -207,7 +210,7 @@ class ConfigBox : public wxDialog
IDG_CONTROLLERTYPE, IDC_CONTROLTYPE, IDC_TRIGGERTYPE, // Controller type
IDC_SAVEBYID, IDC_SAVEBYIDNOTICE, IDC_SHOWADVANCED, // Settings
IDC_SAVEBYID, IDC_SHOWADVANCED, // Settings
ID_INSTATUS1, ID_INSTATUS2, ID_INSTATUS3, ID_INSTATUS4, // Advanced status
ID_STATUSBMP1, ID_STATUSBMP2, ID_STATUSBMP3, ID_STATUSBMP4,
@ -290,7 +293,7 @@ class ConfigBox : public wxDialog
IDT_DPADTYPE, IDT_TRIGGERTYPE,
IDT_WEBSITE,
IDT_DEBUGGING, IDT_DEBUGGING2,
IDT_DEBUGGING, IDT_DEBUGGING2, IDT_DEBUGGING3,
// ============
ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values
@ -300,13 +303,12 @@ 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 DoSave(bool ChangePad = false, int Slot = -1);
void ChangeJoystick(wxCommandEvent& event); void DoChangeJoystick();
void ChangeControllertype(wxCommandEvent& event);
void EnableDisable(wxCommandEvent& event); void UpdateGUI(int _notebookpage);
void DoChangeJoystick(); void PadOpen(int Open); void PadClose(int Close);
void UpdateGUI(int _notebookpage);
void ChangeSettings(wxCommandEvent& event); // Settings
void ChangeSettings(wxCommandEvent& event); void UpdateAllSlots(int Slot); // Settings
void ComboChange(wxCommandEvent& event);
void OnClose(wxCloseEvent& event);
@ -316,8 +318,9 @@ class ConfigBox : public wxDialog
void PadGetStatus(); void Update();
void UpdateGUIKeys(int controller);
void SaveButtonMapping(int controller, bool DontChangeId = false);
void SaveButtonMapping(int controller, bool DontChangeId = false, int FromSlot = -1);
void ToBlank(bool ToBlank = true);
void OnSaveById();
void NotebookPageChanged(wxNotebookEvent& event);

View File

@ -40,7 +40,7 @@
#include "Images/controller.xpm"
extern CONTROLLER_INFO *joyinfo;
//extern CONTROLLER_MAPPING joysticks[4];
//extern CONTROLLER_MAPPING PadMapping[4];
extern bool emulator_running;
////////////////////////
@ -53,115 +53,115 @@ void ConfigBox::UpdateGUIKeys(int controller)
wxString tmp;
// Update selected gamepad
m_Joyname[controller]->SetSelection(joysticks[controller].ID);
m_Joyname[controller]->SetSelection(PadMapping[controller].ID);
// Update the enabled checkbox
m_Joyattach[controller]->SetValue(joysticks[controller].enabled);
m_Joyattach[controller]->SetValue(PadMapping[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();
tmp << PadMapping[controller].buttons[CTL_L_SHOULDER]; m_JoyShoulderL[controller]->SetValue(tmp); tmp.clear();
tmp << PadMapping[controller].buttons[CTL_R_SHOULDER]; m_JoyShoulderR[controller]->SetValue(tmp); tmp.clear();
tmp << joysticks[controller].buttons[CTL_A_BUTTON]; m_JoyButtonA[controller]->SetValue(tmp); tmp.clear();
tmp << joysticks[controller].buttons[CTL_B_BUTTON]; m_JoyButtonB[controller]->SetValue(tmp); tmp.clear();
tmp << joysticks[controller].buttons[CTL_X_BUTTON]; m_JoyButtonX[controller]->SetValue(tmp); tmp.clear();
tmp << joysticks[controller].buttons[CTL_Y_BUTTON]; m_JoyButtonY[controller]->SetValue(tmp); tmp.clear();
tmp << joysticks[controller].buttons[CTL_Z_TRIGGER]; m_JoyButtonZ[controller]->SetValue(tmp); tmp.clear();
tmp << PadMapping[controller].buttons[CTL_A_BUTTON]; m_JoyButtonA[controller]->SetValue(tmp); tmp.clear();
tmp << PadMapping[controller].buttons[CTL_B_BUTTON]; m_JoyButtonB[controller]->SetValue(tmp); tmp.clear();
tmp << PadMapping[controller].buttons[CTL_X_BUTTON]; m_JoyButtonX[controller]->SetValue(tmp); tmp.clear();
tmp << PadMapping[controller].buttons[CTL_Y_BUTTON]; m_JoyButtonY[controller]->SetValue(tmp); tmp.clear();
tmp << PadMapping[controller].buttons[CTL_Z_TRIGGER]; m_JoyButtonZ[controller]->SetValue(tmp); tmp.clear();
tmp << joysticks[controller].buttons[CTL_START]; m_JoyButtonStart[controller]->SetValue(tmp); tmp.clear();
tmp << joysticks[controller].halfpress; m_JoyButtonHalfpress[controller]->SetValue(tmp); tmp.clear();
tmp << PadMapping[controller].buttons[CTL_START]; m_JoyButtonStart[controller]->SetValue(tmp); tmp.clear();
tmp << PadMapping[controller].halfpress; m_JoyButtonHalfpress[controller]->SetValue(tmp); tmp.clear();
tmp << joysticks[controller].axis[CTL_MAIN_X]; m_JoyAnalogMainX[controller]->SetValue(tmp); tmp.clear();
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();
tmp << PadMapping[controller].axis[CTL_MAIN_X]; m_JoyAnalogMainX[controller]->SetValue(tmp); tmp.clear();
tmp << PadMapping[controller].axis[CTL_MAIN_Y]; m_JoyAnalogMainY[controller]->SetValue(tmp); tmp.clear();
tmp << PadMapping[controller].axis[CTL_SUB_X]; m_JoyAnalogSubX[controller]->SetValue(tmp); tmp.clear();
tmp << PadMapping[controller].axis[CTL_SUB_Y]; m_JoyAnalogSubY[controller]->SetValue(tmp); tmp.clear();
// 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);
m_ControlType[controller]->SetSelection(PadMapping[controller].controllertype);
m_TriggerType[controller]->SetSelection(PadMapping[controller].triggertype);
m_Deadzone[controller]->SetSelection(PadMapping[controller].deadzone);
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);
// Update D-Pad
if(joysticks[controller].controllertype == CTL_DPAD_HAT)
if(PadMapping[controller].controllertype == CTL_DPAD_HAT)
{
tmp << joysticks[controller].dpad; m_JoyDpadUp[controller]->SetValue(tmp); tmp.clear();
tmp << PadMapping[controller].dpad; m_JoyDpadUp[controller]->SetValue(tmp); tmp.clear();
}
else
{
tmp << joysticks[controller].dpad2[CTL_D_PAD_UP]; m_JoyDpadUp[controller]->SetValue(tmp); tmp.clear();
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();
tmp << PadMapping[controller].dpad2[CTL_D_PAD_UP]; m_JoyDpadUp[controller]->SetValue(tmp); tmp.clear();
tmp << PadMapping[controller].dpad2[CTL_D_PAD_DOWN]; m_JoyDpadDown[controller]->SetValue(tmp); tmp.clear();
tmp << PadMapping[controller].dpad2[CTL_D_PAD_LEFT]; m_JoyDpadLeft[controller]->SetValue(tmp); tmp.clear();
tmp << PadMapping[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 */
/* Populate the PadMapping array with the dialog items settings (for example
selected joystick, enabled or disabled status and so on) */
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void ConfigBox::SaveButtonMapping(int controller, bool DontChangeId)
void ConfigBox::SaveButtonMapping(int controller, bool DontChangeId, int FromSlot)
{
// Temporary storage
wxString tmp;
long value;
// Save from or to the same or different slots
if (FromSlot == -1) FromSlot = controller;
// 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();
if(!DontChangeId) PadMapping[controller].ID = m_Joyname[FromSlot]->GetSelection();
if(FromSlot == controller) PadMapping[controller].enabled = m_Joyattach[FromSlot]->GetValue(); // Only enable one
PadMapping[controller].controllertype = m_ControlType[FromSlot]->GetSelection();
PadMapping[controller].triggertype = m_TriggerType[FromSlot]->GetSelection();
PadMapping[controller].deadzone = m_Deadzone[FromSlot]->GetSelection();
PadMapping[controller].SDiagonal = m_CoBDiagonal[FromSlot]->GetLabel().mb_str();
PadMapping[controller].bSquareToCircle = m_CBS_to_C[FromSlot]->IsChecked();
// 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();
m_JoyAnalogMainX[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].axis[CTL_MAIN_X] = value; tmp.clear();
m_JoyAnalogMainY[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].axis[CTL_MAIN_Y] = value; tmp.clear();
m_JoyAnalogSubX[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].axis[CTL_SUB_X] = value; tmp.clear();
m_JoyAnalogSubY[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].axis[CTL_SUB_Y] = value; tmp.clear();
// The shoulder buttons
m_JoyShoulderL[controller]->GetValue().ToLong(&value); joysticks[controller].buttons[CTL_L_SHOULDER] = value;
m_JoyShoulderR[controller]->GetValue().ToLong(&value); joysticks[controller].buttons[CTL_R_SHOULDER] = value;
m_JoyShoulderL[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[CTL_L_SHOULDER] = value;
m_JoyShoulderR[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[CTL_R_SHOULDER] = value;
// The digital buttons
m_JoyButtonA[controller]->GetValue().ToLong(&value); joysticks[controller].buttons[CTL_A_BUTTON] = value; tmp.clear();
m_JoyButtonB[controller]->GetValue().ToLong(&value); joysticks[controller].buttons[CTL_B_BUTTON] = value; tmp.clear();
m_JoyButtonX[controller]->GetValue().ToLong(&value); joysticks[controller].buttons[CTL_X_BUTTON] = value; tmp.clear();
m_JoyButtonY[controller]->GetValue().ToLong(&value); joysticks[controller].buttons[CTL_Y_BUTTON] = value; tmp.clear();
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();
m_JoyButtonA[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[CTL_A_BUTTON] = value; tmp.clear();
m_JoyButtonB[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[CTL_B_BUTTON] = value; tmp.clear();
m_JoyButtonX[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[CTL_X_BUTTON] = value; tmp.clear();
m_JoyButtonY[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[CTL_Y_BUTTON] = value; tmp.clear();
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);
// The halfpress button
m_JoyButtonHalfpress[controller]->GetValue().ToLong(&value); joysticks[controller].halfpress = value; tmp.clear();
m_JoyButtonHalfpress[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].halfpress = value; tmp.clear();
// The digital pad
if(joysticks[controller].controllertype == CTL_DPAD_HAT)
if(PadMapping[controller].controllertype == CTL_DPAD_HAT)
{
m_JoyDpadUp[controller]->GetValue().ToLong(&value); joysticks[controller].dpad = value; tmp.clear();
m_JoyDpadUp[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].dpad = value; tmp.clear();
}
else
{
m_JoyDpadUp[controller]->GetValue().ToLong(&value); joysticks[controller].dpad2[CTL_D_PAD_UP] = value; tmp.clear();
m_JoyDpadDown[controller]->GetValue().ToLong(&value); joysticks[controller].dpad2[CTL_D_PAD_DOWN] = value; tmp.clear();
m_JoyDpadLeft[controller]->GetValue().ToLong(&value); joysticks[controller].dpad2[CTL_D_PAD_LEFT] = value; tmp.clear();
m_JoyDpadRight[controller]->GetValue().ToLong(&value); joysticks[controller].dpad2[CTL_D_PAD_RIGHT] = value; tmp.clear();
m_JoyDpadUp[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].dpad2[CTL_D_PAD_UP] = value; tmp.clear();
m_JoyDpadDown[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].dpad2[CTL_D_PAD_DOWN] = value; tmp.clear();
m_JoyDpadLeft[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].dpad2[CTL_D_PAD_LEFT] = value; tmp.clear();
m_JoyDpadRight[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].dpad2[CTL_D_PAD_RIGHT] = value; tmp.clear();
}
// Replace "-1" with ""
ToBlank();
}
// Change controller type
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// Called from: When the controller type is changed
void ConfigBox::ChangeControllertype(wxCommandEvent& event)
{
SaveButtonMapping(notebookpage);
UpdateGUI(notebookpage);
}
// Update the textbox for the buttons
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void ConfigBox::SetButtonText(int id, char text[128])
@ -271,8 +271,8 @@ void ConfigBox::DoGetButtons(int GetId)
int Controller = notebookpage;
// Get the controller and trigger type
int ControllerType = joysticks[Controller].controllertype;
int TriggerType = joysticks[Controller].triggertype;
int ControllerType = PadMapping[Controller].controllertype;
int TriggerType = PadMapping[Controller].triggertype;
// Collect the accepted buttons for this slot
bool LeftRight = (GetId == IDB_SHOULDER_L || GetId == IDB_SHOULDER_R);
@ -287,11 +287,11 @@ void ConfigBox::DoGetButtons(int GetId)
|| (GetId >= IDB_DPAD_UP && GetId <= IDB_DPAD_RIGHT && ControllerType == CTL_DPAD_CUSTOM); // Or the custom hat mode
bool Hat = (GetId >= IDB_DPAD_UP && GetId <= IDB_DPAD_RIGHT) // All DPads
&& (joysticks[Controller].controllertype == CTL_DPAD_HAT); // Not with the hat option defined
&& (PadMapping[Controller].controllertype == CTL_DPAD_HAT); // Not with the hat option defined
/* Open a new joystick. Joysticks[controller].GetId is the system GetId of the physical joystick
that is mapped to controller, for example 0, 1, 2, 3 for the first four joysticks */
SDL_Joystick *joy = SDL_JoystickOpen(joysticks[Controller].ID);
that is mapped to controller, for example 0, 1, 2, 3 for the first four PadMapping */
SDL_Joystick *joy = SDL_JoystickOpen(PadMapping[Controller].ID);
// Get the number of axes, hats and buttons
int buttons = SDL_JoystickNumButtons(joy);
@ -475,6 +475,13 @@ void ConfigBox::DoGetButtons(int GetId)
// Update the button mapping and GUI
SaveButtonMapping(Controller);
UpdateGUI(Controller);
/* Update the button mapping for all slots that use this device. (It doesn't make sense to have several slots
controlled by the same device, but several DirectInput instances of different but identical devices may possible
have the same id, I don't know. So we have to do this. The user may also have selected the same device for
several disabled slots. */
if(g_Config.bSaveByID) UpdateAllSlots(Controller);
}
// If we got a bad button
@ -491,7 +498,7 @@ void ConfigBox::DoGetButtons(int GetId)
// ======================== Process results
// We don't need this gamepad handle any more
if(SDL_JoystickOpened(joysticks[Controller].ID)) SDL_JoystickClose(joy);
if(SDL_JoystickOpened(PadMapping[Controller].ID)) SDL_JoystickClose(joy);
// Debugging
//Console::Print("IsRunning: %i\n", m_ButtonMappingTimer->IsRunning());