From a33a27dbb07c48ff4fd5a1f73d495596fb5cd9d3 Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Fri, 5 May 2017 17:28:11 +0800 Subject: [PATCH] Add More Event Handling Functions. Remove Debug Message in _global_timer_executor... --- MiniEngine.cpp | 1 - MiniEngine_Event.cpp | 15 +++++++++++++++ MiniEngine_Event.h | 5 ++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/MiniEngine.cpp b/MiniEngine.cpp index 63c4618..9c8d33b 100644 --- a/MiniEngine.cpp +++ b/MiniEngine.cpp @@ -1404,7 +1404,6 @@ namespace MiniEngine /// Global Executor For class Timer Uint32 _global_timer_executor(Uint32 interval,void* param) { - printf("DEBUG: Global Timer Executor.\n"); auto p=reinterpret_cast*>(param); return (*p)(interval); } diff --git a/MiniEngine_Event.cpp b/MiniEngine_Event.cpp index 6f39595..d5ed6d8 100644 --- a/MiniEngine_Event.cpp +++ b/MiniEngine_Event.cpp @@ -20,6 +20,21 @@ int PushEvent(const Event& refEvent) return SDL_PushEvent(const_cast(&refEvent)); } +void PumpEvents() +{ + SDL_PumpEvents(); +} + +bool HasEvent(decltype(Event::type) EventType) +{ + return ( SDL_HasEvent(EventType)==SDL_TRUE ); +} + +bool HasEvent(decltype(Event::type) EventTypeMin,decltype(Event::type) EventTypeMax) +{ + return ( SDL_HasEvents(EventTypeMin,EventTypeMax)==SDL_TRUE ); +} + bool operator == (const LooperID& a,const LooperID& b) { return a._type_id==b._type_id && a._looper_cnt==b._looper_cnt ; diff --git a/MiniEngine_Event.h b/MiniEngine_Event.h index 4884bd5..8074765 100644 --- a/MiniEngine_Event.h +++ b/MiniEngine_Event.h @@ -9,6 +9,9 @@ int PollEvent(Event& refEvent); int WaitEvent(Event& refEvent); int WaitEventTimeout(Event& refEvent,int ms); int PushEvent(const Event& refEvent); +void PumpEvents(); +bool HasEvent(decltype(Event::type) EventType); +bool HasEvent(decltype(Event::type) EventTypeMin,decltype(Event::type) EventTypeMax); typedef struct { @@ -86,4 +89,4 @@ public: void run(); protected: int _timeout_ms; -}; \ No newline at end of file +};