Try / OpenGothic

Reimplementation of Gothic 2 Notr
MIT License
1.14k stars 80 forks source link

Caps lock bug #674

Closed YALdysse closed 1 week ago

YALdysse commented 3 weeks ago

Describe the bug OpenGothic:v1.0.2843 (commit 3f7214dd) OS: Linux Mint 21.2

If you press the Caps Lock key while moving in any side the hero will move independently. If you then release all the keys, the hero will still move (something like autoclick). In order to stop the movement, you need to turn off Caps lock and press the key responsible for moving in your direction.

Also, if you turn on Caps lock, the hero will not move when you press the wasd keys, but the jump on the white space will work.

Save-game/Log-file/Screenshots/Video It is works on any saves.

Application log log.txt

Try commented 2 weeks ago

Hi, @YALdysse !

The issues, that you described look like a key-translation problem: K_a and K_A do have different integer id's and engine has some code to mitigate it. Naturally for space it's not an issue, as there is no such thing as capital space.

I've tested in virtual-linux machine with Ubuntu + English, if there is anything wrong with key-mapping: English seem to be correct. Can you please let me know what keyboard layout do you use and does this issues reproducible with en-US layout on your machine?

YALdysse commented 2 weeks ago

When I run OpenGothic with the Ukrainian layout, the wasd keys do not work. When I run it in English, they work. It seems to me that wasd and other keys will only work on the English keyboard layout.

I tried to delete all keyboard layouts except English, but the problem with Caps Lock is still present.

YALdysse commented 2 weeks ago

I just tried to launch Rogue Legacy with the Ukrainian layout and the keys don't work there either. It seems to be a Linux issue. However, when you enable Caps lock on the English layout, the wasd and other keys still work. It seems that the problem with Caps lock is related to OpenGothic.

Try commented 2 weeks ago

So far I want able to reproduce this issues. However I'm testing in a simple-window sample, while running engine in virtual-box. Tested Ukrainian, German, Russian - all appears to work.

If you can build open-gothic from source, can you please check in x11api.cpp:

uint32_t scan = xev.xkey.keycode;
// printf("%s\n",txt); // <-- here you can add some printing to check key/scancode

Tempest::KeyEvent e(Event::KeyType(key),uint32_t(u16.size()>0 ? u16[0] : 0),Event::M_NoModifier,(xev.type==KeyPress) ? Event::KeyDown : Event::KeyUp);
if(xev.type==KeyPress)
  SystemApi::dispatchKeyDown(cb,e,scan); else
  SystemApi::dispatchKeyUp  (cb,e,scan);

When application runs as intended scan should be exactly same for capital and non-capital letters.

YALdysse commented 2 weeks ago

I can build OpenGothic.

Unfortunately, I don't know C++.

// printf("%s\n",txt); // <-- here you can add some printing to check key/scancode What code should be here so that I can check the functionality?

Try commented 2 weeks ago

What code should be here so that I can check the functionality?

Log::d(txt, " : ", scan);

This will print a human-readable representation the character (for example Ц) and a scan-code. Expectation here to have same scan for capital and smaller letters and same scan across languages

YALdysse commented 2 weeks ago

log.txt

Before switching the keyboard layout, I pressed the wasd keys three times, and the log says 6. Is this normal?

Try commented 2 weeks ago

I pressed the wasd keys three times, and the log says 6. Is this normal?

Yes: one line for key-press, one for key-release.

From the log:

w : 25
ц : 25
W : 25

Scan code logic appears to be working as expected: key code stays same, regardless of language/caps. And from that point execution should be same for linux/windows/etc.

I'm not sure what is wrong here, maybe X11 on your particular system doesn't send key-release in some cases.

YALdysse commented 2 weeks ago

@Try, thanks.