Implement libretro input bitmask
This commit is contained in:
parent
109573dea6
commit
25fefc1b3d
|
@ -63,6 +63,7 @@ static bool option_showAdvancedOptions = false;
|
||||||
static double option_sndFiltering = 0.5;
|
static double option_sndFiltering = 0.5;
|
||||||
static unsigned option_gbPalette = 0;
|
static unsigned option_gbPalette = 0;
|
||||||
static bool option_lcdfilter = false;
|
static bool option_lcdfilter = false;
|
||||||
|
|
||||||
// filters
|
// filters
|
||||||
static IFBFilterFunc ifb_filter_func = NULL;
|
static IFBFilterFunc ifb_filter_func = NULL;
|
||||||
|
|
||||||
|
@ -71,6 +72,7 @@ static unsigned systemWidth = gbaWidth;
|
||||||
static unsigned systemHeight = gbaHeight;
|
static unsigned systemHeight = gbaHeight;
|
||||||
static EmulatedSystem* core = NULL;
|
static EmulatedSystem* core = NULL;
|
||||||
static IMAGE_TYPE type = IMAGE_UNKNOWN;
|
static IMAGE_TYPE type = IMAGE_UNKNOWN;
|
||||||
|
static bool libretro_supports_bitmasks = false;
|
||||||
|
|
||||||
// global vars
|
// global vars
|
||||||
uint16_t systemColorMap16[0x10000];
|
uint16_t systemColorMap16[0x10000];
|
||||||
|
@ -643,6 +645,12 @@ void retro_init(void)
|
||||||
rumble_cb = rumble.set_rumble_state;
|
rumble_cb = rumble.set_rumble_state;
|
||||||
else
|
else
|
||||||
rumble_cb = NULL;
|
rumble_cb = NULL;
|
||||||
|
|
||||||
|
if (environ_cb(RETRO_ENVIRONMENT_GET_INPUT_BITMASKS, NULL))
|
||||||
|
{
|
||||||
|
libretro_supports_bitmasks = true;
|
||||||
|
log_cb(RETRO_LOG_INFO, "SET_SUPPORT_INPUT_BITMASK: yes\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *gbGetCartridgeType(void)
|
static const char *gbGetCartridgeType(void)
|
||||||
|
@ -978,6 +986,7 @@ void retro_deinit(void)
|
||||||
emulating = 0;
|
emulating = 0;
|
||||||
core->emuCleanUp();
|
core->emuCleanUp();
|
||||||
soundShutdown();
|
soundShutdown();
|
||||||
|
libretro_supports_bitmasks = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void retro_reset(void)
|
void retro_reset(void)
|
||||||
|
@ -1414,6 +1423,7 @@ void updateInput_SolarSensor(void)
|
||||||
static void updateInput_Joypad(void)
|
static void updateInput_Joypad(void)
|
||||||
{
|
{
|
||||||
unsigned max_buttons = MAX_BUTTONS - ((type == IMAGE_GB) ? 2 : 0); // gb only has 8 buttons
|
unsigned max_buttons = MAX_BUTTONS - ((type == IMAGE_GB) ? 2 : 0); // gb only has 8 buttons
|
||||||
|
int16_t inbuf = 0;
|
||||||
|
|
||||||
for (unsigned port = 0; port < MAX_PLAYERS; port++)
|
for (unsigned port = 0; port < MAX_PLAYERS; port++)
|
||||||
{
|
{
|
||||||
|
@ -1421,8 +1431,16 @@ static void updateInput_Joypad(void)
|
||||||
input_buf[port] = 0;
|
input_buf[port] = 0;
|
||||||
|
|
||||||
if (retropad_device[port] == RETRO_DEVICE_JOYPAD) {
|
if (retropad_device[port] == RETRO_DEVICE_JOYPAD) {
|
||||||
|
if (libretro_supports_bitmasks)
|
||||||
|
inbuf = input_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_MASK);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (int i = 0; i < (RETRO_DEVICE_ID_JOYPAD_R3 + 1); i++)
|
||||||
|
inbuf |= input_cb(0, RETRO_DEVICE_JOYPAD, 0, i) ? (1 << i) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (unsigned button = 0; button < max_buttons; button++)
|
for (unsigned button = 0; button < max_buttons; button++)
|
||||||
input_buf[port] |= input_cb(port, RETRO_DEVICE_JOYPAD, 0, binds[button]) << button;
|
input_buf[port] |= (inbuf & (1 << binds[button])) ? (1 << button) : 0;
|
||||||
|
|
||||||
if (option_turboEnable) {
|
if (option_turboEnable) {
|
||||||
/* Handle Turbo A & B buttons */
|
/* Handle Turbo A & B buttons */
|
||||||
|
|
Loading…
Reference in New Issue