mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
[cscore] Add polled support to listener
Change Java VideoListener to use polling.
This commit is contained in:
@@ -46,6 +46,7 @@ typedef int CS_Status;
|
||||
typedef int CS_Handle;
|
||||
typedef CS_Handle CS_Property;
|
||||
typedef CS_Handle CS_Listener;
|
||||
typedef CS_Handle CS_ListenerPoller;
|
||||
typedef CS_Handle CS_Sink;
|
||||
typedef CS_Handle CS_Source;
|
||||
/** @} */
|
||||
@@ -222,6 +223,9 @@ struct CS_Event {
|
||||
enum CS_PropertyKind propertyKind;
|
||||
int value;
|
||||
const char* valueStr;
|
||||
|
||||
// Listener that was triggered
|
||||
CS_Listener listener;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -429,9 +433,19 @@ void CS_SetListenerOnStart(void (*onStart)(void* data), void* data);
|
||||
void CS_SetListenerOnExit(void (*onExit)(void* data), void* data);
|
||||
CS_Listener CS_AddListener(
|
||||
void* data, void (*callback)(void* data, const struct CS_Event* event),
|
||||
int eventMask, int immediateNotify, CS_Status* status);
|
||||
int eventMask, CS_Bool immediateNotify, CS_Status* status);
|
||||
|
||||
void CS_RemoveListener(CS_Listener handle, CS_Status* status);
|
||||
|
||||
CS_ListenerPoller CS_CreateListenerPoller(void);
|
||||
void CS_DestroyListenerPoller(CS_ListenerPoller poller);
|
||||
CS_Listener CS_AddPolledListener(CS_ListenerPoller poller, int eventMask,
|
||||
CS_Bool immediateNotify, CS_Status* status);
|
||||
struct CS_Event* CS_PollListener(CS_ListenerPoller poller, int* count);
|
||||
struct CS_Event* CS_PollListenerTimeout(CS_ListenerPoller poller, int* count,
|
||||
double timeout, CS_Bool* timedOut);
|
||||
void CS_FreeEvents(struct CS_Event* arr, int count);
|
||||
void CS_CancelPollListener(CS_ListenerPoller poller);
|
||||
/** @} */
|
||||
|
||||
int CS_NotifierDestroyed(void);
|
||||
|
||||
@@ -163,6 +163,9 @@ struct RawEvent {
|
||||
CS_PropertyKind propertyKind;
|
||||
int value;
|
||||
std::string valueStr;
|
||||
|
||||
// Listener that was triggered
|
||||
CS_Listener listener{0};
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -378,6 +381,15 @@ CS_Listener AddListener(std::function<void(const RawEvent& event)> callback,
|
||||
int eventMask, bool immediateNotify, CS_Status* status);
|
||||
|
||||
void RemoveListener(CS_Listener handle, CS_Status* status);
|
||||
|
||||
CS_ListenerPoller CreateListenerPoller();
|
||||
void DestroyListenerPoller(CS_ListenerPoller poller);
|
||||
CS_Listener AddPolledListener(CS_ListenerPoller poller, int eventMask,
|
||||
bool immediateNotify, CS_Status* status);
|
||||
std::vector<RawEvent> PollListener(CS_ListenerPoller poller);
|
||||
std::vector<RawEvent> PollListener(CS_ListenerPoller poller, double timeout,
|
||||
bool* timedOut);
|
||||
void CancelPollListener(CS_ListenerPoller poller);
|
||||
/** @} */
|
||||
|
||||
bool NotifierDestroyed();
|
||||
|
||||
Reference in New Issue
Block a user