diff options
author | Alex Auvolat <alex@adnab.me> | 2017-04-21 16:57:00 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2017-04-21 16:57:00 +0200 |
commit | f8334e283c5eb0efeb4bb8a134041e18388d5f01 (patch) | |
tree | 508bc475133262afee1d4a1d9fe7af3f576e2ee9 /src/sysapp | |
parent | ec08d0410730a16836eb40f5e46082b3bbaf45f6 (diff) | |
download | kogata-f8334e283c5eb0efeb4bb8a134041e18388d5f01.tar.gz kogata-f8334e283c5eb0efeb4bb8a134041e18388d5f01.zip |
Lua init
Diffstat (limited to 'src/sysapp')
-rw-r--r-- | src/sysapp/login/example.lua | 68 | ||||
-rw-r--r-- | src/sysapp/login/main.lua | 74 |
2 files changed, 81 insertions, 61 deletions
diff --git a/src/sysapp/login/example.lua b/src/sysapp/login/example.lua new file mode 100644 index 0000000..d099ec7 --- /dev/null +++ b/src/sysapp/login/example.lua @@ -0,0 +1,68 @@ +local sys = require 'lx.sys' +local sysdef = require 'lx.sysdef' + +local mainloop = require 'lx.mainloop' +local gip = require 'lx.gip' +local draw = require 'lx.draw' + + +local io = gip.new(sysdef.STD_FD_GIP) + +function io:damage(reg) + if self.features & gipdef.GIPF_DAMAGE_NOTIF ~= 0 then + self:send_buffer_damage(draw.region(0, 0, 256, 256)) + end +end + +function io:on_initiate(arg) + self.flags = arg + + self:async_enumerate_modes(function(modes) + sys.dbg_print("Got mode list:\n") + for i, v in pairs(modes) do + sys.dbg_print(string.format("%d: %dx%d %d\n", i, v.width, v.height, v.bpp)) + end + + for i, v in pairs(modes) do + if v.width == 800 and v.height == 600 and v.bpp == 24 then + sys.dbg_print(string.format("Selecting mode %d\n", i)) + io:send_set_mode(i) + return + end + end + end) +end + +function io:on_buffer_info(arg, tok, geom) + self.surface = draw.surface_from_fd(sys.use_token(tok)) + self.geom = geom + + for x = 0, 255 do + for y = 0, 255 do + self.surface:put(x, y, draw.rgb(x, y, 128)) + end + end + + self:damage(draw.region(0, 0, 256, 256)) +end + +function io:async_enumerate_modes(callback) + local modelist = {} + local function gotmode(cmd, arg) + if arg == nil then + callback(modelist) + else + modelist[#modelist + 1] = arg + io.on_reply[io:send_query_mode(#modelist)] = gotmode + end + end + io.on_reply[io:send_query_mode(#modelist)] = gotmode +end + +mainloop.add(io) + +io:send_reset() +mainloop.run() + + + diff --git a/src/sysapp/login/main.lua b/src/sysapp/login/main.lua index d099ec7..dec8b82 100644 --- a/src/sysapp/login/main.lua +++ b/src/sysapp/login/main.lua @@ -1,68 +1,20 @@ local sys = require 'lx.sys' -local sysdef = require 'lx.sysdef' +local sysdef= require 'lx.sysdef' +local ioctl = require 'lx.ioctl' -local mainloop = require 'lx.mainloop' -local gip = require 'lx.gip' -local draw = require 'lx.draw' +print("Hello, world!") +local vesa_fd = sys.open("io:/display/vesa", sysdef.FM_IOCTL | sysdef.FM_READ | sysdef.FM_WRITE | sysdef.FM_MMAP) +print("vesa_fd = " .. vesa_fd) -local io = gip.new(sysdef.STD_FD_GIP) +local vesa_info = ioctl.fb_get_info(vesa_fd) +print("vesa_info = ", vesa_info) -function io:damage(reg) - if self.features & gipdef.GIPF_DAMAGE_NOTIF ~= 0 then - self:send_buffer_damage(draw.region(0, 0, 256, 256)) - end +local i = 1 +while true do + print(i) + i = i + 1 + sys.usleep(1000000) end -function io:on_initiate(arg) - self.flags = arg - - self:async_enumerate_modes(function(modes) - sys.dbg_print("Got mode list:\n") - for i, v in pairs(modes) do - sys.dbg_print(string.format("%d: %dx%d %d\n", i, v.width, v.height, v.bpp)) - end - - for i, v in pairs(modes) do - if v.width == 800 and v.height == 600 and v.bpp == 24 then - sys.dbg_print(string.format("Selecting mode %d\n", i)) - io:send_set_mode(i) - return - end - end - end) -end - -function io:on_buffer_info(arg, tok, geom) - self.surface = draw.surface_from_fd(sys.use_token(tok)) - self.geom = geom - - for x = 0, 255 do - for y = 0, 255 do - self.surface:put(x, y, draw.rgb(x, y, 128)) - end - end - - self:damage(draw.region(0, 0, 256, 256)) -end - -function io:async_enumerate_modes(callback) - local modelist = {} - local function gotmode(cmd, arg) - if arg == nil then - callback(modelist) - else - modelist[#modelist + 1] = arg - io.on_reply[io:send_query_mode(#modelist)] = gotmode - end - end - io.on_reply[io:send_query_mode(#modelist)] = gotmode -end - -mainloop.add(io) - -io:send_reset() -mainloop.run() - - - +os.exit() |