mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 22:25:38 +00:00
Print all Log messages to cout with --debug set.
Added startPolling and stopPolling to InputManager.
This commit is contained in:
parent
20d08587f2
commit
1dfb45e133
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue