diff --git a/Source/Plugins/Plugin_Wiimote/Src/Config.cpp b/Source/Plugins/Plugin_Wiimote/Src/Config.cpp index cda5699198..bd7fe6fb02 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/Config.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/Config.cpp @@ -83,7 +83,7 @@ void Config::Load(bool ChangePad) /* Prevent a crash from illegal access to joyinfo that will only have values for the current amount of connected PadMapping */ - if(WiiMoteEmu::PadMapping[i].ID >= SDL_NumJoysticks()) continue; + if(WiiMoteEmu::PadMapping[i].ID >= WiiMoteEmu::joyinfo.size()) continue; // Create a section name SectionName = WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[i].ID].Name; @@ -146,7 +146,7 @@ void Config::Save(int Slot) /* Save joypad specific settings. Check for "PadMapping[i].ID < SDL_NumJoysticks()" to avoid reading a joyinfo that does't exist */ - if(WiiMoteEmu::PadMapping[i].ID >= SDL_NumJoysticks()) continue; + if(WiiMoteEmu::PadMapping[i].ID >= WiiMoteEmu::joyinfo.size()) continue; // Create a new section name after the joypad name SectionName = WiiMoteEmu::joyinfo[WiiMoteEmu::PadMapping[i].ID].Name; diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp index 02faed42b1..3deec285ab 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp @@ -1143,9 +1143,21 @@ void ConfigDialog::UpdateGUI(int Slot) m_UseRealWiimote[Page]->Enable((m_bEnableUseRealWiimote && g_RealWiiMotePresent && g_Config.bConnectRealWiimote) || !g_EmulatorRunning); // Linux has no FindItem() + // Disable all pad items if no pads are detected + if(ControlsCreated) + { + bool PadEnabled = WiiMoteEmu::NumGoodPads != 0; + #ifdef _WIN32 + for(int i = IDB_ANALOG_LEFT_X; i <= IDB_TRIGGER_R; i++) m_Notebook->FindItem(i)->Enable(PadEnabled); + m_Notebook->FindItem(IDC_JOYNAME)->Enable(PadEnabled); + m_Notebook->FindItem(ID_TRIGGER_TYPE)->Enable(PadEnabled); + #endif + } + + // Disable all recording buttons + bool ActiveRecording = !(m_bWaitForRecording || m_bRecording); #ifdef _WIN32 - // Disable all recording buttons for(int i = IDB_RECORD + 1; i < (IDB_RECORD + RECORDING_ROWS + 1); i++) - if(ControlsCreated) m_Notebook->FindItem(i)->Enable(!(m_bWaitForRecording || m_bRecording)); + if(ControlsCreated) m_Notebook->FindItem(i)->Enable(ActiveRecording); #endif } diff --git a/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp b/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp index 3d8bf2f89f..59edb02a7a 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp @@ -365,10 +365,13 @@ void SingleShake(u8 &_z, u8 &_y) // ------------------------------------------ /* Tilting Wiimote with gamepad. We can guess that the game will calculate a Wiimote pitch and use it as a measure of the tilting of the Wiimote. We are interested in this tilting range - 90° to -90° */ + 90° to -90° */ // --------------- void TiltWiimoteGamepad(u8 &_y, u8 &_z) { + // Return if we have no pads + if (NumGoodPads == 0) return; + // Update the pad state const int Page = 0; WiiMoteEmu::GetJoyState(PadState[Page], PadMapping[Page], Page, joyinfo[PadMapping[Page].ID].NumButtons);