Skip to content

Commit

Permalink
add exports for polling control
Browse files Browse the repository at this point in the history
  • Loading branch information
xan1242 committed Mar 13, 2023
1 parent ac22169 commit 3036db7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions NFS_XtendedInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ unsigned int LastControlledDeviceOldState = 0;
unsigned int ControllerIconMode = 0; // read modes above

bool bInDebugWorldCamera = false;
bool bGlobalDoPolling = true;
2 changes: 1 addition & 1 deletion NFS_XtendedInput_FEng.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ void* FEngSetTextureHash_CheckObj(FEObject* inobj, unsigned int obj_hash, unsign

void UpdateFECursorPos()
{
if (*(int*)GAMEFLOWMANAGER_STATUS_ADDR != 0) // don't execute until we're in the game... fixes BSOD crash on old ATI video drivers...
if ((*(int*)GAMEFLOWMANAGER_STATUS_ADDR != 0) && bGlobalDoPolling) // don't execute until we're in the game... fixes BSOD crash on old ATI video drivers...
{
bool bMouseInGameWindow = false;
bool bShowMouse = true;
Expand Down
17 changes: 15 additions & 2 deletions dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ HRESULT UpdateControllerState()
void ReadXInput_Extra()
{
#ifndef NO_QUIT_BUTTON
if (g_Controllers[0].bConnected)
if (g_Controllers[0].bConnected && bGlobalDoPolling)
{
WORD wButtons = g_Controllers[0].state.Gamepad.wButtons;

Expand Down Expand Up @@ -349,7 +349,7 @@ void __stdcall ReadControllerData()
GetKeyboardState(VKeyStates[0]);

// read mouse info for Debug World Camera
if (bInDebugWorldCamera)
if (bInDebugWorldCamera && bGlobalDoPolling)
{
RECT windowRect;
POINT MousePos;
Expand Down Expand Up @@ -820,6 +820,9 @@ class InputDevice
}
virtual void PollDevice()
{
if (!bGlobalDoPolling)
return;

ReadControllerData();
WORD wButtons = g_Controllers[fDeviceIndex].state.Gamepad.wButtons;
WORD SecondBind = 0;
Expand Down Expand Up @@ -1618,6 +1621,16 @@ int Init()
return 0;
}

extern "C" __declspec(dllexport) bool GetPollingState()
{
return bGlobalDoPolling;
}

extern "C" __declspec(dllexport) bool SetPollingState(bool state)
{
bGlobalDoPolling = state;
return state;
}

BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD reason, LPVOID /*lpReserved*/)
{
Expand Down

0 comments on commit 3036db7

Please sign in to comment.