(Android) Control if back button exits on a per-controller basis

This commit is contained in:
twinaphex 2013-01-30 18:07:04 +01:00
parent 0fb902cc47
commit 630608a7fc
3 changed files with 13 additions and 6 deletions

View File

@ -32,6 +32,7 @@
static unsigned pads_connected;
static int state_device_ids[MAX_PADS];
static int back_exits[MAX_PADS];
static uint64_t state[MAX_PADS];
struct input_pointer
@ -119,14 +120,18 @@ static void android_input_poll(void *data)
{
state_id = pads_connected;
state_device_ids[pads_connected++] = id;
bool back_exit = true;
input_autodetect_setup(android_app, msg, sizeof(msg), state_id, id, source);
input_autodetect_setup(android_app, msg, sizeof(msg), state_id, id, source, &back_exit);
long_msg_enable = true;
back_exits[state_id] = back_exit;
}
if (keycode == AKEYCODE_BACK && (source & (AINPUT_SOURCE_KEYBOARD)))
if (keycode == AKEYCODE_BACK)
{
*lifecycle_state |= (1ULL << RARCH_QUIT_KEY);
if (back_exits[state_id])
*lifecycle_state |= (1ULL << RARCH_QUIT_KEY);
AInputQueue_finishEvent(android_app->inputQueue, event, handled);
break;
}

View File

@ -96,7 +96,7 @@ void input_autodetect_init (void)
}
}
void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned port, unsigned id, int source)
void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned port, unsigned id, int source, bool *back_exits)
{
struct android_app *android_app = (struct android_app*)data;
// Hack - we have to add '1' to the bit mask here because
@ -364,6 +364,7 @@ void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned
keycode_lut[AKEYCODE_BACK] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
keycode_lut[AKEYCODE_BUTTON_THUMBL] |= ((RETRO_DEVICE_ID_JOYPAD_L3+1) << shift);
keycode_lut[AKEYCODE_BUTTON_THUMBR] |= ((RETRO_DEVICE_ID_JOYPAD_R3+1) << shift);
*back_exits = false;
}
else if (strstr(name_buf, "USB,2-axis 8-button gamepad") ||
strstr(name_buf, "BUFFALO BGC-FC801"))
@ -496,6 +497,7 @@ void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned
/* Xperia Play */
/* TODO: menu button */
/* Menu : 82 */
*back_exits = false;
keycode_lut[AKEYCODE_DPAD_CENTER] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
keycode_lut[AKEYCODE_BACK] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
keycode_lut[AKEYCODE_BUTTON_X] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
@ -519,6 +521,7 @@ void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned
* RStick Right: 40 */
/* Red Samurai */
*back_exits = false;
keycode_lut[AKEYCODE_W] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
keycode_lut[AKEYCODE_S] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
keycode_lut[AKEYCODE_A] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
@ -709,7 +712,6 @@ void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned
keycode_lut[AKEYCODE_F9] |= ((RARCH_MUTE+1) << shift);
keycode_lut[AKEYCODE_ESCAPE] |= ((RARCH_QUIT_KEY+1) << shift);
keycode_lut[AKEYCODE_BACK] |= ((RARCH_QUIT_KEY+1) << shift);
}
}

View File

@ -64,6 +64,6 @@ extern uint64_t keycode_lut[LAST_KEYCODE];
extern bool volume_enable;
void input_autodetect_init (void);
void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned port, unsigned id, int source);
void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned port, unsigned id, int source, bool *back_exit);
#endif