diff --git a/CHANGES b/CHANGES index 73891e951..ccd8b7789 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,7 @@ Features: - Support for VBA-style cheat codes - Savestates now store creation timestamps - Key autofire + - Libretro: Allow blocking opposing directional input Bugfixes: - Util: Fix PowerPC PNG read/write pixel order - VFS: Fix VFileReadline and remove _vfdReadline diff --git a/src/platform/libretro/libretro.c b/src/platform/libretro/libretro.c index fa25825a3..ceca7b869 100644 --- a/src/platform/libretro/libretro.c +++ b/src/platform/libretro/libretro.c @@ -19,6 +19,7 @@ #define RUMBLE_PWM 35 #define SOLAR_SENSOR_LEVEL "mgba_solar_sensor_level" +#define ALLOW_OPPOSING_DIRECTIONS "mgba_allow_opposing_directions" static retro_environment_t environCallback; static retro_video_refresh_t videoCallback; @@ -58,6 +59,7 @@ void retro_set_environment(retro_environment_t env) { struct retro_variable vars[] = { { SOLAR_SENSOR_LEVEL, "Solar sensor level; 0|1|2|3|4|5|6|7|8|9|10" }, + { ALLOW_OPPOSING_DIRECTIONS, "Allow opposing directional input; no|yes" }, { 0, 0 } }; @@ -212,6 +214,18 @@ void retro_run(void) { uint16_t keys; inputPollCallback(); + struct retro_variable var = { + .key = ALLOW_OPPOSING_DIRECTIONS, + .value = 0 + }; + + bool updated = false; + if (environCallback(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated) { + if (environCallback(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { + context.gba->allowOpposingDirections = strcmp(var.value, "yes") == 0; + } + } + keys = 0; keys |= (!!inputCallback(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A)) << 0; keys |= (!!inputCallback(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B)) << 1;