Merge pull request #4820 from bunnei/android-fixes
common: Various fixes and minor improvements.
This commit is contained in:
commit
4ec2b2d45a
|
@ -20,6 +20,10 @@
|
||||||
#else
|
#else
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define EMU_DATA_DIR "Citra"
|
#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
|
#else
|
||||||
#define EMU_DATA_DIR "citra-emu"
|
#define EMU_DATA_DIR "citra-emu"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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::ConfigDir, user_path + CONFIG_DIR DIR_SEP);
|
||||||
g_paths.emplace(UserPath::CacheDir, user_path + CACHE_DIR DIR_SEP);
|
g_paths.emplace(UserPath::CacheDir, user_path + CACHE_DIR DIR_SEP);
|
||||||
#elif ANDROID
|
#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
|
#else
|
||||||
if (FileUtil::Exists(ROOT_DIR DIR_SEP USERDATA_DIR)) {
|
if (FileUtil::Exists(ROOT_DIR DIR_SEP USERDATA_DIR)) {
|
||||||
user_path = ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP;
|
user_path = ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP;
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#elif defined(ANDROID)
|
||||||
|
#include <android/log.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
|
@ -32,7 +34,13 @@ std::string FormatLogMessage(const Entry& entry) {
|
||||||
|
|
||||||
void PrintMessage(const Entry& entry) {
|
void PrintMessage(const Entry& entry) {
|
||||||
const auto str = FormatLogMessage(entry).append(1, '\n');
|
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<int>(entry.log_level) + 2;
|
||||||
|
__android_log_print(android_log_level, "CitraNative", "%s", str.c_str());
|
||||||
|
#else
|
||||||
fputs(str.c_str(), stderr);
|
fputs(str.c_str(), stderr);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintColoredMessage(const Entry& entry) {
|
void PrintColoredMessage(const Entry& entry) {
|
||||||
|
@ -70,7 +78,7 @@ void PrintColoredMessage(const Entry& entry) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SetConsoleTextAttribute(console_handle, color);
|
SetConsoleTextAttribute(console_handle, color);
|
||||||
#else
|
#elif !defined(ANDROID)
|
||||||
#define ESC "\x1b"
|
#define ESC "\x1b"
|
||||||
const char* color = "";
|
const char* color = "";
|
||||||
switch (entry.log_level) {
|
switch (entry.log_level) {
|
||||||
|
@ -103,7 +111,7 @@ void PrintColoredMessage(const Entry& entry) {
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
SetConsoleTextAttribute(console_handle, original_info.wAttributes);
|
SetConsoleTextAttribute(console_handle, original_info.wAttributes);
|
||||||
#else
|
#elif !defined(ANDROID)
|
||||||
fputs(ESC "[0m", stderr);
|
fputs(ESC "[0m", stderr);
|
||||||
#undef ESC
|
#undef ESC
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -9,10 +9,8 @@
|
||||||
#include "input_common/keyboard.h"
|
#include "input_common/keyboard.h"
|
||||||
#include "input_common/main.h"
|
#include "input_common/main.h"
|
||||||
#include "input_common/motion_emu.h"
|
#include "input_common/motion_emu.h"
|
||||||
#include "input_common/udp/udp.h"
|
|
||||||
#ifdef HAVE_SDL2
|
|
||||||
#include "input_common/sdl/sdl.h"
|
#include "input_common/sdl/sdl.h"
|
||||||
#endif
|
#include "input_common/udp/udp.h"
|
||||||
|
|
||||||
namespace InputCommon {
|
namespace InputCommon {
|
||||||
|
|
||||||
|
|
Reference in New Issue