From 0a846721217fe380d180b133dd64005b9b7ab0f2 Mon Sep 17 00:00:00 2001 From: terminx Date: Sun, 18 Nov 2018 18:12:43 +0000 Subject: [PATCH] Use clamp in mact LIMITCONTROL macro git-svn-id: https://svn.eduke32.com/eduke32@7216 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/mact/include/_control.h | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/source/mact/include/_control.h b/source/mact/include/_control.h index 6b0392446..59ff5fe96 100644 --- a/source/mact/include/_control.h +++ b/source/mact/include/_control.h @@ -36,6 +36,10 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms #ifndef control_private_h_ #define control_private_h_ + +#include "compat.h" +#include "keyboard.h" + #ifdef __cplusplus extern "C" { #endif @@ -85,21 +89,8 @@ extern "C" { #define BUTTONSET(x, value) (CONTROL_ButtonState |= ((uint64_t)value << ((uint64_t)(x)))) #define BUTTONCLEAR(x) (CONTROL_ButtonState &= ~((uint64_t)1 << ((uint64_t)(x)))) - #define BUTTONHELDSET(x, value) (CONTROL_ButtonHeldState |= (uint64_t)(value << ((uint64_t)(x)))) - -#define LIMITCONTROL(x) \ - { \ - if ((*x) > MAXCONTROLVALUE) \ - { \ - (*x) = MAXCONTROLVALUE; \ - } \ - if ((*x) < -MAXCONTROLVALUE) \ - { \ - (*x) = -MAXCONTROLVALUE; \ - } \ - } -#define SGN(x) (((x) > 0) ? 1 : ((x) < 0) ? -1 : 0) +#define LIMITCONTROL(x) (*x = clamp(*x, -MAXCONTROLVALUE, MAXCONTROLVALUE)) //**************************************************************************** //