mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-22 18:58:21 +00:00
(Android) Rewrite new input code some more
This commit is contained in:
parent
ec114db356
commit
28c9f51913
@ -46,9 +46,13 @@ static unsigned pointer_count;
|
||||
/**
|
||||
* Process the next main command.
|
||||
*/
|
||||
void engine_handle_cmd (void *data, int32_t cmd)
|
||||
void engine_handle_cmd(void)
|
||||
{
|
||||
struct android_app *android_app = (struct android_app*)data;
|
||||
struct android_app *android_app = (struct android_app*)g_android;
|
||||
int8_t cmd;
|
||||
|
||||
if (read(android_app->msgread, &cmd, sizeof(cmd)) != sizeof(cmd))
|
||||
cmd = -1;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
@ -162,12 +166,18 @@ void engine_handle_cmd (void *data, int32_t cmd)
|
||||
g_extern.lifecycle_state |= (1ULL << RARCH_QUIT_KEY);
|
||||
break;
|
||||
}
|
||||
|
||||
if (cmd == APP_CMD_INIT_WINDOW)
|
||||
{
|
||||
if (g_extern.lifecycle_state & (1ULL << RARCH_PAUSE_TOGGLE))
|
||||
init_drivers();
|
||||
}
|
||||
}
|
||||
|
||||
void engine_handle_input (void *data, int32_t cmd)
|
||||
void engine_handle_input(void)
|
||||
{
|
||||
bool debug_enable = g_settings.input.debug_enable;
|
||||
struct android_app *android_app = (struct android_app*)data;
|
||||
struct android_app *android_app = (struct android_app*)g_android;
|
||||
uint64_t *lifecycle_state = &g_extern.lifecycle_state;
|
||||
|
||||
*lifecycle_state &= ~((1ULL << RARCH_RESET) | (1ULL << RARCH_REWIND) | (1ULL << RARCH_FAST_FORWARD_KEY) | (1ULL << RARCH_FAST_FORWARD_HOLD_KEY) | (1ULL << RARCH_MUTE) | (1ULL << RARCH_SAVE_STATE_KEY) | (1ULL << RARCH_LOAD_STATE_KEY) | (1ULL << RARCH_STATE_SLOT_PLUS) | (1ULL << RARCH_STATE_SLOT_MINUS));
|
||||
|
@ -61,24 +61,10 @@ static void print_cur_config (void *data)
|
||||
|
||||
static bool android_run_events (void *data)
|
||||
{
|
||||
struct android_app *android_app = (struct android_app*)data;
|
||||
int id = ALooper_pollOnce(-1, NULL, NULL, NULL);
|
||||
|
||||
if (id == LOOPER_ID_MAIN)
|
||||
{
|
||||
int8_t cmd;
|
||||
|
||||
if (read(android_app->msgread, &cmd, sizeof(cmd)) != sizeof(cmd))
|
||||
cmd = -1;
|
||||
|
||||
engine_handle_cmd(android_app, cmd);
|
||||
|
||||
if (cmd == APP_CMD_INIT_WINDOW)
|
||||
{
|
||||
if (g_extern.lifecycle_state & (1ULL << RARCH_PAUSE_TOGGLE))
|
||||
init_drivers();
|
||||
}
|
||||
}
|
||||
engine_handle_cmd();
|
||||
|
||||
// Check if we are exiting.
|
||||
if (g_extern.lifecycle_state & (1ULL << RARCH_QUIT_KEY))
|
||||
|
@ -154,8 +154,8 @@ enum {
|
||||
};
|
||||
|
||||
int8_t android_app_read_cmd (void *data);
|
||||
extern void engine_app_read_cmd (void *data);
|
||||
extern void engine_handle_cmd (void *data, int32_t cmd);
|
||||
extern void engine_app_read_cmd(void);
|
||||
extern void engine_handle_cmd(void);
|
||||
|
||||
extern struct android_app *g_android;
|
||||
|
||||
|
18
retroarch.c
18
retroarch.c
@ -2793,28 +2793,14 @@ bool rarch_main_iterate(void)
|
||||
}
|
||||
|
||||
#ifdef ANDROID
|
||||
struct android_app *android_app = (struct android_app*)g_android;
|
||||
int ident;
|
||||
|
||||
while ((ident = ALooper_pollAll( (input_key_pressed_func(RARCH_PAUSE_TOGGLE)) ? -1 : 0, NULL, NULL, NULL)) >= 0)
|
||||
{
|
||||
if (ident == LOOPER_ID_MAIN)
|
||||
{
|
||||
int8_t cmd;
|
||||
|
||||
if (read(android_app->msgread, &cmd, sizeof(cmd)) != sizeof(cmd))
|
||||
cmd = -1;
|
||||
|
||||
engine_handle_cmd(android_app, cmd);
|
||||
|
||||
if (cmd == APP_CMD_INIT_WINDOW)
|
||||
{
|
||||
if (g_extern.lifecycle_state & (1ULL << RARCH_PAUSE_TOGGLE))
|
||||
init_drivers();
|
||||
}
|
||||
}
|
||||
engine_handle_cmd();
|
||||
else if (!input_key_pressed_func(RARCH_PAUSE_TOGGLE))
|
||||
engine_handle_input(android_app, 0);
|
||||
engine_handle_input();
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user