fceux icon indicating copy to clipboard operation
fceux copied to clipboard

Lua input.get() doesn't return keyboard press

Open fmahnke opened this issue 3 years ago • 5 comments

fceux 2.6.4 on NixOS 22.05 with i3 4.20.1: https://github.com/NixOS/nixpkgs/blob/nixos-22.05/pkgs/applications/emulators/fceux/default.nix

From the documentation of input.get() at https://fceux.com/web/help/LuaFunctionsList.html

The function returns a table with at least two properties; table.xmouse and table.ymouse. Additionally any of these keys will be set to true if they were held at the time of executing this function: leftclick, rightclick, middleclick, capslock, numlock, scrolllock, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, backspace, tab, enter, shift, control, alt, pause, escape, space, pageup, pagedown, end, home, left, up, right, down, numpad0, numpad1, numpad2, numpad3, numpad4, numpad5, numpad6, numpad7, numpad8, numpad9, numpad*, insert, delete, numpad+, numpad-, numpad., numpad/, semicolon, plus, minus, comma, period, slash, backslash, tilde, quote, leftbracket, rightbracket.

When I call this function from a Lua script, I always get a table with 3 keys: xmouse, ymouse, and click. There are never keys for any keyboard keys that are pressed when the fceux window has focus.

fmahnke avatar Jul 08 '22 05:07 fmahnke

This works on the windows non-QT version only. I'll update the docs to reflect that, unless @thor2016 wants to add support (input_get in lua-engine.cpp) for SDL which wouldnt be hard--there's a function just like GetKeyboardState() in SDL

zeromus avatar Aug 21 '22 18:08 zeromus

@zeromus I will take look at this. Does anyone have a simple LUA script that would help me test this?

thor2016 avatar Aug 21 '22 18:08 thor2016

while true do
	print(input.get())
	emu.frameadvance()
end

zeromus avatar Aug 21 '22 18:08 zeromus

Can someone try the latest dev build and provide feedback please? @fmahnke ?

thor2016 avatar Aug 23 '22 22:08 thor2016

Hi, I will see if I can make a dev build and try this.

fmahnke avatar Oct 18 '22 16:10 fmahnke