MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / enable

Method enable

Engine/source/platformWin32/winDirectInput.cpp:70–138  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

68
69//------------------------------------------------------------------------------
70bool DInputManager::enable()
71{
72 FN_DirectInputCreate fnDInputCreate;
73
74 disable();
75
76 // Dynamically load the XInput 9 DLL and cache function pointers to the
77 // two APIs we use
78#ifdef LOG_INPUT
79 Input::log( "Enabling XInput...\n" );
80#endif
81 mXInputLib = LoadLibrary( dT("xinput9_1_0.dll") );
82 if ( mXInputLib )
83 {
84 mfnXInputGetState = (FN_XInputGetState) GetProcAddress( mXInputLib, "XInputGetState" );
85 mfnXInputSetState = (FN_XInputSetState) GetProcAddress( mXInputLib, "XInputSetState" );
86 if ( mfnXInputGetState && mfnXInputSetState )
87 {
88#ifdef LOG_INPUT
89 Input::log( "XInput detected.\n" );
90#endif
91 mXInputStateReset = true;
92 mXInputDeadZoneOn = true;
93 smXInputEnabled = true;
94 }
95 }
96 else
97 {
98#ifdef LOG_INPUT
99 Input::log( "XInput was not found.\n" );
100 mXInputStateReset = false;
101 mXInputDeadZoneOn = false;
102#endif
103 }
104
105#ifdef LOG_INPUT
106 Input::log( "Enabling DirectInput...\n" );
107#endif
108 mDInputLib = LoadLibrary( dT("DInput8.dll") );
109 if ( mDInputLib )
110 {
111 fnDInputCreate = (FN_DirectInputCreate) GetProcAddress( mDInputLib, "DirectInput8Create" );
112 if ( fnDInputCreate )
113 {
114 bool result = SUCCEEDED( fnDInputCreate( winState.appInstance, DIRECTINPUT_VERSION, IID_IDirectInput8, reinterpret_cast<void**>(&mDInputInterface), NULL ));
115 if ( result )
116 {
117#ifdef LOG_INPUT
118 Input::log( "DirectX 8 or greater detected.\n" );
119#endif
120 }
121
122 if ( result )
123 {
124 enumerateDevices();
125 mEnabled = true;
126 return true;
127 }

Callers

nothing calls this directly

Calls 1

logFunction · 0.50

Tested by

no test coverage detected