载入中...
搜索中...
未找到
EventSink.cpp
浏览该文件的文档.
1// Lets ImGui see platform events before anything else claims them.
2//
3// The SDL event pump used to call UI::processEvent directly, which was one of
4// the eight modules it had to know about.
5
6#include "common/Capability.h"
7#include "common/Module.h"
9#include "ui/UI.h"
10
11#include <SDL2/SDL_events.h>
12
13namespace eve::ui {
14namespace {
15
16class UIEventSink : public eve::event::IPlatformEventSink {
17public:
18 bool observePlatformEvent(const void *nativeEvent) override {
19 if (auto *ui = eve::ModuleManager::getInstance<UI>("UI"))
20 ui->processEvent(static_cast<const SDL_Event *>(nativeEvent));
21 // ImGui records the event for its own state but does not claim it; the
22 // game still receives the matching message.
23 return false;
24 }
25};
26
27struct Register {
28 Register() {
29 static UIEventSink sink;
32 }
33} g_register;
34
35} // namespace
36} // namespace eve::ui
I * query()
Definition Capability.h:77