From eb1c6163f7335c830d61f58dc21803f95740854a Mon Sep 17 00:00:00 2001 From: John Peterson Date: Thu, 12 Feb 2009 10:49:38 +0000 Subject: [PATCH] Emulated Wiimote: Enabled the roll and pitch function again (I had accidently disabled it in the last commit) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2220 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp | 38 +++++++++---------- .../Plugin_Wiimote/Src/ConfigGamepad.cpp | 4 +- Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp | 11 ++++-- Source/Plugins/Plugin_Wiimote/Src/EmuMain.h | 1 + .../Plugins/Plugin_Wiimote/Src/FillReport.cpp | 2 +- Source/Plugins/Plugin_Wiimote/Src/main.cpp | 5 ++- Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp | 12 +++--- 7 files changed, 42 insertions(+), 31 deletions(-) diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp index 7111c3c474..2bbea50e18 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigDlg.cpp @@ -498,31 +498,31 @@ void ConfigDialog::CreateGUIControls() /**/ // Controller m_Joyname[i] = new wxComboBox(m_Controller[i], IDC_JOYNAME, StrJoyname[0], wxDefaultPosition, wxSize(205, -1), StrJoyname, wxCB_READONLY); - - // Circle to square + + // Circle to square m_CheckC2S[i] = new wxCheckBox(m_Controller[i], IDC_LEFT_C2S, wxT("Circle to square")); - // The label + // The label m_CheckC2SLabel[i] = new wxStaticText(m_Controller[i], wxID_ANY, wxT("Diagonal")); - // The drop down menu for the circle to square adjustment - wxArrayString asStatusInSet; - asStatusInSet.Add(wxT("100%")); - asStatusInSet.Add(wxT("95%")); - asStatusInSet.Add(wxT("90%")); - asStatusInSet.Add(wxT("85%")); - asStatusInSet.Add(wxT("80%")); + // The drop down menu for the circle to square adjustment + wxArrayString asStatusInSet; + asStatusInSet.Add(wxT("100%")); + asStatusInSet.Add(wxT("95%")); + asStatusInSet.Add(wxT("90%")); + asStatusInSet.Add(wxT("85%")); + asStatusInSet.Add(wxT("80%")); m_ComboDiagonal[i] = new wxComboBox(m_Controller[i], IDCB_LEFT_DIAGONAL, asStatusInSet[0], wxDefaultPosition, wxDefaultSize, asStatusInSet, wxCB_READONLY); // Tooltips m_Joyname[i]->SetToolTip(wxT("Save your settings and configure another joypad")); - m_CheckC2S[i]->SetToolTip(wxT( - "This will convert a circular stick radius to a square stick radius." - " This can be useful for the pitch and roll emulation." + m_CheckC2S[i]->SetToolTip(wxT( + "This will convert a circular stick radius to a square stick radius." + " This can be useful for the pitch and roll emulation." )); - m_CheckC2SLabel[i]->SetToolTip(wxT( - "To produce a perfect square circle in the 'Out' window you have to manually set" - "\nyour diagonal values here from what is shown in the 'In' window." + m_CheckC2SLabel[i]->SetToolTip(wxT( + "To produce a perfect square circle in the 'Out' window you have to manually set" + "\nyour diagonal values here from what is shown in the 'In' window." )); // Sizers @@ -531,8 +531,8 @@ void ConfigDialog::CreateGUIControls() m_gCircle2Square[i]->Add(m_ComboDiagonal[i], 0, (wxLEFT), 2); m_gJoyname[i] = new wxStaticBoxSizer (wxVERTICAL, m_Controller[i], wxT("Gamepad")); - m_gJoyname[i]->Add(m_Joyname[i], 0, wxALIGN_CENTER | (wxLEFT | wxRIGHT | wxDOWN), 5); - m_gJoyname[i]->Add(m_CheckC2S[i], 0, wxALIGN_CENTER | (wxLEFT | wxRIGHT | wxDOWN), 5); + m_gJoyname[i]->Add(m_Joyname[i], 0, wxALIGN_CENTER | (wxLEFT | wxRIGHT | wxDOWN), 5); + m_gJoyname[i]->Add(m_CheckC2S[i], 0, wxALIGN_CENTER | (wxLEFT | wxRIGHT | wxDOWN), 5); m_gJoyname[i]->Add(m_gCircle2Square[i], 0, wxALIGN_CENTER | (wxLEFT | wxRIGHT | wxDOWN), 5); @@ -1187,7 +1187,7 @@ void ConfigDialog::UpdateGUI(int Slot) has been initialized. Functions for that are basically already in place so these two options could possibly be simplified to one option. */ m_ConnectRealWiimote[Page]->Enable(!g_EmulatorRunning); - m_UseRealWiimote[Page]->Enable((m_bEnableUseRealWiimote && g_RealWiiMotePresent && g_Config.bConnectRealWiimote) || !g_EmulatorRunning); + m_UseRealWiimote[Page]->Enable((m_bEnableUseRealWiimote && g_RealWiiMotePresent && g_Config.bConnectRealWiimote) || (!g_EmulatorRunning && g_Config.bConnectRealWiimote)); // Linux has no FindItem() // Disable all pad items if no pads are detected diff --git a/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp b/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp index 374bf37b28..9fb2e4e48d 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/ConfigGamepad.cpp @@ -449,6 +449,8 @@ void ConfigDialog::DoGetButtons(int GetId) // ŻŻŻŻŻŻŻŻŻŻŻŻŻŻ void ConfigDialog::PadGetStatus() { + //Console::Print("SDL_WasInit: %i\n", SDL_WasInit(0)); + // Return if it's not detected if(WiiMoteEmu::PadMapping[Page].ID >= SDL_NumJoysticks()) { @@ -596,7 +598,5 @@ void ConfigDialog::UpdatePad(wxTimerEvent& WXUNUSED(event)) //LogMsg("Abc%s\n", ShowStatus(notebookpage).c_str()); PadGetStatus(); - - //Console::Print("a\n"); } ///////////////////////////////////////////////////// \ No newline at end of file diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp index a285b883a0..1f1fee725e 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp @@ -39,7 +39,6 @@ #include "Logging.h" // for startConsoleWin, Console::Print, GetConsoleHwnd #include "Config.h" // for g_Config //////////////////////////////////// - extern SWiimoteInitialize g_WiimoteInitialize; namespace WiiMoteEmu @@ -341,8 +340,11 @@ void Initialize() g_RecordingCurrentTime[i] = 0; } - // Load avaliable pads - Search_Devices(joyinfo, NumPads, NumGoodPads); + // Populate joyinfo for all attached devices if the configuration window is not already open + if(!g_FrameOpen) + { + Search_Devices(joyinfo, NumPads, NumGoodPads); + } /* The Nuncheck extension ID for homebrew applications that use the zero key. This writes 0x0000 in encrypted form (0xfefe) to 0xfe in the extension register. */ @@ -379,11 +381,14 @@ void Shutdown(void) /* SDL_JoystickClose() crashes for some reason so I avoid this for now, SDL_Quit() should close the pads to I think */ //if(SDL_JoystickOpened(PadMapping[i].ID)) SDL_JoystickClose(PadState[i].joy); + //PadState[i].joy = NULL; } } // Clear the physical device info joyinfo.clear(); + NumPads = 0; + NumGoodPads = 0; // Finally close SDL if (SDL_WasInit(0)) SDL_Quit(); diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.h b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.h index 2652f23932..081a5c0a82 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.h +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.h @@ -45,6 +45,7 @@ void Update(); void LoadRecordedMovements(); // Registers and calibration values +void ResetVariables(); void UpdateEeprom(); void SetDefaultExtensionRegistry(); diff --git a/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp b/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp index 86a03e07a7..86c03c1fe2 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/FillReport.cpp @@ -568,7 +568,7 @@ void FillReportAcc(wm_accel& _acc) SingleShake(g_z, g_y); // Tilt Wiimote - + Tilt(g_x, g_y, g_z); // Write final values _acc.x = g_x; diff --git a/Source/Plugins/Plugin_Wiimote/Src/main.cpp b/Source/Plugins/Plugin_Wiimote/Src/main.cpp index f7bf5d4d37..14b924a1a4 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/main.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/main.cpp @@ -228,6 +228,9 @@ extern "C" void Shutdown(void) if(frame) frame->UpdateGUI(); #endif + // Reset the variables + WiiMoteEmu::ResetVariables(); + /* Don't shut down the wiimote when we still have the config window open, we may still want want to use the Wiimote in the config window. */ return; @@ -238,7 +241,7 @@ extern "C" void Shutdown(void) #endif WiiMoteEmu::Shutdown(); - //Console::Close(); + Console::Close(); } diff --git a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp index 0066324a69..5fa651fc3f 100644 --- a/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp +++ b/Source/Plugins/Plugin_nJoy_SDL/Src/nJoy.cpp @@ -302,7 +302,13 @@ void Shutdown() // Always change this variable g_EmulatorRunning = false; - // Don't shutdown if the configuration window is still showing + // Stop debugging + #ifdef _DEBUG + DEBUG_QUIT(); + #endif + + // Don't shutdown the gamepad if the configuration window is still showing + // Todo: Coordinate with the Wiimote plugin, SDL_Quit() will remove the pad for it to if (m_frame) return; /* Close all devices carefully. We must check that we are not accessing any undefined @@ -329,10 +335,6 @@ void Shutdown() // Remove the pointer to the initialize data g_PADInitialize = NULL; - #ifdef _DEBUG - DEBUG_QUIT(); - #endif - #ifdef _WIN32 #ifdef USE_RUMBLE_DINPUT_HACK FreeDirectInput();