00-Evan/shattered-pixel-dungeon

Issue with Linux keybindings and swapescape

Closed this issue · 7 comments

Hi there, and thanks for all the incredible work on SPD!

I've started playing on a Linux machine recently, where I've swapped the Escape and Caps Lock keys with setxkbmap -option caps:swapescape. Most applications (web browsers, other desktop apps, etc) respond as expected (e.g. hitting the Caps Lock key triggers the Escape behavior), but this doesn't seem to be the case in SPD. I have to hit the physical Escape key, which ends up toggling my Caps Lock.

I'm not knowledgeable enough about Linux/X11 to know what the underlying issue is, but it seems like whatever Java input API being used is getting more 'raw' keypresses than other applications.

I'm afraid I'm also not well acquainted with how input handling on Linux works, and so am not really in a position to help you with this. Shattered uses libGDX, which uses LWJGL, which in turn uses GLFW, which appears to use the XKB extension: https://www.glfw.org/docs/3.3/compat.html

I have no idea why Shattered might not respect modified layouts, I don't do anything in particular to grab 'raw' keypresses. From a quick look it does seem like 'modifier' keys such as caps lock, shift, etc, might be finicky with remapping.

It's worth noting that Shattered does support single key remapping within the application, including modifier keys.

Hi there, and thanks for all the incredible work on SPD!

I've started playing on a Linux machine recently, where I've swapped the Escape and Caps Lock keys with setxkbmap -option caps:swapescape. Most applications (web browsers, other desktop apps, etc) respond as expected (e.g. hitting the Caps Lock key triggers the Escape behavior), but this doesn't seem to be the case in SPD. I have to hit the physical Escape key, which ends up toggling my Caps Lock.

I'm not knowledgeable enough about Linux/X11 to know what the underlying issue is, but it seems like whatever Java input API being used is getting more 'raw' keypresses than other applications.

What operating system and version are you running?

What operating system and version are you running?

Arch Linux, kernel 6.8.1, no desktop environment, running X11 and using bspwm as a window manager

How do you have the game installed?

How do you have the game installed?

I downloaded the Linux option from the release, unzipped it and run ./bin/<spd binary>

Can you replicate the problem with the game Mindustry and/ or this one? https://github.com/yairm210/Unciv

Can you replicate the problem with the game Mindustry and/ or this one? https://github.com/yairm210/Unciv

Instead of risking addiction to another OSS game, I opted to just remap the "Back" action to "Caps Lock" as 00-Evan suggested, e.g.

2024-03-27_12-16-44

This is a perfectly fine and simple workaround (which I probably should have just done in the first place 🙃)