mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
More control/input cleanup
git-svn-id: https://svn.eduke32.com/eduke32@7181 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
a4182305d0
commit
5164ab4a25
11 changed files with 143 additions and 210 deletions
|
@ -234,12 +234,12 @@ static FORCE_INLINE void keyBufferInsert(char code)
|
|||
|
||||
void keyFlushChars(void);
|
||||
|
||||
int32_t mouseInit(void);
|
||||
void mouseInit(void);
|
||||
void mouseUninit(void);
|
||||
int32_t mouseReadAbs(vec2_t *pResult, vec2_t const *pInput);
|
||||
void mouseGrabInput(bool grab);
|
||||
void mouseLockToWindow(char a);
|
||||
void mouseReadButtons(int32_t *pResult);
|
||||
int32_t mouseReadButtons(void);
|
||||
void mouseReadPos(int32_t *x, int32_t *y);
|
||||
|
||||
void joyReadButtons(int32_t *pResult);
|
||||
|
|
|
@ -121,9 +121,9 @@ int32_t mouseReadAbs(vec2_t * const pResult, vec2_t const * const pInput)
|
|||
return 1;
|
||||
}
|
||||
|
||||
void mouseReadButtons(int32_t *pResult)
|
||||
int32_t mouseReadButtons(void)
|
||||
{
|
||||
*pResult = (!g_mouseEnabled || !appactive || !g_mouseInsideWindow || (osd && osd->flags & OSD_CAPTURE)) ? 0 : g_mouseBits;
|
||||
return (!g_mouseEnabled || !appactive || !g_mouseInsideWindow || (osd && osd->flags & OSD_CAPTURE)) ? 0 : g_mouseBits;
|
||||
}
|
||||
|
||||
controllerinput_t joystick;
|
||||
|
|
|
@ -11530,8 +11530,8 @@ void rotatepoint(vec2_t const pivot, vec2_t p, int16_t daang, vec2_t *p2)
|
|||
|
||||
void mouseGetValues(int32_t *mousx, int32_t *mousy, int32_t *bstatus)
|
||||
{
|
||||
mouseReadPos(mousx,mousy);
|
||||
mouseReadButtons(bstatus);
|
||||
mouseReadPos(mousx, mousy);
|
||||
*bstatus = mouseReadButtons();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -279,11 +279,10 @@ void RI_PollDevices(BOOL loop)
|
|||
}
|
||||
}
|
||||
|
||||
int32_t mouseInit(void)
|
||||
void mouseInit(void)
|
||||
{
|
||||
if (g_mouseEnabled) return 0;
|
||||
if (!g_mouseEnabled)
|
||||
mouseGrabInput(g_mouseEnabled = g_mouseLockedToWindow);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mouseUninit(void)
|
||||
|
|
|
@ -898,11 +898,9 @@ const char *joyGetName(int32_t what, int32_t num)
|
|||
//
|
||||
// initmouse() -- init mouse input
|
||||
//
|
||||
int32_t mouseInit(void)
|
||||
void mouseInit(void)
|
||||
{
|
||||
g_mouseEnabled=g_mouseLockedToWindow;
|
||||
mouseGrabInput(g_mouseLockedToWindow); // FIXME - SA
|
||||
return 0;
|
||||
mouseGrabInput(g_mouseEnabled = g_mouseLockedToWindow); // FIXME - SA
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -10899,7 +10899,7 @@ void ExtCheckKeys(void)
|
|||
}
|
||||
|
||||
lastbstatus = bstatus;
|
||||
mouseReadButtons(&bstatus);
|
||||
bstatus = mouseReadButtons();
|
||||
|
||||
Keys2d3d();
|
||||
|
||||
|
|
|
@ -140,10 +140,8 @@ void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN])
|
|||
|
||||
void CONFIG_SetDefaults(void)
|
||||
{
|
||||
// JBF 20031211
|
||||
int32_t i;
|
||||
|
||||
ud.config.scripthandle = -1;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
droidinput.forward_sens = 5.f;
|
||||
droidinput.gameControlsAlpha = 0.5;
|
||||
|
@ -194,15 +192,9 @@ void CONFIG_SetDefaults(void)
|
|||
|
||||
#if defined GEKKO || defined __OPENDINGUX__
|
||||
ud.config.NumVoices = 32;
|
||||
ud.camera_time = 11;
|
||||
#else
|
||||
ud.config.NumVoices = 64;
|
||||
#endif
|
||||
|
||||
#if defined GEKKO || defined __OPENDINGUX__
|
||||
ud.camera_time = 11;
|
||||
#elif defined(__ANDROID__)
|
||||
ud.camera_time = 7;
|
||||
#else
|
||||
ud.camera_time = 4;
|
||||
#endif
|
||||
|
||||
|
@ -316,7 +308,7 @@ void CONFIG_SetDefaults(void)
|
|||
|
||||
CONTROL_MouseSensitivity = DEFAULTMOUSESENSITIVITY;
|
||||
|
||||
for (i=0; i<MAXMOUSEBUTTONS; i++)
|
||||
for (int i=0; i<MAXMOUSEBUTTONS; i++)
|
||||
{
|
||||
ud.config.MouseFunctions[i][0] = CONFIG_FunctionNameToNum(mousedefaults[i]);
|
||||
CONTROL_MapButton(ud.config.MouseFunctions[i][0], i, 0, controldevice_mouse);
|
||||
|
@ -325,7 +317,7 @@ void CONFIG_SetDefaults(void)
|
|||
CONTROL_MapButton(ud.config.MouseFunctions[i][1], i, 1, controldevice_mouse);
|
||||
}
|
||||
|
||||
for (i=0; i<MAXMOUSEAXES; i++)
|
||||
for (int i=0; i<MAXMOUSEAXES; i++)
|
||||
{
|
||||
ud.config.MouseAnalogueScale[i] = DEFAULTMOUSEANALOGUESCALE;
|
||||
CONTROL_SetAnalogAxisScale(i, ud.config.MouseAnalogueScale[i], controldevice_mouse);
|
||||
|
@ -339,7 +331,7 @@ void CONFIG_SetDefaults(void)
|
|||
CONTROL_MapAnalogAxis(i, ud.config.MouseAnalogueAxes[i], controldevice_mouse);
|
||||
}
|
||||
|
||||
for (i=0; i<MAXJOYBUTTONSANDHATS; i++)
|
||||
for (int i=0; i<MAXJOYBUTTONSANDHATS; i++)
|
||||
{
|
||||
ud.config.JoystickFunctions[i][0] = CONFIG_FunctionNameToNum(joystickdefaults[i]);
|
||||
ud.config.JoystickFunctions[i][1] = CONFIG_FunctionNameToNum(joystickclickeddefaults[i]);
|
||||
|
@ -347,7 +339,7 @@ void CONFIG_SetDefaults(void)
|
|||
CONTROL_MapButton(ud.config.JoystickFunctions[i][1], i, 1, controldevice_joystick);
|
||||
}
|
||||
|
||||
for (i=0; i<MAXJOYAXES; i++)
|
||||
for (int i=0; i<MAXJOYAXES; i++)
|
||||
{
|
||||
ud.config.JoystickAnalogueScale[i] = DEFAULTJOYSTICKANALOGUESCALE;
|
||||
ud.config.JoystickAnalogueDead[i] = DEFAULTJOYSTICKANALOGUEDEAD;
|
||||
|
|
|
@ -866,9 +866,14 @@ static int osdcmd_name(osdcmdptr_t parm)
|
|||
|
||||
static int osdcmd_button(osdcmdptr_t parm)
|
||||
{
|
||||
char const *p = parm->name+9; // skip "gamefunc_"
|
||||
static char const s_gamefunc_[] = "gamefunc_";
|
||||
int constexpr strlen_gamefunc_ = ARRAY_SIZE(s_gamefunc_) - 1;
|
||||
|
||||
char const *p = parm->name + strlen_gamefunc_;
|
||||
|
||||
// if (g_player[myconnectindex].ps->gm == MODE_GAME) // only trigger these if in game
|
||||
CONTROL_OSDInput[CONFIG_FunctionNameToNum(p)] = 1; // FIXME
|
||||
CONTROL_ButtonFlags[CONFIG_FunctionNameToNum(p)] = 1; // FIXME
|
||||
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,15 +48,12 @@ extern "C" {
|
|||
|
||||
#define MAXGAMEBUTTONS 64
|
||||
|
||||
#define BUTTON(x) ((CONTROL_ButtonState>> ((uint64_t)(x)) ) & 1)
|
||||
#define BUTTONHELD(x) ((CONTROL_ButtonHeldState>> ((uint64_t)(x)) ) & 1)
|
||||
#define BUTTON(x) ((CONTROL_ButtonState >> ((uint64_t)(x))) & 1)
|
||||
#define BUTTONHELD(x) ((CONTROL_ButtonHeldState >> ((uint64_t)(x))) & 1)
|
||||
|
||||
#define BUTTONJUSTPRESSED(x) \
|
||||
( BUTTON( x ) && !BUTTONHELD( x ) )
|
||||
#define BUTTONRELEASED(x) \
|
||||
( !BUTTON( x ) && BUTTONHELD( x ) )
|
||||
#define BUTTONSTATECHANGED(x) \
|
||||
( BUTTON( x ) != BUTTONHELD( x ) )
|
||||
#define BUTTONJUSTPRESSED(x) (BUTTON(x) && !BUTTONHELD(x))
|
||||
#define BUTTONRELEASED(x) (!BUTTON(x) && BUTTONHELD(x))
|
||||
#define BUTTONSTATECHANGED(x) (BUTTON(x) != BUTTONHELD(x))
|
||||
|
||||
|
||||
//***************************************************************************
|
||||
|
@ -134,11 +131,12 @@ typedef enum
|
|||
//
|
||||
//***************************************************************************
|
||||
|
||||
extern int32_t CONTROL_Started;
|
||||
extern int32_t CONTROL_MousePresent;
|
||||
extern int32_t CONTROL_JoyPresent;
|
||||
extern int32_t CONTROL_MouseEnabled;
|
||||
extern int32_t CONTROL_JoystickEnabled;
|
||||
extern bool CONTROL_Started;
|
||||
extern bool CONTROL_MousePresent;
|
||||
extern bool CONTROL_JoyPresent;
|
||||
extern bool CONTROL_MouseEnabled;
|
||||
extern bool CONTROL_JoystickEnabled;
|
||||
|
||||
extern uint64_t CONTROL_ButtonState;
|
||||
extern uint64_t CONTROL_ButtonHeldState;
|
||||
|
||||
|
@ -156,14 +154,11 @@ int CONTROL_FlagActive( int which );
|
|||
void CONTROL_ClearAssignments( void );
|
||||
// void CONTROL_GetFunctionInput( void );
|
||||
void CONTROL_GetInput( ControlInfo *info );
|
||||
void CONTROL_ClearButton( int32_t whichbutton );
|
||||
void CONTROL_ClearButton( int whichbutton );
|
||||
extern float CONTROL_MouseSensitivity;
|
||||
int32_t CONTROL_Startup(controltype which, int32_t ( *TimeFunction )( void ), int32_t ticspersecond);
|
||||
bool CONTROL_Startup(controltype which, int32_t ( *TimeFunction )( void ), int32_t ticspersecond);
|
||||
void CONTROL_Shutdown( void );
|
||||
|
||||
void CONTROL_SetDoubleClickDelay(int32_t delay);
|
||||
int32_t CONTROL_GetDoubleClickDelay(void);
|
||||
|
||||
void CONTROL_MapAnalogAxis(int whichaxis, int whichanalog, controldevice device);
|
||||
void CONTROL_MapDigitalAxis(int32_t whichaxis, int32_t whichfunction, int32_t direction, controldevice device);
|
||||
void CONTROL_SetAnalogAxisScale(int32_t whichaxis, int32_t axisscale, controldevice device);
|
||||
|
@ -178,16 +173,18 @@ void CONTROL_SetAnalogAxisScale(int32_t whichaxis, int32_t axisscale, controldev
|
|||
#define MAXBOUNDKEYS MAXKEYBOARDSCAN
|
||||
#define MAXMOUSEBUTTONS 10
|
||||
|
||||
typedef struct binding {
|
||||
const char *key; // always set to const char *
|
||||
char *cmdstr; // alloc'd
|
||||
typedef struct
|
||||
{
|
||||
const char *key;
|
||||
char *cmdstr;
|
||||
char repeat;
|
||||
char laststate;
|
||||
} keybind;
|
||||
}
|
||||
consolekeybind_t;
|
||||
|
||||
// Direct use DEPRECATED:
|
||||
extern keybind CONTROL_KeyBinds[MAXBOUNDKEYS+MAXMOUSEBUTTONS];
|
||||
extern int32_t CONTROL_BindsEnabled;
|
||||
extern consolekeybind_t CONTROL_KeyBinds[MAXBOUNDKEYS+MAXMOUSEBUTTONS];
|
||||
extern bool CONTROL_BindsEnabled;
|
||||
|
||||
void CONTROL_ClearAllBinds(void);
|
||||
void CONTROL_BindKey(int i, char const * cmd, int repeat, char const * keyname);
|
||||
|
@ -195,9 +192,10 @@ void CONTROL_BindMouse(int i, char const * cmd, int repeat, char const * keyname
|
|||
void CONTROL_FreeKeyBind(int i);
|
||||
void CONTROL_FreeMouseBind(int i);
|
||||
|
||||
static inline int32_t CONTROL_KeyIsBound(int32_t i)
|
||||
static inline int CONTROL_KeyIsBound(int const key)
|
||||
{
|
||||
return (CONTROL_KeyBinds[i].cmdstr && CONTROL_KeyBinds[i].key);
|
||||
auto &bind = CONTROL_KeyBinds[key];
|
||||
return bind.cmdstr && bind.key;
|
||||
}
|
||||
|
||||
void CONTROL_ProcessBinds(void);
|
||||
|
@ -205,8 +203,8 @@ void CONTROL_ProcessBinds(void);
|
|||
////////////////////
|
||||
|
||||
#define CONTROL_NUM_FLAGS 64
|
||||
extern int32_t CONTROL_OSDInput[CONTROL_NUM_FLAGS];
|
||||
extern int32_t CONTROL_SmoothMouse;
|
||||
extern int32_t CONTROL_ButtonFlags[CONTROL_NUM_FLAGS];
|
||||
extern bool CONTROL_SmoothMouse;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -46,29 +46,16 @@ extern "C" {
|
|||
|
||||
#include "baselayer.h"
|
||||
|
||||
static inline int32_t Mouse_Init(void)
|
||||
static inline bool Mouse_Init(void)
|
||||
{
|
||||
mouseInit();
|
||||
return ((inputdevices & 2) == 2);
|
||||
}
|
||||
|
||||
|
||||
static inline void MOUSE_Shutdown(void) { mouseUninit(); }
|
||||
|
||||
#if 0
|
||||
static inline void MOUSE_ShowCursor(void) {}
|
||||
static inline void MOUSE_HideCursor(void) {}
|
||||
#endif
|
||||
|
||||
static inline int32_t MOUSE_GetButtons(void)
|
||||
{
|
||||
int32_t buttons;
|
||||
mouseReadButtons(&buttons);
|
||||
return buttons;
|
||||
}
|
||||
|
||||
#define MOUSE_ClearButton(b) (g_mouseBits &= ~b)
|
||||
#define MOUSE_ClearAllButtons() g_mouseBits = 0
|
||||
static inline int32_t MOUSE_GetButtons(void) { return mouseReadButtons(); }
|
||||
static inline void MOUSE_ClearButton(int32_t b) { g_mouseBits &= ~b; }
|
||||
static inline void MOUSE_ClearAllButtons(void) { g_mouseBits = 0; }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -22,10 +22,12 @@
|
|||
#include "android.h"
|
||||
#endif
|
||||
|
||||
int32_t CONTROL_JoyPresent = FALSE;
|
||||
int32_t CONTROL_JoystickEnabled = FALSE;
|
||||
int32_t CONTROL_MousePresent = FALSE;
|
||||
int32_t CONTROL_MouseEnabled = FALSE;
|
||||
bool CONTROL_Started = false;
|
||||
bool CONTROL_JoyPresent = false;
|
||||
bool CONTROL_JoystickEnabled = false;
|
||||
bool CONTROL_MousePresent = false;
|
||||
bool CONTROL_MouseEnabled = false;
|
||||
|
||||
uint64_t CONTROL_ButtonState = 0;
|
||||
uint64_t CONTROL_ButtonHeldState = 0;
|
||||
|
||||
|
@ -52,7 +54,6 @@ static controlaxistype CONTROL_LastJoyAxes[MAXJOYAXES];
|
|||
static int32_t CONTROL_MouseAxesScale[MAXMOUSEAXES];
|
||||
static int32_t CONTROL_JoyAxesScale[MAXJOYAXES];
|
||||
|
||||
#ifndef __ANDROID__
|
||||
static int32_t CONTROL_MouseButtonState[MAXMOUSEBUTTONS];
|
||||
static int32_t CONTROL_MouseButtonClickedTime[MAXMOUSEBUTTONS];
|
||||
static int32_t CONTROL_MouseButtonClickedState[MAXMOUSEBUTTONS];
|
||||
|
@ -64,27 +65,24 @@ static int32_t CONTROL_JoyButtonClickedTime[MAXJOYBUTTONS];
|
|||
static int32_t CONTROL_JoyButtonClickedState[MAXJOYBUTTONS];
|
||||
static int32_t CONTROL_JoyButtonClicked[MAXJOYBUTTONS];
|
||||
static uint8_t CONTROL_JoyButtonClickedCount[MAXJOYBUTTONS];
|
||||
#endif
|
||||
|
||||
static int32_t(*ExtGetTime)(void);
|
||||
int32_t CONTROL_Started = FALSE;
|
||||
//static int32_t ticrate;
|
||||
static int32_t CONTROL_DoubleClickSpeed;
|
||||
static uint8_t CONTROL_DoubleClickSpeed;
|
||||
|
||||
int32_t CONTROL_OSDInput[CONTROL_NUM_FLAGS];
|
||||
keybind CONTROL_KeyBinds[MAXBOUNDKEYS + MAXMOUSEBUTTONS];
|
||||
int32_t CONTROL_BindsEnabled = 0;
|
||||
int32_t CONTROL_SmoothMouse = 0;
|
||||
int32_t CONTROL_ButtonFlags[CONTROL_NUM_FLAGS];
|
||||
consolekeybind_t CONTROL_KeyBinds[MAXBOUNDKEYS + MAXMOUSEBUTTONS];
|
||||
bool CONTROL_BindsEnabled = 0;
|
||||
bool CONTROL_SmoothMouse = 0;
|
||||
|
||||
#define CONTROL_CheckRange(which) ((unsigned)which >= (unsigned)CONTROL_NUM_FLAGS)
|
||||
#define BIND(x, s, r, k) do { Bfree(x.cmdstr); x.cmdstr = s; x.repeat = r; x.key = k; } while (0)
|
||||
|
||||
void CONTROL_ClearAllBinds(void)
|
||||
{
|
||||
int32_t i;
|
||||
for (i=0; i<MAXBOUNDKEYS; i++)
|
||||
for (int i=0; i<MAXBOUNDKEYS; i++)
|
||||
CONTROL_FreeKeyBind(i);
|
||||
for (i=0; i<MAXMOUSEBUTTONS; i++)
|
||||
for (int i=0; i<MAXMOUSEBUTTONS; i++)
|
||||
CONTROL_FreeMouseBind(i);
|
||||
}
|
||||
|
||||
|
@ -108,7 +106,6 @@ void CONTROL_FreeMouseBind(int i)
|
|||
BIND(CONTROL_KeyBinds[MAXBOUNDKEYS + i], NULL, 0, NULL);
|
||||
}
|
||||
|
||||
#ifndef __ANDROID__
|
||||
static void CONTROL_GetMouseDelta(void)
|
||||
{
|
||||
vec2_t input;
|
||||
|
@ -126,7 +123,6 @@ static void CONTROL_GetMouseDelta(void)
|
|||
CONTROL_MouseAxes[0].analog = Blrintf(finput.x * 4.f * CONTROL_MouseSensitivity);
|
||||
CONTROL_MouseAxes[1].analog = Blrintf(finput.y * 8.f * CONTROL_MouseSensitivity);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int32_t CONTROL_GetTime(void)
|
||||
{
|
||||
|
@ -135,8 +131,7 @@ static int32_t CONTROL_GetTime(void)
|
|||
return t;
|
||||
}
|
||||
|
||||
#ifndef __ANDROID__
|
||||
static void CONTROL_SetFlag(int32_t which, int32_t active)
|
||||
static void CONTROL_SetFlag(int which, int active)
|
||||
{
|
||||
if (CONTROL_CheckRange(which)) return;
|
||||
|
||||
|
@ -152,7 +147,6 @@ static void CONTROL_SetFlag(int32_t which, int32_t active)
|
|||
flags.active = (flags.active ? FALSE : TRUE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
int32_t CONTROL_KeyboardFunctionPressed(int32_t which)
|
||||
|
@ -193,10 +187,10 @@ void CONTROL_DefineFlag(int which, int toggle)
|
|||
controlflags &flags = CONTROL_Flags[which];
|
||||
|
||||
flags.active = FALSE;
|
||||
flags.used = TRUE;
|
||||
flags.toggle = toggle;
|
||||
flags.buttonheld = FALSE;
|
||||
flags.cleared = 0;
|
||||
flags.toggle = toggle;
|
||||
flags.used = TRUE;
|
||||
}
|
||||
|
||||
int CONTROL_FlagActive(int which)
|
||||
|
@ -426,24 +420,23 @@ void CONTROL_MapDigitalAxis(int32_t whichaxis, int32_t whichfunction, int32_t di
|
|||
|
||||
void CONTROL_ClearAssignments(void)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
memset(CONTROL_MouseButtonMapping, BUTTONUNDEFINED, sizeof(CONTROL_MouseButtonMapping));
|
||||
memset(CONTROL_JoyAxes, 0, sizeof(CONTROL_JoyAxes));
|
||||
memset(CONTROL_JoyAxesMap, AXISUNDEFINED, sizeof(CONTROL_JoyAxesMap));
|
||||
memset(CONTROL_JoyButtonMapping, BUTTONUNDEFINED, sizeof(CONTROL_JoyButtonMapping));
|
||||
// memset(CONTROL_KeyMapping, KEYUNDEFINED, sizeof(CONTROL_KeyMapping));
|
||||
memset(CONTROL_MouseAxesMap, AXISUNDEFINED, sizeof(CONTROL_MouseAxesMap));
|
||||
memset(CONTROL_JoyAxesMap, AXISUNDEFINED, sizeof(CONTROL_JoyAxesMap));
|
||||
memset(CONTROL_MouseAxes, 0, sizeof(CONTROL_MouseAxes));
|
||||
memset(CONTROL_JoyAxes, 0, sizeof(CONTROL_JoyAxes));
|
||||
memset(CONTROL_LastMouseAxes, 0, sizeof(CONTROL_LastMouseAxes));
|
||||
memset(CONTROL_LastJoyAxes, 0, sizeof(CONTROL_LastJoyAxes));
|
||||
for (i=0; i<MAXMOUSEAXES; i++)
|
||||
CONTROL_MouseAxesScale[i] = NORMALAXISSCALE;
|
||||
for (i=0; i<MAXJOYAXES; i++)
|
||||
CONTROL_JoyAxesScale[i] = NORMALAXISSCALE;
|
||||
memset(CONTROL_LastMouseAxes, 0, sizeof(CONTROL_LastMouseAxes));
|
||||
memset(CONTROL_MouseAxes, 0, sizeof(CONTROL_MouseAxes));
|
||||
memset(CONTROL_MouseAxesMap, AXISUNDEFINED, sizeof(CONTROL_MouseAxesMap));
|
||||
memset(CONTROL_MouseButtonMapping, BUTTONUNDEFINED, sizeof(CONTROL_MouseButtonMapping));
|
||||
|
||||
for (int & i : CONTROL_MouseAxesScale)
|
||||
i = NORMALAXISSCALE;
|
||||
|
||||
for (int & i : CONTROL_JoyAxesScale)
|
||||
i = NORMALAXISSCALE;
|
||||
}
|
||||
|
||||
#ifndef __ANDROID__
|
||||
static void DoGetDeviceButtons(
|
||||
int32_t buttons, int32_t tm,
|
||||
int32_t NumButtons,
|
||||
|
@ -458,7 +451,7 @@ static void DoGetDeviceButtons(
|
|||
|
||||
for (; i>=0; i--)
|
||||
{
|
||||
int32_t bs = (buttons >> i) & 1;
|
||||
int const bs = (buttons >> i) & 1;
|
||||
|
||||
DeviceButtonState[i] = bs;
|
||||
ButtonClickedState[i] = FALSE;
|
||||
|
@ -498,7 +491,7 @@ static void DoGetDeviceButtons(
|
|||
|
||||
static void CONTROL_GetDeviceButtons(void)
|
||||
{
|
||||
int32_t t = ExtGetTime();
|
||||
int32_t const t = ExtGetTime();
|
||||
|
||||
if (CONTROL_MouseEnabled)
|
||||
{
|
||||
|
@ -527,7 +520,7 @@ static void CONTROL_GetDeviceButtons(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void CONTROL_DigitizeAxis(int32_t axis, controldevice device)
|
||||
static void CONTROL_DigitizeAxis(int axis, controldevice device)
|
||||
{
|
||||
controlaxistype *set, *lastset;
|
||||
|
||||
|
@ -558,7 +551,7 @@ static void CONTROL_DigitizeAxis(int32_t axis, controldevice device)
|
|||
}
|
||||
}
|
||||
|
||||
static void CONTROL_ScaleAxis(int32_t axis, controldevice device)
|
||||
static void CONTROL_ScaleAxis(int axis, controldevice device)
|
||||
{
|
||||
controlaxistype *set;
|
||||
int32_t *scale;
|
||||
|
@ -581,7 +574,7 @@ static void CONTROL_ScaleAxis(int32_t axis, controldevice device)
|
|||
set[axis].analog = mulscale16(set[axis].analog, scale[axis]);
|
||||
}
|
||||
|
||||
static void CONTROL_ApplyAxis(int32_t axis, ControlInfo *info, controldevice device)
|
||||
static void CONTROL_ApplyAxis(int axis, ControlInfo *info, controldevice device)
|
||||
{
|
||||
controlaxistype *set;
|
||||
controlaxismaptype *map;
|
||||
|
@ -623,13 +616,11 @@ static void CONTROL_PollDevices(ControlInfo *info)
|
|||
|
||||
if (CONTROL_MouseEnabled)
|
||||
{
|
||||
int32_t i = MAXMOUSEAXES-1;
|
||||
|
||||
Bmemcpy(CONTROL_LastMouseAxes, CONTROL_MouseAxes, sizeof(CONTROL_MouseAxes));
|
||||
memset(CONTROL_MouseAxes, 0, sizeof(CONTROL_MouseAxes));
|
||||
|
||||
CONTROL_GetMouseDelta();
|
||||
for (; i>=0; i--)
|
||||
for (int i=MAXMOUSEAXES-1; i>=0; i--)
|
||||
{
|
||||
CONTROL_DigitizeAxis(i, controldevice_mouse);
|
||||
CONTROL_ScaleAxis(i, controldevice_mouse);
|
||||
|
@ -640,12 +631,10 @@ static void CONTROL_PollDevices(ControlInfo *info)
|
|||
|
||||
if (CONTROL_JoystickEnabled)
|
||||
{
|
||||
int32_t i = joystick.numAxes-1;
|
||||
|
||||
Bmemcpy(CONTROL_LastJoyAxes, CONTROL_JoyAxes, sizeof(CONTROL_JoyAxes));
|
||||
memset(CONTROL_JoyAxes, 0, sizeof(CONTROL_JoyAxes));
|
||||
|
||||
for (; i>=0; i--)
|
||||
for (int i=joystick.numAxes-1; i>=0; i--)
|
||||
{
|
||||
CONTROL_JoyAxes[i].analog = joystick.pAxis[i];
|
||||
|
||||
|
@ -659,52 +648,37 @@ static void CONTROL_PollDevices(ControlInfo *info)
|
|||
CONTROL_GetDeviceButtons();
|
||||
}
|
||||
|
||||
static void CONTROL_HandleAxisFunction(int32_t *p1, controlaxistype *axes, controlaxismaptype *axismap, int numAxes)
|
||||
{
|
||||
int axis = numAxes - 1;
|
||||
|
||||
do
|
||||
{
|
||||
if (!axes[axis].digital)
|
||||
continue;
|
||||
|
||||
int const j = (axes[axis].digital < 0) ? axismap[axis].minmap : axismap[axis].maxmap;
|
||||
|
||||
if (j != AXISUNDEFINED)
|
||||
p1[j] = 1;
|
||||
}
|
||||
while (axis--);
|
||||
}
|
||||
|
||||
static void CONTROL_AxisFunctionState(int32_t *p1)
|
||||
{
|
||||
if (CONTROL_NumMouseAxes)
|
||||
{
|
||||
int32_t j, i = CONTROL_NumMouseAxes-1;
|
||||
|
||||
do
|
||||
{
|
||||
if (!CONTROL_MouseAxes[i].digital) continue;
|
||||
|
||||
if (CONTROL_MouseAxes[i].digital < 0)
|
||||
j = CONTROL_MouseAxesMap[i].minmap;
|
||||
else
|
||||
j = CONTROL_MouseAxesMap[i].maxmap;
|
||||
|
||||
if (j != AXISUNDEFINED)
|
||||
p1[j] = 1;
|
||||
}
|
||||
while (i--);
|
||||
}
|
||||
CONTROL_HandleAxisFunction(p1, CONTROL_MouseAxes, CONTROL_MouseAxesMap, CONTROL_NumMouseAxes);
|
||||
|
||||
if (CONTROL_NumJoyAxes)
|
||||
{
|
||||
int32_t j, i = CONTROL_NumJoyAxes-1;
|
||||
|
||||
do
|
||||
{
|
||||
if (!CONTROL_JoyAxes[i].digital) continue;
|
||||
|
||||
if (CONTROL_JoyAxes[i].digital < 0)
|
||||
j = CONTROL_JoyAxesMap[i].minmap;
|
||||
else
|
||||
j = CONTROL_JoyAxesMap[i].maxmap;
|
||||
|
||||
if (j != AXISUNDEFINED)
|
||||
p1[j] = 1;
|
||||
}
|
||||
while (i--);
|
||||
}
|
||||
CONTROL_HandleAxisFunction(p1, CONTROL_JoyAxes, CONTROL_JoyAxesMap, CONTROL_NumJoyAxes);
|
||||
}
|
||||
|
||||
static void CONTROL_ButtonFunctionState(int32_t *p1)
|
||||
{
|
||||
if (CONTROL_NumMouseButtons)
|
||||
{
|
||||
int32_t i = CONTROL_NumMouseButtons-1, j;
|
||||
int i = CONTROL_NumMouseButtons-1, j;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -734,7 +708,7 @@ static void CONTROL_ButtonFunctionState(int32_t *p1)
|
|||
|
||||
if (CONTROL_NumJoyButtons)
|
||||
{
|
||||
int32_t i=CONTROL_NumJoyButtons-1, j;
|
||||
int i=CONTROL_NumJoyButtons-1, j;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -749,9 +723,8 @@ static void CONTROL_ButtonFunctionState(int32_t *p1)
|
|||
while (i--);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void CONTROL_ClearButton(int32_t whichbutton)
|
||||
void CONTROL_ClearButton(int whichbutton)
|
||||
{
|
||||
if (CONTROL_CheckRange(whichbutton)) return;
|
||||
|
||||
|
@ -765,11 +738,11 @@ void CONTROL_ClearButton(int32_t whichbutton)
|
|||
|
||||
void CONTROL_ProcessBinds(void)
|
||||
{
|
||||
int32_t i=MAXBOUNDKEYS-1;
|
||||
|
||||
if (!CONTROL_BindsEnabled)
|
||||
return;
|
||||
|
||||
int i = MAXBOUNDKEYS-1;
|
||||
|
||||
do
|
||||
{
|
||||
if (CONTROL_KeyBinds[i].cmdstr)
|
||||
|
@ -783,89 +756,70 @@ void CONTROL_ProcessBinds(void)
|
|||
while (i--);
|
||||
}
|
||||
|
||||
#ifndef __ANDROID__
|
||||
static void CONTROL_GetFunctionInput(void)
|
||||
{
|
||||
int32_t periphs[CONTROL_NUM_FLAGS];
|
||||
int32_t i = CONTROL_NUM_FLAGS-1;
|
||||
|
||||
memset(periphs, 0, sizeof(periphs));
|
||||
CONTROL_ButtonFunctionState(periphs);
|
||||
CONTROL_AxisFunctionState(periphs);
|
||||
CONTROL_ButtonFunctionState(CONTROL_ButtonFlags);
|
||||
CONTROL_AxisFunctionState(CONTROL_ButtonFlags);
|
||||
|
||||
CONTROL_ButtonHeldState = CONTROL_ButtonState;
|
||||
CONTROL_ButtonState = 0;
|
||||
|
||||
int i = CONTROL_NUM_FLAGS-1;
|
||||
|
||||
do
|
||||
{
|
||||
CONTROL_SetFlag(i, /*CONTROL_KeyboardFunctionPressed(i) | */periphs[i] | CONTROL_OSDInput[i]);
|
||||
CONTROL_SetFlag(i, /*CONTROL_KeyboardFunctionPressed(i) | */CONTROL_ButtonFlags[i]);
|
||||
|
||||
if (CONTROL_Flags[i].cleared == FALSE) BUTTONSET(i, CONTROL_Flags[i].active);
|
||||
else if (CONTROL_Flags[i].active == FALSE) CONTROL_Flags[i].cleared = 0;
|
||||
}
|
||||
while (i--);
|
||||
|
||||
memset(CONTROL_OSDInput, 0, sizeof(CONTROL_OSDInput));
|
||||
memset(CONTROL_ButtonFlags, 0, sizeof(CONTROL_ButtonFlags));
|
||||
}
|
||||
#endif
|
||||
|
||||
void CONTROL_GetInput(ControlInfo *info)
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
CONTROL_Android_PollDevices(info);
|
||||
#else
|
||||
#endif
|
||||
CONTROL_PollDevices(info);
|
||||
CONTROL_GetFunctionInput();
|
||||
inputchecked = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t CONTROL_Startup(controltype which, int32_t(*TimeFunction)(void), int32_t ticspersecond)
|
||||
bool CONTROL_Startup(controltype which, int32_t(*TimeFunction)(void), int32_t ticspersecond)
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
UNREFERENCED_PARAMETER(which);
|
||||
|
||||
if (CONTROL_Started) return FALSE;
|
||||
if (CONTROL_Started) return false;
|
||||
|
||||
if (TimeFunction) ExtGetTime = TimeFunction;
|
||||
else ExtGetTime = CONTROL_GetTime;
|
||||
ExtGetTime = TimeFunction ? TimeFunction : CONTROL_GetTime;
|
||||
|
||||
// ticrate = ticspersecond;
|
||||
// what the fuck???
|
||||
CONTROL_DoubleClickSpeed = (ticspersecond * 57) / 100;
|
||||
|
||||
CONTROL_DoubleClickSpeed = (ticspersecond*57)/100;
|
||||
if (CONTROL_DoubleClickSpeed <= 0)
|
||||
CONTROL_DoubleClickSpeed = 1;
|
||||
|
||||
if (initinput()) return TRUE;
|
||||
if (initinput())
|
||||
return true;
|
||||
|
||||
CONTROL_MousePresent = CONTROL_MouseEnabled = FALSE;
|
||||
CONTROL_JoyPresent = CONTROL_JoystickEnabled = FALSE;
|
||||
CONTROL_NumMouseButtons = CONTROL_NumJoyButtons = 0;
|
||||
CONTROL_NumMouseAxes = CONTROL_NumJoyAxes = 0;
|
||||
KB_Startup();
|
||||
|
||||
//switch (which) {
|
||||
// case controltype_keyboard:
|
||||
// break;
|
||||
|
||||
// case controltype_keyboardandmouse:
|
||||
CONTROL_NumMouseAxes = MAXMOUSEAXES;
|
||||
CONTROL_NumMouseButtons = MAXMOUSEBUTTONS;
|
||||
CONTROL_MousePresent = Mouse_Init();
|
||||
CONTROL_MouseEnabled = CONTROL_MousePresent;
|
||||
// break;
|
||||
|
||||
// case controltype_keyboardandjoystick:
|
||||
CONTROL_NumJoyAxes = min(MAXJOYAXES,joystick.numAxes);
|
||||
CONTROL_NumJoyButtons = min(MAXJOYBUTTONS,joystick.numButtons + 4*(joystick.numHats>0));
|
||||
CONTROL_JoystickEnabled = CONTROL_JoyPresent = (inputdevices&4)>>2;
|
||||
// break;
|
||||
//}
|
||||
CONTROL_NumJoyAxes = min(MAXJOYAXES, joystick.numAxes);
|
||||
CONTROL_NumJoyButtons = min(MAXJOYBUTTONS, joystick.numButtons + 4 * (joystick.numHats > 0));
|
||||
CONTROL_JoystickEnabled = CONTROL_JoyPresent = !!((inputdevices & 4) >> 2);
|
||||
|
||||
#ifdef GEKKO
|
||||
if (CONTROL_MousePresent)
|
||||
initprintf("CONTROL_Startup: Mouse Present\n");
|
||||
|
||||
if (CONTROL_JoyPresent)
|
||||
initprintf("CONTROL_Startup: Joystick Present\n");
|
||||
#endif
|
||||
|
@ -873,12 +827,12 @@ int32_t CONTROL_Startup(controltype which, int32_t(*TimeFunction)(void), int32_t
|
|||
CONTROL_ButtonState = 0;
|
||||
CONTROL_ButtonHeldState = 0;
|
||||
|
||||
for (i=0; i<CONTROL_NUM_FLAGS; i++)
|
||||
CONTROL_Flags[i].used = FALSE;
|
||||
for (auto & CONTROL_Flag : CONTROL_Flags)
|
||||
CONTROL_Flag.used = FALSE;
|
||||
|
||||
CONTROL_Started = TRUE;
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
void CONTROL_Shutdown(void)
|
||||
|
|
Loading…
Reference in a new issue