mirror of
https://github.com/libretro/RetroArch
synced 2025-01-27 03:35:22 +00:00
Revert "(Android) touchpad is now always first controller"
This reverts commit 5bc5195bc48a7ed85f89b43db9c9dbd6a2bc2dec. Conflicts: android/native/jni/input_android.c
This commit is contained in:
parent
15f79f78a1
commit
6638ee1257
@ -33,6 +33,7 @@
|
||||
static unsigned pads_connected;
|
||||
static int state_device_ids[MAX_PADS];
|
||||
static uint64_t state[MAX_PADS];
|
||||
static bool ignore_p1_back;
|
||||
|
||||
struct input_pointer
|
||||
{
|
||||
@ -107,42 +108,32 @@ static void android_input_poll(void *data)
|
||||
|
||||
int source = AInputEvent_getSource(event);
|
||||
int id = AInputEvent_getDeviceId(event);
|
||||
if (id == zeus_second_id)
|
||||
id = zeus_id;
|
||||
int keycode = AKeyEvent_getKeyCode(event);
|
||||
|
||||
int type_event = AInputEvent_getType(event);
|
||||
int state_id = -1;
|
||||
|
||||
if (source & (AINPUT_SOURCE_TOUCHSCREEN | AINPUT_SOURCE_MOUSE | AINPUT_SOURCE_TOUCHPAD | AINPUT_SOURCE_KEYBOARD))
|
||||
state_id = 0; // touch overlay is always player 1, AINPUT_SOURCE_KEYBOARD is for phone hardware keys
|
||||
else
|
||||
{
|
||||
for (unsigned i = 0; i < pads_connected; i++)
|
||||
if (state_device_ids[i] == id)
|
||||
state_id = i;
|
||||
}
|
||||
for (unsigned i = 0; i < pads_connected; i++)
|
||||
if (state_device_ids[i] == id)
|
||||
state_id = i;
|
||||
|
||||
if (state_id < 0)
|
||||
{
|
||||
state_id = pads_connected;
|
||||
state_device_ids[pads_connected++] = id;
|
||||
|
||||
if (input_autodetect_setup(android_app, msg, sizeof(msg), &state_id, id, source))
|
||||
pads_connected--;
|
||||
else
|
||||
long_msg_enable = true;
|
||||
input_autodetect_setup(android_app, msg, sizeof(msg), state_id, id, source);
|
||||
long_msg_enable = true;
|
||||
|
||||
if (state_id == 0)
|
||||
ignore_p1_back = (keycode_lut[AKEYCODE_BACK] != 0);
|
||||
}
|
||||
|
||||
if (type_event == AINPUT_EVENT_TYPE_KEY && keycode == AKEYCODE_BACK)
|
||||
if (keycode == AKEYCODE_BACK && (!ignore_p1_back || state_id != 0))
|
||||
{
|
||||
int meta = AKeyEvent_getMetaState(event);
|
||||
if (meta == AMETA_NONE)
|
||||
{
|
||||
*lifecycle_state |= (1ULL << RARCH_QUIT_KEY);
|
||||
AInputQueue_finishEvent(android_app->inputQueue, event, handled);
|
||||
break;
|
||||
}
|
||||
*lifecycle_state |= (1ULL << RARCH_QUIT_KEY);
|
||||
AInputQueue_finishEvent(android_app->inputQueue, event, handled);
|
||||
break;
|
||||
}
|
||||
else if(type_event == AINPUT_EVENT_TYPE_MOTION && (g_settings.input.dpad_emulation[state_id] != DPAD_EMULATION_NONE))
|
||||
{
|
||||
@ -223,7 +214,7 @@ static void android_input_poll(void *data)
|
||||
*key |= input_state;
|
||||
}
|
||||
|
||||
if((keycode == AKEYCODE_VOLUME_UP || keycode == AKEYCODE_VOLUME_DOWN) && keycode_lut[keycode] == 0)
|
||||
if(volume_enable && (keycode == AKEYCODE_VOLUME_UP || keycode == AKEYCODE_VOLUME_DOWN))
|
||||
handled = 0;
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,7 @@
|
||||
|
||||
uint64_t keycode_lut[LAST_KEYCODE];
|
||||
|
||||
int zeus_id = -1;
|
||||
int zeus_second_id = -1;
|
||||
bool volume_enable;
|
||||
|
||||
static void input_autodetect_get_device_name(void *data, char *buf, size_t size, int id)
|
||||
{
|
||||
@ -77,6 +76,8 @@ void input_autodetect_init (void)
|
||||
int j, k;
|
||||
for(j = 0; j < LAST_KEYCODE; j++)
|
||||
keycode_lut[j] = 0;
|
||||
|
||||
volume_enable = true;
|
||||
|
||||
if (g_settings.input.autodetect_enable)
|
||||
return;
|
||||
@ -95,9 +96,8 @@ void input_autodetect_init (void)
|
||||
}
|
||||
}
|
||||
|
||||
bool input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, int *port, unsigned id, int source)
|
||||
void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned port, unsigned id, int source)
|
||||
{
|
||||
bool ret = false;
|
||||
struct android_app *android_app = (struct android_app*)data;
|
||||
// Hack - we have to add '1' to the bit mask here because
|
||||
// RETRO_DEVICE_ID_JOYPAD_B is 0
|
||||
@ -105,17 +105,17 @@ bool input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, int *port
|
||||
char name_buf[256];
|
||||
name_buf[0] = 0;
|
||||
|
||||
if (*port > MAX_PADS)
|
||||
if (port > MAX_PADS)
|
||||
{
|
||||
snprintf(msg, sizeof_msg, "Max number of pads reached.\n");
|
||||
return ret;
|
||||
return;
|
||||
}
|
||||
|
||||
/* eight 8-bit values are packed into one uint64_t
|
||||
* one for each of the 8 pads */
|
||||
uint8_t shift = 8 + (*port * 8);
|
||||
uint8_t shift = 8 + (port * 8);
|
||||
|
||||
g_settings.input.dpad_emulation[*port] = DPAD_EMULATION_LSTICK;
|
||||
g_settings.input.dpad_emulation[port] = DPAD_EMULATION_LSTICK;
|
||||
|
||||
char *current_ime = android_app->current_ime;
|
||||
|
||||
@ -267,7 +267,7 @@ bool input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, int *port
|
||||
bool do_invert = (strstr(name_buf, "Gamepad 0") || strstr(name_buf, "Gamepad 1") ||
|
||||
strstr(name_buf, "Gamepad 2") || strstr(name_buf, "Gamepad 3"));
|
||||
|
||||
g_settings.input.dpad_emulation[*port] = DPAD_EMULATION_NONE;
|
||||
g_settings.input.dpad_emulation[port] = DPAD_EMULATION_NONE;
|
||||
keycode_lut[AKEYCODE_DPAD_UP] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
|
||||
keycode_lut[AKEYCODE_DPAD_DOWN] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
|
||||
keycode_lut[AKEYCODE_DPAD_LEFT] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
|
||||
@ -305,7 +305,7 @@ bool input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, int *port
|
||||
}
|
||||
else if (strstr(name_buf, "MOGA"))
|
||||
{
|
||||
g_settings.input.dpad_emulation[*port] = DPAD_EMULATION_NONE;
|
||||
g_settings.input.dpad_emulation[port] = DPAD_EMULATION_NONE;
|
||||
keycode_lut[AKEYCODE_DPAD_UP] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
|
||||
keycode_lut[AKEYCODE_DPAD_DOWN] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
|
||||
keycode_lut[AKEYCODE_DPAD_LEFT] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
|
||||
@ -410,7 +410,7 @@ bool input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, int *port
|
||||
else if (strstr(name_buf, "Mayflash Wii Classic") ||
|
||||
strstr(name_buf, "SZMy-power LTD CO. Dual Box WII"))
|
||||
{
|
||||
g_settings.input.dpad_emulation[*port] = DPAD_EMULATION_NONE;
|
||||
g_settings.input.dpad_emulation[port] = DPAD_EMULATION_NONE;
|
||||
|
||||
if (strstr(name_buf, "Mayflash Wii Classic"))
|
||||
{
|
||||
@ -491,17 +491,8 @@ bool input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, int *port
|
||||
}
|
||||
else if (strstr(name_buf, "keypad-game-zeus") || strstr(name_buf, "keypad-zeus"))
|
||||
{
|
||||
if (zeus_id < 0)
|
||||
{
|
||||
zeus_id = *port;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = true;
|
||||
zeus_second_id = *port;
|
||||
*port = zeus_id;
|
||||
shift = 8 + (*port * 8);
|
||||
}
|
||||
volume_enable = false;
|
||||
|
||||
/* Xperia Play */
|
||||
/* TODO: menu button */
|
||||
/* Menu : 82 */
|
||||
@ -585,7 +576,7 @@ bool input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, int *port
|
||||
|
||||
/* Wiimote (IME) */
|
||||
snprintf(name_buf, sizeof(name_buf), "ccpcreations WiiUse");
|
||||
g_settings.input.dpad_emulation[*port] = DPAD_EMULATION_NONE;
|
||||
g_settings.input.dpad_emulation[port] = DPAD_EMULATION_NONE;
|
||||
keycode_lut[AKEYCODE_DPAD_UP] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
|
||||
keycode_lut[AKEYCODE_DPAD_DOWN] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
|
||||
keycode_lut[AKEYCODE_DPAD_LEFT] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
|
||||
@ -616,6 +607,7 @@ bool input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, int *port
|
||||
|
||||
//player 2
|
||||
shift += 8;
|
||||
volume_enable = false;
|
||||
keycode_lut[AKEYCODE_I] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
|
||||
keycode_lut[AKEYCODE_K] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
|
||||
keycode_lut[AKEYCODE_J] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift);
|
||||
@ -721,7 +713,5 @@ bool input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, int *port
|
||||
}
|
||||
|
||||
if (name_buf[0] != 0)
|
||||
snprintf(msg, sizeof_msg, "HID %d: %s, p: %d.\n", id, name_buf, *port);
|
||||
|
||||
return ret;
|
||||
snprintf(msg, sizeof_msg, "HID %d: %s, p: %d.\n", id, name_buf, port);
|
||||
}
|
||||
|
@ -61,10 +61,9 @@ enum {
|
||||
#define LAST_KEYCODE AKEYCODE_ASSIST
|
||||
|
||||
extern uint64_t keycode_lut[LAST_KEYCODE];
|
||||
extern int zeus_id;
|
||||
extern int zeus_second_id;
|
||||
extern bool volume_enable;
|
||||
|
||||
void input_autodetect_init (void);
|
||||
bool input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, int *port, unsigned id, int source);
|
||||
void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned port, unsigned id, int source);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user