aboutsummaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
authorTwinaphex2016-10-18 05:38:59 +0200
committerGitHub2016-10-18 05:38:59 +0200
commit1aa232fb3eb8fdf2242d251bfd2770e4de1b2c37 (patch)
treea9281b024df60613f16872c8d7d05523ef545202 /frontend
parenteaa0324ba9d317f2841baedc11dca6fa7154ab4b (diff)
parentce098e12475cfe0a40c5be4c3c0913501cb02ecc (diff)
downloadpcsx_rearmed-1aa232fb3eb8fdf2242d251bfd2770e4de1b2c37.tar.gz
pcsx_rearmed-1aa232fb3eb8fdf2242d251bfd2770e4de1b2c37.tar.bz2
pcsx_rearmed-1aa232fb3eb8fdf2242d251bfd2770e4de1b2c37.zip
Merge pull request #76 from heronr/analog_range_fix
Fixed analog stick ranges to be [0, 255]
Diffstat (limited to 'frontend')
-rw-r--r--frontend/libretro.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/frontend/libretro.c b/frontend/libretro.c
index bab3060..f9be756 100644
--- a/frontend/libretro.c
+++ b/frontend/libretro.c
@@ -1464,6 +1464,11 @@ static void update_variables(bool in_flight)
}
}
+static int min(int a, int b)
+{
+ return a < b ? a : b;
+}
+
void retro_run(void)
{
int i;
@@ -1489,10 +1494,10 @@ void retro_run(void)
if (in_type[i] == PSE_PAD_TYPE_ANALOGPAD)
{
- in_analog_left[i][0] = (input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128;
- in_analog_left[i][1] = (input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128;
- in_analog_right[i][0] = (input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 256) + 128;
- in_analog_right[i][1] = (input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 256) + 128;
+ in_analog_left[i][0] = min((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_X) / 255) + 128, 255);
+ in_analog_left[i][1] = min((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_LEFT, RETRO_DEVICE_ID_ANALOG_Y) / 255) + 128, 255);
+ in_analog_right[i][0] = min((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_X) / 255) + 128, 255);
+ in_analog_right[i][1] = min((input_state_cb(i, RETRO_DEVICE_ANALOG, RETRO_DEVICE_INDEX_ANALOG_RIGHT, RETRO_DEVICE_ID_ANALOG_Y) / 255) + 128, 255);
}
}