Some Android fixes.

Dump config with RARCH_LOG instead of fprintf.
This commit is contained in:
Themaister 2014-06-11 14:19:34 +02:00
parent 3f6850169d
commit ee916bf2f1
5 changed files with 37 additions and 31 deletions

View File

@ -13,7 +13,6 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "config_file.h"
#include <stdlib.h>
#include <string.h>
@ -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 <sys/param.h> // 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;
}
}

View File

@ -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
}

View File

@ -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;
}
}
}

View File

@ -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)
{

View File

@ -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");
}