HomeWildfire Games

Let players remap hotkeys in-game, fix default hotkeys being qwerty-specific.

Description

Let players remap hotkeys in-game, fix default hotkeys being qwerty-specific.

  • Provide a "Hotkey" screen to let players remap hotkeys in-game using a convenient setup.
  • Make all .cfg hotkeys refer to scancodes (i.e. position on the keyboard), so that default hotkeys now translate correctly for AZERTY, QWERTZ and other layouts.
  • 'BackSpace' is now an alias for 'Delete', and works for killing units. This fixes #1917, as macs don't have a proper delete key and would need to use Fn+Del otherwise. This shifts "timewarp" to Shift+BackSpace.

Functionally, this switches hotkeys to scancodes, as that makes more sense (they are combinations of key positions, not actual text output).
SDL includes are cleaned and key names are reused.

Fixes #2850, Fixes #2604, Refs #1810, Fixes #1917.

Follows work in rP19624.

Various diffs tested by: Angen, Stan, Freagarach

Comments by: Nescio

Differential Revision: https://code.wildfiregames.com/D2814

Event Timeline

Suggest improvements here: #5867

Nescio added a subscriber: Nescio.Nov 19 2020, 11:09 AM

Concerning the in-game manual, previously it was:


Now it is:

I may be biased, but I think the old + and or are better readable than the new + and , . Moreover, the new version has but LeftBracket, whereas the previous version displayed ↑ (Up) and [ (Left Bracket), which I think was clearer.
Ideally, though, the manual ought to use columns, with the key combination nicely aligned in one and the description in another.

Also, when running the checkrefs.pl script, I get:

Loading GUI XML...
Unexpected GUI XML root element 'page':
$VAR1 = {
          'page' => {
                      'include' => [
                                     'common/modern/setup.xml',
                                     'common/modern/styles.xml',
                                     'common/modern/sprites.xml',
                                     'common/setup.xml',
                                     'common/sprites.xml',
                                     'common/styles.xml',
                                     'common/global.xml',
                                     'hotkeys/sprites.xml',
                                     'hotkeys/hotkeys.xml'
                                   ]
                    }
        };
Stan added a subscriber: Stan.Nov 19 2020, 5:00 PM
Stan added inline comments.
/ps/trunk/source/gui/ObjectTypes/CHotkeyPicker.cpp
21–25
#include "gui/ObjectBases/IGUIObject.h"
#include "lib/timer.h"
#include "ps/CLogger.h"
#include "ps/Hotkey.h"
#include "ps/KeyName.h"
#include "scriptinterface/ScriptConversions.h"
/ps/trunk/source/gui/ObjectTypes/CHotkeyPicker.h
21–23
#include "gui/CGUI.h"
#include "lib/external_libraries/libsdl.h"
#include "ps/CStr.h"

#include <vector>
/ps/trunk/source/ps/KeyName.h
22
#include "CStr.h"

Or see below.

26

CStr8?

/ps/trunk/source/ps/scripting/JSInterface_Hotkey.cpp
20–29
#include "lib/external_libraries/libsdl.h"
#include "ps/CLogger.h"
#include "ps/Hotkey.h"
#include "ps/KeyName.h"
#include "scriptinterface/ScriptConversions.h"

#include <unordered_map>
#include <vector>
#include <set>

Missing + wrong order.

Stan raised a concern with this commit.Nov 27 2020, 1:16 PM
Stan added inline comments.
/ps/trunk/source/gui/CGUI.cpp
255–260

This change broke copy pasting in CInput fields

This commit now has outstanding concerns.Nov 27 2020, 1:16 PM
wraitii added inline comments.Nov 27 2020, 3:15 PM
/ps/trunk/source/gui/CGUI.cpp
255–260
wraitii requested verification of this commit.Nov 28 2020, 9:25 AM
This commit now requires verification by auditors.Nov 28 2020, 9:25 AM
Stan removed an auditor: Stan.Dec 5 2020, 4:52 PM
This commit no longer requires audit.Dec 5 2020, 4:52 PM
Stan added a comment.Dec 17 2020, 5:13 PM

Seems like it broke checkrefs. Refs D3213

+ cd source/tools/entity/
+ perl checkrefs.pl --check-map-xml --validate-templates
Checking public's integrity. 
The following mod(s) will be loaded: public|mod. 
Loading maps XML...
Loading maps PMP...
Loading entities...
Loading actors...
Loading variants...
Loading art files...
Loading materials...
Loading particles...
Loading sound groups...
Loading audio files...
Loading GUI XML...
Unexpected GUI XML root element 'page':
$VAR1 = {
          'page' => {
                      'include' => [
                                     'common/modern/setup.xml',
                                     'common/modern/styles.xml',
                                     'common/modern/sprites.xml',
                                     'common/setup.xml',
                                     'common/sprites.xml',
                                     'common/styles.xml',
                                     'common/global.xml',
                                     'hotkeys/sprites.xml',
                                     'hotkeys/hotkeys.xml'
                                   ]
                    }
        };
vladislavbelov added inline comments.
/ps/trunk/binaries/data/mods/public/gui/manual/intro.txt
16

Mistype.

/ps/trunk/source/ps/KeyName.cpp
163–166

Not ASCII symbols in code.

OptimusShepard raised a concern with this commit.Jan 16 2021, 12:03 AM
OptimusShepard added a subscriber: OptimusShepard.

Causes #5922

This commit now has outstanding concerns.Jan 16 2021, 12:03 AM
All concerns with this commit have now been addressed.Jan 21 2021, 2:35 PM
Imarok raised a concern with this commit.Jun 9 2021, 7:13 PM
Imarok added a subscriber: Imarok.

introduced #6092

This commit now has outstanding concerns.Jun 9 2021, 7:13 PM

Both tickets are fixed.

This commit no longer requires audit.Jul 21 2021, 7:58 PM