Change to how NRage is dynamically linking XInput, rather than loading it every time functions such as GetXInputControllerKeys is called. Do it on initiate of controllers. Still not the best way to handle it.
Need to rethink the way NRage handles the different API's rather than just tacking it on the side
This commit is contained in:
parent
e51ec31e65
commit
6b1a88d3a4
|
@ -155,17 +155,6 @@ void AxisDeadzone( SHORT &AxisValue, long lDeadZoneValue, float fDeadZoneRelati
|
|||
|
||||
void GetXInputControllerKeys( const int indexController, LPDWORD Keys )
|
||||
{
|
||||
HMODULE hInput = LoadLibrary("Xinput1_4.dll");
|
||||
if (hInput == NULL)
|
||||
{
|
||||
hInput = LoadLibrary("Xinput9_1_0.dll");
|
||||
}
|
||||
if (hInput == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DWORD(WINAPI * fnXInputGetState) (DWORD dwUserIndex, XINPUT_STATE* pState) = NULL;
|
||||
if (fnXInputGetState == NULL)
|
||||
{
|
||||
return;
|
||||
|
@ -302,6 +291,11 @@ void DefaultXInputControllerKeys( LPXCONTROLLER gController)
|
|||
|
||||
void VibrateXInputController( DWORD nController, int LeftMotorVal, int RightMotorVal )
|
||||
{
|
||||
if (fnXInputSetState == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
XINPUT_VIBRATION vibration;
|
||||
|
||||
ZeroMemory( &vibration, sizeof( XINPUT_VIBRATION ) );
|
||||
|
@ -309,23 +303,6 @@ void VibrateXInputController( DWORD nController, int LeftMotorVal, int RightMoto
|
|||
vibration.wLeftMotorSpeed = LeftMotorVal;
|
||||
vibration.wRightMotorSpeed = RightMotorVal;
|
||||
|
||||
HMODULE hInput = LoadLibrary("Xinput1_4.dll");
|
||||
if (hInput == NULL)
|
||||
{
|
||||
hInput = LoadLibrary("Xinput9_1_0.dll");
|
||||
}
|
||||
if (hInput == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DWORD (WINAPI * fnXInputSetState) ( DWORD dwUserIndex, XINPUT_VIBRATION* pVibration ) = NULL;
|
||||
fnXInputSetState = (DWORD(WINAPI *) (DWORD, XINPUT_VIBRATION*))GetProcAddress(hInput, "XInputSetState");
|
||||
if (fnXInputSetState == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fnXInputSetState(nController, &vibration);
|
||||
}
|
||||
|
||||
|
@ -340,10 +317,10 @@ bool InitiateXInputController( LPXCONTROLLER gController, int nControl )
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD(WINAPI * fnXInputGetState) (DWORD dwUserIndex, XINPUT_STATE* pState) = NULL;
|
||||
|
||||
fnXInputSetState = (DWORD(WINAPI *) (DWORD, XINPUT_VIBRATION*))GetProcAddress(hInput, "XInputSetState");
|
||||
fnXInputGetState = (DWORD(WINAPI *) (DWORD, XINPUT_STATE*))GetProcAddress(hInput, "XInputGetState");
|
||||
if (fnXInputGetState == NULL)
|
||||
if (fnXInputGetState == NULL || fnXInputSetState == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -114,6 +114,9 @@ void VibrateXInputController( DWORD nController, int LeftMotorVal = 65535, int R
|
|||
// Initialize nControl XInput enabled controller
|
||||
bool InitiateXInputController( LPXCONTROLLER gController, int nControl );
|
||||
|
||||
static DWORD(WINAPI * fnXInputGetState) (DWORD dwUserIndex, XINPUT_STATE* pState) = NULL;
|
||||
static DWORD(WINAPI * fnXInputSetState) (DWORD dwUserIndex, XINPUT_VIBRATION* pVibration) = NULL;
|
||||
|
||||
// XController dialog
|
||||
|
||||
#define XC_DPAD 1
|
||||
|
|
Loading…
Reference in New Issue