From a351849f5c016a3603c4cd81ba41ab4f9389e8a5 Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 21 Feb 2018 08:13:19 +0000 Subject: [PATCH] Use define instead of hardcoded number. --- src/system/controls.c | 8 ++++---- src/system/controls.h | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/system/controls.c b/src/system/controls.c index 248b574..e8e519d 100644 --- a/src/system/controls.c +++ b/src/system/controls.c @@ -27,22 +27,22 @@ int isControl(int type) key = app.config.keyControls[type]; btn = app.config.joypadControls[type]; - if (type == CONTROL_LEFT && app.joypadAxis[JOYPAD_AXIS_X] <= -16384) + if (type == CONTROL_LEFT && app.joypadAxis[JOYPAD_AXIS_X] <= -AXIS_MAX / 2) { return 1; } - if (type == CONTROL_RIGHT && app.joypadAxis[JOYPAD_AXIS_X] >= 16384) + if (type == CONTROL_RIGHT && app.joypadAxis[JOYPAD_AXIS_X] >= AXIS_MAX / 2) { return 1; } - if (type == CONTROL_UP && app.joypadAxis[JOYPAD_AXIS_Y] <= -16384) + if (type == CONTROL_UP && app.joypadAxis[JOYPAD_AXIS_Y] <= -AXIS_MAX / 2) { return 1; } - if (type == CONTROL_DOWN && app.joypadAxis[JOYPAD_AXIS_Y] >= 16384) + if (type == CONTROL_DOWN && app.joypadAxis[JOYPAD_AXIS_Y] >= AXIS_MAX / 2) { return 1; } diff --git a/src/system/controls.h b/src/system/controls.h index 2ed81bd..321c2dc 100644 --- a/src/system/controls.h +++ b/src/system/controls.h @@ -20,4 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../common.h" +#define AXIS_MAX 32767 + extern App app;