aboutsummaryrefslogtreecommitdiff
path: root/frontend/libretro.c
diff options
context:
space:
mode:
authorSquarepusher2013-06-19 02:51:41 -0700
committerSquarepusher2013-06-19 02:51:41 -0700
commitcbe0561f7794ced67ba38d0aa0f118fca21e367d (patch)
tree4ad8faca77c9303bdcc14842979ef7814a421986 /frontend/libretro.c
parentc0adc1d662ed933b8d3369746fc7cf25736b1219 (diff)
parente88aeb509e02e532a2972acdf5acd84d33611eb2 (diff)
downloadpcsx_rearmed-cbe0561f7794ced67ba38d0aa0f118fca21e367d.tar.gz
pcsx_rearmed-cbe0561f7794ced67ba38d0aa0f118fca21e367d.tar.bz2
pcsx_rearmed-cbe0561f7794ced67ba38d0aa0f118fca21e367d.zip
Merge pull request #3 from meancoot/master
Add a core option to allow analog pads
Diffstat (limited to 'frontend/libretro.c')
-rw-r--r--frontend/libretro.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/frontend/libretro.c b/frontend/libretro.c
index 103ee8e..be132a1 100644
--- a/frontend/libretro.c
+++ b/frontend/libretro.c
@@ -242,6 +242,7 @@ void retro_set_environment(retro_environment_t cb)
static const struct retro_variable vars[] = {
{ "frameskip", "Frameskip; 0|1|2|3" },
{ "region", "Region; Auto|NTSC|PAL" },
+ { "pad1type", "Pad 1 Type; standard|analog" },
#ifdef __ARM_NEON__
{ "neon_interlace_enable", "Enable interlacing mode(s); disabled|enabled" },
{ "neon_enhancement_enable", "Enhanced resolution (slow); disabled|enabled" },
@@ -785,6 +786,17 @@ static void update_variables(bool in_flight)
else if (strcmp(var.value, "PAL") == 0)
Config.PsxType = 1;
}
+
+ var.value = NULL;
+ var.key = "pad1type";
+
+ if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value)
+ {
+ in_type1 = PSE_PAD_TYPE_STANDARD;
+ if (strcmp(var.value, "analog") == 0)
+ in_type1 = PSE_PAD_TYPE_ANALOGPAD;
+ }
+
#ifdef __ARM_NEON__
var.value = "NULL";
var.key = "neon_interlace_enable";
@@ -852,6 +864,14 @@ void retro_run(void)
if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, i))
in_keystate |= retro_psx_map[i];
+ if (in_type1 == PSE_PAD_TYPE_ANALOGPAD)
+ {
+ in_a1[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128;
+ in_a1[1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128;
+ in_a2[0] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128;
+ in_a2[1] = (input_state_cb(0, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128;
+ }
+
stop = 0;
psxCpu->Execute();