Initial code for joystick port instancing

This commit is contained in:
Jasmine Iwanek
2025-01-10 18:42:09 -05:00
parent 3b29b769c3
commit ac891a05a5
12 changed files with 172 additions and 174 deletions

View File

@@ -62,23 +62,23 @@ ch_flightstick_pro_read(UNUSED(void *priv))
{
uint8_t ret = 0xf0;
if (JOYSTICK_PRESENT(0)) {
if (joystick_state[0].button[0])
if (JOYSTICK_PRESENT(0, 0)) {
if (joystick_state[0][0].button[0])
ret &= ~0x10;
if (joystick_state[0].button[1])
if (joystick_state[0][0].button[1])
ret &= ~0x20;
if (joystick_state[0].button[2])
if (joystick_state[0][0].button[2])
ret &= ~0x40;
if (joystick_state[0].button[3])
if (joystick_state[0][0].button[3])
ret &= ~0x80;
if (joystick_state[0].pov[0] != -1) {
if (joystick_state[0].pov[0] > 315 || joystick_state[0].pov[0] < 45)
if (joystick_state[0][0].pov[0] != -1) {
if (joystick_state[0][0].pov[0] > 315 || joystick_state[0][0].pov[0] < 45)
ret &= ~0xf0;
else if (joystick_state[0].pov[0] >= 45 && joystick_state[0].pov[0] < 135)
else if (joystick_state[0][0].pov[0] >= 45 && joystick_state[0][0].pov[0] < 135)
ret &= ~0xb0;
else if (joystick_state[0].pov[0] >= 135 && joystick_state[0].pov[0] < 225)
else if (joystick_state[0][0].pov[0] >= 135 && joystick_state[0][0].pov[0] < 225)
ret &= ~0x70;
else if (joystick_state[0].pov[0] >= 225 && joystick_state[0].pov[0] < 315)
else if (joystick_state[0][0].pov[0] >= 225 && joystick_state[0][0].pov[0] < 315)
ret &= ~0x30;
}
}
@@ -95,18 +95,18 @@ ch_flightstick_pro_write(UNUSED(void *priv))
static int
ch_flightstick_pro_read_axis(UNUSED(void *priv), int axis)
{
if (!JOYSTICK_PRESENT(0))
if (!JOYSTICK_PRESENT(0, 0))
return AXIS_NOT_PRESENT;
switch (axis) {
case 0:
return joystick_state[0].axis[0];
return joystick_state[0][0].axis[0];
case 1:
return joystick_state[0].axis[1];
return joystick_state[0][0].axis[1];
case 2:
return 0;
case 3:
return joystick_state[0].axis[2];
return joystick_state[0][0].axis[2];
default:
return 0;
}