diff --git a/sysdata/programs/sketchpad/src/main.hb b/sysdata/programs/sketchpad/src/main.hb index 38df4bf..a9a3c29 100644 --- a/sysdata/programs/sketchpad/src/main.hb +++ b/sysdata/programs/sketchpad/src/main.hb @@ -1,3 +1,83 @@ -main := fn(): int { - return 0 +sunset := @use("lib:sunset_proto") +intouch := @use("lib:intouch") +render := @use("lib:render") +stn := @use("stn"); +.{log} := stn; + + +Tools := struct { + pen_size: u8 = 10, + bg_colour: render.Color = render.WHITE, + pen_colour: render.Color = render.BLACK, + +} + + + + + + + main := fn(): void { + sunset.client.find_server() + + window := sunset.client.new(.(.(600, 400), .(200, 200), "Sketch Pad")) + if window == null { + log.error("got no window") + return + } + + mouse_pos := stn.math.Vec2(int).(0, 0) +tools := Tools.{} + + + + + + loop { + mouse := intouch.recieve_mouse_event() + if mouse != null { + mouse_pos.x = stn.math.clamp(int, mouse_pos.x + mouse.x_change, tools.pen_size, @bitcast(window.surface.width) - tools.pen_size) + mouse_pos.y = stn.math.clamp(int, mouse_pos.y - mouse.y_change, tools.pen_size, @bitcast(window.surface.height) - tools.pen_size) + + if mouse.left { + window.surface.put_filled_circle(@bitcast(mouse_pos), tools.pen_size, tools.pen_colour) + } else if mouse.right { + window.surface.put_filled_circle(@bitcast(mouse_pos), tools.pen_size, tools.bg_colour) + } else if mouse.middle { + tools.pen_colour = *window.surface.indexptr(@bitcast(mouse_pos.x), @bitcast(mouse_pos.y)) + } + } + + kb := intouch.recieve_key_event() + if kb != null { + if kb.just_triggered { + if kb.key == intouch.keycodes.NUMBER1 { + tools.pen_colour = render.WHITE + } else if kb.key == intouch.keycodes.NUMBER2 { + tools.pen_colour = render.BLACK + } else if kb.key == intouch.keycodes.NUMBER3 { + tools.pen_colour = render.RED + } else if kb.key == intouch.keycodes.NUMBER4 { + tools.pen_colour = render.YELLOW + } else if kb.key == intouch.keycodes.NUMBER5 { + tools.pen_colour = render.BLUE + } else if kb.key == intouch.keycodes.NUMBER6 { + tools.pen_colour = render.CYAN + } else if kb.key == intouch.keycodes.NUMBER7 { + tools.pen_colour = render.GREEN + } else if kb.key == intouch.keycodes.NUMBER8 { + tools.pen_colour = render.MAGENTA + } else if kb.key == intouch.keycodes.NUMBER9 { + tools.pen_colour = render.GRAY + } else if kb.key == intouch.keycodes.NUMBER0 { + tools.pen_colour = stn.random.any(render.Color) + } else { + tools.bg_colour = stn.random.any(render.Color) + window.surface.clear(tools.bg_colour) + } + } + } + + _ = sunset.client.send_frame(window) + } } \ No newline at end of file diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index 3b5e7d6..8eb21bd 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -29,8 +29,8 @@ resolution = "1024x768x24" [boot.limine.ableos.modules.sunset_server] path = "boot:///sunset_server.hbf" -# [boot.limine.ableos.modules.ps2_mouse_driver] -# path = "boot:///ps2_mouse_driver.hbf" +[boot.limine.ableos.modules.ps2_mouse_driver] +path = "boot:///ps2_mouse_driver.hbf" # [boot.limine.ableos.modules.ps2_keyboard_driver] # path = "boot:///ps2_keyboard_driver.hbf" @@ -38,14 +38,14 @@ path = "boot:///sunset_server.hbf" # [boot.limine.ableos.modules.ps2_driver] # path = "boot:///ps2_driver.hbf" -[boot.limine.ableos.modules.sunset_client] -path = "boot:///sunset_client.hbf" +# [boot.limine.ableos.modules.sunset_client] +# path = "boot:///sunset_client.hbf" -[boot.limine.ableos.modules.sdoom] -path = "boot:///sdoom.hbf" +# [boot.limine.ableos.modules.sdoom] +# path = "boot:///sdoom.hbf" -# [boot.limine.ableos.modules.diskio_driver] -# path = "boot:///diskio_driver.hbf" +[boot.limine.ableos.modules.sketchpad] +path = "boot:///sketchpad.hbf" # [boot.limine.ableos.modules.angels_halo] # path = "boot:///angels_halo.hbf"