aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2017-04-25 18:04:01 +0200
committerAlex Auvolat <alex@adnab.me>2017-04-25 18:04:01 +0200
commita959c94c1d67e234adbbb96d0d290eaf3bc26ac1 (patch)
tree7056780f8cc1398fccf870991f2a155b963acfb8
parent978b3234a04f11f959f603db4756253278ca65df (diff)
downloadkogata-a959c94c1d67e234adbbb96d0d290eaf3bc26ac1.tar.gz
kogata-a959c94c1d67e234adbbb96d0d290eaf3bc26ac1.zip
Gui start
-rw-r--r--res/cursors/left_ptr.c64
-rw-r--r--res/cursors/left_ptr.pngbin0 -> 730 bytes
-rw-r--r--src/sysapp/login/main.lua13
-rw-r--r--src/sysbin/lx/lxdrawlib.c4
-rw-r--r--src/syslua/lx/gui.lua76
5 files changed, 153 insertions, 4 deletions
diff --git a/res/cursors/left_ptr.c b/res/cursors/left_ptr.c
new file mode 100644
index 0000000..26a2e6f
--- /dev/null
+++ b/res/cursors/left_ptr.c
@@ -0,0 +1,64 @@
+/* GIMP RGBA C-Source image dump 1-byte-run-length-encoded (left_ptr.c) */
+
+#define LEFT_PTR_RUN_LENGTH_DECODE(image_buf, rle_data, size, bpp) do \
+{ unsigned int __bpp; unsigned char *__ip; const unsigned char *__il, *__rd; \
+ __bpp = (bpp); __ip = (image_buf); __il = __ip + (size) * __bpp; \
+ __rd = (rle_data); if (__bpp > 3) { /* RGBA */ \
+ while (__ip < __il) { unsigned int __l = *(__rd++); \
+ if (__l & 128) { __l = __l - 128; \
+ do { memcpy (__ip, __rd, 4); __ip += 4; } while (--__l); __rd += 4; \
+ } else { __l *= 4; memcpy (__ip, __rd, __l); \
+ __ip += __l; __rd += __l; } } \
+ } else { /* RGB */ \
+ while (__ip < __il) { unsigned int __l = *(__rd++); \
+ if (__l & 128) { __l = __l - 128; \
+ do { memcpy (__ip, __rd, 3); __ip += 3; } while (--__l); __rd += 3; \
+ } else { __l *= 3; memcpy (__ip, __rd, __l); \
+ __ip += __l; __rd += __l; } } \
+ } } while (0)
+static const struct {
+ unsigned int width;
+ unsigned int height;
+ unsigned int bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */
+ unsigned char rle_pixel_data[955 + 1];
+} left_ptr = {
+ 24, 24, 4,
+ "\263\000\000\000\000\003\364\364\364\304\020\020\020\012\000\000\000\001\225\000\000\000\000\004\377\377"
+ "\377\377\260\260\260\364\001\001\001\021\000\000\000\002\224\000\000\000\000\005\377\377\377\377\340"
+ "\340\340\377\254\254\254\357\006\006\006\021\000\000\000\001\223\000\000\000\000\006\377\377\377\377"
+ "\015\015\015\377\362\362\362\377\254\254\254\335\005\005\005\017\000\000\000\001\222\000\000\000"
+ "\000\007\377\377\377\377\000\000\000\377(((\377\367\367\367\377\234\234\234\243\013"
+ "\013\013\016\000\000\000\001\221\000\000\000\000\010\377\377\377\377\000\000\000\377\026\026\026\377\062"
+ "\062\062\377\373\373\373\377\221\221\221\227\012\012\012\016\000\000\000\001\220\000\000\000"
+ "\000\011\377\377\377\377\000\000\000\377\020\020\020\377\035\035\035\377>>>\377\376\376"
+ "\376\377\210\210\210\212\013\013\013\015\000\000\000\001\216\000\000\000\000\013\242\242\242\001"
+ "\377\377\377\377\000\000\000\377\012\012\012\377\027\027\027\377$$$\377JJJ\377\377\377"
+ "\377\377\202\202\202z\006\006\006\015\000\000\000\001\216\000\000\000\000\013\377\377\377\377\000\000"
+ "\000\377\005\005\005\377\022\022\022\377\037\037\037\377+++\377UUU\377\377\377\377\377"
+ "\202\202\202r\000\000\000\013\000\000\000\001\215\000\000\000\000\014\377\377\377\377\000\000\000\377\001"
+ "\001\001\377\014\014\014\377\031\031\031\377%%%\377\062\062\062\377aaa\377\377\377\377"
+ "\377\177\177\177W\000\000\000\012\000\000\000\001\214\000\000\000\000\001\377\377\377\377\202\000\000"
+ "\000\377\012\007\007\007\377\024\024\024\377!!!\377---\377\071\071\071\377mmm\377\377\377"
+ "\377\377sssO\006\006\006\012\000\000\000\001\213\000\000\000\000\001\377\377\377\377\202\000\000\000\377"
+ "\013\002\002\002\377\016\016\016\377\033\033\033\377\032\032\032\377'''\377\063\063\063\377"
+ "kkk\377\377\377\377\377eeeH\014\014\014\011\000\000\000\001\212\000\000\000\000\001\377\377\377"
+ "\377\203\000\000\000\377\003\006\006\006\377\016\016\016\377\371\371\371\377\205\377\377\377"
+ "\377\002\202\202\202E\000\000\000\002\211\000\000\000\000\017aaa\001\377\377\377\377\000\000\000\377"
+ "\001\001\001\377\016\016\016\377ttt\377\016\016\016\377sss\377\321\321\321\334\000\000\000"
+ "^\000\000\000J\000\000\000H\000\000\000A\000\000\000)\000\000\000\003\212\000\000\000\000\016\377\377\377\377\000\000"
+ "\000\377\021\021\021\377\364\364\364\377\377\377\377\377\013\013\013\377\020\020\020"
+ "\377\375\375\375\377PPPd\001\001\001\024\000\000\000\012\000\000\000\011\000\000\000\006\000\000\000\001\212\000"
+ "\000\000\000\013\377\377\377\377\004\004\004\377\371\371\371\377\206\206\206\257\312\312"
+ "\312\310\204\204\204\377\020\020\020\377\205\205\205\377\331\331\331\310\000\000"
+ "\000\035\000\000\000\002\215\000\000\000\000\013\377\377\377\377\361\361\361\377\204\204\204"
+ "\252\000\000\000HQQQ=\377\377\377\377\013\013\013\377\030\030\030\377\377\377\377\377"
+ "\066\066\066N\000\000\000\010\215\000\000\000\000\014\377\377\377\377\202\202\202\240\000\000\000"
+ "E\000\000\000\022\000\000\000\006\354\354\354\265\177\177\177\377\011\011\011\377\257\257\257"
+ "\377\247\247\247\232\000\000\000\024\000\000\000\001\214\000\000\000\000\014\266\266\266\201\000\000"
+ "\000:\000\000\000\021\000\000\000\001\023\023\023\001zzz\060\374\374\374\377\272\272\272\377\377"
+ "\377\377\377***j\000\000\000\024\000\000\000\001\213\000\000\000\000\004...\001\000\000\000\015\000\000\000\013\000"
+ "\000\000\001\202\000\000\000\000\006\000\000\000\006jjjG\220\220\220\214\005\005\005^\003\003\003-\000\000\000\007\215"
+ "\000\000\000\000\001\000\000\000\001\204\000\000\000\000\006\000\000\000\001\000\000\000\007\000\000\000\022\000\000\000\017\000\000\000"
+ "\005\000\000\000\001\242\000\000\000\000",
+};
+
diff --git a/res/cursors/left_ptr.png b/res/cursors/left_ptr.png
new file mode 100644
index 0000000..380e2e4
--- /dev/null
+++ b/res/cursors/left_ptr.png
Binary files differ
diff --git a/src/sysapp/login/main.lua b/src/sysapp/login/main.lua
index 0c54769..0ef8727 100644
--- a/src/sysapp/login/main.lua
+++ b/src/sysapp/login/main.lua
@@ -11,7 +11,7 @@ print("vesa_fd = " .. vesa_fd)
local vesa_info = ioctl.fb_get_info(vesa_fd)
print("vesa_info = ", vesa_info)
-local surface = draw.from_fd(vesa_fd, vesa_info)
+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))
@@ -20,8 +20,17 @@ end
local fnt = draw.load_font('default')
+local mouse_fd = sys.open("io:/input/pcmouse", sysdef.FM_READ)
+print("mouse_fd = " .. mouse_fd)
+
local i = 1
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))
+ end
+
surface:rect((i*3) % (vesa_info.width-3),
(i*3) % (vesa_info.height-5),
3, 3,
@@ -40,7 +49,7 @@ while true do
surface:fillrect(x0, y0, x1-x0, y1-y0, c)
end
if i % 10000 == 0 then
- print(i)
+ -- print(i)
local txt = tostring(i)
surface:fillrect(0, 0, fnt:text_width(txt),
fnt:text_height(txt),
diff --git a/src/sysbin/lx/lxdrawlib.c b/src/sysbin/lx/lxdrawlib.c
index 91bf07f..001d378 100644
--- a/src/sysbin/lx/lxdrawlib.c
+++ b/src/sysbin/lx/lxdrawlib.c
@@ -89,7 +89,7 @@ static int font_text_height(lua_State *L) {
// ====================================================================
// SURFACES
-static int draw_from_fd(lua_State *L) {
+static int draw_surface_from_fd(lua_State *L) {
int fd = luaL_checkinteger(L, 1);
luaL_checktype(L, 2, LUA_TTABLE);
@@ -267,7 +267,7 @@ static int surface_write(lua_State *L) {
/* }====================================================== */
static const luaL_Reg drawlib[] = {
- {"from_fd", draw_from_fd},
+ {"surface_from_fd",draw_surface_from_fd},
{"load_font", draw_loadfont},
{NULL, NULL}
};
diff --git a/src/syslua/lx/gui.lua b/src/syslua/lx/gui.lua
new file mode 100644
index 0000000..beb382e
--- /dev/null
+++ b/src/syslua/lx/gui.lua
@@ -0,0 +1,76 @@
+local sys = require 'lx.sys'
+local sysdef= require 'lx.sysdef'
+local ioctl = require 'lx.ioctl'
+local draw = require 'lx.draw'
+
+local mainloop = require 'lx.mainloop'
+
+local gui = {
+ -- Keyboard info
+ -- TODO
+ -- Mouse info
+ mouse_x = 0,
+ mouse_y = 0,
+ mouse_lbtn = false,
+ mouse_rbtn = false,
+ mouse_midbtn = false,
+}
+
+function gui.open()
+ if sys.stat('io:/display/vesa') and sys.stat('io:/input/pckbd') and sys.stat('io:/input/pcmouse') then
+ gui.open_io()
+ elseif sys.stat_open(sysdef.STD_FD_GIP) then
+ gui.open_gip()
+ else
+ error("Could not open GUI!")
+ end
+end
+
+function gui.open_io()
+ -- Open display
+ gui.vesa_fd = sys.open("io:/display/vesa", sysdef.FM_IOCTL | sysdef.FM_READ | sysdef.FM_WRITE | sysdef.FM_MMAP)
+ assert(gui.vesa_fd ~= 0)
+
+ gui.vesa_info = ioctl.fb_get_info(gui.vesa_fd)
+ gui.surface = draw.surface_from_fd(gui.vesa_fd, gui.vesa_info)
+
+ -- Open keyboard
+ gui.pckbd_fd = sys.open("io:/input/pckbd", sysdef.FM_READ)
+ assert(gui.pckbd_fd ~= 0)
+
+ 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)
+ gui.on_keyboard(scancode, ty)
+
+ gui.pckbd_mainloop_fd:expect(4, pckbd_handler)
+ end
+ gui.pckbd_mainloop_fd:expect(4, pckbd_handler)
+
+ -- Open mouse
+ gui.pcmouse_fd = sys.open("io:/input/pcmouse", sysdef.FM_READ)
+ assert(gui.pcmouse_fd ~= 0)
+
+ 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)
+ gui.on_mouse(dx, dy, dw, lb, rb, mb)
+
+ gui.pcmouse_mainloop_fd:expect(8, pcmouse_handler)
+ end
+ gui.pcmouse_mainloop_fd:expect(8, pcmouse_handler)
+end
+
+function gui.open_gip()
+ -- TODO
+end
+
+function gui.on_keyboard(scancode, ty)
+ -- TODO
+end
+
+function gui.on_mouse(dx, dy, dw, lb, rb, mb)
+ -- TODO
+end
+
+return gui