Skip to content

Commit d707750

Browse files
committed
add single-poll blocker function
1 parent 6481645 commit d707750

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/Main.hpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,11 @@ class InputDevice {
11491149
virtual void PollDevice() {
11501150
if (!bGlobalDoPolling) return;
11511151

1152+
if (bBlockThisPoll) {
1153+
bBlockThisPoll = false;
1154+
return;
1155+
}
1156+
11521157
ReadControllerData();
11531158
WORD wButtons = g_Controllers[fDeviceIndex].state.Gamepad.wButtons;
11541159
WORD SecondBind = 0;
@@ -1992,13 +1997,24 @@ int Init() {
19921997
return 0;
19931998
}
19941999

2000+
//
2001+
// Interface functions -- for use with other plugins and/or mods.
2002+
//
2003+
19952004
extern "C" __declspec(dllexport) bool GetPollingState() { return bGlobalDoPolling; }
19962005

19972006
extern "C" __declspec(dllexport) bool SetPollingState(bool state) {
19982007
bGlobalDoPolling = state;
19992008
return state;
20002009
}
20012010

2011+
// Blocks a poll for exactly 1 poll cycle -- useful for frame-accurate blocks
2012+
extern "C" __declspec(dllexport) void BlockNextPoll() {
2013+
bBlockThisPoll = true;
2014+
}
2015+
2016+
extern "C" __declspec(dllexport) bool GetBlockNextPoll() { return bBlockThisPoll; }
2017+
20022018
#ifndef NO_FENG
20032019
extern "C" __declspec(dllexport) float GetFEScale() { return fFEScale; }
20042020

src/NFS_XtendedInput.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ unsigned int ControllerIconMode = 0; // read modes above
5454

5555
bool bInDebugWorldCamera = false;
5656
bool bGlobalDoPolling = true;
57+
bool bBlockThisPoll = false;
5758
bool bEnableSplashTakeover = true;
5859
#ifndef NO_FENG
5960
bool bConsoleFEng = false;

0 commit comments

Comments
 (0)