mirror of
https://github.com/libretro/beetle-pce-fast-libretro.git
synced 2024-11-23 07:50:03 +00:00
libretro: use input bitmask
This commit is contained in:
parent
d09673b2ac
commit
23a18c7b29
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 retro_input_state_t input_state_cb;
|
||||||
static double last_sound_rate;
|
static double last_sound_rate;
|
||||||
|
|
||||||
|
static bool libretro_supports_bitmasks = false;
|
||||||
|
|
||||||
static MDFN_Surface *surf;
|
static MDFN_Surface *surf;
|
||||||
|
|
||||||
static bool failed_init;
|
static bool failed_init;
|
||||||
@ -1155,6 +1157,9 @@ void retro_init(void)
|
|||||||
setting_last_scanline = 242;
|
setting_last_scanline = 242;
|
||||||
|
|
||||||
check_system_specs();
|
check_system_specs();
|
||||||
|
|
||||||
|
if (environ_cb(RETRO_ENVIRONMENT_GET_INPUT_BITMASKS, NULL))
|
||||||
|
libretro_supports_bitmasks = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void retro_reset(void)
|
void retro_reset(void)
|
||||||
@ -1491,6 +1496,9 @@ void retro_unload_game(void)
|
|||||||
|
|
||||||
static void update_input(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[] = { -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 };
|
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);
|
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
|
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++)
|
for (unsigned j = 0; j < MAX_PLAYERS; j++)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (input_type[j])
|
switch (input_type[j])
|
||||||
{
|
{
|
||||||
case RETRO_DEVICE_JOYPAD:
|
case RETRO_DEVICE_JOYPAD:
|
||||||
@ -1524,7 +1542,7 @@ static void update_input(void)
|
|||||||
// read normal inputs
|
// read normal inputs
|
||||||
for (unsigned i = 0; i < MAX_BUTTONS; i++)
|
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
|
// disable soft reset
|
||||||
if (disable_softreset == true)
|
if (disable_softreset == true)
|
||||||
@ -1724,6 +1742,8 @@ void retro_deinit()
|
|||||||
log_cb(RETRO_LOG_INFO, "[%s]: Estimated FPS: %.5f\n",
|
log_cb(RETRO_LOG_INFO, "[%s]: Estimated FPS: %.5f\n",
|
||||||
MEDNAFEN_CORE_NAME, (double)video_frames * 44100 / audio_frames);
|
MEDNAFEN_CORE_NAME, (double)video_frames * 44100 / audio_frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
libretro_supports_bitmasks = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned retro_get_region(void)
|
unsigned retro_get_region(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user