Commit 3b9aecd0 authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Update - add new RETRO_ENVIRONMENT_GET_INPUT_BITMASKS

parent c794094a
......@@ -81,6 +81,7 @@ unsigned device_type = 0;
unsigned MEMSIZE_MB;
static struct retro_rumble_interface rumble;
static bool libretro_supports_bitmasks = false;
#if defined(HW_DOL)
#define DEFAULT_MEMSIZE_MB 8
......@@ -379,6 +380,9 @@ void retro_init(void)
else
log_cb = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_INPUT_BITMASKS, NULL))
libretro_supports_bitmasks = true;
Sys_Init();
}
......@@ -387,6 +391,8 @@ void retro_deinit(void)
Sys_Quit();
if (heap)
free(heap);
libretro_supports_bitmasks = false;
}
unsigned retro_api_version(void)
......@@ -541,14 +547,27 @@ void Sys_SendKeyEvents(void)
{
case RETRO_DEVICE_JOYPAD:
case RETRO_DEVICE_MODERN:
if (libretro_supports_bitmasks)
{
unsigned i;
int16_t ret = input_cb(port, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_MASK);
for (i=RETRO_DEVICE_ID_JOYPAD_B; i <= RETRO_DEVICE_ID_JOYPAD_R3; ++i)
{
if (ret & (1 << i))
Key_Event(K_JOY_B + i, 1);
else
Key_Event(K_JOY_B + i, 0);
}
}
else
{
unsigned i;
for (i=RETRO_DEVICE_ID_JOYPAD_B; i <= RETRO_DEVICE_ID_JOYPAD_R3; ++i)
{
if (input_cb(port, RETRO_DEVICE_JOYPAD, 0, i))
Key_Event(K_JOY_B + i, 1);
else
Key_Event(K_JOY_B + i, 0);
if (input_cb(port, RETRO_DEVICE_JOYPAD, 0, i))
Key_Event(K_JOY_B + i, 1);
else
Key_Event(K_JOY_B + i, 0);
}
}
break;
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment