diff options
Diffstat (limited to 'honey/window.lua')
-rw-r--r-- | honey/window.lua | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/honey/window.lua b/honey/window.lua index 3b5d5c1..e2b9fb2 100644 --- a/honey/window.lua +++ b/honey/window.lua @@ -1,3 +1,5 @@ +local ecs = require 'honey.ecs' + local module = {} local glfw = honey.glfw setmetatable(module, {__index=_G}) @@ -165,4 +167,17 @@ function Window.swapBuffers(self) end +function Window.bindEvents(self, db) + self:setCursorPosCallback(function(_, xpos, ypos) + ecs.script.dispatch(db, "onCursorPos", {window=self, xpos=xpos, ypos=ypos}) + end) + self:setKeyCallback(function(_, key, scancode, action) + ecs.script.dispatch(db, "onKey", {window=self, key=key, scancode=scancode, action=action}) + end) + self:setFramebufferSizeCallback(function(_, width, height) + ecs.script.dispatch(db, "onFramebufferSize", {window=self, width=width, height=height}) + end) +end + + return module.Window |