mirror of
https://github.com/libretro/RetroArch
synced 2025-04-01 13:20:43 +00:00
(Android) Cleanups to the way messages are passed and pushed for
debug input key reporting
This commit is contained in:
parent
9a8e6a6432
commit
aeebac522c
@ -86,6 +86,7 @@ static void android_input_poll(void *data)
|
||||
RARCH_PERFORMANCE_INIT(input_poll);
|
||||
RARCH_PERFORMANCE_START(input_poll);
|
||||
|
||||
bool debug_enable = g_settings.input.debug_enable;
|
||||
struct android_app* android_app = (struct android_app*)g_android;
|
||||
|
||||
g_extern.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));
|
||||
@ -98,6 +99,9 @@ static void android_input_poll(void *data)
|
||||
break;
|
||||
|
||||
int32_t handled = 1;
|
||||
int action = 0;
|
||||
char msg[128];
|
||||
msg[0] = 0;
|
||||
|
||||
int source = AInputEvent_getSource(event);
|
||||
int id = AInputEvent_getDeviceId(event);
|
||||
@ -115,12 +119,9 @@ static void android_input_poll(void *data)
|
||||
state_id = pads_connected;
|
||||
state_device_ids[pads_connected++] = id;
|
||||
|
||||
input_autodetect_setup(android_app, state_id, id, source);
|
||||
input_autodetect_setup(android_app, msg, sizeof(msg), state_id, id, source);
|
||||
}
|
||||
|
||||
int action = 0;
|
||||
char msg[128];
|
||||
|
||||
if (keycode == AKEYCODE_BACK && (source & (AINPUT_SOURCE_KEYBOARD)))
|
||||
{
|
||||
g_extern.lifecycle_state |= (1ULL << RARCH_QUIT_KEY);
|
||||
@ -169,12 +170,12 @@ static void android_input_poll(void *data)
|
||||
}
|
||||
}
|
||||
|
||||
if (g_settings.input.debug_enable)
|
||||
if (debug_enable)
|
||||
snprintf(msg, sizeof(msg), "Pad %d : x = %.2f, y = %.2f, src %d.\n", state_id, x, y, source);
|
||||
}
|
||||
else if (type_event == AINPUT_EVENT_TYPE_KEY)
|
||||
{
|
||||
if (g_settings.input.debug_enable)
|
||||
if (debug_enable)
|
||||
snprintf(msg, sizeof(msg), "Pad %d : %d, ac = %d, src = %d.\n", state_id, keycode, action, source);
|
||||
|
||||
/* Hack - we have to decrease the unpacked value by 1
|
||||
@ -203,7 +204,7 @@ static void android_input_poll(void *data)
|
||||
handled = 0;
|
||||
}
|
||||
|
||||
if (g_settings.input.debug_enable)
|
||||
if (msg[0] != 0)
|
||||
msg_queue_push(g_extern.msg_queue, msg, 0, 30);
|
||||
|
||||
AInputQueue_finishEvent(android_app->inputQueue, event, handled);
|
||||
|
@ -78,20 +78,18 @@ void input_autodetect_init (void)
|
||||
volume_enable = true;
|
||||
}
|
||||
|
||||
void input_autodetect_setup (void *data, unsigned port, unsigned id, int source)
|
||||
void input_autodetect_setup (void *data, char *msg, size_t sizeof_msg, unsigned port, unsigned id, int source)
|
||||
{
|
||||
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
|
||||
|
||||
char msg[128];
|
||||
char name_buf[256];
|
||||
msg[0] = name_buf[0] = 0;
|
||||
name_buf[0] = 0;
|
||||
|
||||
if (port > MAX_PADS)
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "Max number of pads reached.\n");
|
||||
msg_queue_push(g_extern.msg_queue, msg, 0, 30);
|
||||
snprintf(msg, sizeof_msg, "Max number of pads reached.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -111,7 +109,7 @@ void input_autodetect_setup (void *data, unsigned port, unsigned id, int source)
|
||||
{
|
||||
if (strstr(name_buf, "RumblePad 2"))
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: RumblePad 2.\n", port);
|
||||
snprintf(msg, sizeof_msg, "RetroPad #%d is: RumblePad 2.\n", port);
|
||||
keycode_lut[AKEYCODE_BUTTON_2] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||
keycode_lut[AKEYCODE_BUTTON_1] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
||||
keycode_lut[AKEYCODE_BUTTON_9] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
||||
@ -128,7 +126,7 @@ void input_autodetect_setup (void *data, unsigned port, unsigned id, int source)
|
||||
}
|
||||
else if (strstr(name_buf, "HuiJia USB GamePad"))
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: HuiJia USB Gamepad.\n", port);
|
||||
snprintf(msg, sizeof_msg, "RetroPad #%d is: HuiJia USB Gamepad.\n", port);
|
||||
keycode_lut[AKEYCODE_BUTTON_3] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||
keycode_lut[AKEYCODE_BUTTON_4] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
||||
keycode_lut[AKEYCODE_BUTTON_9] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
||||
@ -142,7 +140,7 @@ void input_autodetect_setup (void *data, unsigned port, unsigned id, int source)
|
||||
{
|
||||
if (strstr(name_buf, "Dual Strike"))
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: Sidewinder Dual Strike.\n", port);
|
||||
snprintf(msg, sizeof_msg, "RetroPad #%d is: Sidewinder Dual Strike.\n", port);
|
||||
keycode_lut[AKEYCODE_BUTTON_4] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||
keycode_lut[AKEYCODE_BUTTON_2] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
||||
keycode_lut[AKEYCODE_BUTTON_6] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
||||
@ -155,7 +153,7 @@ void input_autodetect_setup (void *data, unsigned port, unsigned id, int source)
|
||||
}
|
||||
else if (strstr(name_buf, "SideWinder"))
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: Sidewinder.\n", port);
|
||||
snprintf(msg, sizeof_msg, "RetroPad #%d is: Sidewinder.\n", port);
|
||||
keycode_lut[AKEYCODE_BUTTON_A] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||
keycode_lut[AKEYCODE_BUTTON_X] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
||||
keycode_lut[AKEYCODE_BUTTON_R2] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
||||
@ -172,7 +170,7 @@ void input_autodetect_setup (void *data, unsigned port, unsigned id, int source)
|
||||
}
|
||||
else if (strstr(name_buf, "WiseGroup") && strstr(name_buf, "Dual USB Joypad"))
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: WiseGroup PS2 to USB.\n", port);
|
||||
snprintf(msg, sizeof_msg, "RetroPad #%d is: WiseGroup PS2 to USB.\n", port);
|
||||
keycode_lut[AKEYCODE_BUTTON_3] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||
keycode_lut[AKEYCODE_BUTTON_4] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
||||
keycode_lut[AKEYCODE_BUTTON_10] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift);
|
||||
@ -189,7 +187,7 @@ void input_autodetect_setup (void *data, unsigned port, unsigned id, int source)
|
||||
else if (strstr(name_buf, "PLAYSTATION(R)3") || strstr(name_buf, "Dualshock3")
|
||||
|| strstr(name_buf,"Sixaxis"))
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: DualShock3/Sixaxis.\n", port);
|
||||
snprintf(msg, sizeof_msg, "RetroPad #%d is: DualShock3/Sixaxis.\n", port);
|
||||
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);
|
||||
@ -210,7 +208,7 @@ void input_autodetect_setup (void *data, unsigned port, unsigned id, int source)
|
||||
}
|
||||
else if (strstr(name_buf, "MOGA"))
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: MOGA.\n", port);
|
||||
snprintf(msg, sizeof_msg, "RetroPad #%d is: MOGA.\n", port);
|
||||
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);
|
||||
@ -227,7 +225,7 @@ void input_autodetect_setup (void *data, unsigned port, unsigned id, int source)
|
||||
}
|
||||
else if (strstr(name_buf, "Sony Navigation Controller"))
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: PS Move Navi.\n", port);
|
||||
snprintf(msg, sizeof_msg, "RetroPad #%d is: PS Move Navi.\n", port);
|
||||
keycode_lut[AKEYCODE_BUTTON_7] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||
keycode_lut[AKEYCODE_BUTTON_8] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
||||
keycode_lut[AKEYCODE_BUTTON_5] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
||||
@ -242,7 +240,7 @@ void input_autodetect_setup (void *data, unsigned port, unsigned id, int source)
|
||||
}
|
||||
else if (strstr(name_buf, "CYPRESS USB"))
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: Saturn USB.\n", port);
|
||||
snprintf(msg, sizeof_msg, "RetroPad #%d is: Saturn USB.\n", port);
|
||||
keycode_lut[AKEYCODE_BUTTON_A] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift);
|
||||
keycode_lut[AKEYCODE_BUTTON_B] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift);
|
||||
keycode_lut[AKEYCODE_BUTTON_C] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift);
|
||||
@ -255,7 +253,7 @@ void input_autodetect_setup (void *data, unsigned port, unsigned id, int source)
|
||||
}
|
||||
else if (strstr(name_buf, "Mayflash Wii Classic"))
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: Mayflash Wii Classic.\n", port);
|
||||
snprintf(msg, sizeof_msg, "RetroPad #%d is: Mayflash Wii Classic.\n", port);
|
||||
g_settings.input.dpad_emulation[port] = DPAD_EMULATION_NONE;
|
||||
keycode_lut[AKEYCODE_BUTTON_12] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
|
||||
keycode_lut[AKEYCODE_BUTTON_14] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift);
|
||||
@ -274,7 +272,7 @@ void input_autodetect_setup (void *data, unsigned port, unsigned id, int source)
|
||||
}
|
||||
else if (strstr(name_buf, "Toodles 2008 ChImp"))
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: Chimp Board.\n", port);
|
||||
snprintf(msg, sizeof_msg, "RetroPad #%d is: Chimp Board.\n", port);
|
||||
keycode_lut[AKEYCODE_BUTTON_A] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift);
|
||||
keycode_lut[AKEYCODE_BUTTON_X] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift);
|
||||
keycode_lut[AKEYCODE_BUTTON_Z] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift);
|
||||
@ -289,7 +287,7 @@ void input_autodetect_setup (void *data, unsigned port, unsigned id, int source)
|
||||
else if (strstr(name_buf, "keypad-game-zeus"))
|
||||
{
|
||||
volume_enable = false;
|
||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: Xperia Play.\n", port);
|
||||
snprintf(msg, sizeof_msg, "RetroPad #%d is: Xperia Play.\n", port);
|
||||
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);
|
||||
@ -306,7 +304,7 @@ void input_autodetect_setup (void *data, unsigned port, unsigned id, int source)
|
||||
if (strstr(current_ime, "com.ccpcreations.android.WiiUseAndroid"))
|
||||
{
|
||||
// Player 1
|
||||
snprintf(msg, sizeof(msg), "RetroPad #%d, %d, %d, %d is: Wiimote (IME).\n",
|
||||
snprintf(msg, sizeof_msg, "RetroPad #%d, %d, %d, %d is: Wiimote (IME).\n",
|
||||
port, port + 1, port + 2, port + 3);
|
||||
snprintf(name_buf, sizeof(name_buf), "ccpcreations WiiUse");
|
||||
g_settings.input.dpad_emulation[port] = DPAD_EMULATION_NONE;
|
||||
@ -412,7 +410,7 @@ void input_autodetect_setup (void *data, unsigned port, unsigned id, int source)
|
||||
}
|
||||
else if (strstr(current_ime, "SixaxisIME"))
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: SixAxis Bluetooth (IME).\n", port);
|
||||
snprintf(msg, sizeof_msg, "RetroPad #%d is: SixAxis Bluetooth (IME).\n", port);
|
||||
snprintf(name_buf, sizeof(name_buf), "dancingpixelstudios.SixAxis");
|
||||
g_settings.input.dpad_emulation[port] = DPAD_EMULATION_NONE;
|
||||
keycode_lut[AKEYCODE_DPAD_UP] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift);
|
||||
@ -435,15 +433,15 @@ void input_autodetect_setup (void *data, unsigned port, unsigned id, int source)
|
||||
}
|
||||
else if (source == AINPUT_SOURCE_TOUCHSCREEN)
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: Touchscreen.\n", port);
|
||||
snprintf(msg, sizeof_msg, "RetroPad #%d is: Touchscreen.\n", port);
|
||||
}
|
||||
else if (source == AINPUT_SOURCE_MOUSE)
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: Mouse.\n", port);
|
||||
snprintf(msg, sizeof_msg, "RetroPad #%d is: Mouse.\n", port);
|
||||
}
|
||||
else if (source == AINPUT_SOURCE_KEYBOARD)
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "RetroPad #%d is: Keyboard.\n", port);
|
||||
snprintf(msg, sizeof_msg, "RetroPad #%d is: Keyboard.\n", port);
|
||||
// Keyboard
|
||||
// TODO: Map L2/R2/L3/R3
|
||||
|
||||
@ -481,14 +479,6 @@ void input_autodetect_setup (void *data, unsigned port, unsigned id, int source)
|
||||
if (name_buf[0] != 0)
|
||||
RARCH_LOG("Device %d: %s, port: %d.\n", id, name_buf, port);
|
||||
|
||||
unsigned timeout_val = 30;
|
||||
|
||||
if (msg[0] == 0 && name_buf[0] != 0)
|
||||
{
|
||||
snprintf(msg, sizeof(msg), "HID [%s] unbound.\n", name_buf);
|
||||
timeout_val = 120;
|
||||
}
|
||||
|
||||
if (msg[0] != 0)
|
||||
msg_queue_push(g_extern.msg_queue, msg, 0, timeout_val);
|
||||
snprintf(msg, sizeof_msg, "HID [%s] unbound.\n", name_buf);
|
||||
}
|
||||
|
@ -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, unsigned 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