diff --git a/src/common/common_paths.h b/src/common/common_paths.h index 4942c02ab..dd58e90e7 100644 --- a/src/common/common_paths.h +++ b/src/common/common_paths.h @@ -20,6 +20,10 @@ #else #ifdef _WIN32 #define EMU_DATA_DIR "Citra" +#elif ANDROID +// On Android internal storage is mounted as "/sdcard" +#define SDCARD_DIR "sdcard" +#define EMU_DATA_DIR "citra-emu" #else #define EMU_DATA_DIR "citra-emu" #endif diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 338d4bebb..247104b6d 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -683,7 +683,11 @@ void SetUserPath(const std::string& path) { g_paths.emplace(UserPath::ConfigDir, user_path + CONFIG_DIR DIR_SEP); g_paths.emplace(UserPath::CacheDir, user_path + CACHE_DIR DIR_SEP); #elif ANDROID - ASSERT_MSG(false, "Specified path {} is not valid", path); + if (FileUtil::Exists(ROOT_DIR DIR_SEP SDCARD_DIR)) { + user_path = ROOT_DIR DIR_SEP SDCARD_DIR DIR_SEP EMU_DATA_DIR DIR_SEP; + g_paths.emplace(UserPath::ConfigDir, user_path + CONFIG_DIR DIR_SEP); + g_paths.emplace(UserPath::CacheDir, user_path + CACHE_DIR DIR_SEP); + } #else if (FileUtil::Exists(ROOT_DIR DIR_SEP USERDATA_DIR)) { user_path = ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP; diff --git a/src/common/logging/text_formatter.cpp b/src/common/logging/text_formatter.cpp index 2bfb6ce4b..aa0dbd0c6 100644 --- a/src/common/logging/text_formatter.cpp +++ b/src/common/logging/text_formatter.cpp @@ -7,6 +7,8 @@ #ifdef _WIN32 #include +#elif defined(ANDROID) +#include #endif #include "common/assert.h" @@ -32,7 +34,13 @@ std::string FormatLogMessage(const Entry& entry) { void PrintMessage(const Entry& entry) { const auto str = FormatLogMessage(entry).append(1, '\n'); +#ifdef ANDROID + // Android's log level enum are offset by '2' + const int android_log_level = static_cast(entry.log_level) + 2; + __android_log_print(android_log_level, "CitraNative", "%s", str.c_str()); +#else fputs(str.c_str(), stderr); +#endif } void PrintColoredMessage(const Entry& entry) { @@ -70,7 +78,7 @@ void PrintColoredMessage(const Entry& entry) { } SetConsoleTextAttribute(console_handle, color); -#else +#elif !defined(ANDROID) #define ESC "\x1b" const char* color = ""; switch (entry.log_level) { @@ -103,7 +111,7 @@ void PrintColoredMessage(const Entry& entry) { #ifdef _WIN32 SetConsoleTextAttribute(console_handle, original_info.wAttributes); -#else +#elif !defined(ANDROID) fputs(ESC "[0m", stderr); #undef ESC #endif diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index 0beef8c48..4674a0978 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp @@ -9,10 +9,8 @@ #include "input_common/keyboard.h" #include "input_common/main.h" #include "input_common/motion_emu.h" -#include "input_common/udp/udp.h" -#ifdef HAVE_SDL2 #include "input_common/sdl/sdl.h" -#endif +#include "input_common/udp/udp.h" namespace InputCommon {