From 45b97ede8128bd0217943e6b4b88a08a3c1a7003 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 28 Jan 2013 05:06:43 +0200 Subject: [PATCH] frontend: logging updates go to logcat on Android --- frontend/libpicofe | 2 +- frontend/main.c | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/frontend/libpicofe b/frontend/libpicofe index 4db02226..215e7ed2 160000 --- a/frontend/libpicofe +++ b/frontend/libpicofe @@ -1 +1 @@ -Subproject commit 4db02226eb3c80f49f5c412f7718c437c5e817fc +Subproject commit 215e7ed2510e191664b611a578ffb987cf4fdab3 diff --git a/frontend/main.c b/frontend/main.c index 43a1a032..8b35b09a 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -454,6 +454,8 @@ int emu_core_preinit(void) int emu_core_init(void) { + SysPrintf("Starting PCSX-ReARMed " REV "\n"); + CheckSubDir(); check_memcards(); @@ -553,7 +555,8 @@ int main(int argc, char *argv[]) plat_init(); menu_init(); // loads config - emu_core_init(); + if (emu_core_init() != 0) + return 1; if (psxout) Config.PsxOut = 1; @@ -761,6 +764,8 @@ int emu_load_state(int slot) return LoadState(fname); } +#ifndef ANDROID + void SysPrintf(const char *fmt, ...) { va_list list; @@ -769,16 +774,31 @@ void SysPrintf(const char *fmt, ...) { va_end(list); } +#else + +#include + +void SysPrintf(const char *fmt, ...) { + va_list list; + + va_start(list, fmt); + __android_log_vprint(ANDROID_LOG_INFO, "PCSX", fmt, list); + va_end(list); +} + +#endif + void SysMessage(const char *fmt, ...) { - va_list list; - char msg[512]; + va_list list; + char msg[512]; + int ret; - va_start(list, fmt); - vsnprintf(msg, sizeof(msg), fmt, list); - va_end(list); + va_start(list, fmt); + ret = vsnprintf(msg, sizeof(msg), fmt, list); + va_end(list); - if (msg[strlen(msg) - 1] == '\n') - msg[strlen(msg) - 1] = 0; + if (ret < sizeof(msg) && msg[ret - 1] == '\n') + msg[ret - 1] = 0; SysPrintf("%s\n", msg); } -- 2.39.5