diff --git a/src/InputManager.cpp b/src/InputManager.cpp index 8a4b916be..fb76e48b1 100644 --- a/src/InputManager.cpp +++ b/src/InputManager.cpp @@ -28,7 +28,7 @@ bool InputDevice::operator==(const InputDevice & b) const InputManager::InputManager(Window* window) : mWindow(window), mJoysticks(NULL), mInputConfigs(NULL), mKeyboardInputConfig(NULL), mPrevAxisValues(NULL), - mNumJoysticks(0), mNumPlayers(0), devicePollingTimer(nullptr) + mNumJoysticks(0), mNumPlayers(0), devicePollingTimer(NULL) { } @@ -164,14 +164,31 @@ void InputManager::init() SDL_JoystickEventState(SDL_ENABLE); //start timer for input device polling - devicePollingTimer = SDL_AddTimer(POLLING_INTERVAL, devicePollingCallback, (void *)this); + startPolling(); loadConfig(); } +void InputManager::startPolling() +{ + if(devicePollingTimer != NULL) + return; + + devicePollingTimer = SDL_AddTimer(POLLING_INTERVAL, devicePollingCallback, (void *)this); +} + +void InputManager::stopPolling() +{ + if(devicePollingTimer == NULL) + return; + + SDL_RemoveTimer(devicePollingTimer); + devicePollingTimer = NULL; +} + void InputManager::deinit() { - SDL_RemoveTimer(devicePollingTimer); + stopPolling(); SDL_JoystickEventState(SDL_DISABLE); @@ -380,6 +397,8 @@ void InputManager::loadConfig() LOG(LogInfo) << "No input configs loaded. Loading default keyboard config."; loadDefaultConfig(); } + + LOG(LogInfo) << "Loaded InputConfig data for " << getNumPlayers() << " devices."; } //used in an "emergency" where no configs could be loaded from the inputmanager config file diff --git a/src/InputManager.h b/src/InputManager.h index 921a29fa5..e0cef8b61 100644 --- a/src/InputManager.h +++ b/src/InputManager.h @@ -77,6 +77,9 @@ public: bool parseEvent(const SDL_Event& ev); InputConfig* getInputConfigByPlayer(int player); + + void startPolling(); + void stopPolling(); }; #endif diff --git a/src/Log.cpp b/src/Log.cpp index fe3c50c6c..0e8522601 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -65,6 +65,7 @@ Log::~Log() fprintf(getOutput(), "%s", os.str().c_str()); //if it's an error, also print to console - if(messageLevel == LogError) + //print all messages if using --debug + if(messageLevel == LogError || reportingLevel >= LogDebug) fprintf(stderr, "%s", os.str().c_str()); } diff --git a/src/components/GuiDetectDevice.cpp b/src/components/GuiDetectDevice.cpp index 8c05f1d91..570d4c9f4 100644 --- a/src/components/GuiDetectDevice.cpp +++ b/src/components/GuiDetectDevice.cpp @@ -44,6 +44,10 @@ bool GuiDetectDevice::input(InputConfig* config, Input input) if(!input.value) return false; + //don't allow device list to change once the first player has registered + if(mCurrentPlayer == 0) + mWindow->getInputManager()->stopPolling(); + config->setPlayerNum(mCurrentPlayer); mWindow->getInputManager()->setNumPlayers(mWindow->getInputManager()->getNumPlayers() + 1); //inc total number of players mCurrentPlayer++; diff --git a/src/components/GuiGameList.cpp b/src/components/GuiGameList.cpp index 044aa0325..c77775f46 100644 --- a/src/components/GuiGameList.cpp +++ b/src/components/GuiGameList.cpp @@ -35,6 +35,8 @@ GuiGameList::GuiGameList(Window* window, bool useDetail) : GuiComponent(window), mTheme = new ThemeComponent(mWindow, mDetailed); + mScreenshot = new ImageComponent(mWindow, getImagePos().x, getImagePos().y, "", (unsigned int)mTheme->getFloat("gameImageWidth"), (unsigned int)mTheme->getFloat("gameImageHeight"), false); + //The GuiGameList can use the older, simple game list if so desired. //The old view only shows a list in the center of the screen; the new view can display an image and description. //Those with smaller displays may prefer the older view. @@ -48,7 +50,6 @@ GuiGameList::GuiGameList(Window* window, bool useDetail) : GuiComponent(window), mList = new TextListComponent(mWindow, 0, Renderer::getDefaultFont(Renderer::LARGE)->getHeight() + 2, Renderer::getDefaultFont(Renderer::MEDIUM)); } - mScreenshot = new ImageComponent(mWindow, getImagePos().x, getImagePos().y, "", (unsigned int)mTheme->getFloat("gameImageWidth"), (unsigned int)mTheme->getFloat("gameImageHeight"), false); mScreenshot->setOrigin(mTheme->getFloat("gameImageOriginX"), mTheme->getFloat("gameImageOriginY")); mDescription.setOffset(Vector2i((int)(Renderer::getScreenWidth() * 0.03), mScreenshot->getOffset().y + mScreenshot->getSize().y + 12)); @@ -72,11 +73,11 @@ GuiGameList::~GuiGameList() //undo the parenting hack because otherwise it's not really a child and will try to remove itself on delete mList->setParent(NULL); delete mList; + delete mScreenshot; if(mDetailed) { delete mImageAnimation; - delete mScreenshot; } delete mTheme; diff --git a/src/components/GuiInputConfig.cpp b/src/components/GuiInputConfig.cpp index 6f217fcec..78f7a272a 100644 --- a/src/components/GuiInputConfig.cpp +++ b/src/components/GuiInputConfig.cpp @@ -38,6 +38,7 @@ bool GuiInputConfig::input(InputConfig* config, Input input) mWindow->pushGui(new GuiInputConfig(mWindow, mWindow->getInputManager()->getInputConfigByPlayer(mTargetConfig->getPlayerNum() + 1))); }else{ mWindow->getInputManager()->writeConfig(); + mWindow->getInputManager()->startPolling(); //enable polling again since we're done GuiGameList::create(mWindow); } delete this; diff --git a/src/components/TextListComponent.h b/src/components/TextListComponent.h index 0aea6cea4..e5c16e2fd 100644 --- a/src/components/TextListComponent.h +++ b/src/components/TextListComponent.h @@ -117,7 +117,7 @@ void TextListComponent::onRender() //number of entries that can fit on the screen simultaniously int screenCount = (Renderer::getScreenHeight() - cutoff) / entrySize; - //screenCount -= 1; + screenCount -= 1; if((int)mRowVector.size() >= screenCount) {