diff --git a/Source/Core/Common/Src/DynamicLibrary.cpp b/Source/Core/Common/Src/DynamicLibrary.cpp
index 6b37a8f529..3fa5d65483 100644
--- a/Source/Core/Common/Src/DynamicLibrary.cpp
+++ b/Source/Core/Common/Src/DynamicLibrary.cpp
@@ -86,7 +86,9 @@ std::string GetLastErrorAsString()
This is done when Dolphin is started to determine which dlls are good, and before opening
the Config and Debugging windows from Plugin.cpp and before opening the dll for running
the emulation in Video_...cpp in Core. Since this is fairly slow, TODO: think about
- implementing some sort of cache. */
+ implementing some sort of cache.
+
+ Called from: The Dolphin Core */
int DynamicLibrary::Load(const char* filename)
{
if (!filename || strlen(filename) == 0)
diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp
index f54ae3e617..a423b7f805 100644
--- a/Source/Core/Core/Src/Core.cpp
+++ b/Source/Core/Core/Src/Core.cpp
@@ -319,8 +319,6 @@ THREAD_RETURN EmuThread(void *pArg)
Callback_PeekMessages = VideoInitialize.pPeekMessages;
g_pUpdateFPSDisplay = VideoInitialize.pUpdateFPSDisplay;
-
-
// Load and init DSPPlugin
DSPInitialize dspInit;
dspInit.hWnd = g_pWindowHandle;
@@ -332,8 +330,8 @@ THREAD_RETURN EmuThread(void *pArg)
dspInit.pDebuggerBreak = Callback_DebuggerBreak;
dspInit.pGenerateDSPInterrupt = Callback_DSPInterrupt;
dspInit.pGetAudioStreaming = AudioInterface::Callback_GetStreaming;
- Plugins.GetDSP()->Initialize((void *)&dspInit);
-
+ Plugins.GetDSP()->Initialize((void *)&dspInit);
+
// Load and Init PadPlugin
for (int i = 0; i < MAXPADS; i++)
{
@@ -427,8 +425,10 @@ THREAD_RETURN EmuThread(void *pArg)
// Returns after game exited
cpuThread = NULL;
}
+
+ // The hardware is uninitialized
g_bHwInit = false;
-
+
Plugins.ShutdownPlugins();
HW::Shutdown();
diff --git a/Source/MusicMod.sln b/Source/MusicMod.sln
index d5553e9712..b1ba572b28 100644
--- a/Source/MusicMod.sln
+++ b/Source/MusicMod.sln
@@ -54,12 +54,12 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DolphinWX", "Core\DolphinWX\DolphinWX.vcproj", "{A72606EF-C5C1-4954-90AD-F0F93A8D97D9}"
ProjectSection(ProjectDependencies) = postProject
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F} = {48AD7E0A-25B1-4974-A1E3-03F8C438D34F}
- {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160} = {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}
{0318BA30-EF48-441A-9E10-DC85EFAE39F0} = {0318BA30-EF48-441A-9E10-DC85EFAE39F0}
{71B16F46-0B00-4EDA-B253-D6D9D03A215C} = {71B16F46-0B00-4EDA-B253-D6D9D03A215C}
{33546D62-7F34-4EA6-A88E-D538B36E16BF} = {33546D62-7F34-4EA6-A88E-D538B36E16BF}
{3E03C179-8251-46E4-81F4-466F114BAC63} = {3E03C179-8251-46E4-81F4-466F114BAC63}
{95CCAABC-7062-47C4-B8C1-A064DD5F16FF} = {95CCAABC-7062-47C4-B8C1-A064DD5F16FF}
+ {521498BE-6089-4780-8223-E67C22F4E068} = {521498BE-6089-4780-8223-E67C22F4E068}
{29C2ABC1-ADA5-42CD-A5FC-96022D52A510} = {29C2ABC1-ADA5-42CD-A5FC-96022D52A510}
{4D3CD4C5-412B-4B49-9B1B-A68A2A129C77} = {4D3CD4C5-412B-4B49-9B1B-A68A2A129C77}
{F0B874CB-4476-4199-9315-8343D05AE684} = {F0B874CB-4476-4199-9315-8343D05AE684}
@@ -155,6 +155,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Main", "..\Branches\MusicMo
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InputCommon", "Core\InputCommon\InputCommon.vcproj", "{C7E5D50A-2916-464B-86A7-E10B3CC88ADA}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL", "..\Externals\SDL\SDL\SDL.vcproj", "{B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -236,7 +238,6 @@ Global
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.DebugFast|Win32.Build.0 = DebugFast|Win32
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.DebugFast|x64.ActiveCfg = DebugFast|x64
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Release|Win32.ActiveCfg = Release|Win32
- {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Release|Win32.Build.0 = Release|Win32
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Release|x64.ActiveCfg = Release|x64
{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Release|x64.Build.0 = Release|x64
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9}.Debug|Win32.ActiveCfg = Debug|Win32
@@ -320,7 +321,6 @@ Global
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.DebugFast|x64.ActiveCfg = DebugFast|x64
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|Win32.ActiveCfg = Release|Win32
- {8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|Win32.Build.0 = Release|Win32
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|x64.ActiveCfg = Release|x64
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|x64.Build.0 = Release|x64
{C6CC7A52-0FDD-433A-B2CF-9C6F187DA807}.Debug|Win32.ActiveCfg = Debug|Win32
@@ -354,6 +354,7 @@ Global
{521498BE-6089-4780-8223-E67C22F4E068}.DebugFast|x64.ActiveCfg = DebugFast|x64
{521498BE-6089-4780-8223-E67C22F4E068}.DebugFast|x64.Build.0 = DebugFast|x64
{521498BE-6089-4780-8223-E67C22F4E068}.Release|Win32.ActiveCfg = Release|Win32
+ {521498BE-6089-4780-8223-E67C22F4E068}.Release|Win32.Build.0 = Release|Win32
{521498BE-6089-4780-8223-E67C22F4E068}.Release|x64.ActiveCfg = Release|x64
{521498BE-6089-4780-8223-E67C22F4E068}.Release|x64.Build.0 = Release|x64
{0B72B5D6-5D72-4391-84A7-9CCA5392668A}.Debug|Win32.ActiveCfg = Debug|Win32
@@ -410,6 +411,15 @@ Global
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA}.Release|Win32.Build.0 = Release|Win32
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA}.Release|x64.ActiveCfg = Release|x64
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA}.Release|x64.Build.0 = Release|x64
+ {B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA}.Debug|Win32.ActiveCfg = Debug|Win32
+ {B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA}.Debug|Win32.Build.0 = Debug|Win32
+ {B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA}.Debug|x64.ActiveCfg = Debug|Win32
+ {B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA}.DebugFast|Win32.ActiveCfg = Debug|Win32
+ {B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA}.DebugFast|Win32.Build.0 = Debug|Win32
+ {B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA}.DebugFast|x64.ActiveCfg = Debug|Win32
+ {B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA}.Release|Win32.ActiveCfg = Release|Win32
+ {B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA}.Release|Win32.Build.0 = Release|Win32
+ {B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -437,6 +447,7 @@ Global
{33546D62-7F34-4EA6-A88E-D538B36E16BF} = {4F427D1B-8C90-4D9C-B23D-A51493A1C471}
{71B16F46-0B00-4EDA-B253-D6D9D03A215C} = {4F427D1B-8C90-4D9C-B23D-A51493A1C471}
{29C2ABC1-ADA5-42CD-A5FC-96022D52A510} = {4F427D1B-8C90-4D9C-B23D-A51493A1C471}
+ {B6C1A81F-99A5-42F5-8C31-E86A6AEF4DCA} = {4F427D1B-8C90-4D9C-B23D-A51493A1C471}
{0B72B5D6-5D72-4391-84A7-9CCA5392668A} = {77CF6E34-3038-4B23-A2E7-90AD17801609}
{0D14F1E9-490B-4A2D-A4EF-0535E8B3C718} = {77CF6E34-3038-4B23-A2E7-90AD17801609}
{DE7C596C-CBC4-4278-8909-146D63990803} = {77CF6E34-3038-4B23-A2E7-90AD17801609}
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL.vcproj b/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL.vcproj
index 87a6548d6b..a57536e7d8 100644
--- a/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL.vcproj
+++ b/Source/Plugins/Plugin_nJoy_SDL/Plugin_nJoy_SDL.vcproj
@@ -65,7 +65,7 @@
/>
SetLabel(wxString::Format(
- "Id: %i",
- joysticks[0].ID
- ));*/
+ "%s", ShowStatus().c_str()
+ ));
}
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp
index 72a7aeea82..a974cdb934 100644
--- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp
+++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.cpp
@@ -45,7 +45,7 @@ extern bool emulator_running;
static const char* ControllerType[] =
{
- "Joystick (default)",
+ "Joystick (with hat)",
"Joystick (no hat)",
// "Joytstick (xbox360)", // Shoulder buttons -> axis
// "Keyboard" // Not supported yet, sorry F|RES ;( ...
@@ -85,11 +85,10 @@ BEGIN_EVENT_TABLE(ConfigBox,wxDialog)
EVT_BUTTON(IDB_DPAD_DOWN, ConfigBox::GetButtons)
EVT_BUTTON(IDB_DPAD_LEFT, ConfigBox::GetButtons)
EVT_BUTTON(IDB_DPAD_RIGHT, ConfigBox::GetButtons)
-
- EVT_BUTTON(IDB_ANALOG_MAIN_X, ConfigBox::GetAxis)
- EVT_BUTTON(IDB_ANALOG_MAIN_Y, ConfigBox::GetAxis)
- EVT_BUTTON(IDB_ANALOG_SUB_X, ConfigBox::GetAxis)
- EVT_BUTTON(IDB_ANALOG_SUB_Y, ConfigBox::GetAxis)
+ EVT_BUTTON(IDB_ANALOG_MAIN_X, ConfigBox::GetButtons)
+ EVT_BUTTON(IDB_ANALOG_MAIN_Y, ConfigBox::GetButtons)
+ EVT_BUTTON(IDB_ANALOG_SUB_X, ConfigBox::GetButtons)
+ EVT_BUTTON(IDB_ANALOG_SUB_Y, ConfigBox::GetButtons)
#if wxUSE_TIMER
EVT_TIMER(wxID_ANY, ConfigBox::OnTimer)
@@ -238,26 +237,30 @@ void ConfigBox::EnableDisable(wxCommandEvent& event)
g_Config.Save();
// Update the enable / disable status
- DoEnableDisable(notebookpage);
+ UpdateGUI(notebookpage);
}
-void ConfigBox::DoEnableDisable(int _notebookpage)
-{
+// Update GUI
+// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
+// Called from: SetControllerAll(), ChangeControllertype()
+void ConfigBox::UpdateGUI(int _notebookpage)
+{
// Update the enable / disable status
joysticks[_notebookpage].enabled = m_Joyattach[_notebookpage]->GetValue();
-#ifdef _WIN32 // There is no FindItem in linux so this doesn't work
- // Enable or disable all buttons
- for(int i = IDB_SHOULDER_L; i < (IDB_SHOULDER_L + 13 + 4); i++)
- {
- m_Controller[_notebookpage]->FindItem(i)->Enable(joysticks[_notebookpage].enabled);
- }
-
- // Enable or disable settings controls
- m_Controller[_notebookpage]->FindItem(IDC_DEADZONE)->Enable(joysticks[_notebookpage].enabled);
- m_Controller[_notebookpage]->FindItem(IDC_CONTROLTYPE)->Enable(joysticks[_notebookpage].enabled);
-#endif
+ // Controller type settings
+ bool HasHat = (joysticks[_notebookpage].controllertype == CTL_TYPE_JOYSTICK);
+ m_JoyDpadDown[_notebookpage]->Show(HasHat);
+ m_JoyDpadLeft[_notebookpage]->Show(HasHat);
+ m_JoyDpadRight[_notebookpage]->Show(HasHat);
+ m_bJoyDpadDown[_notebookpage]->Show(HasHat);
+ m_bJoyDpadLeft[_notebookpage]->Show(HasHat);
+ m_bJoyDpadRight[_notebookpage]->Show(HasHat);
+ m_textDpadUp[_notebookpage]->Show(HasHat);
+ m_textDpadDown[_notebookpage]->Show(HasHat);
+ m_textDpadLeft[_notebookpage]->Show(HasHat);
+ m_textDpadRight[_notebookpage]->Show(HasHat);
// General settings
m_CBSaveByID[_notebookpage]->SetValue(g_Config.bSaveByID.at(_notebookpage));
@@ -268,8 +271,22 @@ void ConfigBox::DoEnableDisable(int _notebookpage)
m_CoBDiagonal[_notebookpage]->SetValue(wxString::FromAscii(g_Config.SDiagonal.c_str()));
m_CBS_to_C[_notebookpage]->SetValue(g_Config.bSquareToCircle.at(_notebookpage));
- m_Controller[_notebookpage]->Refresh(); // Repaint the background
+ // 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);
+ }
+ // Controller type settings
+ m_Controller[_notebookpage]->FindItem(IDC_DEADZONE)->Enable(joysticks[_notebookpage].enabled);
+ //m_Controller[_notebookpage]->FindItem(IDC_CONTROLTYPE)->Enable(joysticks[_notebookpage].enabled);
+ #endif
+ m_Controltype[_notebookpage]->SetSelection(HasHat ? 0 : 1);
+
+ // Repaint the background
+ m_Controller[_notebookpage]->Refresh();
}
@@ -281,14 +298,16 @@ void ConfigBox::NotebookPageChanged(wxNotebookEvent& event)
}
-// Change Joystick. Load saved settings.
+// 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)
{
- // Save potential changes to support SaveByID
- int Tmp = joysticks[notebookpage].ID; // Don't update the ID
+ // Before chaning the pad we save potential changes (to support SaveByID)
+ int TmpID = joysticks[notebookpage].ID; // Don't update the ID
GetControllerAll(notebookpage);
- joysticks[notebookpage].ID = Tmp;
+ joysticks[notebookpage].ID = TmpID;
g_Config.Save();
//PanicAlert("%i", m_Joyname[notebookpage]->GetSelection());
@@ -296,14 +315,18 @@ void ConfigBox::ChangeJoystick(wxCommandEvent& event)
// Update the ID for the virtual device to a new physical device
joysticks[notebookpage].ID = m_Joyname[notebookpage]->GetSelection();
+ // Update the controller type
+ if(joyinfo[joysticks[notebookpage].ID].NumHats > 0)
+ joysticks[notebookpage].controllertype = CTL_TYPE_JOYSTICK;
+
//PanicAlert("%i %i", joysticks[notebookpage].ID, notebookpage);
// Load device settings to support SaveByID
g_Config.Load(true); // Then load the current
SetControllerAll(notebookpage); // Update joystick dialog items
- DoEnableDisable(notebookpage); // Update other dialog items
+ UpdateGUI(notebookpage); // Update other dialog items
- // Remap the controller to
+ // Remap the controller
if (joysticks[notebookpage].enabled)
{
if (SDL_JoystickOpened(notebookpage)) SDL_JoystickClose(joystate[notebookpage].joy);
@@ -455,11 +478,14 @@ void ConfigBox::CreateGUIControls()
// --------------------------------------------------------------------
// Keys objects
// -----------------------------
- // Left shoulder
+ // Left and right shoulder buttons
m_JoyShoulderL[i] = new wxTextCtrl(m_pKeys[i], ID_SHOULDER_L, wxT("0"), wxPoint(l + 6, t + 80), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
m_JoyShoulderL[i]->Enable(false);
m_bJoyShoulderL[i] = new wxButton(m_pKeys[i], IDB_SHOULDER_L, wxEmptyString, wxPoint(l + 70, t + 82), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString);
-
+ m_JoyShoulderR[i] = new wxTextCtrl(m_pKeys[i], ID_SHOULDER_R, wxT("0"), wxPoint(l + 552, t + 106), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
+ m_JoyShoulderR[i]->Enable(false);
+ m_bJoyShoulderR[i] = new wxButton(m_pKeys[i], IDB_SHOULDER_R, wxEmptyString, wxPoint(l + 526, t + 108), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString);
+
// Left analog
int ALt = 170; int ALw = ALt + 14; int ALb = ALw + 2; // Set offset
m_JoyAnalogMainX[i] = new wxTextCtrl(m_pKeys[i], ID_ANALOG_MAIN_X, wxT("0"), wxPoint(l + 6, t + ALw), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
@@ -473,13 +499,13 @@ void ConfigBox::CreateGUIControls()
// D-Pad
int DPt = 255; int DPw = DPt + 14; int DPb = DPw + 2; // Set offset
- m_JoyDpadUp[i] = new wxTextCtrl(m_pKeys[i], ID_DPAD_UP, wxT("0"), wxPoint(l + 6, t + DPw), wxSize(59, t + 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
+ m_JoyDpadUp[i] = new wxTextCtrl(m_pKeys[i], ID_DPAD_UP, wxT("0"), wxPoint(l + 6, t + DPw), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
+ m_JoyDpadDown[i] = new wxTextCtrl(m_pKeys[i], ID_DPAD_DOWN, wxT("0"), wxPoint(l + 6, t + DPw + 36*1), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
+ m_JoyDpadLeft[i] = new wxTextCtrl(m_pKeys[i], ID_DPAD_LEFT, wxT("0"), wxPoint(l + 6, t + DPw + 36*2), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
+ m_JoyDpadRight[i] = new wxTextCtrl(m_pKeys[i], ID_DPAD_RIGHT, wxT("0"), wxPoint(l + 6, t + DPw + 36*3), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
m_JoyDpadUp[i]->Enable(false);
- m_JoyDpadDown[i] = new wxTextCtrl(m_pKeys[i], ID_DPAD_DOWN, wxT("0"), wxPoint(l + 6, t + DPw + 36*1), wxSize(59, t + 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
m_JoyDpadDown[i]->Enable(false);
- m_JoyDpadLeft[i] = new wxTextCtrl(m_pKeys[i], ID_DPAD_LEFT, wxT("0"), wxPoint(l + 6, t + DPw + 36*2), wxSize(59, t + 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
m_JoyDpadLeft[i]->Enable(false);
- m_JoyDpadRight[i] = new wxTextCtrl(m_pKeys[i], ID_DPAD_RIGHT, wxT("0"), wxPoint(l + 6, t + DPw + 36*3), wxSize(59, t + 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
m_JoyDpadRight[i]->Enable(false);
m_bJoyDpadUp[i] = new wxButton(m_pKeys[i], IDB_DPAD_UP, wxEmptyString, wxPoint(l + 70, t + DPb + 36*0), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString);
m_bJoyDpadDown[i] = new wxButton(m_pKeys[i], IDB_DPAD_DOWN, wxEmptyString, wxPoint(l + 70, t + DPb + 36*1), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString);
@@ -490,9 +516,7 @@ void ConfigBox::CreateGUIControls()
m_textDpadLeft[i] = new wxStaticText(m_pKeys[i], IDT_DPAD_LEFT, wxT("Left"), wxPoint(l + 6, t + DPt + 36*2), wxDefaultSize, 0, wxT("Left"));
m_textDpadRight[i] = new wxStaticText(m_pKeys[i], IDT_DPAD_RIGHT, wxT("Right"), wxPoint(l + 6, t + DPt + 36*3), wxDefaultSize, 0, wxT("Right"));
- // Right side buttons
- m_JoyShoulderR[i] = new wxTextCtrl(m_pKeys[i], ID_SHOULDER_R, wxT("0"), wxPoint(l + 552, t + 106), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
- m_JoyShoulderR[i]->Enable(false);
+ // Buttons
m_JoyButtonA[i] = new wxTextCtrl(m_pKeys[i], ID_BUTTON_A, wxT("0"), wxPoint(l + 552, t + 280), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
m_JoyButtonA[i]->Enable(false);
m_JoyButtonB[i] = new wxTextCtrl(m_pKeys[i], ID_BUTTON_B, wxT("0"), wxPoint(l + 552, t + 80), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
@@ -503,7 +527,6 @@ void ConfigBox::CreateGUIControls()
m_JoyButtonY[i]->Enable(false);
m_JoyButtonZ[i] = new wxTextCtrl(m_pKeys[i], ID_BUTTON_Z, wxT("0"), wxPoint(l + 552, t + 145), wxSize(59, 19), wxTE_READONLY | wxTE_CENTRE, wxDefaultValidator, wxT("0"));
m_JoyButtonZ[i]->Enable(false);
- m_bJoyShoulderR[i] = new wxButton(m_pKeys[i], IDB_SHOULDER_R, wxEmptyString, wxPoint(l + 526, t + 108), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString);
m_bJoyButtonA[i] = new wxButton(m_pKeys[i], IDB_BUTTON_A, wxEmptyString, wxPoint(l + 526, t + 282), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString);
m_bJoyButtonB[i] = new wxButton(m_pKeys[i], IDB_BUTTON_B, wxEmptyString, wxPoint(l + 526, t + 82), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString);
m_bJoyButtonX[i] = new wxButton(m_pKeys[i], IDB_BUTTON_X, wxEmptyString, wxPoint(l + 526, t + 244), wxSize(21, 14), 0, wxDefaultValidator, wxEmptyString);
@@ -581,10 +604,14 @@ void ConfigBox::CreateGUIControls()
m_gGBExtrasettings[i]->Add(m_bJoyButtonHalfpress[i], wxGBPosition(1, 2), wxGBSpan(1, 1), (wxLEFT | wxTOP), 2);
m_gExtrasettings[i]->Add(m_gGBExtrasettings[i], 0, wxEXPAND | wxALL, 3);
+
+ // Why is there a setting for this? Is it to replaced the analog stick with the digital pad?
+
// Populate controller typ
m_gControllertype[i] = new wxStaticBoxSizer( wxVERTICAL, m_Controller[i], wxT("Controller type"));
m_Controltype[i] = new wxComboBox(m_Controller[i], IDC_CONTROLTYPE, arrayStringFor_Controltype[0], wxDefaultPosition, wxDefaultSize, arrayStringFor_Controltype, wxCB_READONLY);
- m_gControllertype[i]->Add(m_Controltype[i], 0, wxEXPAND | wxALL, 3);
+ m_gControllertype[i]->Add(m_Controltype[i], 0, wxEXPAND | wxALL, 3);
+ m_Controltype[i]->Enable(false);
// Create objects for general settings
m_gGenSettings[i] = new wxStaticBoxSizer( wxVERTICAL, m_Controller[i], wxT("Settings") );
@@ -706,12 +733,12 @@ void ConfigBox::CreateGUIControls()
m_Joyattach[i]->Enable(false);
m_Controltype[i]->Enable(false);
}
-
+
// Set dialog items from saved values
SetControllerAll(i);
// Update GUI
- DoEnableDisable(i);
+ UpdateGUI(i);
} // end of loop
@@ -736,7 +763,7 @@ void ConfigBox::CreateGUIControls()
// --------------------------------------------------------------------
// Debugging
// -----------------------------
- //m_pStatusBar = new wxStaticText(this, IDT_DEBUGGING, wxT("Debugging"), wxPoint(100, 510), wxDefaultSize);
+ m_pStatusBar = new wxStaticText(this, IDT_DEBUGGING, wxT("Debugging"), wxPoint(100, 490), wxDefaultSize);
//m_pStatusBar2 = new wxStaticText(this, IDT_DEBUGGING2, wxT("Debugging2"), wxPoint(100, 530), wxDefaultSize);
//m_pStatusBar->SetLabel(wxString::Format("Debugging text"));
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h
index 1b1c2e6163..7468b461d5 100644
--- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h
+++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigBox.h
@@ -235,28 +235,28 @@ class ConfigBox : public wxDialog
ID_DPAD_LEFT,
ID_DPAD_RIGHT,
- // Buttons controls
- IDB_SHOULDER_L = 3000,
+ // Buttons controls (it's important that they are placed in this order)
+ IDB_ANALOG_MAIN_X = 3000,
+ IDB_ANALOG_MAIN_Y,
+ IDB_ANALOG_SUB_X,
+ IDB_ANALOG_SUB_Y,
+ IDB_SHOULDER_L,
IDB_SHOULDER_R,
+ IDB_DPAD_UP,
+ IDB_DPAD_DOWN,
+ IDB_DPAD_LEFT,
+ IDB_DPAD_RIGHT,
+
IDB_BUTTON_A,
IDB_BUTTON_B,
IDB_BUTTON_X,
IDB_BUTTON_Y,
IDB_BUTTON_Z,
IDB_BUTTONSTART,
+
IDB_BUTTONHALFPRESS,
- IDB_ANALOG_MAIN_X,
- IDB_ANALOG_MAIN_Y,
- IDB_ANALOG_SUB_X,
- IDB_ANALOG_SUB_Y,
-
- IDB_DPAD_UP,
- IDB_DPAD_DOWN,
- IDB_DPAD_LEFT,
- IDB_DPAD_RIGHT,
-
// Text controls
IDT_ANALOG_MAIN_X = 4000,
IDT_ANALOG_MAIN_Y,
@@ -281,7 +281,7 @@ class ConfigBox : public wxDialog
void ChangeJoystick(wxCommandEvent& event);
void ChangeControllertype(wxCommandEvent& event);
- void EnableDisable(wxCommandEvent& event); void DoEnableDisable(int _notebookpage);
+ void EnableDisable(wxCommandEvent& event); void UpdateGUI(int _notebookpage);
void ChangeSettings(wxCommandEvent& event); // Settings
void ComboChange(wxCommandEvent& event);
@@ -293,7 +293,6 @@ class ConfigBox : public wxDialog
void PadGetStatus(); void Update();
void SetControllerAll(int controller);
- void UpdateVisibleItems(int controller);
void GetControllerAll(int controller);
void NotebookPageChanged(wxNotebookEvent& event);
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp
index 7ddf6d1c6c..f0a5503fff 100644
--- a/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp
+++ b/Source/Plugins/Plugin_nJoy_SDL/Src/GUI/ConfigJoypad.cpp
@@ -76,10 +76,11 @@ void ConfigBox::SetControllerAll(int controller)
else
m_Joyattach[controller]->SetValue(FALSE);
+ // Update the deadzone and controller type controls
m_Controltype[controller]->SetSelection(joysticks[controller].controllertype);
m_Deadzone[controller]->SetSelection(joysticks[controller].deadzone);
- UpdateVisibleItems(controller);
+ UpdateGUI(controller);
if(joysticks[controller].controllertype == CTL_TYPE_JOYSTICK)
{
@@ -103,6 +104,7 @@ void ConfigBox::GetControllerAll(int controller)
long value;
joysticks[controller].ID = m_Joyname[controller]->GetSelection();
+ if(joyinfo[joysticks[controller].ID].NumHats > 0) joysticks[controller].controllertype = CTL_TYPE_JOYSTICK;
m_JoyShoulderL[controller]->GetValue().ToLong(&value); joysticks[controller].buttons[CTL_L_SHOULDER] = value; tmp.clear();
m_JoyShoulderR[controller]->GetValue().ToLong(&value); joysticks[controller].buttons[CTL_R_SHOULDER] = value; tmp.clear();
@@ -140,41 +142,6 @@ void ConfigBox::GetControllerAll(int controller)
}
-void ConfigBox::UpdateVisibleItems(int controller)
-{
- if(joysticks[controller].controllertype)
- {
- m_JoyDpadDown[controller]->Show(TRUE);
- m_JoyDpadLeft[controller]->Show(TRUE);
- m_JoyDpadRight[controller]->Show(TRUE);
-
- m_bJoyDpadDown[controller]->Show(TRUE);
- m_bJoyDpadLeft[controller]->Show(TRUE);
- m_bJoyDpadRight[controller]->Show(TRUE);
-
- m_textDpadUp[controller]->Show(TRUE);
- m_textDpadDown[controller]->Show(TRUE);
- m_textDpadLeft[controller]->Show(TRUE);
- m_textDpadRight[controller]->Show(TRUE);
- }
- else
- {
- m_JoyDpadDown[controller]->Show(FALSE);
- m_JoyDpadLeft[controller]->Show(FALSE);
- m_JoyDpadRight[controller]->Show(FALSE);
-
- m_bJoyDpadDown[controller]->Show(FALSE);
- m_bJoyDpadLeft[controller]->Show(FALSE);
- m_bJoyDpadRight[controller]->Show(FALSE);
-
- m_textDpadUp[controller]->Show(FALSE);
- m_textDpadDown[controller]->Show(FALSE);
- m_textDpadLeft[controller]->Show(FALSE);
- m_textDpadRight[controller]->Show(FALSE);
- }
-}
-
-
// Change controller type
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
void ConfigBox::ChangeControllertype(wxCommandEvent& event)
@@ -184,7 +151,7 @@ void ConfigBox::ChangeControllertype(wxCommandEvent& event)
joysticks[2].controllertype = m_Controltype[2]->GetSelection();
joysticks[3].controllertype = m_Controltype[3]->GetSelection();
- for(int i=0; i<4 ;i++) UpdateVisibleItems(i);
+ for(int i=0; i<4 ;i++) UpdateGUI(i);
}
@@ -195,22 +162,13 @@ void ConfigBox::SetButtonText(int id, char text[128])
switch(id)
{
case IDB_SHOULDER_L:
- {
- m_JoyShoulderL[controller]->SetValue(wxString::FromAscii(text));
- }
- break;
+ m_JoyShoulderL[controller]->SetValue(wxString::FromAscii(text)); break;
case IDB_SHOULDER_R:
- {
- m_JoyShoulderR[controller]->SetValue(wxString::FromAscii(text));
- }
- break;
+ m_JoyShoulderR[controller]->SetValue(wxString::FromAscii(text)); break;
case IDB_BUTTON_A:
- {
- m_JoyButtonA[controller]->SetValue(wxString::FromAscii(text));
- }
- break;
+ m_JoyButtonA[controller]->SetValue(wxString::FromAscii(text)); break;
case IDB_BUTTON_B:
{
@@ -225,16 +183,10 @@ void ConfigBox::SetButtonText(int id, char text[128])
break;
case IDB_BUTTON_Y:
- {
- m_JoyButtonY[controller]->SetValue(wxString::FromAscii(text));
- }
- break;
+ m_JoyButtonY[controller]->SetValue(wxString::FromAscii(text)); break;
case IDB_BUTTON_Z:
- {
- m_JoyButtonZ[controller]->SetValue(wxString::FromAscii(text));
- }
- break;
+ m_JoyButtonZ[controller]->SetValue(wxString::FromAscii(text)); break;
case IDB_BUTTONSTART:
{
@@ -267,34 +219,19 @@ void ConfigBox::SetButtonText(int id, char text[128])
break;
case IDB_DPAD_RIGHT:
- {
- m_JoyDpadRight[controller]->SetValue(wxString::FromAscii(text));
- }
- break;
+ m_JoyDpadRight[controller]->SetValue(wxString::FromAscii(text)); break;
case IDB_ANALOG_MAIN_X:
- {
- m_JoyAnalogMainX[controller]->SetValue(wxString::FromAscii(text));
- }
- break;
+ m_JoyAnalogMainX[controller]->SetValue(wxString::FromAscii(text)); break;
case IDB_ANALOG_MAIN_Y:
- {
- m_JoyAnalogMainY[controller]->SetValue(wxString::FromAscii(text));
- }
- break;
+ m_JoyAnalogMainY[controller]->SetValue(wxString::FromAscii(text)); break;
case IDB_ANALOG_SUB_X:
- {
- m_JoyAnalogSubX[controller]->SetValue(wxString::FromAscii(text));
- }
- break;
+ m_JoyAnalogSubX[controller]->SetValue(wxString::FromAscii(text)); break;
case IDB_ANALOG_SUB_Y:
- {
- m_JoyAnalogSubY[controller]->SetValue(wxString::FromAscii(text));
- }
- break;
+ m_JoyAnalogSubY[controller]->SetValue(wxString::FromAscii(text)); break;
default:
break;
@@ -302,6 +239,26 @@ void ConfigBox::SetButtonText(int id, char text[128])
}
+//////////////////////////////////////////////////////////////////////////////////////////
+// Condifigure button mapping
+// ŻŻŻŻŻŻŻŻŻŻ
+
+
+// Avoid extreme axis values
+// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
+/* Function: We have to avoid very big values to becuse some triggers are -0x8000 in the
+ unpressed state (and then go from -0x8000 to 0x8000 as they are fully pressed) */
+bool AvoidValues(int value)
+{
+ // Avoid detecting very small or very big (for triggers) values
+ if( (value > -0x1000 && value < 0x1000) // Small values
+ || (value < -0x7000 || value > 0x7000)) // Big values
+ return true; // Avoid
+ else
+ return false; // Keep
+}
+
+
// Wait for button press
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
void ConfigBox::GetButtons(wxCommandEvent& event)
@@ -312,44 +269,85 @@ void ConfigBox::GetButtons(wxCommandEvent& event)
// Get the ID for the wxWidgets button that was pressed
int ID = event.GetId();
- // DPAD type check
- if(ID == IDB_DPAD_UP)
- if(joysticks[controller].controllertype == 0)
- {
- GetHats(ID);
- return;
- }
+ // Collect the accepted buttons for this slot
+ bool Axis = (event.GetId() >= IDB_ANALOG_MAIN_X && event.GetId() <= IDB_SHOULDER_R);
+ bool Button = (event.GetId() >= IDB_BUTTON_A && event.GetId() <= IDB_BUTTONSTART)
+ || (event.GetId() == IDB_SHOULDER_L || event.GetId() == IDB_SHOULDER_R);
+ bool Hat = (event.GetId() >= IDB_DPAD_UP && event.GetId() <= IDB_DPAD_RIGHT);
- /* Open a new joystick. Joysticks[controller].ID is the system ID of the physicaljoystick
+ /* Open a new joystick. Joysticks[controller].ID is the system ID 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);
+ // Get the number of axes, hats and buttons
+ int buttons = SDL_JoystickNumButtons(joy);
+ int axes = SDL_JoystickNumAxes(joy);
+ int hats = SDL_JoystickNumHats(joy);
+
// Declare values
char format[128];
- int buttons = SDL_JoystickNumButtons(joy); // Get number of buttons
+ int value; // Axis value
bool waiting = true;
bool succeed = false;
int pressed = 0;
int counter1 = 0; // Waiting limits
int counter2 = 30; // Iterations to wait for
-
+
+ // Update the text box
sprintf(format, "[%d]", counter2);
SetButtonText(ID, format);
- wxWindow::Update(); // win only? doesnt seem to work in linux...
+ wxWindow::Update(); // Win only? doesnt seem to work in linux...
while(waiting)
- {
- // Go through all axes and read out their values
+ {
+ // Update the internal status
SDL_JoystickUpdate();
- for(int b = 0; b < buttons; b++)
- {
- if(SDL_JoystickGetButton(joy, b))
+
+ // For the triggers we accept both a digital or an analog button
+ if(Axis)
+ {
+ for(int i = 0; i < axes; i++)
{
- pressed = b;
+ value = SDL_JoystickGetAxis(joy, i);
+
+ if(AvoidValues(value)) continue; // Avoid values
+
+ pressed = i;
waiting = false;
succeed = true;
- break;
- }
+ break; // Stop this loop
+ }
+ }
+
+ // Check for a hat
+ if(Hat)
+ {
+ for(int i = 0; i < hats; i++)
+ {
+ value = SDL_JoystickGetHat(joy, i);
+ if(value)
+ {
+ pressed = value;
+ waiting = false;
+ succeed = true;
+ break;
+ }
+ }
+ }
+
+ // Check for a button
+ if(Button)
+ {
+ for(int i = 0; i < buttons; i++)
+ {
+ if(SDL_JoystickGetButton(joy, i))
+ {
+ pressed = i;
+ waiting = false;
+ succeed = true;
+ break;
+ }
+ }
}
// Check for keyboard action
@@ -409,22 +407,92 @@ void ConfigBox::GetButtons(wxCommandEvent& event)
sprintf(format, "%d", succeed ? pressed : -1);
SetButtonText(ID, format);
- // We don't need this any more
+ // We don't need thisgamepad handle any more
if(SDL_JoystickOpened(joysticks[controller].ID)) SDL_JoystickClose(joy);
-
}
+
+// Wait for Analog
+// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
+void ConfigBox::GetAxis(wxCommandEvent& event)
+{
+ int ID = event.GetId();
+ int controller = notebookpage;
+
+ SDL_Joystick *joy = SDL_JoystickOpen(joysticks[controller].ID);
+
+ char format[128];
+ int axes = SDL_JoystickNumAxes(joy); // Get number of axes
+ bool waiting = true;
+ bool succeed = false;
+ int pressed = 0;
+ Sint16 value;
+
+ int counter1 = 0;
+ int counter2 = 10;
+
+ sprintf(format, "[%d]", counter2);
+ SetButtonText(ID, format);
+ wxWindow::Update(); // Win only? doesnt seem to work in linux...
+
+ while(waiting)
+ {
+ // Go through all axes and read out their values
+ SDL_JoystickUpdate();
+ for(int i = 0; i < axes; i++)
+ {
+ value = SDL_JoystickGetAxis(joy, i);
+
+ if(AvoidValues(value)) continue; // Avoid values
+
+ pressed = i;
+ waiting = false;
+ succeed = true;
+ break; // Stop this loop
+ }
+
+ // Stop waiting for a button
+ counter1++;
+ if(counter1 == 100)
+ {
+ counter1 = 0;
+ counter2--;
+
+ sprintf(format, "[%d]", counter2);
+ SetButtonText(ID, format);
+ wxWindow::Update(); // win only? doesnt seem to work in linux...
+ wxYieldIfNeeded(); // Let through debugging events
+
+ if(counter2<0)
+ waiting = false;
+ }
+ SLEEP(10);
+ }
+
+ sprintf(format, "%d", succeed ? pressed : -1); // Update the status text box
+ SetButtonText(ID, format);
+
+ if(SDL_JoystickOpened(joysticks[controller].ID)) // Close the handle
+ SDL_JoystickClose(joy);
+
+ // Update the axises for the advanced settings status
+ GetControllerAll(controller);
+}
+
+
// Wait for D-Pad
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
void ConfigBox::GetHats(int ID)
{
+ // Get the active controller
int controller = notebookpage;
- SDL_Joystick *joy;
- joy = SDL_JoystickOpen(joysticks[controller].ID);
+ /* Open a new joystick. Joysticks[controller].ID is the system ID 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);
char format[128];
- int hats = SDL_JoystickNumHats(joy);
+ int hats = SDL_JoystickNumHats(joy); // Get the number of sticks
bool waiting = true;
bool succeed = false;
int pressed = 0;
@@ -439,16 +507,6 @@ void ConfigBox::GetHats(int ID)
while(waiting)
{
SDL_JoystickUpdate();
- for(int b = 0; b < hats; b++)
- {
- if(SDL_JoystickGetHat(joy, b))
- {
- pressed = b;
- waiting = false;
- succeed = true;
- break;
- }
- }
counter1++;
if(counter1==100)
@@ -473,69 +531,4 @@ void ConfigBox::GetHats(int ID)
SDL_JoystickClose(joy);
}
-// Wait for Analog
-// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
-void ConfigBox::GetAxis(wxCommandEvent& event)
-{
- int ID = event.GetId();
- int controller = notebookpage;
-
- SDL_Joystick *joy;
- joy=SDL_JoystickOpen(joysticks[controller].ID);
-
- char format[128];
- int axes = SDL_JoystickNumAxes(joy);
- bool waiting = true;
- bool succeed = false;
- int pressed = 0;
- Sint16 value;
-
- int counter1 = 0;
- int counter2 = 10;
-
- sprintf(format, "[%d]", counter2);
- SetButtonText(ID, format);
- wxWindow::Update(); // win only? doesnt seem to work in linux...
-
- while(waiting)
- {
- // Go through all axes and read out their values
- SDL_JoystickUpdate();
- for(int b = 0; b < axes; b++)
- {
- value = SDL_JoystickGetAxis(joy, b);
- if(value < -10000 || value > 10000) // Avoid detecting small values
- {
- pressed = b;
- waiting = false;
- succeed = true;
- break;
- }
- }
-
- // Stop waiting for a button
- counter1++;
- if(counter1 == 100)
- {
- counter1=0;
- counter2--;
-
- sprintf(format, "[%d]", counter2);
- SetButtonText(ID, format);
- wxWindow::Update(); // win only? doesnt seem to work in linux...
-
- if(counter2<0)
- waiting = false;
- }
- SLEEP(10);
- }
-
- sprintf(format, "%d", succeed ? pressed : -1); // Update the status text box
- SetButtonText(ID, format);
-
- if(SDL_JoystickOpened(joysticks[controller].ID)) // Close the handle
- SDL_JoystickClose(joy);
-
- // Update the axises for the advanced settings status
- GetControllerAll(controller);
-}
+/////////////////////////////////////////////////////////// Configure button mapping
\ No newline at end of file
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp
index b5f5847e47..b8550cf597 100644
--- a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp
+++ b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp
@@ -47,14 +47,18 @@
// Variables guide
/* ŻŻŻŻŻŻŻŻŻ
- The arrays joysticks[] and joystate[] are numbered 0 to 3 for the four different virtual
- controllers. Joysticks[].ID will have the number of the inputs device mapped to that controller,
- this value can be between 0 and the total number of connected physical devices. The mapping
- is initially done by PAD_Initialize(), but for the configuration we can remap them, like in
- ConfigBox::ChangeJoystick().
+ Joyinfo: A hardcoded struct of with gamepad info that is populate by Search_Devices()
+ Joysticks: A custom struct with the button mapping
+ Joystate: A custom struct with the current button states
- The joyinfo[] array is for a certain physical device. It's therefore used as
- joyinfo[joysticks[controller].ID].
+ The arrays joysticks[] and joystate[] are numbered 0 to 3 for the four different virtual
+ controllers. Joysticks[].ID will have the number of the physical input device mapped to that
+ controller (this value range between 0 and the total number of connected physical devices). The
+ mapping of a certain physical device to joystate[].joy is initially done by Initialize(), but
+ for the configuration we can remap that, like in ConfigBox::ChangeJoystick().
+
+ The joyinfo[] array holds the physical gamepad info for a certain physical device. It's therefore
+ used as joyinfo[joysticks[controller].ID] if we want to get the joyinfo for a certain joystick.
////////////////////////*/
@@ -181,11 +185,6 @@ void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) {
void DllConfig(HWND _hParent)
{
#ifdef _WIN32
- if (SDL_Init(SDL_INIT_JOYSTICK ) < 0)
- {
- MessageBox(NULL, SDL_GetError(), "Could not initialize SDL!", MB_ICONERROR);
- return;
- }
// Start the pads so we can use them in the configuration and advanced controls
if(!emulator_running)
@@ -234,17 +233,19 @@ void DllDebugger(HWND _hParent, bool Show) {
void Initialize(void *init)
{
SPADInitialize _PADInitialize = *(SPADInitialize*)init;
- emulator_running = TRUE;
+ emulator_running = true;
#ifdef _DEBUG
- DEBUG_INIT();
+ DEBUG_INIT();
#endif
- if (SDL_Init(SDL_INIT_JOYSTICK) < 0)
+ /* SDL 1.3 use DirectInput instead of the old Microsoft Multimeda API, and with this we need
+ the SDL_INIT_VIDEO flag to */
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0)
{
#ifdef _WIN32
- MessageBox(NULL, SDL_GetError(), "Could not initialize SDL!", MB_ICONERROR);
+ MessageBox(NULL, SDL_GetError(), "Could not initialize SDL!", MB_ICONERROR);
#else
- printf("Could not initialize SDL! (%s)\n", SDL_GetError());
+ printf("Could not initialize SDL! (%s)\n", SDL_GetError());
#endif
return;
}
@@ -333,16 +334,19 @@ int Search_Devices()
// Shutdown PAD (stop emulation)
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
+// Called from: The Dolphin Core
void Shutdown()
{
- if (joysticks[0].enabled)
+ //if(!emulator_running) return;
+
+ if (joysticks[0].enabled && SDL_JoystickOpened(joysticks[0].ID))
SDL_JoystickClose(joystate[0].joy);
- if (joysticks[1].enabled)
+ if (joysticks[1].enabled && SDL_JoystickOpened(joysticks[1].ID))
SDL_JoystickClose(joystate[1].joy);
- if (joysticks[2].enabled)
+ if (joysticks[2].enabled && SDL_JoystickOpened(joysticks[2].ID))
SDL_JoystickClose(joystate[2].joy);
- if (joysticks[3].enabled)
- SDL_JoystickClose(joystate[3].joy);
+ if (joysticks[3].enabled && SDL_JoystickOpened(joysticks[3].ID))
+ SDL_JoystickClose(joystate[3].joy);
SDL_Quit();
@@ -352,7 +356,7 @@ void Shutdown()
delete [] joyinfo;
- emulator_running = FALSE;
+ emulator_running = false;
#ifdef _WIN32
#ifdef USE_RUMBLE_DINPUT_HACK
@@ -383,8 +387,10 @@ void PAD_Input(u8 _Key, u8 _UpDown)
void DoState(unsigned char **ptr, int mode) {
}
-// Set PAD status. This is called from SerialInterface_Devices.cpp
+// Set PAD status.
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
+// Called from: SerialInterface_Devices.cpp
+// Function: Gives the current pad status to the Core
void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
{
if (!joysticks[_numPAD].enabled)
@@ -456,12 +462,12 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
if (joystate[_numPAD].buttons[CTL_A_BUTTON])
{
- _pPADStatus->button|=PAD_BUTTON_A;
+ _pPADStatus->button |= PAD_BUTTON_A;
_pPADStatus->analogA = 255; // Perhaps support pressure?
}
if (joystate[_numPAD].buttons[CTL_B_BUTTON])
{
- _pPADStatus->button|=PAD_BUTTON_B;
+ _pPADStatus->button |= PAD_BUTTON_B;
_pPADStatus->analogB = 255; // Perhaps support pressure?
}
if (joystate[_numPAD].buttons[CTL_X_BUTTON]) _pPADStatus->button|=PAD_BUTTON_X;
@@ -640,8 +646,11 @@ void ReadButton(int controller, int button)
}
}
-// Request joystick state. The input value "controller" is for a virtual controller 0 to 3.
+// Request joystick state.
// ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
+// Called from: PAD_GetStatus()
+/* Function: Updates the joystate struct with the current pad status. The input value "controller" is
+ for a virtual controller 0 to 3. */
void GetJoyState(int controller)
{
SDL_JoystickUpdate();
diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h
index 29713b580b..c03cc43aee 100644
--- a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h
+++ b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.h
@@ -41,6 +41,7 @@
#include "Common.h" // Common
#include "pluginspecs_pad.h"
#include "IniFile.h"
+//#include "ConsoleWindow.h"
#include "Config.h" // Local
@@ -51,8 +52,6 @@
#endif
#ifdef _WIN32
- #pragma comment(lib, "SDL.lib")
- #pragma comment(lib, "comctl32.lib")
#include
#define _CRT_SECURE_NO_WARNINGS
#define DIRECTINPUT_VERSION 0x0800
@@ -117,7 +116,7 @@ struct CONTROLLER_MAPPING{ // GC PAD MAPPING
int deadzone; // Deadzone... what else?
int halfpress; // Halfpress... you know, like not fully pressed ;)...
int ID; // SDL joystick device ID
- int controllertype; // Joystick, Joystick no hat or a keyboard (perhaps a mouse later)
+ int controllertype; // Joystick, Joystick with no hat or a keyboard (perhaps a mouse later)
int eventnum; // Linux Event Number, Can't be found dynamically yet
};
diff --git a/Source/Plugins/Plugin_nJoy_Testing/Src/nJoy.cpp b/Source/Plugins/Plugin_nJoy_Testing/Src/nJoy.cpp
index 96bdcfb30f..90776a0330 100644
--- a/Source/Plugins/Plugin_nJoy_Testing/Src/nJoy.cpp
+++ b/Source/Plugins/Plugin_nJoy_Testing/Src/nJoy.cpp
@@ -401,6 +401,7 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
{
int TriggerValue = 0;
+
if(joysticks[_numPAD].buttons[a].c_str()[1] == '+')
{
if(joystate[_numPAD].buttons[a] >= 0)
@@ -411,6 +412,8 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
if(joystate[_numPAD].buttons[a] <= 0)
TriggerValue = abs((255.0f / joysticks[_numPAD].sData[JoyNum].Min) * joystate[_numPAD].buttons[a]);
}
+
+
// Analog L and R
if(a == CTL_L_SHOULDER)
{