-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dynamically load latest version of XInput instead of static linking
- Loading branch information
Showing
11 changed files
with
145 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#include "nil.h" | ||
#include "nilLogitech.h" | ||
#include "nilWindows.h" | ||
|
||
namespace Nil { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#include "nil.h" | ||
#include "nilUtil.h" | ||
#include "nilWindows.h" | ||
|
||
# define NIL_LOAD_EXTERNAL_FUNC(x) mFunctions.pfn##x##=(fn##x##)GetProcAddress(mModule,#x) | ||
|
||
namespace Nil { | ||
|
||
XInput::Functions::Functions(): pfnXInputGetState( nullptr ), | ||
pfnXInputSetState( nullptr ), pfnXInputGetCapabilities( nullptr ) | ||
{ | ||
} | ||
|
||
XInput::XInput(): mVersion( Version_None ) | ||
{ | ||
} | ||
|
||
XInput::InitReturn XInput::initialize() | ||
{ | ||
mModule = LoadLibraryW( L"xinput1_4.dll" ); | ||
if ( mModule ) | ||
mVersion = Version_14; | ||
else | ||
{ | ||
mModule = LoadLibraryW( L"xinput1_3.dll" ); | ||
if ( mModule ) | ||
mVersion = Version_13; | ||
else | ||
{ | ||
mModule = LoadLibraryW( L"xinput9_1_0.dll" ); | ||
if ( mModule ) | ||
mVersion = Version_910; | ||
else | ||
return Initialization_ModuleNotFound; | ||
} | ||
} | ||
|
||
NIL_LOAD_EXTERNAL_FUNC( XInputGetState ); | ||
NIL_LOAD_EXTERNAL_FUNC( XInputSetState ); | ||
NIL_LOAD_EXTERNAL_FUNC( XInputGetCapabilities ); | ||
|
||
if ( !mFunctions.pfnXInputGetState | ||
|| !mFunctions.pfnXInputSetState | ||
|| !mFunctions.pfnXInputGetCapabilities ) | ||
return Initialization_MissingExports; | ||
|
||
mInitialized = true; | ||
|
||
return Initialization_OK; | ||
} | ||
|
||
void XInput::shutdown() | ||
{ | ||
if ( mModule ) | ||
{ | ||
FreeLibrary( mModule ); | ||
mModule = NULL; | ||
} | ||
mInitialized = false; | ||
} | ||
|
||
XInput::~XInput() | ||
{ | ||
shutdown(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters