From ee916bf2f15f0004a1edf64d2a543d04539529f9 Mon Sep 17 00:00:00 2001 From: Themaister Date: Wed, 11 Jun 2014 14:19:34 +0200 Subject: [PATCH] Some Android fixes. Dump config with RARCH_LOG instead of fprintf. --- conf/config_file.c | 8 ++--- conf/config_file.h | 2 +- frontend/platform/platform_android.c | 49 ++++++++++++++++------------ input/android_input.c | 7 ++-- settings.c | 2 +- 5 files changed, 37 insertions(+), 31 deletions(-) diff --git a/conf/config_file.c b/conf/config_file.c index f10a762c3d..56ce559b9b 100644 --- a/conf/config_file.c +++ b/conf/config_file.c @@ -13,7 +13,6 @@ * If not, see . */ - #include "config_file.h" #include #include @@ -25,6 +24,7 @@ #include "../msvc/msvc_compat.h" #include "../file.h" #include "../miscellaneous.h" +#include "../general.h" #if !defined(_WIN32) && !defined(__CELLOS_LV2__) && !defined(_XBOX) #include // PATH_MAX @@ -818,19 +818,19 @@ void config_file_dump(config_file_t *conf, FILE *file) } } -void config_file_dump_all(config_file_t *conf, FILE *file) +void config_file_dump_all(config_file_t *conf) { struct include_list *includes = conf->includes; while (includes) { - fprintf(file, "#include \"%s\"\n", includes->path); + RARCH_LOG("#include \"%s\"\n", includes->path); includes = includes->next; } struct config_entry_list *list = conf->entries; while (list) { - fprintf(file, "%s = \"%s\" %s\n", list->key, list->value, list->readonly ? "(included)" : ""); + RARCH_LOG("%s = \"%s\" %s\n", list->key, list->value, list->readonly ? "(included)" : ""); list = list->next; } } diff --git a/conf/config_file.h b/conf/config_file.h index 63e64054ef..c9550f058d 100644 --- a/conf/config_file.h +++ b/conf/config_file.h @@ -107,7 +107,7 @@ bool config_file_write(config_file_t *conf, const char *path); // Dump the current config to an already opened file. Does not close the file. void config_file_dump(config_file_t *conf, FILE *file); // Also dumps inherited values, useful for logging. -void config_file_dump_all(config_file_t *conf, FILE *file); +void config_file_dump_all(config_file_t *conf); #ifdef __cplusplus } diff --git a/frontend/platform/platform_android.c b/frontend/platform/platform_android.c index db2fd38fce..abc428095d 100644 --- a/frontend/platform/platform_android.c +++ b/frontend/platform/platform_android.c @@ -409,7 +409,10 @@ static bool android_run_events (void *data) static void frontend_android_get_environment_settings(int *argc, char *argv[], void *data, void *params_data) { - char config_path[PATH_MAX], core_path[PATH_MAX], path[PATH_MAX]; + static char config_path[PATH_MAX]; + static char core_path[PATH_MAX]; + static char path[PATH_MAX]; + JNIEnv *env; jobject obj = NULL; jstring jstr = NULL; @@ -422,6 +425,16 @@ static void frontend_android_get_environment_settings(int *argc, char *argv[], if (!env) return; + struct rarch_main_wrap *args = (struct rarch_main_wrap*)params_data; + if (args) + { + args->touched = true; + args->no_rom = false; + args->verbose = false; + args->sram_path = NULL; + args->state_path = NULL; + } + CALL_OBJ_METHOD(env, obj, android_app->activity->clazz, android_app->getIntent); RARCH_LOG("Checking arguments passed from intent ...\n"); @@ -431,11 +444,13 @@ static void frontend_android_get_environment_settings(int *argc, char *argv[], { const char *argv = (*env)->GetStringUTFChars(env, jstr, 0); - if (*argv && argv[0] != '\0') + if (*argv && *argv) strlcpy(config_path, argv, sizeof(config_path)); (*env)->ReleaseStringUTFChars(env, jstr, argv); RARCH_LOG("Config file: [%s].\n", config_path); + if (args) + args->config_path = config_path; } // Current IME @@ -459,47 +474,39 @@ static void frontend_android_get_environment_settings(int *argc, char *argv[], RARCH_LOG("USED: [%s].\n", used ? "true" : "false"); } - //LIBRETRO + // LIBRETRO CALL_OBJ_METHOD_PARAM(env, jstr, obj, android_app->getStringExtra, (*env)->NewStringUTF(env, "LIBRETRO")); + *core_path = '\0'; if (android_app->getStringExtra && jstr) { const char *argv = (*env)->GetStringUTFChars(env, jstr, 0); - - if (*argv && argv[0] != '\0') + if (*argv && *argv) strlcpy(core_path, argv, sizeof(core_path)); (*env)->ReleaseStringUTFChars(env, jstr, argv); RARCH_LOG("Libretro path: [%s].\n", core_path); + if (args) + args->libretro_path = core_path; } // Content CALL_OBJ_METHOD_PARAM(env, jstr, obj, android_app->getStringExtra, (*env)->NewStringUTF(env, "ROM")); + *path = '\0'; + if (android_app->getStringExtra && jstr) { const char *argv = (*env)->GetStringUTFChars(env, jstr, 0); - if (*argv && argv[0] != '\0') + if (*argv && *argv) strlcpy(path, argv, sizeof(path)); (*env)->ReleaseStringUTFChars(env, jstr, argv); - if (path[0] != '\0') + if (*path) { - struct rarch_main_wrap *args = (struct rarch_main_wrap*)params_data; - + RARCH_LOG("Auto-start game %s.\n", path); if (args) - { - args->touched = true; - args->no_rom = false; - args->verbose = false; - args->config_path = strdup(config_path); - args->sram_path = NULL; - args->state_path = NULL; - args->rom_path = strdup(path); - args->libretro_path = strdup(core_path); - - RARCH_LOG("Auto-start game %s.\n", path); - } + args->rom_path = path; } } } diff --git a/input/android_input.c b/input/android_input.c index 0746204ca3..df14e796e9 100644 --- a/input/android_input.c +++ b/input/android_input.c @@ -599,7 +599,7 @@ static void handle_hotplug(void *data, unsigned port, unsigned id, else if (strstr(name_buf, "NVIDIA Controller")) { device = DEVICE_NVIDIA_SHIELD; - port = 0; // Shield is always player 1. + //port = 0; // Shield is always player 1. strlcpy(name_buf, "NVIDIA Shield", sizeof(name_buf)); } else if (strstr(name_buf, "Samsung Game Pad EI-GP20")) @@ -630,7 +630,6 @@ static void handle_hotplug(void *data, unsigned port, unsigned id, input_config_autoconfigure_joypad(port, name_buf, android_joypad.ident); RARCH_LOG("Port %d: %s.\n", port, name_buf); } - } // Handle all events. If our activity is in pause state, block until we're unpaused. @@ -660,7 +659,7 @@ static void android_input_poll(void *data) int predispatched; msg[0] = 0; - predispatched = AInputQueue_preDispatchEvent(android_app->inputQueue,event); + predispatched = AInputQueue_preDispatchEvent(android_app->inputQueue, event); if (predispatched) continue; @@ -721,7 +720,7 @@ static void android_input_poll(void *data) AInputQueue_finishEvent(android_app->inputQueue, event, handled); } - }while (AInputQueue_hasEvents(android_app->inputQueue)); + } while (AInputQueue_hasEvents(android_app->inputQueue)); } else if (ident == LOOPER_ID_USER) { diff --git a/settings.c b/settings.c index f1f1caf0f5..64bc93280a 100644 --- a/settings.c +++ b/settings.c @@ -785,7 +785,7 @@ bool config_load_file(const char *path, bool set_defaults) if (g_extern.verbose) { RARCH_LOG_OUTPUT("=== Config ===\n"); - config_file_dump_all(conf, stderr); + config_file_dump_all(conf); RARCH_LOG_OUTPUT("=== Config end ===\n"); }