transition tot kernel

This commit is contained in:
kepler155c@gmail.com
2018-01-11 20:53:32 -05:00
parent d224f5df25
commit fc8d44b60d
19 changed files with 425 additions and 366 deletions

View File

@@ -30,6 +30,7 @@ local Util = require('util')
local device = _G.device
local kernel = _G.kernel
local keyboard = _G.device.keyboard
local mouse = _G.device.mouse
local os = _G.os
kernel.hook('peripheral', function(_, eventData)
@@ -74,6 +75,23 @@ kernel.hook({ 'key', 'key_up', 'char', 'paste' }, function(event, eventData)
end
end)
kernel.hook({ 'mouse_click', 'mouse_up', 'mouse_drag' }, function(event, eventData)
local button = eventData[1]
if event == 'mouse_click' then
mouse.state[button] = true
else
if not mouse.state[button] then
return true -- ensure mouse ups are only generated if a mouse down was sent
end
mouse.state[button] = nil
end
end)
kernel.hook('kernel_focus', function()
Util.clear(keyboard.state)
Util.clear(mouse.state)
end)
function keyboard.addHotkey(code, fn)
keyboard.hotkeys[code] = fn
end