Change in handling overlapping button presses (fixes issue #824) (#907)

* Modifications to input handling to prevent held inputs from being
overridden by an alternate input mapped to the same button.
i.e. R-Type holding fire to charge special shot will not be
disrupted if a secondary fire button is pressed, autofire
or not.

* Modifications to input handling to prevent held inputs from being overridden by an alternate input mapped to the same button.
i.e. R-Type holding fire to charge special shot will not be
disrupted if a secondary fire button is pressed, autofire
or not.

* Prevent held inputs from being disrupted by alternate inputs.

i.e. in R-Type, if holding the fire button to charge a special shot,
tapping an alternately assigned fire button will not cause the charge
to stop.
This commit is contained in:
deepthaw
2024-06-30 02:02:49 -05:00
committed by GitHub
parent 6537cbb167
commit 03f62ded4c
3 changed files with 26 additions and 21 deletions

View File

@@ -1697,21 +1697,23 @@ void user_io_r_analog_joystick(unsigned char joystick, char valueX, char valueY)
}
}
void user_io_digital_joystick(unsigned char joystick, uint32_t map, int newdir)
void user_io_digital_joystick(unsigned char joystick, uint64_t map, int newdir)
{
uint8_t joy = (joystick>1 || !joyswap) ? joystick : joystick ^ 1;
static int use32 = 0;
use32 |= map >> 16;
// primary button mappings are in 31:0, alternate mappings are in 64:32.
// take the logical OR to ensure a held button isn't overriden
// by other mapping being pressed
uint32_t bitmask = (uint32_t)(map) | (uint32_t)(map >> 32);
use32 |= bitmask >> 16;
spi_uio_cmd_cont((joy < 2) ? (UIO_JOYSTICK0 + joy) : (UIO_JOYSTICK2 + joy - 2));
spi_w(map);
if(use32) spi_w(map >> 16);
spi_w(bitmask);
if(use32) spi_w(bitmask >> 16);
DisableIO();
if (!is_minimig() && joy_transl == 1 && newdir)
{
user_io_l_analog_joystick(joystick, (map & 2) ? 128 : (map & 1) ? 127 : 0, (map & 8) ? 128 : (map & 4) ? 127 : 0);
user_io_l_analog_joystick(joystick, (bitmask & 2) ? 128 : (bitmask & 1) ? 127 : 0, (bitmask & 8) ? 128 : (bitmask & 4) ? 127 : 0);
}
}