aboutsummaryrefslogtreecommitdiff
path: root/src/sysapp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sysapp')
-rw-r--r--src/sysapp/login/main.lua89
1 files changed, 26 insertions, 63 deletions
diff --git a/src/sysapp/login/main.lua b/src/sysapp/login/main.lua
index 1745064..40aa9d9 100644
--- a/src/sysapp/login/main.lua
+++ b/src/sysapp/login/main.lua
@@ -3,80 +3,43 @@ local sysdef= require 'lx.sysdef'
local ioctl = require 'lx.ioctl'
local draw = require 'lx.draw'
-print("Hello, world!")
+local gui = require 'lx.gui'
+local mainloop = require 'lx.mainloop'
-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)
+print("Hello, world!")
-local vesa_info = ioctl.fb_get_info(vesa_fd)
-print("vesa_info = ", vesa_info)
+gui.open()
+gui.load_cursor('sys:/cursors/left_ptr.png')
-local surface = draw.surface_from_fd(vesa_fd, vesa_info)
-for x = 0, 255 do
- for y = 0, 255 do
- surface:plot(x, y, surface:rgb(x, y, 0))
+for x = 0, 255, 16 do
+ for y = 0, 255, 16 do
+ gui.surface:fillrect(x, y, 16, 16, gui.surface:rgb(x, y, 0))
end
end
-local fnt = draw.load_font('sys:/fonts/default.bf')
-
-local mouse_fd = sys.open("io:/input/pcmouse", sysdef.FM_READ)
-print("mouse_fd = " .. mouse_fd)
-
-local cursor = draw.load_image('sys:/cursors/left_ptr.png')
-local csrbkp = draw.new_surface(cursor:width(), cursor:height(), vesa_info.bpp, false)
-csrbkp:blit(0, 0, surface:sub(0, 0, cursor:width(), cursor:height()))
-
-local i = 1
-local mouse_x, mouse_y = 0, 0
-while true do
- local mouse_data, mouse_l = sys.read(mouse_fd, 0, 8)
- if mouse_l > 0 then
- print("mouse_l = ", mouse_l)
- print("mouse_data = ", string.unpack("hhbBBB", mouse_data))
- dx, dy = string.unpack("hhbBBB", mouse_data)
+gui.show_cursor()
- surface:blit(mouse_x, mouse_y, csrbkp)
+local fnt = draw.load_font('sys:/fonts/default.bf')
- mouse_x = mouse_x + dx
- mouse_y = mouse_y - dy
- if mouse_x < 0 then mouse_x = 0 end
- if mouse_y < 0 then mouse_y = 0 end
- if mouse_x >= vesa_info.width then mouse_x = vesa_info.width - 1 end
- if mouse_y >= vesa_info.height then mouse_y = vesa_info.height - 1 end
+local txt_x, txt_y = 0, 0
- csrbkp:blit(0, 0, surface:sub(mouse_x, mouse_y, cursor:width(), cursor:height()))
- surface:blit(mouse_x, mouse_y, cursor)
+gui.on_mouse_down = function (lb, rb, mb)
+ if lb then
+ gui.hide_cursor()
+ gui.surface:write(gui.mouse_x, gui.mouse_y, string.format("Click at %d, %d", gui.mouse_x, gui.mouse_y), fnt, gui.surface:rgb(0, 0, 255))
+ txt_x = gui.mouse_x
+ txt_y = gui.mouse_y + fnt:text_height(" ")
+ gui.show_cursor()
end
+end
-
- --[[
- surface:rect((i*3) % (vesa_info.width-3),
- (i*3) % (vesa_info.height-5),
- 3, 3,
- surface:rgb(i % 256,
- (i + 96) % 256,
- (i + 2*96) % 256))
- i = i + 1
- if i % 10000 == 0 then
- local x0 = math.random(vesa_info.width)-1
- local x1 = math.random(vesa_info.width)-1
- local y0 = math.random(vesa_info.height)-1
- local y1 = math.random(vesa_info.height)-1
- if x0 > x1 then x0, x1 = x1, x0 end
- if y0 > y1 then y0, y1 = y1, y0 end
- local c = surface:rgb(math.random(0, 255), math.random(0, 255), math.random(0, 255))
- surface:fillrect(x0, y0, x1-x0, y1-y0, c)
- end
- if i % 10000 == 0 then
- -- print(i)
- local txt = tostring(i)
- surface:fillrect(0, 0, fnt:text_width(txt),
- fnt:text_height(txt),
- surface:rgb(0, 0, 0))
- surface:write(0, 0, txt, fnt, surface:rgb(255, 0, 0))
- end
- --]]
+gui.on_text_input = function(chr)
+ gui.hide_cursor()
+ gui.surface:write(txt_x, txt_y, chr, fnt, gui.surface:rgb(0, 0, 255))
+ txt_x = txt_x + fnt:text_width(chr)
+ gui.show_cursor()
end
+mainloop.run()
+
os.exit()