all repos — mgba @ 5147a5160f1bb46590f19119e3ae424f1ee57fbf

mGBA Game Boy Advance Emulator

Libretro: Allow blocking opposing directional input
Jeffrey Pfau jeffrey@endrift.com
Tue, 29 Dec 2015 23:10:02 -0500
commit

5147a5160f1bb46590f19119e3ae424f1ee57fbf

parent

089e692bd1f18ef4ea687606903c8bcf9098b4be

2 files changed, 15 insertions(+), 0 deletions(-)

jump to
M CHANGESCHANGES

@@ -10,6 +10,7 @@ - ROM information view

- 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
M src/platform/libretro/libretro.csrc/platform/libretro/libretro.c

@@ -19,6 +19,7 @@ #define SAMPLES 1024

#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 @@ environCallback = 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 } };

@@ -211,6 +213,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;