SDLInputSource: Add log callback
This commit is contained in:
parent
536f1511c2
commit
a4127aa2ea
|
@ -104,6 +104,21 @@ static void SetControllerRGBLED(SDL_GameController* gc, u32 color)
|
||||||
SDL_GameControllerSetLED(gc, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff);
|
SDL_GameControllerSetLED(gc, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void SDLLogCallback(void* userdata, int category, SDL_LogPriority priority, const char* message)
|
||||||
|
{
|
||||||
|
static constexpr LOGLEVEL priority_map[SDL_NUM_LOG_PRIORITIES] = {
|
||||||
|
LOGLEVEL_DEBUG,
|
||||||
|
LOGLEVEL_DEBUG, // SDL_LOG_PRIORITY_VERBOSE
|
||||||
|
LOGLEVEL_DEBUG, // SDL_LOG_PRIORITY_DEBUG
|
||||||
|
LOGLEVEL_INFO, // SDL_LOG_PRIORITY_INFO
|
||||||
|
LOGLEVEL_WARNING, // SDL_LOG_PRIORITY_WARN
|
||||||
|
LOGLEVEL_ERROR, // SDL_LOG_PRIORITY_ERROR
|
||||||
|
LOGLEVEL_ERROR, // SDL_LOG_PRIORITY_CRITICAL
|
||||||
|
};
|
||||||
|
|
||||||
|
Log::Write("SDL", "SDL", priority_map[priority], message);
|
||||||
|
}
|
||||||
|
|
||||||
SDLInputSource::SDLInputSource() = default;
|
SDLInputSource::SDLInputSource() = default;
|
||||||
|
|
||||||
SDLInputSource::~SDLInputSource()
|
SDLInputSource::~SDLInputSource()
|
||||||
|
@ -226,6 +241,13 @@ bool SDLInputSource::InitializeSubsystem()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_LogSetOutputFunction(SDLLogCallback, nullptr);
|
||||||
|
#ifdef _DEBUG
|
||||||
|
SDL_LogSetAllPriority(SDL_LOG_PRIORITY_VERBOSE);
|
||||||
|
#else
|
||||||
|
SDL_LogSetAllPriority(SDL_LOG_PRIORITY_INFO);
|
||||||
|
#endif
|
||||||
|
|
||||||
// we should open the controllers as the connected events come in, so no need to do any more here
|
// we should open the controllers as the connected events come in, so no need to do any more here
|
||||||
m_sdl_subsystem_initialized = true;
|
m_sdl_subsystem_initialized = true;
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue