TASEmulators / BizHawk

BizHawk is a multi-system emulator written in C#. BizHawk provides nice features for casual gamers such as full screen, and joypad support in addition to full rerecording and debugging tools for all system cores.
http://tasvideos.org/BizHawk.html
Other
2.2k stars 385 forks source link

Lua input.get() stops detecting keyboard keys #931

Closed Warepire closed 7 years ago

Warepire commented 7 years ago

Windows 7, BizHawk 2.1, NLua+KopiLua backend. Seen with PSX core.

Using input.get() to turn features on and off in a Lua script will eventually stop working after a random(?) amount of time. Meaning that pressing keys on the keyboard will no longer have the keys register as pressed in the dictionary provided by the input.get() function.

I made sure the keys are not used as hotkeys / input keys.

If I need to provide anything else, let me know.

Warepire commented 7 years ago

I should add, nothing is open except the game and the Lua console, and the game has focus when this happens. Not recording a movie either.

Warepire commented 7 years ago

Simple test script:

while true do
    local keysToCheck = {"J", "K", "L"}
    local keys = input.get()

    for i, v in ipairs(keysToCheck) do
        if keys[v] == true and keysPrev[v] ~= true then
            console.log(string.format("key %s pressed!", v))
        end
    end

    keysPrev = input.get()
    emu.frameadvance()
end
zeromus commented 7 years ago

Just committed what should be a fix for this. Part of the "luainterface and nlua never supported coroutines so we had to do it ourselves" mastertask which I have not noticed needed doing for years.

Fixed it in luainterface too -- it might have been the cause of the crashes. Or it might just make things worse.

Warepire commented 7 years ago

Tested NLua+KopiLua on the latest master, I can no longer trigger this problem. Thanks!