Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

love.keyboard.isDown('ralt') always returns false #1875

Closed
Svalorzen opened this issue Dec 7, 2022 · 9 comments
Closed

love.keyboard.isDown('ralt') always returns false #1875

Svalorzen opened this issue Dec 7, 2022 · 9 comments
Labels
library dependency Related to a library used by LÖVE Linux

Comments

@Svalorzen
Copy link

I reported this problem on the forums, and other people have confirmed it.

It seems that love.keyboard.isDown('ralt') always returns false, no matter what the state of the key is. Note that if they key is pressed or released, the appropriate events are correctly registered (so that love.keypressed(key) and love.keyreleased(key) are correclty called with parameter 'ralt').

My system is Lubuntu 20.04, using LOVE 11.4.

@slime73
Copy link
Member

slime73 commented Dec 7, 2022

From the forums, it seems like you're probably using a very old version of SDL? have you tried updating? If you use the love AppImage instead of relying on whatever dependency versions that old Ubuntu version provides in its package manager, it will use a more recent SDL version.

The equivalent love code to your C test program would be love.keyboard.isScancodeDown("ralt") rather than love.keyboard.isDown("ralt"). When you call love.keyboard.isDown("ralt") it does something like this:

SDL_Scancode scancode = SDL_GetScancodeFromKey(SDLK_RALT);
const Uint8 *keyboardstate = SDL_GetKeyboardState(NULL);
if (keyboardstate[scancode])
  /* etc */;

So I'm guessing SDL_GetScancodeFromKey(SDLK_RALT) isn't behaving as expected in your old SDL version.

@Svalorzen
Copy link
Author

It seems you are correct once again. However, this time I spent a bit of time bisecting the SDL repo to figure out exactly which commit had fixed this problem. Turns out, the commit is libsdl-org/SDL@99f2a50, which is in the 2.25.1 pre-release, and it was submitted on the 13th of October 2022, which I would say is fairly recent.

Ubuntu 22.10 is still at 2.24.0 which wouldn't have the fix anyway, so yeah I guess the AppImage is truly the only fix possible. Thanks for looking into it.

@slime73
Copy link
Member

slime73 commented Dec 7, 2022

Thanks for investigating!

The love 11.4 appimage was created almost a year ago, so it doesn't have the change from that SDL commit.

@Svalorzen
Copy link
Author

Oh wow.. that is very strange. Do you know by any chance the commit it is based on so I can test it?

@MikuAuahDark
Copy link
Contributor

The AppImage script commit is love2d/love-appimage-source@30aaffc, so SDL 2.0.18.

@Svalorzen Svalorzen reopened this Dec 8, 2022
@Svalorzen
Copy link
Author

Svalorzen commented Dec 8, 2022

And indeed that SDL version has the bug for me, so I downloaded the AppImage.. and it also has the bug! At least I'm not crazy :)

image

@MikuAuahDark
Copy link
Contributor

Honestly I don't think there's LOVE can do about it other than updating SDL. Since LOVE relies heavily on SDL for input, if SDL itself is broken in its input handling then there's nothing LOVE can do.

@MikuAuahDark MikuAuahDark added the library dependency Related to a library used by LÖVE label Dec 8, 2022
@Svalorzen
Copy link
Author

Ah yes, I'm not really saying otherwise. I still think it's useful to know that the problem exists, for example when choosing the SDL version to regenerate the AppImage and so on. Also in case someone else finds this problem, at least it is already tracked.

@MikuAuahDark
Copy link
Contributor

MikuAuahDark commented Dec 8, 2022

In the LOVE appimage build script, choosing the SDL version can be as simple as make SDL2_BRANCH=release-2.26.1 to change the SDL to 2.26.1 (which correspond to libsdl-org/SDL@f17058b).

We always update to latest version of the libraries before releasing new LOVE version when possible.

@MikuAuahDark MikuAuahDark closed this as not planned Won't fix, can't repro, duplicate, stale Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
library dependency Related to a library used by LÖVE Linux
Projects
None yet
Development

No branches or pull requests

3 participants