diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 64dd20db..d9362e9d 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -731,28 +731,28 @@ Window::Window(GtkWindow * _pstWindow, const Glib::RefPtr & _poXml) : // Autofire menu // - /*struct + struct { - const char * m_csName; - const char * m_csKey; - const EKeyFlag m_eKeyFlag; + const char * m_csName; + const char * m_csKey; + const EKey m_eKey; } astAutofire[] = { - { "AutofireA", "autofire_A", KeyFlagA }, - { "AutofireB", "autofire_B", KeyFlagB }, - { "AutofireL", "autofire_L", KeyFlagL }, - { "AutofireR", "autofire_R", KeyFlagR } + { "AutofireA", "autofire_A", KEY_BUTTON_A }, + { "AutofireB", "autofire_B", KEY_BUTTON_B }, + { "AutofireL", "autofire_L", KEY_BUTTON_L }, + { "AutofireR", "autofire_R", KEY_BUTTON_R } }; for (guint i = 0; i < G_N_ELEMENTS(astAutofire); i++) { poCMI = dynamic_cast(_poXml->get_widget(astAutofire[i].m_csName)); poCMI->set_active(m_poInputConfig->oGetKey(astAutofire[i].m_csKey)); - vOnAutofireToggled(poCMI, astAutofire[i].m_eKeyFlag); + vOnAutofireToggled(poCMI, astAutofire[i].m_eKey); poCMI->signal_toggled().connect(sigc::bind( sigc::mem_fun(*this, &Window::vOnAutofireToggled), - poCMI, astAutofire[i].m_eKeyFlag)); - }*/ + poCMI, astAutofire[i].m_eKey)); + } // Fullscreen menu // diff --git a/src/gtk/window.h b/src/gtk/window.h index 3800ca98..be3c40f5 100644 --- a/src/gtk/window.h +++ b/src/gtk/window.h @@ -166,7 +166,7 @@ protected: virtual void vOnFilterIBToggled(Gtk::CheckMenuItem * _poCMI, int _iFilterIB); virtual void vOnJoypadConfigure(EPad _eJoypad); virtual void vOnJoypadToggled(Gtk::CheckMenuItem * _poCMI, EPad _eJoypad); - virtual void vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, u32 _uiKeyFlag); + virtual void vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, EKey _eKey); #ifndef NO_DEBUGGER virtual void vOnGDBWait(); virtual void vOnGDBLoadAndWait(); diff --git a/src/gtk/windowcallbacks.cpp b/src/gtk/windowcallbacks.cpp index 4a31dd9d..b4c0c000 100644 --- a/src/gtk/windowcallbacks.cpp +++ b/src/gtk/windowcallbacks.cpp @@ -887,35 +887,31 @@ void Window::vOnJoypadToggled(Gtk::CheckMenuItem * _poCMI, EPad _eJoypad) m_poInputConfig->vSetKey("active_joypad", _eJoypad); } -void Window::vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, u32 _uiKeyFlag) +void Window::vOnAutofireToggled(Gtk::CheckMenuItem * _poCMI, EKey _eKey) { -/* if (_poCMI->get_active()) + if (_poCMI->get_active() != inputGetAutoFire(_eKey)) { - m_uiAutofireState |= _uiKeyFlag; - } - else - { - m_uiAutofireState &= ~_uiKeyFlag; + inputToggleAutoFire(_eKey); } std::string sKey; - if (_uiKeyFlag == KeyFlagA) + if (_eKey == KEY_BUTTON_A) { sKey = "autofire_A"; } - else if (_uiKeyFlag == KeyFlagB) + else if (_eKey == KEY_BUTTON_B) { sKey = "autofire_B"; } - else if (_uiKeyFlag == KeyFlagL) + else if (_eKey == KEY_BUTTON_L) { sKey = "autofire_L"; } - else if (_uiKeyFlag == KeyFlagR) + else if (_eKey == KEY_BUTTON_R) { sKey = "autofire_R"; } - m_poInputConfig->vSetKey(sKey, _poCMI->get_active());*/ + m_poInputConfig->vSetKey(sKey, _poCMI->get_active()); } #ifndef NO_DEBUGGER diff --git a/src/sdl/inputSDL.cpp b/src/sdl/inputSDL.cpp index fd24c397..c7f7e397 100644 --- a/src/sdl/inputSDL.cpp +++ b/src/sdl/inputSDL.cpp @@ -151,6 +151,31 @@ void inputSetMotionKeymap(EKey key, uint32_t code) motion[key] = code; } +bool inputGetAutoFire(EKey key) +{ + int mask = 0; + + switch (key) + { + case KEY_BUTTON_A: + mask = 1 << 0; + break; + case KEY_BUTTON_B: + mask = 1 << 1; + break; + case KEY_BUTTON_R: + mask = 1 << 8; + break; + case KEY_BUTTON_L: + mask = 1 << 9; + break; + default: + break; + } + + return !(autoFire & mask); +} + bool inputToggleAutoFire(EKey key) { int mask = 0; diff --git a/src/sdl/inputSDL.h b/src/sdl/inputSDL.h index b0396e90..ef341a7e 100644 --- a/src/sdl/inputSDL.h +++ b/src/sdl/inputSDL.h @@ -84,6 +84,13 @@ void inputSetMotionKeymap(EKey key, uint32_t code); */ bool inputToggleAutoFire(EKey key); +/** + * Get Auto fire status for the specified button. Only A, B, R, L are supported. + * @param key Emulated joypad button + * @return Auto fire enabled + */ +bool inputGetAutoFire(EKey key); + /** * Update the emulated pads state with a SDL event * @param SDL_Event An event that has just occured