1852
|
1 |
#summary Solutions for fixing bug 240 (frontend displays wrong key name)
|
|
2 |
|
1859
|
3 |
*This wiki page is OBSOLETE now. Bug 240 is now fixed.*
|
|
4 |
|
|
5 |
Everything below the line is only of historic interest.
|
|
6 |
|
1860
|
7 |
----
|
1859
|
8 |
|
1852
|
9 |
This wiki page is for documenting and analyzing possible solutions for [https://issues.hedgewars.org/show_bug.cgi?id=240 bug 240] that have been discussed before.
|
|
10 |
|
1854
|
11 |
== Criteria ==
|
1852
|
12 |
|
|
13 |
First, for a working solution, it should match these criteria:
|
|
14 |
|
1853
|
15 |
# They key you selected in frontend is the key that you actually need to push (so if it says āZā, you must press the āZā key in game; it must respect keyboard layout). This is the bug that was reported
|
|
16 |
# The key that is displayed in frontend must match the key that is saved in config file
|
|
17 |
# (optional) Engine is able to convert the code to human-readable text. It's not a bug if it's not possible, however
|
|
18 |
# Default key config works with MOST normal keyboards (100% perfect coverage not required as its unrealistic; owners of exotic keyboards are expected to reconfig)
|
1852
|
19 |
|
1854
|
20 |
== Possible solutions ==
|
1852
|
21 |
|
1853
|
22 |
=== A) Use keycode in frontend and config file, use scancode in engine (current broken approach) ===
|
|
23 |
|
|
24 |
Criteria:
|
|
25 |
|
|
26 |
# No.
|
|
27 |
# Yes.
|
|
28 |
# No.
|
|
29 |
# Yes.
|
|
30 |
|
|
31 |
Summary: The problem with our current approach is point 1. The frontend displays the wrong key. The fact that the game inconsistently uses keycodes AND scancodes is also a little insane. Any solution definitely must fix point 1, otherwise it gains us nothing
|
|
32 |
|
1855
|
33 |
=== B) Use scancodes in frontend, engine und config. Create a small helper program that queries scancode in frontend to replace the drop-down menu ===
|
1856
|
34 |
|
|
35 |
How it's supposed to work:
|
|
36 |
# Write SDL window for getting the key. It must give scancode as return/exit code
|
|
37 |
# Frontend: Replace drop-down with widget that opens the SDL window and detect the exit code
|
|
38 |
# Save scancode in config file
|
|
39 |
# Frontend: Figure out how to turn the scancode into human-readable text
|
|
40 |
|
|
41 |
Criteria:
|
|
42 |
|
1853
|
43 |
# Yes.
|
|
44 |
# No obvious solution in sight. Maybe there is one?
|
|
45 |
* Possible, hacky solution: Convert scancode to keycode using a hardcoded lookup table or something like that
|
|
46 |
* https://github.com/hluk/qxtglobalshortcut/blob/16446200b699e0610b8a5fb20b74938225d81d87/src/xcbkeyboard.h#L249
|
|
47 |
# Yes. Convert scancode to keycode with SDL_GetKeyFromScancode
|
|
48 |
# No idea.
|
|
49 |
|
|
50 |
* Note: Adding a new program only to grab the key seems a little insane, but it seems to work
|
|
51 |
* Note: We have a mock-up of the keygrab program, but no code for the rest exists yet
|
|
52 |
|
|
53 |
Summary: This solution depends on whether 2) is solvable. We need to be able to render the correct key name in frontend, otherwise, this solution would be a regression. Another open question is how to store the keys in the config. Just the raw scancodes? Anyway, if we can figure all that out, then this approach is a valid solution.
|
1852
|
54 |
|
1853
|
55 |
=== C) Use keycodes in frontend, config und engine ===
|
|
56 |
|
|
57 |
Criteria:
|
|
58 |
|
|
59 |
# Yes.
|
|
60 |
# Yes.
|
|
61 |
# Yes.
|
|
62 |
# Meh. What will semi-break is the default config for e.g. French keyboards because of the number keys (for timer) which are secondary inputs, so owners of French keyboards need to reconfig.
|
1852
|
63 |
|
1853
|
64 |
Possible solutions for 4)
|
|
65 |
* Allow numpad numbers as alternative input for timer keys
|
|
66 |
* Implement user-selectable alternative keys for everything and add numpad keys as alternative input for timer by default
|
|
67 |
* When detecting French keyboard on first launch, use different default keys (does not sound very stable ... Also, how to detect keyboard layout in Qt?)
|
|
68 |
* Non-solution: Ignore it. Expect French users to re-config. This would be a regression.
|
|
69 |
|
|
70 |
Real, tested code does exist for this appraoch in the hedgewars-draft repo, but nemo has hidden the commits. Code is now very old and probably would needs a rewrite anyway.
|
1852
|
71 |
|
1853
|
72 |
Summary: This solution works (I have tested it). The only problem is with default config which would be less universal than our current approach, but this might be solvable.
|
|
73 |
|
|
74 |
=== D) Marry frontend with engine and only use SDL calls for all things keyboard ===
|
|
75 |
|
|
76 |
Criteria:
|
|
77 |
|
|
78 |
* Would likely solve all problems
|
|
79 |
|
|
80 |
But this is a very very huge task, should not be done before 1.0 or otherwise we'd never get the 1.0 out
|