C++17ification.
C++17ification! - Filesystem interaction now uses std::filesystem::path. - Usage of const char*, std::string have been changed to std::string_view where appropriate. - Usage of printf-style functions changed to use fmt.
This commit is contained in:
@@ -88,7 +88,7 @@ std::unique_ptr<xe::ui::GraphicsProvider> CreateDemoGraphicsProvider(
|
||||
|
||||
void DrawInputStatus();
|
||||
|
||||
int hid_demo_main(const std::vector<std::wstring>& args) {
|
||||
int hid_demo_main(const std::vector<std::string>& args) {
|
||||
// Create run loop and the window.
|
||||
auto loop = ui::Loop::Create();
|
||||
auto window = xe::ui::Window::Create(loop.get(), GetEntryInfo().name);
|
||||
@@ -231,4 +231,4 @@ void DrawInputStatus() {
|
||||
} // namespace hid
|
||||
} // namespace xe
|
||||
|
||||
DEFINE_ENTRY_POINT(L"xenia-hid-demo", xe::hid::hid_demo_main, "");
|
||||
DEFINE_ENTRY_POINT("xenia-hid-demo", xe::hid::hid_demo_main, "");
|
||||
|
||||
@@ -20,6 +20,7 @@ project("xenia-hid-demo")
|
||||
kind("WindowedApp")
|
||||
language("C++")
|
||||
links({
|
||||
"fmt",
|
||||
"imgui",
|
||||
"volk",
|
||||
"xenia-base",
|
||||
|
||||
@@ -14,12 +14,13 @@
|
||||
#endif // XE_PLATFORM_WIN32
|
||||
|
||||
#include "xenia/base/cvar.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/ui/window.h"
|
||||
|
||||
// TODO(joellinn) make this path relative to the config folder.
|
||||
DEFINE_string(mappings_file, "gamecontrollerdb.txt",
|
||||
"Filename of a database with custom game controller mappings.",
|
||||
"SDL");
|
||||
DEFINE_path(mappings_file, "gamecontrollerdb.txt",
|
||||
"Filename of a database with custom game controller mappings.",
|
||||
"SDL");
|
||||
|
||||
namespace xe {
|
||||
namespace hid {
|
||||
@@ -118,7 +119,29 @@ X_STATUS SDLInputDriver::Setup() {
|
||||
}
|
||||
sdl_gamecontroller_initialized_ = true;
|
||||
|
||||
SDL_GameControllerAddMappingsFromFile(cvars::mappings_file.c_str());
|
||||
if (!cvars::mappings_file.empty()) {
|
||||
if (!filesystem::PathExists(cvars::mappings_file)) {
|
||||
XELOGW("SDL GameControllerDB: file '%s' does not exist.",
|
||||
xe::path_to_utf8(cvars::mappings_file).c_str());
|
||||
} else {
|
||||
auto mappings_file = filesystem::OpenFile(cvars::mappings_file, "rb");
|
||||
if (!mappings_file) {
|
||||
XELOGE("SDL GameControllerDB: failed to open file '%s'.",
|
||||
xe::path_to_utf8(cvars::mappings_file).c_str());
|
||||
} else {
|
||||
auto mappings_result = SDL_GameControllerAddMappingsFromRW(
|
||||
SDL_RWFromFP(mappings_file, SDL_TRUE), 1);
|
||||
if (mappings_result < 0) {
|
||||
XELOGE("SDL GameControllerDB: error loading file '%s': %d.",
|
||||
xe::path_to_utf8(cvars::mappings_file).c_str(),
|
||||
mappings_result);
|
||||
} else {
|
||||
XELOGI("SDL GameControllerDB: loaded %d mappings.",
|
||||
mappings_result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return sdl_events_initialized_ && sdl_gamecontroller_initialized_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user