From dd31be16d9d8bc662c89a28ed20447a16b609214 Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 5 Jul 2019 18:27:59 -0400 Subject: [PATCH 1/4] input_common: main: Remove unnecessary HAVE_SDL2 check. --- src/input_common/main.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index 0beef8c48c..4674a0978d 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 { From 4d1de484c6fc1e413d4de271093f5e238ebe3015 Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 5 Jul 2019 18:54:50 -0400 Subject: [PATCH 2/4] android: common: Add paths for Android SDCARD_DIR and EMU_DATA_DIR. --- src/common/common_paths.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/common/common_paths.h b/src/common/common_paths.h index 4942c02ab4..dd58e90e73 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 From 1c61f066d1bf4ccfe08a44b27e63d5be39c921a4 Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 5 Jul 2019 18:55:27 -0400 Subject: [PATCH 3/4] android: common: logging: Add log output support. --- src/common/logging/text_formatter.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/common/logging/text_formatter.cpp b/src/common/logging/text_formatter.cpp index 2bfb6ce4b9..aa0dbd0c62 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 From bf8224213d2a06f1668fb9c123cabe6cfde50da9 Mon Sep 17 00:00:00 2001 From: bunnei Date: Fri, 5 Jul 2019 18:56:17 -0400 Subject: [PATCH 4/4] android: common: file_util: Add user_path, ConfigDir, and CacheDir. --- src/common/file_util.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 338d4bebba..247104b6d2 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;