git repos / blockattack-game

commit 409492c9

sago007 · 2020-06-27 22:22
409492c99f0a12516a6207a21fba96a5186f3b94 patch · browse files
parent 9c7fa9a1f402533e0fd53136c81572050910e0e2

Now also possible to plugin a controller while on the menu

Changed files

M source/code/HelpGamepadState.cpp before
M source/code/MenuSystem.cpp before
diff --git a/source/code/HelpGamepadState.cpp b/source/code/HelpGamepadState.cpp index 3cfa6ed..6107e8b 100644 --- a/source/code/HelpGamepadState.cpp +++ b/source/code/HelpGamepadState.cpp
@@ -86,6 +86,7 @@ void HelpGamepadState::ProcessInput(const SDL_Event& event, bool& processed) {
InitGameControllers();
std::string s = getLabelForSupportedControllerNames();
setHelpGamepadFont(&globalData.spriteHolder->GetDataHolder(), supportedControllers, s.c_str());
+ processed = true;
}
if (isConfirmEvent(event) || isEscapeEvent(event)) {
diff --git a/source/code/MenuSystem.cpp b/source/code/MenuSystem.cpp index f183ab7..f22e7f5 100644 --- a/source/code/MenuSystem.cpp +++ b/source/code/MenuSystem.cpp
@@ -334,6 +334,12 @@ void Menu::Draw(SDL_Renderer* target) {
#endif
}
void Menu::ProcessInput(const SDL_Event& event, bool& processed) {
+ if (isGameControllerConnectionEvent(event)) {
+ UnInitGameControllers();
+ InitGameControllers();
+ processed = true;
+ }
+
if (isUpEvent(event)) {
marked--;
if (marked<0) {