merge sys_public.h changes for gamepad support

not sure if any of this is relevant for mods, but shouldn't hurt..
This commit is contained in:
Daniel Gibson 2024-03-18 21:13:51 +01:00
parent dbf155277b
commit 54fb408103

View file

@ -44,12 +44,12 @@ typedef enum {
} cpuidSimd_t; } cpuidSimd_t;
typedef enum { typedef enum {
AXIS_SIDE, AXIS_LEFT_X,
AXIS_FORWARD, AXIS_LEFT_Y,
AXIS_UP, AXIS_RIGHT_X,
AXIS_ROLL, AXIS_RIGHT_Y,
AXIS_YAW, AXIS_LEFT_TRIG,
AXIS_PITCH, AXIS_RIGHT_TRIG,
MAX_JOYSTICK_AXIS MAX_JOYSTICK_AXIS
} joystickAxis_t; } joystickAxis_t;
@ -57,9 +57,9 @@ typedef enum {
SE_NONE, // evTime is still valid SE_NONE, // evTime is still valid
SE_KEY, // evValue is a key code, evValue2 is the down flag SE_KEY, // evValue is a key code, evValue2 is the down flag
SE_CHAR, // evValue is an ascii char SE_CHAR, // evValue is an ascii char
SE_MOUSE, // evValue and evValue2 are reletive signed x / y moves SE_MOUSE, // evValue and evValue2 are relative signed x / y moves
SE_MOUSE_ABS, // evValue and evValue2 are absolute x / y coordinates in the window SE_MOUSE_ABS, // evValue and evValue2 are absolute x / y coordinates in the window
SE_JOYSTICK_AXIS, // evValue is an axis number and evValue2 is the current state (-127 to 127) SE_JOYSTICK, // evValue is an axis number and evValue2 is the current state (-127 to 127)
SE_CONSOLE // evPtr is a char*, from typing something at a non-game console SE_CONSOLE // evPtr is a char*, from typing something at a non-game console
} sysEventType_t; } sysEventType_t;
@ -77,10 +77,52 @@ typedef enum {
M_DELTAZ M_DELTAZ
} sys_mEvents; } sys_mEvents;
typedef enum {
J_ACTION_FIRST,
// these names are similar to the SDL3 SDL_GamepadButton names
J_BTN_SOUTH = J_ACTION_FIRST, // bottom face button, like Xbox A
J_BTN_EAST, // right face button, like Xbox B
J_BTN_WEST, // left face button, like Xbox X
J_BTN_NORTH, // top face button, like Xbox Y
J_BTN_BACK,
J_BTN_GUIDE, // Note: this one should probably not be used?
J_BTN_START,
J_BTN_LSTICK, // press left stick
J_BTN_RSTICK, // press right stick
J_BTN_LSHOULDER,
J_BTN_RSHOULDER,
J_DPAD_UP,
J_DPAD_DOWN,
J_DPAD_LEFT,
J_DPAD_RIGHT,
J_BTN_MISC1, // Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button)
J_BTN_RPADDLE1, // Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1)
J_BTN_LPADDLE1, // Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3)
J_BTN_RPADDLE2, // Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2)
J_BTN_LPADDLE2, // Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4)
J_ACTION_MAX = J_BTN_LPADDLE2,
// leaving some space here for about 12 additional J_ACTIONs, if needed
J_AXIS_MIN = 32,
J_AXIS_LEFT_X = J_AXIS_MIN + AXIS_LEFT_X,
J_AXIS_LEFT_Y = J_AXIS_MIN + AXIS_LEFT_Y,
J_AXIS_RIGHT_X = J_AXIS_MIN + AXIS_RIGHT_X,
J_AXIS_RIGHT_Y = J_AXIS_MIN + AXIS_RIGHT_Y,
J_AXIS_LEFT_TRIG = J_AXIS_MIN + AXIS_LEFT_TRIG,
J_AXIS_RIGHT_TRIG = J_AXIS_MIN + AXIS_RIGHT_TRIG,
J_AXIS_MAX = J_AXIS_MIN + MAX_JOYSTICK_AXIS - 1,
MAX_JOY_EVENT
} sys_jEvents;
struct sysEvent_t { struct sysEvent_t {
sysEventType_t evType; sysEventType_t evType;
int evValue; int evValue; // for keys: K_* or ASCII code; for joystick: axis; for mouse: mouseX
int evValue2; int evValue2; // for keys: 0/1 for up/down; for axis: value; for mouse: mouseY
int evPtrLength; // bytes of data pointed to by evPtr, for journaling int evPtrLength; // bytes of data pointed to by evPtr, for journaling
void * evPtr; // this must be manually freed if not NULL void * evPtr; // this must be manually freed if not NULL
}; };
@ -102,6 +144,7 @@ void Sys_Quit( void );
// note that this isn't journaled... // note that this isn't journaled...
char * Sys_GetClipboardData( void ); char * Sys_GetClipboardData( void );
void Sys_FreeClipboardData( char* data );
void Sys_SetClipboardData( const char *string ); void Sys_SetClipboardData( const char *string );
// will go to the various text consoles // will go to the various text consoles
@ -296,7 +339,7 @@ typedef int (*xthread_t)( void * );
typedef struct { typedef struct {
const char *name; const char *name;
SDL_Thread *threadHandle; SDL_Thread *threadHandle;
unsigned int threadId; unsigned long threadId;
} xthreadInfo; } xthreadInfo;
void Sys_CreateThread( xthread_t function, void *parms, xthreadInfo &info, const char *name ); void Sys_CreateThread( xthread_t function, void *parms, xthreadInfo &info, const char *name );