Print all Log messages to cout with --debug set.

Added startPolling and stopPolling to InputManager.
This commit is contained in:
Aloshi 2013-06-29 20:37:18 -05:00
parent 20d08587f2
commit 1dfb45e133
3 changed files with 27 additions and 4 deletions

View file

@ -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

View 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

View file

@ -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());
} }