ControlsRework.wiki
author Wuzzy
Thu, 25 Apr 2019 13:35:45 +0100
changeset 1856 2d2693ace6fe
parent 1855 699f4981643d
child 1859 695f35df799e
permissions -rw-r--r--
ControlsRework: Possible todo list
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1852
32c29d1293ea Add ControlsRework.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
     1
#summary Solutions for fixing bug 240 (frontend displays wrong key name)
32c29d1293ea Add ControlsRework.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
     2
32c29d1293ea Add ControlsRework.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
     3
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.
32c29d1293ea Add ControlsRework.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
     4
1854
0da81c188327 ControlsRework: More formatting
Wuzzy
parents: 1853
diff changeset
     5
== Criteria ==
1852
32c29d1293ea Add ControlsRework.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
     6
32c29d1293ea Add ControlsRework.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
     7
First, for a working solution, it should match these criteria:
32c29d1293ea Add ControlsRework.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
     8
1853
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
     9
 # 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
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    10
 # The key that is displayed in frontend must match the key that is saved in config file
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    11
 # (optional) Engine is able to convert the code to human-readable text. It's not a bug if it's not possible, however
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    12
 # 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
32c29d1293ea Add ControlsRework.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
    13
1854
0da81c188327 ControlsRework: More formatting
Wuzzy
parents: 1853
diff changeset
    14
== Possible solutions ==
1852
32c29d1293ea Add ControlsRework.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
    15
1853
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    16
=== A) Use keycode in frontend and config file, use scancode in engine (current broken approach) ===
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    17
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    18
Criteria:
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    19
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    20
 # No.
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    21
 # Yes.
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    22
 # No.
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    23
 # Yes.
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    24
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    25
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
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    26
1855
699f4981643d ControlsRework: fix typo
Wuzzy
parents: 1854
diff changeset
    27
=== 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
2d2693ace6fe ControlsRework: Possible todo list
Wuzzy
parents: 1855
diff changeset
    28
2d2693ace6fe ControlsRework: Possible todo list
Wuzzy
parents: 1855
diff changeset
    29
How it's supposed to work:
2d2693ace6fe ControlsRework: Possible todo list
Wuzzy
parents: 1855
diff changeset
    30
 # Write SDL window for getting the key. It must give scancode as return/exit code
2d2693ace6fe ControlsRework: Possible todo list
Wuzzy
parents: 1855
diff changeset
    31
 # Frontend: Replace drop-down with widget that opens the SDL window and detect the exit code
2d2693ace6fe ControlsRework: Possible todo list
Wuzzy
parents: 1855
diff changeset
    32
 # Save scancode in config file
2d2693ace6fe ControlsRework: Possible todo list
Wuzzy
parents: 1855
diff changeset
    33
 # Frontend: Figure out how to turn the scancode into human-readable text
2d2693ace6fe ControlsRework: Possible todo list
Wuzzy
parents: 1855
diff changeset
    34
2d2693ace6fe ControlsRework: Possible todo list
Wuzzy
parents: 1855
diff changeset
    35
Criteria:
2d2693ace6fe ControlsRework: Possible todo list
Wuzzy
parents: 1855
diff changeset
    36
1853
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    37
 # Yes.
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    38
 # No obvious solution in sight. Maybe there is one?
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    39
   * Possible, hacky solution: Convert scancode to keycode using a hardcoded lookup table or something like that
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    40
   * https://github.com/hluk/qxtglobalshortcut/blob/16446200b699e0610b8a5fb20b74938225d81d87/src/xcbkeyboard.h#L249
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    41
 # Yes. Convert scancode to keycode with SDL_GetKeyFromScancode
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    42
 # No idea.
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    43
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    44
 * Note: Adding a new program only to grab the key seems a little insane, but it seems to work
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    45
 * Note: We have a mock-up of the keygrab program, but no code for the rest exists yet
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    46
 
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    47
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
32c29d1293ea Add ControlsRework.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
    48
1853
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    49
=== C) Use keycodes in frontend, config und engine ===
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    50
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    51
Criteria:
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    52
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    53
 # Yes.
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    54
 # Yes.
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    55
 # Yes.
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    56
 # 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
32c29d1293ea Add ControlsRework.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
    57
1853
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    58
Possible solutions for 4)
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    59
 * Allow numpad numbers as alternative input for timer keys
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    60
 * Implement user-selectable alternative keys for everything and add numpad keys as alternative input for timer by default
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    61
 * When detecting French keyboard on first launch, use different default keys (does not sound very stable ... Also, how to detect keyboard layout in Qt?)
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    62
 * Non-solution: Ignore it. Expect French users to re-config. This would be a regression.
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    63
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    64
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
32c29d1293ea Add ControlsRework.wiki
Wuzzy <almikes@aol.com>
parents:
diff changeset
    65
1853
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    66
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.
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    67
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    68
=== D) Marry frontend with engine and only use SDL calls for all things keyboard ===
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    69
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    70
Criteria:
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    71
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    72
 * Would likely solve all problems
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    73
f8b313ab3417 ControlsRework: Reformat page
Wuzzy
parents: 1852
diff changeset
    74
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