From c31ada11466233f28e0a5cb8ec990504d70775a6 Mon Sep 17 00:00:00 2001 From: bgk Date: Wed, 3 Sep 2008 20:36:29 +0000 Subject: [PATCH] GTK : The joypad config dialog can now be used to configure the 4 joypads. git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@695 a31d4220-a93d-0410-bf67-fe4944624d44 --- src/gtk/joypadconfig.cpp | 17 +++++++++++------ src/gtk/joypadconfig.h | 2 ++ src/gtk/window.cpp | 8 ++++---- src/gtk/window.h | 2 +- src/gtk/windowcallbacks.cpp | 12 +++--------- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/gtk/joypadconfig.cpp b/src/gtk/joypadconfig.cpp index be58ae88..738ca9c9 100644 --- a/src/gtk/joypadconfig.cpp +++ b/src/gtk/joypadconfig.cpp @@ -43,7 +43,8 @@ const EKey JoypadConfigDialog::m_aeKeys[] = JoypadConfigDialog::JoypadConfigDialog(GtkDialog * _pstDialog, const Glib::RefPtr & _poXml) : - Gtk::Dialog(_pstDialog) + Gtk::Dialog(_pstDialog), + m_ePad(PAD_MAIN) { m_poOkButton = dynamic_cast(_poXml->get_widget("JoypadOkButton")); @@ -70,16 +71,20 @@ JoypadConfigDialog::JoypadConfigDialog(GtkDialog * _pstDialog, poEntry->signal_focus_out_event().connect(sigc::mem_fun(*this, &JoypadConfigDialog::bOnEntryFocusOut)); } - vUpdateEntries(); + memset(&m_oPreviousEvent, 0, sizeof(m_oPreviousEvent)); vEmptyEventQueue(); - memset(&m_oPreviousEvent, 0, sizeof(m_oPreviousEvent)); - m_oConfigSig = Glib::signal_idle().connect(sigc::mem_fun(*this, &JoypadConfigDialog::bOnConfigIdle), Glib::PRIORITY_DEFAULT_IDLE); } +void JoypadConfigDialog::vInitDialog(EPad _ePad) +{ + m_ePad = _ePad; + vUpdateEntries(); +} + JoypadConfigDialog::~JoypadConfigDialog() { m_oConfigSig.disconnect(); @@ -91,7 +96,7 @@ void JoypadConfigDialog::vUpdateEntries() { const char * csName = 0; - guint uiKeyval = inputGetKeymap(PAD_MAIN, m_aeKeys[i]); + guint uiKeyval = inputGetKeymap(m_ePad, m_aeKeys[i]); int dev = uiKeyval >> 16; if (dev == 0) { @@ -177,7 +182,7 @@ void JoypadConfigDialog::vOnInputEvent(const SDL_Event &event) } int code = inputGetEventCode(event); - inputSetKeymap(PAD_MAIN, m_aeKeys[m_iCurrentEntry], code); + inputSetKeymap(m_ePad, m_aeKeys[m_iCurrentEntry], code); vUpdateEntries(); if (m_iCurrentEntry + 1 < (gint)m_oEntries.size()) diff --git a/src/gtk/joypadconfig.h b/src/gtk/joypadconfig.h index f2ca33dd..5ca75d0a 100644 --- a/src/gtk/joypadconfig.h +++ b/src/gtk/joypadconfig.h @@ -37,6 +37,7 @@ public: const Glib::RefPtr & _poXml); virtual ~JoypadConfigDialog(); + void vInitDialog(EPad _ePad); protected: bool bOnEntryFocusIn(GdkEventFocus * _pstEvent, guint _uiEntry); bool bOnEntryFocusOut(GdkEventFocus * _pstEvent); @@ -51,6 +52,7 @@ private: static const EKey m_aeKeys[]; sigc::connection m_oConfigSig; SDL_Event m_oPreviousEvent; + EPad m_ePad; void vUpdateEntries(); bool bOnConfigIdle(); diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index a028bec3..64dd20db 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -698,19 +698,19 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : // poMI = dynamic_cast(_poXml->get_widget("JoypadConfigure1")); poMI->signal_activate().connect(sigc::bind( - sigc::mem_fun(*this, &Window::vOnJoypadConfigure), 1)); + sigc::mem_fun(*this, &Window::vOnJoypadConfigure), PAD_1)); poMI = dynamic_cast(_poXml->get_widget("JoypadConfigure2")); poMI->signal_activate().connect(sigc::bind( - sigc::mem_fun(*this, &Window::vOnJoypadConfigure), 2)); + sigc::mem_fun(*this, &Window::vOnJoypadConfigure), PAD_2)); poMI = dynamic_cast(_poXml->get_widget("JoypadConfigure3")); poMI->signal_activate().connect(sigc::bind( - sigc::mem_fun(*this, &Window::vOnJoypadConfigure), 3)); + sigc::mem_fun(*this, &Window::vOnJoypadConfigure), PAD_3)); poMI = dynamic_cast(_poXml->get_widget("JoypadConfigure4")); poMI->signal_activate().connect(sigc::bind( - sigc::mem_fun(*this, &Window::vOnJoypadConfigure), 4)); + sigc::mem_fun(*this, &Window::vOnJoypadConfigure), PAD_4)); int iDefaultJoypad = m_poInputConfig->oGetKey("active_joypad"); for (int i = m_iJoypadMin; i <= m_iJoypadMax; i++) diff --git a/src/gtk/window.h b/src/gtk/window.h index 9b27db01..3800ca98 100644 --- a/src/gtk/window.h +++ b/src/gtk/window.h @@ -164,7 +164,7 @@ protected: virtual void vOnEmulatorTypeToggled(Gtk::CheckMenuItem * _poCMI, int _iEmulatorType); virtual void vOnFilter2xToggled(Gtk::CheckMenuItem * _poCMI, int _iFilter2x); virtual void vOnFilterIBToggled(Gtk::CheckMenuItem * _poCMI, int _iFilterIB); - virtual void vOnJoypadConfigure(int _iJoypad); + virtual void vOnJoypadConfigure(EPad _eJoypad); virtual void vOnJoypadToggled(Gtk::CheckMenuItem * _poCMI, EPad _eJoypad); virtual void vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, u32 _uiKeyFlag); #ifndef NO_DEBUGGER diff --git a/src/gtk/windowcallbacks.cpp b/src/gtk/windowcallbacks.cpp index 19b2b277..4a31dd9d 100644 --- a/src/gtk/windowcallbacks.cpp +++ b/src/gtk/windowcallbacks.cpp @@ -860,7 +860,7 @@ void Window::vOnFilterIBToggled(Gtk::CheckMenuItem * _poCMI, int _iFilterIB) m_poDisplayConfig->vSetKey("filterIB", _iFilterIB); } -void Window::vOnJoypadConfigure(int _iJoypad) +void Window::vOnJoypadConfigure(EPad _eJoypad) { Glib::RefPtr poXml; poXml = Xml::create(PKGDATADIR "/vba.glade", "JoypadConfigDialog"); @@ -868,15 +868,9 @@ void Window::vOnJoypadConfigure(int _iJoypad) JoypadConfigDialog * poDialog = NULL; poXml->get_widget_derived("JoypadConfigDialog", poDialog); poDialog->set_transient_for(*this); + poDialog->vInitDialog(_eJoypad); - if (poDialog->run() == Gtk::RESPONSE_OK) - { - /*m_oJoypads[_iJoypad - 1] = poDialog->stGetConfig(); - if (_iJoypad == m_poInputConfig->oGetKey("active_joypad")) - { - m_oKeymap = m_oJoypads[_iJoypad - 1].oCreateKeymap(); - }*/ - } + poDialog->run(); delete poDialog; }