mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-26 05:16:18 +00:00
(Wii) Add pad autodetection if g_settings.input.autodetect_enable is
set to true - Wiimote + attachment is leading in case both a GC pad and a Wiimote are on the same port
This commit is contained in:
parent
ee18da7632
commit
0f9310543e
@ -147,6 +147,7 @@ static void gx_input_set_keybinds(void *data, unsigned device, unsigned port,
|
||||
size_t arr_size = sizeof(platform_keys) / sizeof(platform_keys[0]);
|
||||
|
||||
(void)device;
|
||||
(void)data;
|
||||
|
||||
if (keybind_action & (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BIND))
|
||||
*key = g_settings.input.binds[port][id].def_joykey;
|
||||
@ -310,6 +311,43 @@ static void gx_input_poll(void *data)
|
||||
uint32_t down = 0;
|
||||
uint64_t *state_cur = &gx->pad_state[port];
|
||||
|
||||
if (SI_GetType(port) & SI_TYPE_GC)
|
||||
{
|
||||
down = PAD_ButtonsHeld(port);
|
||||
|
||||
*state_cur |= (down & PAD_BUTTON_A) ? GX_GC_A : 0;
|
||||
*state_cur |= (down & PAD_BUTTON_B) ? GX_GC_B : 0;
|
||||
*state_cur |= (down & PAD_BUTTON_X) ? GX_GC_X : 0;
|
||||
*state_cur |= (down & PAD_BUTTON_Y) ? GX_GC_Y : 0;
|
||||
*state_cur |= (down & PAD_BUTTON_UP) ? GX_GC_UP : 0;
|
||||
*state_cur |= (down & PAD_BUTTON_DOWN) ? GX_GC_DOWN : 0;
|
||||
*state_cur |= (down & PAD_BUTTON_LEFT) ? GX_GC_LEFT : 0;
|
||||
*state_cur |= (down & PAD_BUTTON_RIGHT) ? GX_GC_RIGHT : 0;
|
||||
*state_cur |= (down & PAD_BUTTON_START) ? GX_GC_START : 0;
|
||||
*state_cur |= (down & PAD_TRIGGER_Z) ? GX_GC_Z_TRIGGER : 0;
|
||||
*state_cur |= ((down & PAD_TRIGGER_L) || PAD_TriggerL(port) > 127) ? GX_GC_L_TRIGGER : 0;
|
||||
*state_cur |= ((down & PAD_TRIGGER_R) || PAD_TriggerR(port) > 127) ? GX_GC_R_TRIGGER : 0;
|
||||
|
||||
int16_t ls_x = (int16_t)PAD_StickX(port) * 256;
|
||||
int16_t ls_y = (int16_t)PAD_StickY(port) * -256;
|
||||
int16_t rs_x = (int16_t)PAD_SubStickX(port) * 256;
|
||||
int16_t rs_y = (int16_t)PAD_SubStickY(port) * -256;
|
||||
|
||||
gx->analog_state[port][RETRO_DEVICE_INDEX_ANALOG_LEFT][RETRO_DEVICE_ID_ANALOG_X] = ls_x;
|
||||
gx->analog_state[port][RETRO_DEVICE_INDEX_ANALOG_LEFT][RETRO_DEVICE_ID_ANALOG_Y] = ls_y;
|
||||
gx->analog_state[port][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_X] = rs_x;
|
||||
gx->analog_state[port][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_Y] = rs_y;
|
||||
|
||||
if ((*state_cur & (GX_GC_START | GX_GC_Z_TRIGGER | GX_GC_L_TRIGGER | GX_GC_R_TRIGGER)) == (GX_GC_START | GX_GC_Z_TRIGGER | GX_GC_L_TRIGGER | GX_GC_R_TRIGGER))
|
||||
*state_cur |= GX_WIIMOTE_HOME;
|
||||
|
||||
if (g_settings.input.autodetect_enable)
|
||||
{
|
||||
if (strcmp(g_settings.input.device_names[port], "Gamecube Controller") != 0)
|
||||
gx_input_set_keybinds(NULL, DEVICE_GAMECUBE, port, 0, (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HW_RVL
|
||||
uint32_t ptype = 0;
|
||||
uint32_t connected = WPAD_Probe(port, &ptype);
|
||||
@ -385,6 +423,12 @@ static void gx_input_poll(void *data)
|
||||
gx->analog_state[port][RETRO_DEVICE_INDEX_ANALOG_LEFT][RETRO_DEVICE_ID_ANALOG_Y] = ls_y;
|
||||
gx->analog_state[port][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_X] = rs_x;
|
||||
gx->analog_state[port][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_Y] = rs_y;
|
||||
|
||||
if (g_settings.input.autodetect_enable)
|
||||
{
|
||||
if (strcmp(g_settings.input.device_names[port], "Classic Controller") != 0)
|
||||
gx_input_set_keybinds(NULL, DEVICE_CLASSIC, port, 0, (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
|
||||
}
|
||||
}
|
||||
else if (ptype == WPAD_EXP_NUNCHUK)
|
||||
{
|
||||
@ -413,40 +457,24 @@ static void gx_input_poll(void *data)
|
||||
|
||||
gx->analog_state[port][RETRO_DEVICE_INDEX_ANALOG_LEFT][RETRO_DEVICE_ID_ANALOG_X] = x;
|
||||
gx->analog_state[port][RETRO_DEVICE_INDEX_ANALOG_LEFT][RETRO_DEVICE_ID_ANALOG_Y] = y;
|
||||
|
||||
if (g_settings.input.autodetect_enable)
|
||||
{
|
||||
if (strcmp(g_settings.input.device_names[port], "Wiimote + Nunchuk") != 0)
|
||||
gx_input_set_keybinds(NULL, DEVICE_NUNCHUK, port, 0, (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//no attachment, assume standalone Wiimote
|
||||
if (g_settings.input.autodetect_enable)
|
||||
{
|
||||
if (strcmp(g_settings.input.device_names[port], "Wiimote") != 0)
|
||||
gx_input_set_keybinds(NULL, DEVICE_WIIMOTE, port, 0, (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (SI_GetType(port) & SI_TYPE_GC)
|
||||
{
|
||||
down = PAD_ButtonsHeld(port);
|
||||
|
||||
*state_cur |= (down & PAD_BUTTON_A) ? GX_GC_A : 0;
|
||||
*state_cur |= (down & PAD_BUTTON_B) ? GX_GC_B : 0;
|
||||
*state_cur |= (down & PAD_BUTTON_X) ? GX_GC_X : 0;
|
||||
*state_cur |= (down & PAD_BUTTON_Y) ? GX_GC_Y : 0;
|
||||
*state_cur |= (down & PAD_BUTTON_UP) ? GX_GC_UP : 0;
|
||||
*state_cur |= (down & PAD_BUTTON_DOWN) ? GX_GC_DOWN : 0;
|
||||
*state_cur |= (down & PAD_BUTTON_LEFT) ? GX_GC_LEFT : 0;
|
||||
*state_cur |= (down & PAD_BUTTON_RIGHT) ? GX_GC_RIGHT : 0;
|
||||
*state_cur |= (down & PAD_BUTTON_START) ? GX_GC_START : 0;
|
||||
*state_cur |= (down & PAD_TRIGGER_Z) ? GX_GC_Z_TRIGGER : 0;
|
||||
*state_cur |= ((down & PAD_TRIGGER_L) || PAD_TriggerL(port) > 127) ? GX_GC_L_TRIGGER : 0;
|
||||
*state_cur |= ((down & PAD_TRIGGER_R) || PAD_TriggerR(port) > 127) ? GX_GC_R_TRIGGER : 0;
|
||||
|
||||
int16_t ls_x = (int16_t)PAD_StickX(port) * 256;
|
||||
int16_t ls_y = (int16_t)PAD_StickY(port) * -256;
|
||||
int16_t rs_x = (int16_t)PAD_SubStickX(port) * 256;
|
||||
int16_t rs_y = (int16_t)PAD_SubStickY(port) * -256;
|
||||
|
||||
gx->analog_state[port][RETRO_DEVICE_INDEX_ANALOG_LEFT][RETRO_DEVICE_ID_ANALOG_X] = ls_x;
|
||||
gx->analog_state[port][RETRO_DEVICE_INDEX_ANALOG_LEFT][RETRO_DEVICE_ID_ANALOG_Y] = ls_y;
|
||||
gx->analog_state[port][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_X] = rs_x;
|
||||
gx->analog_state[port][RETRO_DEVICE_INDEX_ANALOG_RIGHT][RETRO_DEVICE_ID_ANALOG_Y] = rs_y;
|
||||
|
||||
if ((*state_cur & (GX_GC_START | GX_GC_Z_TRIGGER | GX_GC_L_TRIGGER | GX_GC_R_TRIGGER)) == (GX_GC_START | GX_GC_Z_TRIGGER | GX_GC_L_TRIGGER | GX_GC_R_TRIGGER))
|
||||
*state_cur |= GX_WIIMOTE_HOME;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t *state_p1 = &gx->pad_state[0];
|
||||
|
Loading…
x
Reference in New Issue
Block a user