aboutsummaryrefslogtreecommitdiff
path: root/src/syslua/lx/gui.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/syslua/lx/gui.lua')
-rw-r--r--src/syslua/lx/gui.lua19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/syslua/lx/gui.lua b/src/syslua/lx/gui.lua
index 6cfb545..9342025 100644
--- a/src/syslua/lx/gui.lua
+++ b/src/syslua/lx/gui.lua
@@ -1,5 +1,6 @@
local sys = require 'lx.sys'
-local sysdef= require 'lx.sysdef'
+local sysdef = require 'lx.sysdef'
+local protodef = require 'lx.protodef'
local ioctl = require 'lx.ioctl'
local draw = require 'lx.draw'
@@ -44,12 +45,12 @@ function gui.open_io()
gui.pckbd_mainloop_fd = mainloop.add_fd(gui.pckbd_fd, function() error('pckbd fd error') end)
local function pckbd_handler(ev)
- local scancode, ty = string.unpack("HH", ev)
+ local scancode, ty = string.unpack(protodef.kbd_event.fmt, ev)
gui.on_keyboard(scancode, ty)
- gui.pckbd_mainloop_fd:expect(4, pckbd_handler)
+ gui.pckbd_mainloop_fd:expect(protodef.kbd_event.len, pckbd_handler)
end
- gui.pckbd_mainloop_fd:expect(4, pckbd_handler)
+ gui.pckbd_mainloop_fd:expect(protodef.kbd_event.len, pckbd_handler)
gui.kbdlib = kbd.init()
@@ -59,13 +60,13 @@ function gui.open_io()
gui.pcmouse_mainloop_fd = mainloop.add_fd(gui.pcmouse_fd, function() error("pcmouse fd error") end)
local function pcmouse_handler(ev)
- local dx, dy, dw, lb, rb, mb = string.unpack("hhbBBB", ev)
+ local dx, dy, dw, lb, rb, mb = string.unpack(protodef.mouse_event.fmt, ev)
local change_but = false
while not change_but do
- local bytes, n = sys.read(gui.pcmouse_fd, 1, 8)
+ local bytes, n = sys.read(gui.pcmouse_fd, 1, protodef.mouse_event.len)
if n == 8 then
- local dx2, dy2, dw2, lb2, rb2, mb2 = string.unpack("hhbBBB", ev)
+ local dx2, dy2, dw2, lb2, rb2, mb2 = string.unpack(protodef.mouse_event.fmt, ev)
change_but = change_but or (lb2 ~= lb) or (rb2 ~= rb) or (mb2 ~= mb)
dx = dx + dx2
dy = dy + dy2
@@ -78,9 +79,9 @@ function gui.open_io()
end
gui.on_mouse(dx, dy, dw, lb, rb, mb)
- gui.pcmouse_mainloop_fd:expect(8, pcmouse_handler)
+ gui.pcmouse_mainloop_fd:expect(protodef.mouse_event.len, pcmouse_handler)
end
- gui.pcmouse_mainloop_fd:expect(8, pcmouse_handler)
+ gui.pcmouse_mainloop_fd:expect(protodef.mouse_event.len, pcmouse_handler)
end
function gui.open_gip()