Merge pull request #129 from death-droid/master

Change to how NRage is dynamically linking XInput, rather than loading i...
This commit is contained in:
zilmar 2015-02-23 03:56:03 +11:00
commit b0a5bdbc5f
2 changed files with 11 additions and 31 deletions

View File

@ -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;
}

View File

@ -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