mirror of
https://github.com/nefarius/ViGEmBus.git
synced 2025-08-10 00:52:17 +00:00
Implemented timer
This commit is contained in:
@@ -143,6 +143,11 @@ typedef struct _FDO_DEVICE_DATA
|
||||
//
|
||||
WDFSPINLOCK PendingPluginRequestsLock;
|
||||
|
||||
//
|
||||
// Periodic timer sweeping up orphaned requests
|
||||
//
|
||||
WDFTIMER PendingPluginRequestsCleanupTimer;
|
||||
|
||||
} FDO_DEVICE_DATA, *PFDO_DEVICE_DATA;
|
||||
|
||||
#define FDO_FIRST_SESSION_ID 100
|
||||
|
||||
33
sys/Driver.c
33
sys/Driver.c
@@ -93,9 +93,11 @@ NTSTATUS Bus_EvtDeviceAdd(IN WDFDRIVER Driver, IN PWDFDEVICE_INIT DeviceInit)
|
||||
WDF_OBJECT_ATTRIBUTES fdoAttributes;
|
||||
WDF_OBJECT_ATTRIBUTES fileHandleAttributes;
|
||||
WDF_OBJECT_ATTRIBUTES collectionAttributes;
|
||||
WDF_OBJECT_ATTRIBUTES timerAttributes;
|
||||
PFDO_DEVICE_DATA pFDOData;
|
||||
VIGEM_BUS_INTERFACE busInterface;
|
||||
PINTERFACE interfaceHeader;
|
||||
WDF_TIMER_CONFIG reqTimerCfg;
|
||||
|
||||
UNREFERENCED_PARAMETER(Driver);
|
||||
|
||||
@@ -188,6 +190,25 @@ NTSTATUS Bus_EvtDeviceAdd(IN WDFDRIVER Driver, IN PWDFDEVICE_INIT DeviceInit)
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Create timer for sweeping up orphaned requests
|
||||
|
||||
WDF_TIMER_CONFIG_INIT_PERIODIC(&reqTimerCfg, Bus_PlugInRequestCleanUpEvtTimerFunc, 500);
|
||||
WDF_OBJECT_ATTRIBUTES_INIT(&timerAttributes);
|
||||
timerAttributes.ParentObject = device;
|
||||
|
||||
status = WdfTimerCreate(&reqTimerCfg, &timerAttributes, &pFDOData->PendingPluginRequestsCleanupTimer);
|
||||
if (!NT_SUCCESS(status)) {
|
||||
TraceEvents(TRACE_LEVEL_ERROR,
|
||||
TRACE_DRIVER,
|
||||
"WdfTimerCreate failed with status %!STATUS!",
|
||||
status);
|
||||
return status;
|
||||
}
|
||||
|
||||
WdfTimerStart(pFDOData->PendingPluginRequestsCleanupTimer, WDF_REL_TIMEOUT_IN_SEC(1));
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Add query interface
|
||||
|
||||
//
|
||||
@@ -559,3 +580,15 @@ Bus_PdoStageResult(
|
||||
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Exit");
|
||||
}
|
||||
|
||||
_Use_decl_annotations_
|
||||
VOID
|
||||
Bus_PlugInRequestCleanUpEvtTimerFunc(
|
||||
WDFTIMER Timer
|
||||
)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(Timer);
|
||||
|
||||
TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry");
|
||||
}
|
||||
|
||||
|
||||
@@ -102,6 +102,8 @@ EVT_WDF_TIMER Xgip_SysInitTimerFunc;
|
||||
|
||||
EVT_WDF_OBJECT_CONTEXT_CLEANUP Bus_EvtDriverContextCleanup;
|
||||
|
||||
EVT_WDF_TIMER Bus_PlugInRequestCleanUpEvtTimerFunc;
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Bus enumeration-specific functions
|
||||
|
||||
Reference in New Issue
Block a user