mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-09 02:48:54 +00:00
(Android) Create android_app_read_cmd
This commit is contained in:
parent
7bc4a69a4a
commit
5a2c6aa5d6
@ -20,12 +20,44 @@
|
||||
struct android_app *g_android;
|
||||
struct android_app_userdata *g_android_userdata;
|
||||
|
||||
static void free_saved_state(struct android_app* android_app)
|
||||
{
|
||||
slock_lock(android_app->mutex);
|
||||
if (android_app->savedState != NULL)
|
||||
{
|
||||
free(android_app->savedState);
|
||||
android_app->savedState = NULL;
|
||||
android_app->savedStateSize = 0;
|
||||
}
|
||||
slock_unlock(android_app->mutex);
|
||||
}
|
||||
|
||||
void android_app_write_cmd(struct android_app *android_app, int8_t cmd)
|
||||
{
|
||||
if (write(android_app->msgwrite, &cmd, sizeof(cmd)) != sizeof(cmd))
|
||||
RARCH_ERR("Failure writing android_app cmd: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
int8_t android_app_read_cmd(struct android_app *android_app)
|
||||
{
|
||||
int8_t cmd;
|
||||
if (read(android_app->msgread, &cmd, sizeof(cmd)) == sizeof(cmd))
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case APP_CMD_SAVE_STATE:
|
||||
free_saved_state(android_app);
|
||||
break;
|
||||
}
|
||||
return cmd;
|
||||
}
|
||||
else
|
||||
{
|
||||
RARCH_ERR("No data on command pipe.\n");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void android_app_set_input(void *data, AInputQueue* inputQueue)
|
||||
{
|
||||
struct android_app *android_app = (struct android_app*)data;
|
||||
|
@ -332,6 +332,10 @@ enum
|
||||
APP_CMD_DEAD,
|
||||
};
|
||||
|
||||
void android_app_write_cmd(struct android_app *android_app, int8_t cmd);
|
||||
|
||||
int8_t android_app_read_cmd(struct android_app *android_app);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -115,15 +115,12 @@ static void engine_handle_dpad_getaxisvalue(
|
||||
|
||||
static void engine_handle_cmd(void)
|
||||
{
|
||||
int8_t cmd;
|
||||
struct android_app *android_app = (struct android_app*)g_android;
|
||||
struct android_app_userdata *userdata = (struct android_app_userdata*)g_android_userdata;
|
||||
runloop_t *runloop = rarch_main_get_ptr();
|
||||
global_t *global = global_get_ptr();
|
||||
driver_t *driver = driver_get_ptr();
|
||||
|
||||
if (read(android_app->msgread, &cmd, sizeof(cmd)) != sizeof(cmd))
|
||||
cmd = -1;
|
||||
int8_t cmd = android_app_read_cmd(android_app);
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user