Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/core/windows/SDL_gameinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
*/
#include "SDL_internal.h"

#ifdef HAVE_GAMEINPUT_H

#include "SDL_windows.h"
#include "SDL_gameinput.h"

#ifdef HAVE_GAMEINPUT_H

static SDL_SharedObject *g_hGameInputDLL;
static IGameInput *g_pGameInput;
static int g_nGameInputRefCount;
Expand Down Expand Up @@ -99,4 +99,20 @@ void SDL_QuitGameInput(void)
}
}

bool SDL_UsingGameInputForXInputControllers(void)
{
if (SDL_GetHintBoolean(SDL_HINT_JOYSTICK_GAMEINPUT, SDL_GAMEINPUT_DEFAULT) &&
SDL_GameInputReady()) {
return true;
}
return false;
}

#else

bool SDL_UsingGameInputForXInputControllers(void)
{
return false;
}

#endif // HAVE_GAMEINPUT_H
17 changes: 17 additions & 0 deletions src/core/windows/SDL_gameinput.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,27 @@ using namespace GameInput::v2;
using namespace GameInput::v1;
#endif

// Default value for SDL_HINT_JOYSTICK_GAMEINPUT
#if defined(SDL_PLATFORM_GDK) || (GAMEINPUT_API_VERSION >= 3)
#define SDL_GAMEINPUT_DEFAULT true
#else
#define SDL_GAMEINPUT_DEFAULT false
#endif

extern bool SDL_InitGameInput(IGameInput **ppGameInput);
extern bool SDL_GameInputReady(void);
extern void SDL_QuitGameInput(void);

#endif // HAVE_GAMEINPUT_H

#ifdef __cplusplus
extern "C" {
#endif

extern bool SDL_UsingGameInputForXInputControllers(void);
Comment thread
slouken marked this conversation as resolved.

#ifdef __cplusplus
}
#endif

#endif // SDL_gameinput_h_
26 changes: 0 additions & 26 deletions src/joystick/gdk/SDL_gameinputjoystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,13 @@
*/
#include "SDL_internal.h"

#include "SDL_gameinputjoystick_c.h"

#ifdef SDL_JOYSTICK_GAMEINPUT

#include "../SDL_sysjoystick.h"
#include "../usb_ids.h"
#include "../../core/windows/SDL_windows.h"
#include "../../core/windows/SDL_gameinput.h"

// Default value for SDL_HINT_JOYSTICK_GAMEINPUT
#if defined(SDL_PLATFORM_GDK) || (GAMEINPUT_API_VERSION >= 3)
#define SDL_GAMEINPUT_DEFAULT true
#else
#define SDL_GAMEINPUT_DEFAULT false
#endif

enum
{
SDL_GAMEPAD_BUTTON_GAMEINPUT_SHARE = 11
Expand Down Expand Up @@ -1053,15 +1044,6 @@ static bool GAMEINPUT_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap
return true;
}

bool SDL_UsingGameInputForXInputControllers(void)
{
if (SDL_GetHintBoolean(SDL_HINT_JOYSTICK_GAMEINPUT, SDL_GAMEINPUT_DEFAULT) &&
SDL_GameInputReady()) {
return true;
}
return false;
}


SDL_JoystickDriver SDL_GAMEINPUT_JoystickDriver =
{
Expand All @@ -1088,12 +1070,4 @@ SDL_JoystickDriver SDL_GAMEINPUT_JoystickDriver =
GAMEINPUT_JoystickGetGamepadMapping
};


#else

bool SDL_UsingGameInputForXInputControllers(void)
{
return false;
}

#endif // SDL_JOYSTICK_GAMEINPUT
33 changes: 0 additions & 33 deletions src/joystick/gdk/SDL_gameinputjoystick_c.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/joystick/windows/SDL_dinputjoystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
#include "SDL_dinputjoystick_c.h"
#include "SDL_rawinputjoystick_c.h"
#include "SDL_xinputjoystick_c.h"
#include "../../core/windows/SDL_gameinput.h"
#include "../hidapi/SDL_hidapijoystick_c.h"
#include "../gdk/SDL_gameinputjoystick_c.h"

#ifndef DIDFT_OPTIONAL
#define DIDFT_OPTIONAL 0x80000000
Expand Down
2 changes: 1 addition & 1 deletion src/joystick/windows/SDL_rawinputjoystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
#include "../SDL_sysjoystick.h"
#include "../../core/windows/SDL_windows.h"
#include "../../core/windows/SDL_hid.h"
#include "../../core/windows/SDL_gameinput.h"
#include "../hidapi/SDL_hidapijoystick_c.h"
#include "../gdk/SDL_gameinputjoystick_c.h"

/* SDL_JOYSTICK_RAWINPUT_XINPUT is disabled because using XInput at the same time as
raw input will turn off the Xbox Series X controller when it is connected via the
Expand Down
2 changes: 1 addition & 1 deletion src/joystick/windows/SDL_windows_gaming_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "../SDL_sysjoystick.h"
#include "../hidapi/SDL_hidapijoystick_c.h"
#include "../gdk/SDL_gameinputjoystick_c.h"
#include "../../core/windows/SDL_gameinput.h"
#include "SDL_rawinputjoystick_c.h"

#include "../../core/windows/SDL_windows.h"
Expand Down
7 changes: 3 additions & 4 deletions src/joystick/windows/SDL_xinputjoystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,16 @@
#include "SDL_windowsjoystick_c.h"
#include "SDL_xinputjoystick_c.h"
#include "SDL_rawinputjoystick_c.h"
#include "../../core/windows/SDL_gameinput.h"
#include "../hidapi/SDL_hidapijoystick_c.h"
#include "../gdk/SDL_gameinputjoystick_c.h"

// Set up for C function definitions, even when using C++
#ifdef __cplusplus
extern "C" {
#endif

/*
* Internal stuff.
*/
// Internal stuff

static bool s_bXInputEnabled = false;

bool SDL_XINPUT_Enabled(void)
Expand Down
Loading