载入中...
搜索中...
未找到
PlatformEventSink.h
浏览该文件的文档.
1#pragma once
2
3// A module's hook into the raw platform event stream.
4//
5// The SDL pump used to translate every event itself, which meant it had to know
6// about keyboard, joystick, touch, window, graphics, audio and ui -- eight
7// upward dependencies from what should be one of the lowest modules, and the
8// last dependency cycle in the engine.
9//
10// Now each module registers a sink for the events it owns. The pump drains the
11// platform queue and offers each event to the sinks in priority order; whoever
12// recognises it translates it. Modules the build does not contain simply have
13// no sink, so the pump keeps working with any subset linked in.
14//
15// Providers depend on event (downwards, which is fine); event depends on none
16// of them.
17//
18// `nativeEvent` is the backend's own event object -- SDL_Event* for the SDL
19// backend. Only sinks built against the active backend are ever registered, so
20// the cast is safe; the sinks in question are themselves backend code
21// (keyboard/sdl, touch/sdl, ...).
22
23#include "common/Capability.h"
24#include "common/Export.h"
25
26namespace eve::platform_event {
27
28class Message;
29
32public:
35 enum Priority {
36 kObserver = 0, // sees everything before anyone claims it (UI)
37 kSurface = 10, // window / swapchain lifecycle
38 kInput = 20, // keyboard, joystick, touch
39 };
40
41 static constexpr const char* capabilityName = "eve.event.IPlatformEventSink";
42 virtual ~IPlatformEventSink() = default;
43
50 virtual bool shouldConsumePlatformEvent(const void* nativeEvent) { return false; }
51
59 virtual Message* translatePlatformEvent(const void* nativeEvent) { return nullptr; }
60
62 virtual void onPumpFinished() {}
63};
64
65} // namespace eve::platform_event
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
EVENGINE_API_FOUNDATION public API.
virtual bool shouldConsumePlatformEvent(const void *nativeEvent)
virtual Message * translatePlatformEvent(const void *nativeEvent)
A named event carrying an ordered list of Variant payloads. Pushed messages are heap-allocated; the q...