diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 52c1930a..a028bec3 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -712,22 +712,22 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : poMI->signal_activate().connect(sigc::bind( sigc::mem_fun(*this, &Window::vOnJoypadConfigure), 4)); - /*int iDefaultJoypad = m_poInputConfig->oGetKey("active_joypad"); + int iDefaultJoypad = m_poInputConfig->oGetKey("active_joypad"); for (int i = m_iJoypadMin; i <= m_iJoypadMax; i++) { char csName[20]; - snprintf(csName, sizeof(csName), "Joypad%d", i); + snprintf(csName, sizeof(csName), "Joypad%d", i + 1); poCMI = dynamic_cast(_poXml->get_widget(csName)); if (i == iDefaultJoypad) { poCMI->set_active(); - vOnJoypadToggled(poCMI, iDefaultJoypad); + vOnJoypadToggled(poCMI, (EPad)iDefaultJoypad); } poCMI->signal_toggled().connect(sigc::bind( sigc::mem_fun(*this, &Window::vOnJoypadToggled), - poCMI, i)); - }*/ + poCMI, (EPad)i)); + } // Autofire menu // diff --git a/src/gtk/window.h b/src/gtk/window.h index 62b86caa..9b27db01 100644 --- a/src/gtk/window.h +++ b/src/gtk/window.h @@ -165,7 +165,7 @@ protected: virtual void vOnFilter2xToggled(Gtk::CheckMenuItem * _poCMI, int _iFilter2x); virtual void vOnFilterIBToggled(Gtk::CheckMenuItem * _poCMI, int _iFilterIB); virtual void vOnJoypadConfigure(int _iJoypad); - virtual void vOnJoypadToggled(Gtk::CheckMenuItem * _poCMI, int _iJoypad); + virtual void vOnJoypadToggled(Gtk::CheckMenuItem * _poCMI, EPad _eJoypad); virtual void vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, u32 _uiKeyFlag); #ifndef NO_DEBUGGER virtual void vOnGDBWait(); diff --git a/src/gtk/windowcallbacks.cpp b/src/gtk/windowcallbacks.cpp index a0636010..19b2b277 100644 --- a/src/gtk/windowcallbacks.cpp +++ b/src/gtk/windowcallbacks.cpp @@ -881,16 +881,16 @@ void Window::vOnJoypadConfigure(int _iJoypad) delete poDialog; } -void Window::vOnJoypadToggled(Gtk::CheckMenuItem * _poCMI, int _iJoypad) +void Window::vOnJoypadToggled(Gtk::CheckMenuItem * _poCMI, EPad _eJoypad) { -/* if (! _poCMI->get_active()) + if (! _poCMI->get_active()) { return; } - m_oKeymap = m_oJoypads[_iJoypad - 1].oCreateKeymap(); + inputSetDefaultJoypad(_eJoypad); - m_poInputConfig->vSetKey("active_joypad", _iJoypad);*/ + m_poInputConfig->vSetKey("active_joypad", _eJoypad); } void Window::vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, u32 _uiKeyFlag) diff --git a/src/sdl/inputSDL.cpp b/src/sdl/inputSDL.cpp index e7e93811..fd24c397 100644 --- a/src/sdl/inputSDL.cpp +++ b/src/sdl/inputSDL.cpp @@ -47,7 +47,7 @@ static bool sdlMotionButtons[4] = { false, false, false, false }; static int sdlNumDevices = 0; static SDL_Joystick **sdlDevices = NULL; -static int sdlDefaultJoypad = 0; +static EPad sdlDefaultJoypad = PAD_MAIN; static int autoFire = 0; static bool autoFireToggle = false; @@ -568,3 +568,8 @@ int inputGetSensorY() { return sensorY; } + +void inputSetDefaultJoypad(EPad pad) +{ + sdlDefaultJoypad = pad; +} diff --git a/src/sdl/inputSDL.h b/src/sdl/inputSDL.h index 754725f3..b0396e90 100644 --- a/src/sdl/inputSDL.h +++ b/src/sdl/inputSDL.h @@ -121,4 +121,10 @@ int inputGetSensorX(); */ int inputGetSensorY(); +/** + * Set which joypad configuration use when the core doesn't ask for a specific + * pad + */ +void inputSetDefaultJoypad(EPad pad); + #endif // VBAM_SDL_INPUT_H