载入中...
搜索中...
未找到
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::event {
27
28class Message;
29
31public:
33 enum Priority {
34 kObserver = 0, // sees everything before anyone claims it (UI)
35 kSurface = 10, // window / swapchain lifecycle
36 kInput = 20, // keyboard, joystick, touch
37 };
38
39 static constexpr const char* capabilityName = "eve.event.IPlatformEventSink";
40 virtual ~IPlatformEventSink() = default;
41
46 virtual bool observePlatformEvent(const void* nativeEvent) { return false; }
47
53 virtual Message* translatePlatformEvent(const void* nativeEvent) { return nullptr; }
54
56 virtual void onPumpFinished() {}
57};
58
59} // namespace eve::event
#define EVENGINE_API
宿主(eve / libmain)导出宏;插件从进程导入同一批符号。
Definition Export.h:16
virtual bool observePlatformEvent(const void *nativeEvent)
virtual Message * translatePlatformEvent(const void *nativeEvent)
virtual ~IPlatformEventSink()=default
A named event carrying an ordered list of Variant payloads. Pushed messages are heap-allocated; the q...
Definition Event.h:56