mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-30 12:05:39 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
b329a5e1a0
|
@ -28,7 +28,7 @@ bool InputDevice::operator==(const InputDevice & b) const
|
||||||
|
|
||||||
InputManager::InputManager(Window* window) : mWindow(window),
|
InputManager::InputManager(Window* window) : mWindow(window),
|
||||||
mJoysticks(NULL), mInputConfigs(NULL), mKeyboardInputConfig(NULL), mPrevAxisValues(NULL),
|
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);
|
SDL_JoystickEventState(SDL_ENABLE);
|
||||||
|
|
||||||
//start timer for input device polling
|
//start timer for input device polling
|
||||||
devicePollingTimer = SDL_AddTimer(POLLING_INTERVAL, devicePollingCallback, (void *)this);
|
startPolling();
|
||||||
|
|
||||||
loadConfig();
|
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()
|
void InputManager::deinit()
|
||||||
{
|
{
|
||||||
SDL_RemoveTimer(devicePollingTimer);
|
stopPolling();
|
||||||
|
|
||||||
SDL_JoystickEventState(SDL_DISABLE);
|
SDL_JoystickEventState(SDL_DISABLE);
|
||||||
|
|
||||||
|
@ -380,6 +397,8 @@ void InputManager::loadConfig()
|
||||||
LOG(LogInfo) << "No input configs loaded. Loading default keyboard config.";
|
LOG(LogInfo) << "No input configs loaded. Loading default keyboard config.";
|
||||||
loadDefaultConfig();
|
loadDefaultConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG(LogInfo) << "Loaded InputConfig data for " << getNumPlayers() << " devices.";
|
||||||
}
|
}
|
||||||
|
|
||||||
//used in an "emergency" where no configs could be loaded from the inputmanager config file
|
//used in an "emergency" where no configs could be loaded from the inputmanager config file
|
||||||
|
|
|
@ -77,6 +77,9 @@ public:
|
||||||
bool parseEvent(const SDL_Event& ev);
|
bool parseEvent(const SDL_Event& ev);
|
||||||
|
|
||||||
InputConfig* getInputConfigByPlayer(int player);
|
InputConfig* getInputConfigByPlayer(int player);
|
||||||
|
|
||||||
|
void startPolling();
|
||||||
|
void stopPolling();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -65,6 +65,7 @@ Log::~Log()
|
||||||
fprintf(getOutput(), "%s", os.str().c_str());
|
fprintf(getOutput(), "%s", os.str().c_str());
|
||||||
|
|
||||||
//if it's an error, also print to console
|
//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());
|
fprintf(stderr, "%s", os.str().c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,10 @@ bool GuiDetectDevice::input(InputConfig* config, Input input)
|
||||||
if(!input.value)
|
if(!input.value)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
//don't allow device list to change once the first player has registered
|
||||||
|
if(mCurrentPlayer == 0)
|
||||||
|
mWindow->getInputManager()->stopPolling();
|
||||||
|
|
||||||
config->setPlayerNum(mCurrentPlayer);
|
config->setPlayerNum(mCurrentPlayer);
|
||||||
mWindow->getInputManager()->setNumPlayers(mWindow->getInputManager()->getNumPlayers() + 1); //inc total number of players
|
mWindow->getInputManager()->setNumPlayers(mWindow->getInputManager()->getNumPlayers() + 1); //inc total number of players
|
||||||
mCurrentPlayer++;
|
mCurrentPlayer++;
|
||||||
|
|
|
@ -35,6 +35,8 @@ GuiGameList::GuiGameList(Window* window, bool useDetail) : GuiComponent(window),
|
||||||
|
|
||||||
mTheme = new ThemeComponent(mWindow, mDetailed);
|
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 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.
|
//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.
|
//Those with smaller displays may prefer the older view.
|
||||||
|
@ -48,7 +50,6 @@ GuiGameList::GuiGameList(Window* window, bool useDetail) : GuiComponent(window),
|
||||||
mList = new TextListComponent<FileData*>(mWindow, 0, Renderer::getDefaultFont(Renderer::LARGE)->getHeight() + 2, Renderer::getDefaultFont(Renderer::MEDIUM));
|
mList = new TextListComponent<FileData*>(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"));
|
mScreenshot->setOrigin(mTheme->getFloat("gameImageOriginX"), mTheme->getFloat("gameImageOriginY"));
|
||||||
|
|
||||||
mDescription.setOffset(Vector2i((int)(Renderer::getScreenWidth() * 0.03), mScreenshot->getOffset().y + mScreenshot->getSize().y + 12));
|
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
|
//undo the parenting hack because otherwise it's not really a child and will try to remove itself on delete
|
||||||
mList->setParent(NULL);
|
mList->setParent(NULL);
|
||||||
delete mList;
|
delete mList;
|
||||||
|
delete mScreenshot;
|
||||||
|
|
||||||
if(mDetailed)
|
if(mDetailed)
|
||||||
{
|
{
|
||||||
delete mImageAnimation;
|
delete mImageAnimation;
|
||||||
delete mScreenshot;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete mTheme;
|
delete mTheme;
|
||||||
|
|
|
@ -38,6 +38,7 @@ bool GuiInputConfig::input(InputConfig* config, Input input)
|
||||||
mWindow->pushGui(new GuiInputConfig(mWindow, mWindow->getInputManager()->getInputConfigByPlayer(mTargetConfig->getPlayerNum() + 1)));
|
mWindow->pushGui(new GuiInputConfig(mWindow, mWindow->getInputManager()->getInputConfigByPlayer(mTargetConfig->getPlayerNum() + 1)));
|
||||||
}else{
|
}else{
|
||||||
mWindow->getInputManager()->writeConfig();
|
mWindow->getInputManager()->writeConfig();
|
||||||
|
mWindow->getInputManager()->startPolling(); //enable polling again since we're done
|
||||||
GuiGameList::create(mWindow);
|
GuiGameList::create(mWindow);
|
||||||
}
|
}
|
||||||
delete this;
|
delete this;
|
||||||
|
|
|
@ -117,7 +117,7 @@ void TextListComponent<T>::onRender()
|
||||||
|
|
||||||
//number of entries that can fit on the screen simultaniously
|
//number of entries that can fit on the screen simultaniously
|
||||||
int screenCount = (Renderer::getScreenHeight() - cutoff) / entrySize;
|
int screenCount = (Renderer::getScreenHeight() - cutoff) / entrySize;
|
||||||
//screenCount -= 1;
|
screenCount -= 1;
|
||||||
|
|
||||||
if((int)mRowVector.size() >= screenCount)
|
if((int)mRowVector.size() >= screenCount)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue