mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 12:05:14 -04:00
Process input from controllers past the first in some consoles
This commit is contained in:
parent
35ad6372ff
commit
3b0e842ede
@ -245,13 +245,16 @@ void Window_ProcessGamepads(double delta) {
|
|||||||
maple_device_t* cont;
|
maple_device_t* cont;
|
||||||
cont_state_t* state;
|
cont_state_t* state;
|
||||||
|
|
||||||
cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER);
|
for (int port = 0; port < INPUT_MAX_GAMEPADS; port++)
|
||||||
if (!cont) return;
|
{
|
||||||
state = (cont_state_t*)maple_dev_status(cont);
|
cont = maple_enum_type(port, MAPLE_FUNC_CONTROLLER);
|
||||||
if (!state) return;
|
if (!cont) return;
|
||||||
|
state = (cont_state_t*)maple_dev_status(cont);
|
||||||
HandleButtons(0, state->buttons);
|
if (!state) return;
|
||||||
HandleController(0, state, delta);
|
|
||||||
|
HandleButtons(port, state->buttons);
|
||||||
|
HandleController(port, state, delta);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ void Window_RequestClose(void) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*---------------------------------------------GameCube controller processing----------------------------------------------*
|
*---------------------------------------------GameCube controller processing----------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static PADStatus gc_pad;
|
static PADStatus gc_pads[INPUT_MAX_GAMEPADS];
|
||||||
|
|
||||||
#define PAD_AXIS_SCALE 8.0f
|
#define PAD_AXIS_SCALE 8.0f
|
||||||
static void ProcessPAD_Joystick(int port, int axis, int x, int y, double delta) {
|
static void ProcessPAD_Joystick(int port, int axis, int x, int y, double delta) {
|
||||||
@ -115,8 +115,7 @@ static void ProcessPAD_Joystick(int port, int axis, int x, int y, double delta)
|
|||||||
Gamepad_SetAxis(port, axis, x / PAD_AXIS_SCALE, -y / PAD_AXIS_SCALE, delta);
|
Gamepad_SetAxis(port, axis, x / PAD_AXIS_SCALE, -y / PAD_AXIS_SCALE, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ProcessPAD_Buttons(int port) {
|
static void ProcessPAD_Buttons(int port, int mods) {
|
||||||
int mods = gc_pad.button;
|
|
||||||
Gamepad_SetButton(port, CCPAD_L, mods & PAD_TRIGGER_L);
|
Gamepad_SetButton(port, CCPAD_L, mods & PAD_TRIGGER_L);
|
||||||
Gamepad_SetButton(port, CCPAD_R, mods & PAD_TRIGGER_R);
|
Gamepad_SetButton(port, CCPAD_R, mods & PAD_TRIGGER_R);
|
||||||
|
|
||||||
@ -134,22 +133,22 @@ static void ProcessPAD_Buttons(int port) {
|
|||||||
Gamepad_SetButton(port, CCPAD_DOWN, mods & PAD_BUTTON_DOWN);
|
Gamepad_SetButton(port, CCPAD_DOWN, mods & PAD_BUTTON_DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ProcessPADInput(double delta) {
|
static void ProcessPADInput(int port, double delta) {
|
||||||
PADStatus pads[4];
|
PADStatus pads[4];
|
||||||
PAD_Read(pads);
|
PAD_Read(pads);
|
||||||
int error = pads[0].err;
|
int error = pads[port].err;
|
||||||
|
|
||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
gc_pad = pads[0]; // new state arrived
|
gc_pads[port] = pads[port]; // new state arrived
|
||||||
} else if (error == PAD_ERR_TRANSFER) {
|
} else if (error == PAD_ERR_TRANSFER) {
|
||||||
// usually means still busy transferring state - use last state
|
// usually means still busy transferring state - use last state
|
||||||
} else {
|
} else {
|
||||||
return; // not connected, still busy, etc
|
return; // not connected, still busy, etc
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessPAD_Buttons(0);
|
ProcessPAD_Buttons(0, gc_pads[port].button);
|
||||||
ProcessPAD_Joystick(0, PAD_AXIS_LEFT, gc_pad.stickX, gc_pad.stickY, delta);
|
ProcessPAD_Joystick(0, PAD_AXIS_LEFT, gc_pads[port].stickX, gc_pads[port].stickY, delta);
|
||||||
ProcessPAD_Joystick(0, PAD_AXIS_RIGHT, gc_pad.substickX, gc_pad.substickY, delta);
|
ProcessPAD_Joystick(0, PAD_AXIS_RIGHT, gc_pads[port].substickX, gc_pads[port].substickY, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -398,33 +397,39 @@ static void ProcessClassicInput(int port, double delta) {
|
|||||||
ProcessClassic_Joystick(port, PAD_AXIS_RIGHT, &ctrls.rjs, delta);
|
ProcessClassic_Joystick(port, PAD_AXIS_RIGHT, &ctrls.rjs, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ProcessWPADInput(double delta) {
|
static void ProcessWPADInput(int port, double delta) {
|
||||||
WPAD_ScanPads();
|
WPAD_ScanPads();
|
||||||
u32 mods = WPAD_ButtonsDown(0) | WPAD_ButtonsHeld(0);
|
|
||||||
u32 type;
|
u32 type;
|
||||||
int res = WPAD_Probe(0, &type);
|
int res = WPAD_Probe(port, &type);
|
||||||
if (res) return;
|
if (res) return;
|
||||||
|
u32 mods = WPAD_ButtonsDown(port) | WPAD_ButtonsHeld(port);
|
||||||
|
|
||||||
if (type == WPAD_EXP_CLASSIC) {
|
if (type == WPAD_EXP_CLASSIC) {
|
||||||
ProcessClassicInput(0, delta);
|
ProcessClassicInput(port, delta);
|
||||||
} else if (launcherMode) {
|
} else if (launcherMode) {
|
||||||
ProcessWPAD_Buttons(0, mods);
|
ProcessWPAD_Buttons(port, mods);
|
||||||
} else if (type == WPAD_EXP_NUNCHUK) {
|
} else if (type == WPAD_EXP_NUNCHUK) {
|
||||||
ProcessNunchuck_Game(0, mods, delta);
|
ProcessNunchuck_Game(port, mods, delta);
|
||||||
} else {
|
} else {
|
||||||
ProcessWPAD_Buttons(0, mods);
|
ProcessWPAD_Buttons(port, mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessWPADDrag(res, mods);
|
ProcessWPADDrag(res, mods);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_ProcessGamepads(double delta) {
|
void Window_ProcessGamepads(double delta) {
|
||||||
ProcessWPADInput(delta);
|
for (int port = 0; port < INPUT_MAX_GAMEPADS; port++)
|
||||||
ProcessPADInput(delta);
|
{
|
||||||
|
ProcessWPADInput(port, delta);
|
||||||
|
ProcessPADInput( port, delta);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void Window_ProcessGamepads(double delta) {
|
void Window_ProcessGamepads(double delta) {
|
||||||
ProcessPADInput(delta);
|
for (int port = 0; port < INPUT_MAX_GAMEPADS; port++)
|
||||||
|
{
|
||||||
|
ProcessPADInput(port, delta);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -114,15 +114,20 @@ static void ProcessAnalogInput(int port, joypad_inputs_t* inputs, double delta)
|
|||||||
int y = inputs->stick_y;
|
int y = inputs->stick_y;
|
||||||
|
|
||||||
if (Math_AbsI(x) <= 8) x = 0;
|
if (Math_AbsI(x) <= 8) x = 0;
|
||||||
if (Math_AbsI(y) <= 8) y = 0;
|
if (Math_AbsI(y) <= 8) y = 0;
|
||||||
|
|
||||||
Gamepad_SetAxis(port, PAD_AXIS_RIGHT, x / AXIS_SCALE, -y / AXIS_SCALE, delta);
|
Gamepad_SetAxis(port, PAD_AXIS_RIGHT, x / AXIS_SCALE, -y / AXIS_SCALE, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window_ProcessGamepads(double delta) {
|
void Window_ProcessGamepads(double delta) {
|
||||||
joypad_inputs_t inputs = joypad_get_inputs(JOYPAD_PORT_1);
|
for (int port = 0; port < INPUT_MAX_GAMEPADS; port++)
|
||||||
HandleButtons(0, inputs.btn);
|
{
|
||||||
ProcessAnalogInput(0, &inputs, delta);
|
if (!joypad_is_connected(port)) continue;
|
||||||
|
|
||||||
|
joypad_inputs_t inputs = joypad_get_inputs(port);
|
||||||
|
HandleButtons(port, inputs.btn);
|
||||||
|
ProcessAnalogInput(port, &inputs, delta);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -304,9 +304,12 @@ static void ProcessPadInput(int port, double delta, padData* pad) {
|
|||||||
|
|
||||||
void Window_ProcessGamepads(double delta) {
|
void Window_ProcessGamepads(double delta) {
|
||||||
ioPadGetInfo(&pad_info);
|
ioPadGetInfo(&pad_info);
|
||||||
if (pad_info.status[0]) {
|
for (int port = 0; port < INPUT_MAX_GAMEPADS; port++)
|
||||||
ioPadGetData(0, &pad_data);
|
{
|
||||||
ProcessPadInput(0, delta, &pad_data);
|
if (!pad_info.status[port]) continue;
|
||||||
|
|
||||||
|
ioPadGetData(port, &pad_data);
|
||||||
|
ProcessPadInput(port, delta, &pad_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user