mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-20 02:08:13 +00:00
Add SDL_HINT_DIRECTINPUT_ENABLED (on by default)
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
#if SDL_JOYSTICK_DINPUT
|
||||
|
||||
#include "SDL_hints.h"
|
||||
#include "SDL_windowsjoystick_c.h"
|
||||
#include "SDL_dinputjoystick_c.h"
|
||||
#include "SDL_rawinputjoystick_c.h"
|
||||
@@ -397,6 +398,12 @@ SDL_DINPUT_JoystickInit(void)
|
||||
HRESULT result;
|
||||
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();
|
||||
if (FAILED(result)) {
|
||||
return SetDIerror("CoInitialize", result);
|
||||
@@ -539,6 +546,10 @@ err:
|
||||
void
|
||||
SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext)
|
||||
{
|
||||
if (dinput == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
IDirectInput8_EnumDevices(dinput, DI8DEVCLASS_GAMECTRL, EnumJoystickDetectCallback, pContext, DIEDFL_ATTACHEDONLY);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user