diff options
author | chai <chaifix@163.com> | 2018-05-19 12:05:57 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-05-19 12:05:57 +0800 |
commit | adfda73e1810973a40b7bedd9a8edc3e7ab89e3c (patch) | |
tree | 3ee6b9ad4f3c71b5cefc719c694e7a80f3df7088 /src/script/embed/boot.lua.h | |
parent | 3ce3b10167a98f45614408a8042a10c686f3a9cc (diff) |
增加子系统基类
Diffstat (limited to 'src/script/embed/boot.lua.h')
-rw-r--r-- | src/script/embed/boot.lua.h | 33 |
1 files changed, 15 insertions, 18 deletions
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 |