Skip to content

Commit

Permalink
add single-poll blocker function
Browse files Browse the repository at this point in the history
  • Loading branch information
xan1242 committed Oct 18, 2023
1 parent 6481645 commit d707750
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,11 @@ class InputDevice {
virtual void PollDevice() {
if (!bGlobalDoPolling) return;

if (bBlockThisPoll) {
bBlockThisPoll = false;
return;
}

ReadControllerData();
WORD wButtons = g_Controllers[fDeviceIndex].state.Gamepad.wButtons;
WORD SecondBind = 0;
Expand Down Expand Up @@ -1992,13 +1997,24 @@ int Init() {
return 0;
}

//
// Interface functions -- for use with other plugins and/or mods.
//

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

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

// Blocks a poll for exactly 1 poll cycle -- useful for frame-accurate blocks
extern "C" __declspec(dllexport) void BlockNextPoll() {
bBlockThisPoll = true;
}

extern "C" __declspec(dllexport) bool GetBlockNextPoll() { return bBlockThisPoll; }

#ifndef NO_FENG
extern "C" __declspec(dllexport) float GetFEScale() { return fFEScale; }

Expand Down
1 change: 1 addition & 0 deletions src/NFS_XtendedInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ unsigned int ControllerIconMode = 0; // read modes above

bool bInDebugWorldCamera = false;
bool bGlobalDoPolling = true;
bool bBlockThisPoll = false;
bool bEnableSplashTakeover = true;
#ifndef NO_FENG
bool bConsoleFEng = false;
Expand Down

0 comments on commit d707750

Please sign in to comment.