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

input: handle remapped keys on x11 #2974

Open
1 of 11 tasks
kazzmir opened this issue Apr 29, 2024 · 3 comments
Open
1 of 11 tasks

input: handle remapped keys on x11 #2974

kazzmir opened this issue Apr 29, 2024 · 3 comments

Comments

@kazzmir
Copy link

kazzmir commented Apr 29, 2024

Ebitengine Version

2.7.2

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • PlayStation 5
  • Xbox
  • Web Browsers

Go Version (go version)

go version go1.22.2 linux/amd64

What steps will reproduce the problem?

Swap escape and capslock with this command

/usr/bin/setxkbmap -option "caps:swapescape"

press the capslock key in the game, and then invoke inpututil.AppendPressedKeys(keys).

What is the expected result?

The keys array should contain ebiten.KeyEscape, but instead it contains ebiten.KeyCapsLock

What happens instead?

Keys array contains ebiten.KeyCapsLock

Anything else you feel useful to add?

This situation works in SDL2, when I press the capslock key the key event correctly has event.key.keysym.sym == SDLK_ESCAPE.

Maybe the issue is in how the glfx.x11.keycodes array is set up, although the code looks plausible in that it queries xkb.

static void createKeyTables(void)

FWIW this is what xev -event keyboard shows for me (after having swapped escape and capslock with the command above)

Press capslock:

KeyPress event, serial 28, synthetic NO, window 0x8e00001,
    root 0x29d, subw 0x0, time 1205629860, (65,113), root:(3652,550),
    state 0x10, keycode 66 (keysym 0xff1b, Escape), same_screen YES,
    XLookupString gives 1 bytes: (1b) "
mbLookupString gives 1 bytes: (1b) "
FilterEvent returns: False

Press escape:

KeyPress event, serial 28, synthetic NO, window 0x8e00001,
    root 0x29d, subw 0x0, time 1205638081, (65,113), root:(3652,550),
    state 0x12, keycode 9 (keysym 0xffe5, Caps_Lock), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False
@hajimehoshi
Copy link
Owner

Does this work with GLFW?

@hajimehoshi
Copy link
Owner

glfw/glfw#2011

@kazzmir
Copy link
Author

kazzmir commented Apr 29, 2024

Yes I replicated the same issue in GLFW, if I run the gears example then when I press the capslock key nothing happens, but when I press the physical escape key then the gears program will quit. The gears code has

  case GLFW_KEY_ESCAPE:
    glfwSetWindowShouldClose(window, GLFW_TRUE);

But I also have the same issue when I run my game in a web browser via wasm. I would have thought that the browser would handle key remappings correctly. I guess there is little that ebiten can do about the situation with the browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants