From 1b4e3b7d298003e591d9e691c7bb6f4abdbab285 Mon Sep 17 00:00:00 2001 From: Ilari Liusvaara Date: Thu, 12 Aug 2010 13:01:06 +0300 Subject: [PATCH] Add Lua function to obtain keyboard key state at input edge --- datafiles/luakernel | 2 ++ org/jpc/luaextensions/InputDevices.java | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/datafiles/luakernel b/datafiles/luakernel index e077718..b8a1d23 100644 --- a/datafiles/luakernel +++ b/datafiles/luakernel @@ -88,6 +88,8 @@ -- Returns true if in frame hold, false otherwise. -- - jpcrr.keypressed(number key) -- Return true if key is pressed, else false. +-- - jpcrr.keypressed_edge(number key) +-- Return true if key is pressed at input edge, else false. -- - jpcrr.release_vga() -- Allow VGA to exit frame hold mode. Wait for frame hold first. -- - jpcrr.vga_resolution() diff --git a/org/jpc/luaextensions/InputDevices.java b/org/jpc/luaextensions/InputDevices.java index 559e3ea..361f44f 100644 --- a/org/jpc/luaextensions/InputDevices.java +++ b/org/jpc/luaextensions/InputDevices.java @@ -62,6 +62,20 @@ public class InputDevices extends LuaPlugin.LuaResource return 1; } + public static int luaCB_keypressed_edge(Lua l, LuaPlugin plugin) + { + if(l.type(1) != Lua.TNUMBER) { + l.error("Unexpected types to keypressed"); + return 0; + } + Keyboard key = (Keyboard)plugin.getComponent(Keyboard.class); + if(key != null) + l.pushBoolean(key.getKeyStatus((byte)l.checkNumber(1))); + else + l.pushBoolean(false); + return 1; + } + public static int luaCB_keyboard_leds(Lua l, LuaPlugin plugin) { Keyboard key = (Keyboard)plugin.getComponent(Keyboard.class); -- 2.11.4.GIT