Renamed SDL_JOYSTICK_RAWINPUT_GAMING_INPUT to SDL_JOYSTICK_RAWINPUT_WGI

This commit is contained in:
Sam Lantinga 2020-11-27 05:53:50 -08:00
parent 219a28dd8a
commit 849ce80376

View File

@ -46,14 +46,14 @@
#define SDL_JOYSTICK_RAWINPUT_XINPUT #define SDL_JOYSTICK_RAWINPUT_XINPUT
#ifdef SDL_WINDOWS10_SDK #ifdef SDL_WINDOWS10_SDK
#define SDL_JOYSTICK_RAWINPUT_GAMING_INPUT #define SDL_JOYSTICK_RAWINPUT_WGI
#endif #endif
#ifdef SDL_JOYSTICK_RAWINPUT_XINPUT #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT
#include "../../core/windows/SDL_xinput.h" #include "../../core/windows/SDL_xinput.h"
#endif #endif
#ifdef SDL_JOYSTICK_RAWINPUT_GAMING_INPUT #ifdef SDL_JOYSTICK_RAWINPUT_WGI
#include "../../core/windows/SDL_windows.h" #include "../../core/windows/SDL_windows.h"
typedef struct WindowsGamingInputGamepadState WindowsGamingInputGamepadState; typedef struct WindowsGamingInputGamepadState WindowsGamingInputGamepadState;
#define GamepadButtons_GUIDE 0x40000000 #define GamepadButtons_GUIDE 0x40000000
@ -61,11 +61,11 @@ typedef struct WindowsGamingInputGamepadState WindowsGamingInputGamepadState;
#include "windows.gaming.input.h" #include "windows.gaming.input.h"
#endif #endif
#if defined(SDL_JOYSTICK_RAWINPUT_XINPUT) || defined(SDL_JOYSTICK_RAWINPUT_GAMING_INPUT) #if defined(SDL_JOYSTICK_RAWINPUT_XINPUT) || defined(SDL_JOYSTICK_RAWINPUT_WGI)
#define SDL_JOYSTICK_RAWINPUT_MATCHING #define SDL_JOYSTICK_RAWINPUT_MATCHING
#endif #endif
/* #define DEBUG_RAWINPUT */ /*#define DEBUG_RAWINPUT*/
#ifndef RIDEV_EXINPUTSINK #ifndef RIDEV_EXINPUTSINK
#define RIDEV_EXINPUTSINK 0x00001000 #define RIDEV_EXINPUTSINK 0x00001000
@ -140,7 +140,7 @@ struct joystick_hwdata
Uint8 xinput_slot; Uint8 xinput_slot;
#endif #endif
#ifdef SDL_JOYSTICK_RAWINPUT_GAMING_INPUT #ifdef SDL_JOYSTICK_RAWINPUT_WGI
SDL_bool wgi_correlated; SDL_bool wgi_correlated;
Uint8 wgi_correlation_id; Uint8 wgi_correlation_id;
Uint8 wgi_correlation_count; Uint8 wgi_correlation_count;
@ -175,7 +175,7 @@ typedef struct WindowsMatchState {
#ifdef SDL_JOYSTICK_RAWINPUT_XINPUT #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT
WORD xinput_buttons; WORD xinput_buttons;
#endif #endif
#ifdef SDL_JOYSTICK_RAWINPUT_GAMING_INPUT #ifdef SDL_JOYSTICK_RAWINPUT_WGI
Uint32 wgi_buttons; Uint32 wgi_buttons;
#endif #endif
SDL_bool any_data; SDL_bool any_data;
@ -236,7 +236,7 @@ static void RAWINPUT_FillMatchState(WindowsMatchState *state, Uint32 match_state
state->any_data = SDL_TRUE; state->any_data = SDL_TRUE;
#endif #endif
#ifdef SDL_JOYSTICK_RAWINPUT_GAMING_INPUT #ifdef SDL_JOYSTICK_RAWINPUT_WGI
/* Match axes by checking if the distance between the high 4 bits of axis and the 4 bits from match_state is 1 or less */ /* Match axes by checking if the distance between the high 4 bits of axis and the 4 bits from match_state is 1 or less */
#define WindowsGamingInputAxesMatch(gamepad) (\ #define WindowsGamingInputAxesMatch(gamepad) (\
(Uint16)(((Sint16)(gamepad.LeftThumbstickX * SDL_MAX_SINT16) & 0xF000) - state->match_axes[0] + 0x1000) <= 0x2fff && \ (Uint16)(((Sint16)(gamepad.LeftThumbstickX * SDL_MAX_SINT16) & 0xF000) - state->match_axes[0] + 0x1000) <= 0x2fff && \
@ -376,7 +376,7 @@ RAWINPUT_GuessXInputSlot(const WindowsMatchState *state, Uint8 *correlation_id,
#endif /* SDL_JOYSTICK_RAWINPUT_XINPUT */ #endif /* SDL_JOYSTICK_RAWINPUT_XINPUT */
#ifdef SDL_JOYSTICK_RAWINPUT_GAMING_INPUT #ifdef SDL_JOYSTICK_RAWINPUT_WGI
typedef struct WindowsGamingInputGamepadState { typedef struct WindowsGamingInputGamepadState {
__x_ABI_CWindows_CGaming_CInput_CIGamepad *gamepad; __x_ABI_CWindows_CGaming_CInput_CIGamepad *gamepad;
@ -609,7 +609,7 @@ RAWINPUT_QuitWindowsGamingInput(RAWINPUT_DeviceContext *ctx)
} }
} }
#endif /* SDL_JOYSTICK_RAWINPUT_GAMING_INPUT */ #endif /* SDL_JOYSTICK_RAWINPUT_WGI */
static int static int
RAWINPUT_JoystickInit(void) RAWINPUT_JoystickInit(void)
@ -861,7 +861,7 @@ RAWINPUT_PostUpdate(void)
#ifdef SDL_JOYSTICK_RAWINPUT_MATCHING #ifdef SDL_JOYSTICK_RAWINPUT_MATCHING
SDL_bool unmapped_guide_pressed = SDL_FALSE; SDL_bool unmapped_guide_pressed = SDL_FALSE;
#ifdef SDL_JOYSTICK_RAWINPUT_GAMING_INPUT #ifdef SDL_JOYSTICK_RAWINPUT_WGI
if (!wgi_state.dirty) { if (!wgi_state.dirty) {
int ii; int ii;
for (ii = 0; ii < wgi_state.per_gamepad_count; ii++) { for (ii = 0; ii < wgi_state.per_gamepad_count; ii++) {
@ -875,7 +875,6 @@ RAWINPUT_PostUpdate(void)
wgi_state.dirty = SDL_TRUE; wgi_state.dirty = SDL_TRUE;
#endif #endif
#ifdef SDL_JOYSTICK_RAWINPUT_XINPUT #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT
if (!xinput_state_dirty) { if (!xinput_state_dirty) {
int ii; int ii;
@ -1023,7 +1022,7 @@ RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
} }
ctx->xinput_slot = XUSER_INDEX_ANY; ctx->xinput_slot = XUSER_INDEX_ANY;
#endif #endif
#ifdef SDL_JOYSTICK_RAWINPUT_GAMING_INPUT #ifdef SDL_JOYSTICK_RAWINPUT_WGI
RAWINPUT_InitWindowsGamingInput(ctx); RAWINPUT_InitWindowsGamingInput(ctx);
#endif #endif
} }
@ -1188,13 +1187,13 @@ RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
static int static int
RAWINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) RAWINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
{ {
#if defined(SDL_JOYSTICK_RAWINPUT_GAMING_INPUT) || defined(SDL_JOYSTICK_RAWINPUT_XINPUT) #if defined(SDL_JOYSTICK_RAWINPUT_WGI) || defined(SDL_JOYSTICK_RAWINPUT_XINPUT)
RAWINPUT_DeviceContext *ctx = joystick->hwdata; RAWINPUT_DeviceContext *ctx = joystick->hwdata;
#endif #endif
SDL_bool rumbled = SDL_FALSE; SDL_bool rumbled = SDL_FALSE;
#ifdef SDL_JOYSTICK_RAWINPUT_GAMING_INPUT #ifdef SDL_JOYSTICK_RAWINPUT_WGI
if (!rumbled && ctx->wgi_correlated) { if (!rumbled && ctx->wgi_correlated) {
WindowsGamingInputGamepadState *gamepad_state = ctx->wgi_slot; WindowsGamingInputGamepadState *gamepad_state = ctx->wgi_slot;
HRESULT hr; HRESULT hr;
@ -1231,7 +1230,7 @@ RAWINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uin
static int static int
RAWINPUT_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) RAWINPUT_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble)
{ {
#if defined(SDL_JOYSTICK_RAWINPUT_GAMING_INPUT) #if defined(SDL_JOYSTICK_RAWINPUT_WGI)
RAWINPUT_DeviceContext *ctx = joystick->hwdata; RAWINPUT_DeviceContext *ctx = joystick->hwdata;
if (ctx->wgi_correlated) { if (ctx->wgi_correlated) {
@ -1401,11 +1400,11 @@ RAWINPUT_HandleStatePacket(SDL_Joystick *joystick, Uint8 *data, int size)
} }
#endif /* SDL_JOYSTICK_RAWINPUT_XINPUT */ #endif /* SDL_JOYSTICK_RAWINPUT_XINPUT */
#ifdef SDL_JOYSTICK_RAWINPUT_GAMING_INPUT #ifdef SDL_JOYSTICK_RAWINPUT_WGI
if (!has_trigger_data && ctx->wgi_correlated) { if (!has_trigger_data && ctx->wgi_correlated) {
has_trigger_data = SDL_TRUE; has_trigger_data = SDL_TRUE;
} }
#endif /* SDL_JOYSTICK_RAWINPUT_GAMING_INPUT */ #endif /* SDL_JOYSTICK_RAWINPUT_WGI */
if (!has_trigger_data) { if (!has_trigger_data) {
HIDP_DATA *item = GetData(ctx->trigger_hack_index, ctx->data, data_length); HIDP_DATA *item = GetData(ctx->trigger_hack_index, ctx->data, data_length);
@ -1451,7 +1450,7 @@ RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick)
RAWINPUT_FillMatchState(&match_state_xinput, ctx->match_state); RAWINPUT_FillMatchState(&match_state_xinput, ctx->match_state);
#ifdef SDL_JOYSTICK_RAWINPUT_GAMING_INPUT #ifdef SDL_JOYSTICK_RAWINPUT_WGI
/* Parallel logic to WINDOWS_XINPUT below */ /* Parallel logic to WINDOWS_XINPUT below */
RAWINPUT_UpdateWindowsGamingInput(); RAWINPUT_UpdateWindowsGamingInput();
if (ctx->wgi_correlated) { if (ctx->wgi_correlated) {
@ -1526,7 +1525,7 @@ RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick)
} else { } else {
correlated = SDL_TRUE; correlated = SDL_TRUE;
} }
#endif /* SDL_JOYSTICK_RAWINPUT_GAMING_INPUT */ #endif /* SDL_JOYSTICK_RAWINPUT_WGI */
#ifdef SDL_JOYSTICK_RAWINPUT_XINPUT #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT
/* Parallel logic to WINDOWS_GAMING_INPUT above */ /* Parallel logic to WINDOWS_GAMING_INPUT above */
@ -1640,7 +1639,7 @@ RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick)
} }
#endif /* SDL_JOYSTICK_RAWINPUT_XINPUT */ #endif /* SDL_JOYSTICK_RAWINPUT_XINPUT */
#ifdef SDL_JOYSTICK_RAWINPUT_GAMING_INPUT #ifdef SDL_JOYSTICK_RAWINPUT_WGI
if (!has_trigger_data && ctx->wgi_correlated) { if (!has_trigger_data && ctx->wgi_correlated) {
RAWINPUT_UpdateWindowsGamingInput(); /* May detect disconnect / cause uncorrelation */ RAWINPUT_UpdateWindowsGamingInput(); /* May detect disconnect / cause uncorrelation */
if (ctx->wgi_correlated) { /* Still connected */ if (ctx->wgi_correlated) { /* Still connected */
@ -1656,7 +1655,7 @@ RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick)
has_trigger_data = SDL_TRUE; has_trigger_data = SDL_TRUE;
} }
} }
#endif /* SDL_JOYSTICK_RAWINPUT_GAMING_INPUT */ #endif /* SDL_JOYSTICK_RAWINPUT_WGI */
if (!correlated) { if (!correlated) {
if (!guide_button_candidate.joystick || if (!guide_button_candidate.joystick ||
@ -1704,7 +1703,7 @@ RAWINPUT_JoystickClose(SDL_Joystick *joystick)
WIN_UnloadXInputDLL(); WIN_UnloadXInputDLL();
} }
#endif #endif
#ifdef SDL_JOYSTICK_RAWINPUT_GAMING_INPUT #ifdef SDL_JOYSTICK_RAWINPUT_WGI
RAWINPUT_QuitWindowsGamingInput(ctx); RAWINPUT_QuitWindowsGamingInput(ctx);
#endif #endif