sdl event stuff

This commit is contained in:
2025-05-05 11:08:07 -05:00
parent 2820387851
commit c2da1944d8
11 changed files with 195 additions and 134 deletions

View File

@@ -28,7 +28,9 @@ class WindowModule : public Archimedes::Module {
Archimedes::Window* aquireWindow() {
if(!window) {
window = new Archimedes::Window([this](Archimedes::Event* e){
window = new Archimedes::Window([this](Archimedes::Event* e) {
for(std::function<void(Archimedes::Event*)> f : eventFuncs)
f(e);
app->emitEvent(e);
});
@@ -54,6 +56,10 @@ class WindowModule : public Archimedes::Module {
}
}
}
auto addEventFn(const std::function<void(Archimedes::Event*)>& fn) { eventFuncs.push_back(fn); return --eventFuncs.end()++; }
void removeEventFn(std::list<std::function<void(Archimedes::Event*)>>::iterator it) { eventFuncs.erase(it); }
Archimedes::Renderer* getRenderer() { return renderer; }
@@ -61,6 +67,8 @@ class WindowModule : public Archimedes::Module {
int windowRefs = 0;
std::list<std::function<void(Archimedes::Event*)>> eventFuncs;
Archimedes::Window* window = nullptr;
Archimedes::Renderer* renderer = nullptr;