mirror of https://github.com/encounter/SDL.git
Add SDL_HINT_DIRECTINPUT_ENABLED (on by default)
This commit is contained in:
parent
db7dfece16
commit
6a2e6c82a0
|
@ -2001,6 +2001,15 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
#define SDL_HINT_XINPUT_ENABLED "SDL_XINPUT_ENABLED"
|
#define SDL_HINT_XINPUT_ENABLED "SDL_XINPUT_ENABLED"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief A variable that lets you disable the detection and use of DirectInput gamepad devices
|
||||||
|
*
|
||||||
|
* The variable can be set to the following values:
|
||||||
|
* "0" - Disable DirectInput detection (only uses XInput)
|
||||||
|
* "1" - Enable DirectInput detection (the default)
|
||||||
|
*/
|
||||||
|
#define SDL_HINT_DIRECTINPUT_ENABLED "SDL_DIRECTINPUT_ENABLED"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A variable that causes SDL to use the old axis and button mapping for XInput devices.
|
* \brief A variable that causes SDL to use the old axis and button mapping for XInput devices.
|
||||||
*
|
*
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#if SDL_HAPTIC_DINPUT
|
#if SDL_HAPTIC_DINPUT
|
||||||
|
|
||||||
|
#include "SDL_hints.h"
|
||||||
#include "SDL_stdinc.h"
|
#include "SDL_stdinc.h"
|
||||||
#include "SDL_timer.h"
|
#include "SDL_timer.h"
|
||||||
#include "SDL_windowshaptic_c.h"
|
#include "SDL_windowshaptic_c.h"
|
||||||
|
@ -77,6 +78,11 @@ SDL_DINPUT_HapticInit(void)
|
||||||
return SDL_SetError("Haptic: SubSystem already open.");
|
return SDL_SetError("Haptic: SubSystem already open.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!SDL_GetHintBoolean(SDL_HINT_DIRECTINPUT_ENABLED, SDL_TRUE)) {
|
||||||
|
/* In some environments, IDirectInput8_Initialize / _EnumDevices can take a minute even with no controllers. */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
ret = WIN_CoInitialize();
|
ret = WIN_CoInitialize();
|
||||||
if (FAILED(ret)) {
|
if (FAILED(ret)) {
|
||||||
return DI_SetError("Coinitialize", ret);
|
return DI_SetError("Coinitialize", ret);
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#if SDL_JOYSTICK_DINPUT
|
#if SDL_JOYSTICK_DINPUT
|
||||||
|
|
||||||
|
#include "SDL_hints.h"
|
||||||
#include "SDL_windowsjoystick_c.h"
|
#include "SDL_windowsjoystick_c.h"
|
||||||
#include "SDL_dinputjoystick_c.h"
|
#include "SDL_dinputjoystick_c.h"
|
||||||
#include "SDL_rawinputjoystick_c.h"
|
#include "SDL_rawinputjoystick_c.h"
|
||||||
|
@ -397,6 +398,12 @@ SDL_DINPUT_JoystickInit(void)
|
||||||
HRESULT result;
|
HRESULT result;
|
||||||
HINSTANCE instance;
|
HINSTANCE instance;
|
||||||
|
|
||||||
|
if (!SDL_GetHintBoolean(SDL_HINT_DIRECTINPUT_ENABLED, SDL_TRUE)) {
|
||||||
|
/* In some environments, IDirectInput8_Initialize / _EnumDevices can take a minute even with no controllers. */
|
||||||
|
dinput = NULL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
result = WIN_CoInitialize();
|
result = WIN_CoInitialize();
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
return SetDIerror("CoInitialize", result);
|
return SetDIerror("CoInitialize", result);
|
||||||
|
@ -539,6 +546,10 @@ err:
|
||||||
void
|
void
|
||||||
SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext)
|
SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext)
|
||||||
{
|
{
|
||||||
|
if (dinput == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
IDirectInput8_EnumDevices(dinput, DI8DEVCLASS_GAMECTRL, EnumJoystickDetectCallback, pContext, DIEDFL_ATTACHEDONLY);
|
IDirectInput8_EnumDevices(dinput, DI8DEVCLASS_GAMECTRL, EnumJoystickDetectCallback, pContext, DIEDFL_ATTACHEDONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue