mirror of
https://github.com/Reuh/ubiquitousse.git
synced 2025-10-28 01:29:31 +00:00
uqt.signal
This commit is contained in:
parent
82bc7268e6
commit
f6fb8ad649
11 changed files with 331 additions and 80 deletions
43
signal/backend/love.lua
Normal file
43
signal/backend/love.lua
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
local signal = require((...):match("^(.-%.)backend").."signal")
|
||||
|
||||
function signal.registerEvents()
|
||||
local callbacks = { -- everything except run, errorhandler, threaderror
|
||||
"displayrotated", "draw", "load", "lowmemory", "quit", "update",
|
||||
"directorydropped", "filedropped", "focus", "mousefocus", "resize", "visible",
|
||||
"keypressed", "keyreleased", "textedited", "textinput",
|
||||
"mousemoved", "mousepressed", "mousereleased", "wheelmoved",
|
||||
"gamepadaxis", "gamepadpressed", "gamepadreleased",
|
||||
"joystickadded", "joystickaxis", "joystickhat", "joystickpressed", "joystickreleased", "joystickremoved",
|
||||
"touchmoved", "touchpressed", "touchreleased"
|
||||
}
|
||||
local event = signal.event
|
||||
for _, callback in ipairs(callbacks) do
|
||||
if callback == "update" then
|
||||
if love[callback] then
|
||||
local old = love[callback]
|
||||
love[callback] = function(dt)
|
||||
old(dt)
|
||||
event:emit(callback, dt*1000)
|
||||
end
|
||||
else
|
||||
love[callback] = function(dt)
|
||||
event:emit(callback, dt*1000)
|
||||
end
|
||||
end
|
||||
else
|
||||
if love[callback] then
|
||||
local old = love[callback]
|
||||
love[callback] = function(...)
|
||||
old(...)
|
||||
event:emit(callback, ...)
|
||||
end
|
||||
else
|
||||
love[callback] = function(...)
|
||||
event:emit(callback, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return signal
|
||||
Loading…
Add table
Add a link
Reference in a new issue