mirror of
https://github.com/libretro/beetle-pce-fast-libretro.git
synced 2024-11-27 01:50:21 +00:00
Merge pull request #161 from trioan/bitmask
libretro: use input bitmask
This commit is contained in:
commit
fc32584dc0
24
libretro.cpp
24
libretro.cpp
@ -1095,6 +1095,8 @@ static retro_input_poll_t input_poll_cb;
|
||||
static retro_input_state_t input_state_cb;
|
||||
static double last_sound_rate;
|
||||
|
||||
static bool libretro_supports_bitmasks = false;
|
||||
|
||||
static MDFN_Surface *surf;
|
||||
|
||||
static bool failed_init;
|
||||
@ -1155,6 +1157,9 @@ void retro_init(void)
|
||||
setting_last_scanline = 242;
|
||||
|
||||
check_system_specs();
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_INPUT_BITMASKS, NULL))
|
||||
libretro_supports_bitmasks = true;
|
||||
}
|
||||
|
||||
void retro_reset(void)
|
||||
@ -1491,6 +1496,9 @@ void retro_unload_game(void)
|
||||
|
||||
static void update_input(void)
|
||||
{
|
||||
unsigned i,j;
|
||||
int16_t joy_bits[MAX_PLAYERS] = {0};
|
||||
|
||||
static int turbo_map[] = { -1,-1,-1,-1,-1,-1,-1,-1, 1, 0,-1,-1,-1,-1,-1 };
|
||||
static int turbo_map_alt[] = { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 1, 0 };
|
||||
int *turbo_map_selected = (!turbo_toggle_alt ? turbo_map : turbo_map_alt);
|
||||
@ -1512,9 +1520,19 @@ static void update_input(void)
|
||||
RETRO_DEVICE_ID_JOYPAD_R3
|
||||
};
|
||||
|
||||
for (j = 0; j < MAX_PLAYERS; j++)
|
||||
{
|
||||
if (libretro_supports_bitmasks)
|
||||
joy_bits[j] = input_state_cb(j, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_MASK);
|
||||
else
|
||||
{
|
||||
for (i = 0; i < (RETRO_DEVICE_ID_JOYPAD_R3+1); i++)
|
||||
joy_bits[j] |= input_state_cb(j, RETRO_DEVICE_JOYPAD, 0, i) ? (1 << i) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned j = 0; j < MAX_PLAYERS; j++)
|
||||
{
|
||||
|
||||
switch (input_type[j])
|
||||
{
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
@ -1524,7 +1542,7 @@ static void update_input(void)
|
||||
// read normal inputs
|
||||
for (unsigned i = 0; i < MAX_BUTTONS; i++)
|
||||
{
|
||||
input_state |= input_state_cb(j, RETRO_DEVICE_JOYPAD, 0, map[i]) ? (1 << i) : 0;
|
||||
input_state |= (joy_bits[j] & (1 << map[i])) ? (1 << i) : 0;
|
||||
|
||||
// disable soft reset
|
||||
if (disable_softreset == true)
|
||||
@ -1724,6 +1742,8 @@ void retro_deinit()
|
||||
log_cb(RETRO_LOG_INFO, "[%s]: Estimated FPS: %.5f\n",
|
||||
MEDNAFEN_CORE_NAME, (double)video_frames * 44100 / audio_frames);
|
||||
}
|
||||
|
||||
libretro_supports_bitmasks = false;
|
||||
}
|
||||
|
||||
unsigned retro_get_region(void)
|
||||
|
Loading…
Reference in New Issue
Block a user