From c168496b4563a1e24f44ce1cdac91fca3c94d6bb Mon Sep 17 00:00:00 2001 From: Pieter Hulshoff Date: Wed, 11 Mar 2020 14:59:12 +0100 Subject: [PATCH] Fixed problems with zero-delay decoders. --- RetroFE/Source/Control/InputHandler.h | 2 +- RetroFE/Source/Control/JoyAxisHandler.h | 1 + RetroFE/Source/Control/JoyButtonHandler.h | 1 + RetroFE/Source/Control/JoyHatHandler.h | 1 + RetroFE/Source/Control/KeyboardHandler.cpp | 5 +++++ RetroFE/Source/Control/KeyboardHandler.h | 1 + RetroFE/Source/Control/MouseButtonHandler.h | 1 + RetroFE/Source/Control/UserInput.cpp | 14 ++++++++++++++ RetroFE/Source/Control/UserInput.h | 1 + RetroFE/Source/RetroFE.cpp | 2 ++ RetroFE/Source/Version.cpp | 2 +- 11 files changed, 29 insertions(+), 2 deletions(-) diff --git a/RetroFE/Source/Control/InputHandler.h b/RetroFE/Source/Control/InputHandler.h index 8ef88da..9b2c97a 100644 --- a/RetroFE/Source/Control/InputHandler.h +++ b/RetroFE/Source/Control/InputHandler.h @@ -9,5 +9,5 @@ public: virtual bool update(SDL_Event &e) = 0; virtual bool pressed() = 0; virtual void reset() = 0; + virtual void updateKeystate() = 0; }; - diff --git a/RetroFE/Source/Control/JoyAxisHandler.h b/RetroFE/Source/Control/JoyAxisHandler.h index 55bee04..565e610 100644 --- a/RetroFE/Source/Control/JoyAxisHandler.h +++ b/RetroFE/Source/Control/JoyAxisHandler.h @@ -9,6 +9,7 @@ public: bool update(SDL_Event &e); bool pressed(); void reset(); + void updateKeystate() {}; private: SDL_JoystickID joyid_; diff --git a/RetroFE/Source/Control/JoyButtonHandler.h b/RetroFE/Source/Control/JoyButtonHandler.h index adee958..17fbf98 100644 --- a/RetroFE/Source/Control/JoyButtonHandler.h +++ b/RetroFE/Source/Control/JoyButtonHandler.h @@ -9,6 +9,7 @@ public: bool update(SDL_Event &e); bool pressed(); void reset(); + void updateKeystate() {}; private: SDL_JoystickID joynum_; diff --git a/RetroFE/Source/Control/JoyHatHandler.h b/RetroFE/Source/Control/JoyHatHandler.h index ad249db..3c01051 100644 --- a/RetroFE/Source/Control/JoyHatHandler.h +++ b/RetroFE/Source/Control/JoyHatHandler.h @@ -9,6 +9,7 @@ public: bool update(SDL_Event &e); bool pressed(); void reset(); + void updateKeystate() {}; private: SDL_JoystickID joynum_; diff --git a/RetroFE/Source/Control/KeyboardHandler.cpp b/RetroFE/Source/Control/KeyboardHandler.cpp index e7bb72b..e8c4ca1 100644 --- a/RetroFE/Source/Control/KeyboardHandler.cpp +++ b/RetroFE/Source/Control/KeyboardHandler.cpp @@ -29,3 +29,8 @@ bool KeyboardHandler::pressed() return pressed_; } +void KeyboardHandler::updateKeystate() +{ + const Uint8 *state = SDL_GetKeyboardState(NULL); + pressed_ = state[scancode_]; +} diff --git a/RetroFE/Source/Control/KeyboardHandler.h b/RetroFE/Source/Control/KeyboardHandler.h index b49097c..115805c 100644 --- a/RetroFE/Source/Control/KeyboardHandler.h +++ b/RetroFE/Source/Control/KeyboardHandler.h @@ -9,6 +9,7 @@ public: bool update(SDL_Event &e); bool pressed(); void reset(); + void updateKeystate( ); private: SDL_Scancode scancode_; diff --git a/RetroFE/Source/Control/MouseButtonHandler.h b/RetroFE/Source/Control/MouseButtonHandler.h index 48fa476..ca1a4e6 100644 --- a/RetroFE/Source/Control/MouseButtonHandler.h +++ b/RetroFE/Source/Control/MouseButtonHandler.h @@ -9,6 +9,7 @@ public: bool update(SDL_Event &e); bool pressed(); void reset(); + void updateKeystate() {}; private: Uint8 button_; diff --git a/RetroFE/Source/Control/UserInput.cpp b/RetroFE/Source/Control/UserInput.cpp index 5ab1917..d64cb8b 100644 --- a/RetroFE/Source/Control/UserInput.cpp +++ b/RetroFE/Source/Control/UserInput.cpp @@ -375,3 +375,17 @@ void UserInput::reconfigure( ) keyHandlers_.clear(); initialize( ); } + + +void UserInput::updateKeystate( ) +{ + for ( unsigned int i = 0; i < keyHandlers_.size( ); ++i ) + { + InputHandler *h = keyHandlers_[i].first; + if ( h ) + { + h->updateKeystate( ); + currentKeyState_[keyHandlers_[i].second] |= h->pressed( ); + } + } +} diff --git a/RetroFE/Source/Control/UserInput.h b/RetroFE/Source/Control/UserInput.h index f1bee33..8664d5a 100644 --- a/RetroFE/Source/Control/UserInput.h +++ b/RetroFE/Source/Control/UserInput.h @@ -68,6 +68,7 @@ public: bool newKeyPressed(KeyCode_E code); void clearJoysticks( ); void reconfigure( ); + void updateKeystate( ); private: bool MapKey(std::string keyDescription, KeyCode_E key); diff --git a/RetroFE/Source/RetroFE.cpp b/RetroFE/Source/RetroFE.cpp index e4b8794..7e06974 100644 --- a/RetroFE/Source/RetroFE.cpp +++ b/RetroFE/Source/RetroFE.cpp @@ -1213,6 +1213,8 @@ void RetroFE::run( ) attract_.reset( ); } currentPage_->update( deltaTime ); + SDL_PumpEvents( ); + input_.updateKeystate( ); if (!splashMode) { if ( currentPage_->isAttractIdle( ) ) diff --git a/RetroFE/Source/Version.cpp b/RetroFE/Source/Version.cpp index 082a75b..e78be9d 100644 --- a/RetroFE/Source/Version.cpp +++ b/RetroFE/Source/Version.cpp @@ -21,7 +21,7 @@ std::string retrofe_version_major = "0"; std::string retrofe_version_minor = "9"; -std::string retrofe_version_build = "21"; +std::string retrofe_version_build = "22"; std::string Version::getString( )