[Gamecube/Wii] added polling of all input ports for menu control

This commit is contained in:
ekeeke 2023-03-30 20:01:19 +02:00
parent aed9e6c5a3
commit 94399728b8
4 changed files with 61 additions and 34 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 MiB

After

Width:  |  Height:  |  Size: 3.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 MiB

After

Width:  |  Height:  |  Size: 4.0 MiB

View File

@ -3,7 +3,7 @@
* *
* Genesis Plus GX input support * Genesis Plus GX input support
* *
* Copyright Eke-Eke (2007-2022) * Copyright Eke-Eke (2007-2023)
* *
* Redistribution and use of this code or any derivative works are permitted * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met:
@ -1773,45 +1773,69 @@ void gx_input_UpdateMenu(void)
/* Check if inputs update are disabled */ /* Check if inputs update are disabled */
if (inputs_disabled) return; if (inputs_disabled) return;
int i;
s8 x, y;
u16 pp, hp;
#ifdef HW_RVL
u32 pw, hw, pwu, hwu;
#endif
/* PAD status update */ /* PAD status update */
PAD_ScanPads(); PAD_ScanPads();
/* PAD pressed keys */ /* Check all PAD ports */
s16 pp = PAD_ButtonsDown(0); for (i=0; i<4; i++)
{
/* PAD pressed keys */
pp = PAD_ButtonsDown(i);
/* PAD held keys (direction/selection) */ /* PAD held keys (direction/selection only) */
s16 hp = PAD_ButtonsHeld(0) & PAD_BUTTONS_HELD; hp = PAD_ButtonsHeld(i) & PAD_BUTTONS_HELD;
/* PAD analog sticks (handled as PAD held direction keys) */ /* PAD analog sticks (handled as held direction keys) */
s8 x = PAD_StickX(0); x = PAD_StickX(i);
s8 y = PAD_StickY(0); y = PAD_StickY(i);
if (x > ANALOG_SENSITIVITY) hp |= PAD_BUTTON_RIGHT; if (x > ANALOG_SENSITIVITY) hp |= PAD_BUTTON_RIGHT;
else if (x < -ANALOG_SENSITIVITY) hp |= PAD_BUTTON_LEFT; else if (x < -ANALOG_SENSITIVITY) hp |= PAD_BUTTON_LEFT;
else if (y > ANALOG_SENSITIVITY) hp |= PAD_BUTTON_UP; else if (y > ANALOG_SENSITIVITY) hp |= PAD_BUTTON_UP;
else if (y < -ANALOG_SENSITIVITY) hp |= PAD_BUTTON_DOWN; else if (y < -ANALOG_SENSITIVITY) hp |= PAD_BUTTON_DOWN;
/* Ignore other ports once first used PAD controlled is found */
if (pp || hp) break;
}
#ifdef HW_RVL #ifdef HW_RVL
/* WPAD status update */ /* WPAD status update */
WPAD_ScanPads(); WPAD_ScanPads();
WPADData *data = WPAD_Data(0);
/* WPAD pressed keys */ /* Check all WPAD ports */
u32 pw = data->btns_d; for (i=0; i<4; i++)
{
/* WPAD data */
WPADData *data = WPAD_Data(i);
/* WPAD held keys (direction/selection) */ /* WPAD pressed keys */
u32 hw = data->btns_h & WPAD_BUTTONS_HELD; pw = data->btns_d;
/* WPAD analog sticks (handled as PAD held direction keys) */ /* WPAD held keys (direction/selection only) */
x = wpad_StickX(data, 0); hw = data->btns_h & WPAD_BUTTONS_HELD;
y = wpad_StickY(data, 0);
if (x > ANALOG_SENSITIVITY) hp |= PAD_BUTTON_RIGHT;
else if (x < -ANALOG_SENSITIVITY) hp |= PAD_BUTTON_LEFT;
else if (y > ANALOG_SENSITIVITY) hp |= PAD_BUTTON_UP;
else if (y < -ANALOG_SENSITIVITY) hp |= PAD_BUTTON_DOWN;
/* WiiU GamePad status */ /* WPAD analog sticks (handled as held direction keys) */
u32 pwu = 0; x = wpad_StickX(data, i);
u32 hwu = 0; y = wpad_StickY(data, i);
if (x > ANALOG_SENSITIVITY) hw |= PAD_BUTTON_RIGHT;
else if (x < -ANALOG_SENSITIVITY) hw |= PAD_BUTTON_LEFT;
else if (y > ANALOG_SENSITIVITY) hw |= PAD_BUTTON_UP;
else if (y < -ANALOG_SENSITIVITY) hw |= PAD_BUTTON_DOWN;
/* Wiimote orientation */
WPAD_IR(i, &m_input.ir);
/* Ignore other ports once first used WPAD controller is found */
if (m_input.ir.valid || pw || hw) break;
}
/* Check WiiU GamePad status */
if (WiiDRC_Inited()) if (WiiDRC_Inited())
{ {
WiiDRC_ScanPads(); WiiDRC_ScanPads();
@ -1825,12 +1849,16 @@ void gx_input_UpdateMenu(void)
hwu = WiiDRC_ButtonsHeld() & WIIU_BUTTONS_HELD; hwu = WiiDRC_ButtonsHeld() & WIIU_BUTTONS_HELD;
x = WiiDRC_lStickX(); x = WiiDRC_lStickX();
y = WiiDRC_lStickY(); y = WiiDRC_lStickY();
if (x > ANALOG_SENSITIVITY) hp |= PAD_BUTTON_RIGHT; if (x > ANALOG_SENSITIVITY) hwu |= PAD_BUTTON_RIGHT;
else if (x < -ANALOG_SENSITIVITY) hp |= PAD_BUTTON_LEFT; else if (x < -ANALOG_SENSITIVITY) hwu |= PAD_BUTTON_LEFT;
else if (y > ANALOG_SENSITIVITY) hp |= PAD_BUTTON_UP; else if (y > ANALOG_SENSITIVITY) hwu |= PAD_BUTTON_UP;
else if (y < -ANALOG_SENSITIVITY) hp |= PAD_BUTTON_DOWN; else if (y < -ANALOG_SENSITIVITY) hwu |= PAD_BUTTON_DOWN;
}
else
{
pwu = 0;
hwu = 0;
} }
#endif #endif
/* check if any direction/selection key is being held or just being pressed/released */ /* check if any direction/selection key is being held or just being pressed/released */
@ -1860,7 +1888,6 @@ void gx_input_UpdateMenu(void)
#ifdef HW_RVL #ifdef HW_RVL
/* Wiimote & Classic Controller direction keys */ /* Wiimote & Classic Controller direction keys */
WPAD_IR(0, &m_input.ir);
if (m_input.ir.valid) if (m_input.ir.valid)
{ {
/* Wiimote is handled vertically */ /* Wiimote is handled vertically */

View File

@ -3,7 +3,7 @@
* *
* Genesis Plus GX input support * Genesis Plus GX input support
* *
* Copyright Eke-Eke (2007-2022) * Copyright Eke-Eke (2007-2023)
* *
* Redistribution and use of this code or any derivative works are permitted * Redistribution and use of this code or any derivative works are permitted
* provided that the following conditions are met: * provided that the following conditions are met: