mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-06 03:18:13 +00:00
Added SDL_HINT_JOYSTICK_GAMEINPUT
This commit is contained in:
@@ -1226,6 +1226,21 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
#define SDL_HINT_JOYSTICK_FLIGHTSTICK_DEVICES_EXCLUDED "SDL_JOYSTICK_FLIGHTSTICK_DEVICES_EXCLUDED"
|
#define SDL_HINT_JOYSTICK_FLIGHTSTICK_DEVICES_EXCLUDED "SDL_JOYSTICK_FLIGHTSTICK_DEVICES_EXCLUDED"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A variable controlling whether GameInput should be used for
|
||||||
|
* controller handling on Windows.
|
||||||
|
*
|
||||||
|
* The variable can be set to the following values:
|
||||||
|
*
|
||||||
|
* - "0": GameInput is not used.
|
||||||
|
* - "1": GameInput is used. (default)
|
||||||
|
*
|
||||||
|
* This hint should be set before SDL is initialized.
|
||||||
|
*
|
||||||
|
* \since This hint is available since SDL 3.0.0.
|
||||||
|
*/
|
||||||
|
#define SDL_HINT_JOYSTICK_GAMEINPUT "SDL_JOYSTICK_GAMEINPUT"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A variable containing a list of devices known to have a GameCube form
|
* A variable containing a list of devices known to have a GameCube form
|
||||||
* factor.
|
* factor.
|
||||||
|
@@ -234,6 +234,10 @@ static int GAMEINPUT_JoystickInit(void)
|
|||||||
{
|
{
|
||||||
HRESULT hR;
|
HRESULT hR;
|
||||||
|
|
||||||
|
if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_GAMEINPUT, SDL_TRUE)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!g_hGameInputDLL) {
|
if (!g_hGameInputDLL) {
|
||||||
g_hGameInputDLL = SDL_LoadObject("gameinput.dll");
|
g_hGameInputDLL = SDL_LoadObject("gameinput.dll");
|
||||||
if (!g_hGameInputDLL) {
|
if (!g_hGameInputDLL) {
|
||||||
@@ -310,22 +314,21 @@ static void GAMEINPUT_JoystickDetect(void)
|
|||||||
|
|
||||||
static SDL_bool GAMEINPUT_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name)
|
static SDL_bool GAMEINPUT_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name)
|
||||||
{
|
{
|
||||||
int idx = 0;
|
|
||||||
GAMEINPUT_InternalDevice *elem = NULL;
|
|
||||||
|
|
||||||
SDL_AssertJoysticksLocked();
|
SDL_AssertJoysticksLocked();
|
||||||
|
|
||||||
if (vendor_id == USB_VENDOR_MICROSOFT &&
|
if (g_pGameInput) {
|
||||||
product_id == USB_PRODUCT_XBOX_ONE_XBOXGIP_CONTROLLER) {
|
if (vendor_id == USB_VENDOR_MICROSOFT &&
|
||||||
/* The Xbox One controller shows up as a hardcoded raw input VID/PID, which we definitely handle */
|
product_id == USB_PRODUCT_XBOX_ONE_XBOXGIP_CONTROLLER) {
|
||||||
return SDL_TRUE;
|
/* The Xbox One controller shows up as a hardcoded raw input VID/PID, which we definitely handle */
|
||||||
}
|
|
||||||
|
|
||||||
for (idx = 0; idx < g_GameInputList.count; ++idx) {
|
|
||||||
elem = g_GameInputList.devices[idx];
|
|
||||||
if (elem && vendor_id == elem->info->vendorId && product_id == elem->info->productId) {
|
|
||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < g_GameInputList.count; ++i) {
|
||||||
|
GAMEINPUT_InternalDevice *elem = g_GameInputList.devices[i];
|
||||||
|
if (elem && vendor_id == elem->info->vendorId && product_id == elem->info->productId) {
|
||||||
|
return SDL_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user