From adfda73e1810973a40b7bedd9a8edc3e7ab89e3c Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 19 May 2018 12:05:57 +0800 Subject: =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AD=90=E7=B3=BB=E7=BB=9F=E5=9F=BA?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/script/embed/boot.lua.h | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'src/script/embed/boot.lua.h') diff --git a/src/script/embed/boot.lua.h b/src/script/embed/boot.lua.h index 223f354..cb61468 100644 --- a/src/script/embed/boot.lua.h +++ b/src/script/embed/boot.lua.h @@ -1,23 +1,7 @@ /* boot.lua */ static const char* boot_lua = R"( -local function _onEvent(e) - -- update keyboard status - if e.type == "keydown" then - jin.keyboard.set(e.key, true) - elseif e.type == "keyup" then - jin.keyboard.set(e.key, false) - end - - -- call user onEvent function - if jin.core.onEvent then - jin.core.onEvent(e) - end -end - -------------------------------------------------- --- init file system -------------------------------------------------- +-- init filesystem jin._argv[2] = jin._argv[2] or '.' jin.filesystem.init() jin.filesystem.mount(jin._argv[2]) @@ -54,13 +38,26 @@ function jin.core.run() local study = jin.graphics.study local onDraw = jin.core.onDraw local onUpdate = jin.core.onUpdate + local onEvent = jin.core.onEvent local present = jin.graphics.present + local setkey = jin.keyboard.set local dstatus = jin.debug.status local drender = jin.debug.render local fps = conf.fps - + + local _onEvent = function (e) + if e.type == "keydown" then + setkey(e.key, true) + elseif e.type == "keyup" then + setkey(e.key, false) + end + if onEvent then + onEvent(e) + end + end + if load then load() end -- cgit v1.1-26-g67d0