Skip to content

Commit

Permalink
feat(port): UI, accessibility updates, tweaks (#4636)
Browse files Browse the repository at this point in the history
* Port UI, accessibility updates, tweaks

Co-Authored-By: Zhilkin Serg <ZhilkinSerg@users.noreply.github.com>
Co-Authored-By: Chaosvolt <chaosvolt@users.noreply.github.com>
Co-Authored-By: Jianxiang Wang (王健翔) <qrox@sina.com>
Co-Authored-By: Rob Kuijper <robkuijper@live.nl>
Co-Authored-By: Brambor <13402666+Brambor@users.noreply.github.com>
Co-Authored-By: eltank <8000047+eltank@users.noreply.github.com>
Co-Authored-By: David Seguin <davidseguin@live.ca>
Co-Authored-By: ZeroInternalReflection <89038572+zerointernalreflection@users.noreply.github.com>
Co-Authored-By: martinrhan <53336429+martinrhan@users.noreply.github.com>
Co-Authored-By: Mark Langsdorf <mlangsdo@redhat.com>
Co-Authored-By: BevapDin <5095435+bevapdin@users.noreply.github.com>

* style(autofix.ci): automated formatting

* Misc tweaks update

* Misc tweaks update

Co-Authored-By: Zhilkin Serg <ZhilkinSerg@users.noreply.github.com>
Co-Authored-By: Olanti <olanti-p@yandex.ru>
Co-Authored-By: Coolthulhu <Coolthulhu@gmail.com>

* style(autofix.ci): automated formatting

* Misc tweaks update

* Misc tweaks update

* Misc tweaks update

* Misc tweaks update

Co-Authored-By: Jianxiang Wang (王健翔) <qrox@sina.com>
Co-Authored-By: Coolthulhu <Coolthulhu@gmail.com>

* style(autofix.ci): automated formatting

* Misc tweaks update

* style(autofix.ci): automated formatting

* Misc tweaks update

* style(autofix.ci): automated formatting

* Misc tweaks update

* Misc tweaks update

---------

Co-authored-by: Zhilkin Serg <ZhilkinSerg@users.noreply.github.com>
Co-authored-by: Chaosvolt <chaosvolt@users.noreply.github.com>
Co-authored-by: Jianxiang Wang (王健翔) <qrox@sina.com>
Co-authored-by: Rob Kuijper <robkuijper@live.nl>
Co-authored-by: Brambor <13402666+Brambor@users.noreply.github.com>
Co-authored-by: eltank <8000047+eltank@users.noreply.github.com>
Co-authored-by: David Seguin <davidseguin@live.ca>
Co-authored-by: ZeroInternalReflection <89038572+zerointernalreflection@users.noreply.github.com>
Co-authored-by: martinrhan <53336429+martinrhan@users.noreply.github.com>
Co-authored-by: Mark Langsdorf <mlangsdo@redhat.com>
Co-authored-by: BevapDin <5095435+bevapdin@users.noreply.github.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Olanti <olanti-p@yandex.ru>
Co-authored-by: Coolthulhu <Coolthulhu@gmail.com>
  • Loading branch information
15 people committed May 30, 2024
1 parent 9e3d8ef commit db18424
Show file tree
Hide file tree
Showing 100 changed files with 3,666 additions and 2,341 deletions.
1,422 changes: 959 additions & 463 deletions data/raw/keybindings/keybindings.json

Large diffs are not rendered by default.

83 changes: 45 additions & 38 deletions data/raw/keybindings/vehicle.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,265 +4,272 @@
"type": "keybinding",
"category": "VEHICLE",
"name": "Control multiple electronics",
"bindings": [ { "input_method": "keyboard", "key": "E" } ]
"bindings": [ { "input_method": "keyboard_char", "key": "E" }, { "input_method": "keyboard_code", "key": "e", "mod": [ "shift" ] } ]
},
{
"id": "CONTROL_ENGINES",
"type": "keybinding",
"category": "VEHICLE",
"name": "Control individual engines",
"bindings": [ { "input_method": "keyboard", "key": "y" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "y" } ]
},
{
"id": "FOLD_VEHICLE",
"type": "keybinding",
"category": "VEHICLE",
"name": "Fold vehicle",
"bindings": [ { "input_method": "keyboard", "key": "f" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "f" } ]
},
{
"id": "RELEASE_CONTROLS",
"type": "keybinding",
"category": "VEHICLE",
"name": "Release controls",
"bindings": [ { "input_method": "keyboard", "key": "l" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "l" } ]
},
{
"id": "SOUND_HORN",
"type": "keybinding",
"category": "VEHICLE",
"name": "Sound horn",
"bindings": [ { "input_method": "keyboard", "key": "n" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "n" } ]
},
{
"id": "TOGGLE_AISLE_LIGHT",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle aisle lights",
"bindings": [ { "input_method": "keyboard", "key": "L" } ]
"bindings": [ { "input_method": "keyboard_char", "key": "L" }, { "input_method": "keyboard_code", "key": "l", "mod": [ "shift" ] } ]
},
{
"id": "TOGGLE_ALARM",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle alarm",
"bindings": [ { "input_method": "keyboard", "key": "z" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "z" } ]
},
{
"id": "TOGGLE_ATOMIC_LIGHT",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle atomic lights",
"bindings": [ { "input_method": "keyboard", "key": "A" } ]
"bindings": [ { "input_method": "keyboard_char", "key": "A" }, { "input_method": "keyboard_code", "key": "a", "mod": [ "shift" ] } ]
},
{
"id": "CONTROL_AUTOPILOT",
"type": "keybinding",
"category": "VEHICLE",
"name": "Control autopilot",
"bindings": [ { "input_method": "keyboard", "key": "a" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "a" } ]
},
{
"id": "TOGGLE_CAMERA",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle camera system",
"bindings": [ { "input_method": "keyboard", "key": "M" } ]
"bindings": [ { "input_method": "keyboard_char", "key": "M" }, { "input_method": "keyboard_code", "key": "m", "mod": [ "shift" ] } ]
},
{
"id": "TOGGLE_CHIMES",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle chimes",
"bindings": [ { "input_method": "keyboard", "key": "i" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "i" } ]
},
{
"id": "TOGGLE_CRUISE_CONTROL",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle cruise control",
"bindings": [ { "input_method": "keyboard", "key": "c" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "c" } ]
},
{
"id": "TOGGLE_DOME_LIGHT",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle dome lights",
"bindings": [ { "input_method": "keyboard", "key": "d" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "d" } ]
},
{
"id": "TOGGLE_DOORS",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle doors",
"bindings": [ { "input_method": "keyboard", "key": "D" } ]
"bindings": [ { "input_method": "keyboard_char", "key": "D" }, { "input_method": "keyboard_code", "key": "d", "mod": [ "shift" ] } ]
},
{
"id": "TOGGLE_ENGINE",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle engine",
"bindings": [ { "input_method": "keyboard", "key": "e" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "e" } ]
},
{
"id": "TOGGLE_FRIDGE",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle fridge",
"bindings": [ { "input_method": "keyboard", "key": "f" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "f" } ]
},
{
"id": "TOGGLE_FREEZER",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle freezer",
"bindings": [ { "input_method": "keyboard", "key": "r" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "r" } ]
},
{
"id": "TOGGLE_SPACE_HEATER",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle space heater",
"bindings": [ { "input_method": "keyboard", "key": "s" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "s" } ]
},
{
"id": "TOGGLE_COOLER",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle cooler",
"bindings": [ { "input_method": "keyboard", "key": "C" } ]
"bindings": [ { "input_method": "keyboard_char", "key": "C" }, { "input_method": "keyboard_code", "key": "c", "mod": [ "shift" ] } ]
},
{
"id": "TOGGLE_HEADLIGHT",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle headlights",
"bindings": [ { "input_method": "keyboard", "key": "h" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "h" } ]
},
{
"id": "TOGGLE_WIDE_HEADLIGHT",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle wide-angle headlights",
"bindings": [ { "input_method": "keyboard", "key": "b" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "b" } ]
},
{
"id": "TOGGLE_HALF_OVERHEAD_LIGHT",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle directional overhead lights",
"bindings": [ { "input_method": "keyboard", "key": "O" } ]
"bindings": [ { "input_method": "keyboard_char", "key": "O" }, { "input_method": "keyboard_code", "key": "o", "mod": [ "shift" ] } ]
},
{
"id": "TOGGLE_OVERHEAD_LIGHT",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle overhead lights",
"bindings": [ { "input_method": "keyboard", "key": "o" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "o" } ]
},
{
"id": "TOGGLE_PLANTER",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle planter",
"bindings": [ { "input_method": "keyboard", "key": "P" } ]
"bindings": [ { "input_method": "keyboard_char", "key": "P" }, { "input_method": "keyboard_code", "key": "p", "mod": [ "shift" ] } ]
},
{
"id": "TOGGLE_PLOW",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle plow",
"bindings": [ { "input_method": "keyboard", "key": "w" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "w" } ]
},
{
"id": "TOGGLE_REACTOR",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle reactor",
"bindings": [ { "input_method": "keyboard", "key": "k" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "k" } ]
},
{
"id": "TOGGLE_REAPER",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle reaper",
"bindings": [ { "input_method": "keyboard", "key": "H" } ]
"bindings": [ { "input_method": "keyboard_char", "key": "H" }, { "input_method": "keyboard_code", "key": "h", "mod": [ "shift" ] } ]
},
{
"id": "TOGGLE_RECHARGER",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle recharger",
"bindings": [ { "input_method": "keyboard", "key": "g" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "g" } ]
},
{
"id": "TOGGLE_SCOOP",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle scoop",
"bindings": [ { "input_method": "keyboard", "key": "S" } ]
"bindings": [ { "input_method": "keyboard_char", "key": "S" }, { "input_method": "keyboard_code", "key": "s", "mod": [ "shift" ] } ]
},
{
"id": "TOGGLE_STEREO",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle stereo",
"bindings": [ { "input_method": "keyboard", "key": "m" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "m" } ]
},
{
"id": "TOGGLE_WATER_PURIFIER",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle water purifiers",
"bindings": [ { "input_method": "keyboard", "key": "p" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "p" } ]
},
{
"id": "TOGGLE_TRACKING",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle tracking",
"bindings": [ { "input_method": "keyboard", "key": "K" } ]
"bindings": [ { "input_method": "keyboard_char", "key": "K" }, { "input_method": "keyboard_code", "key": "k", "mod": [ "shift" ] } ]
},
{
"id": "TOGGLE_SMART_ENGINE_CONTROLLER",
"type": "keybinding",
"category": "VEHICLE",
"name": "Toggle smart engine controller",
"bindings": [ { "input_method": "keyboard_char", "key": "Y" }, { "input_method": "keyboard_code", "key": "y", "mod": [ "shift" ] } ]
},
{
"id": "TURRET_FIRE_MODE",
"type": "keybinding",
"category": "VEHICLE",
"name": "Set turret firing modes",
"bindings": [ { "input_method": "keyboard", "key": "x" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "x" } ]
},
{
"id": "TURRET_MANUAL_AIM",
"type": "keybinding",
"category": "VEHICLE",
"name": "Aim manual turrets",
"bindings": [ { "input_method": "keyboard", "key": "X" } ]
"bindings": [ { "input_method": "keyboard_char", "key": "X" }, { "input_method": "keyboard_code", "key": "x", "mod": [ "shift" ] } ]
},
{
"id": "TURRET_MANUAL_OVERRIDE",
"type": "keybinding",
"category": "VEHICLE",
"name": "Aim automatic turrets",
"bindings": [ { "input_method": "keyboard", "key": "V" } ]
"bindings": [ { "input_method": "keyboard_char", "key": "V" }, { "input_method": "keyboard_code", "key": "v", "mod": [ "shift" ] } ]
},
{
"id": "TURRET_ALL_OVERRIDE",
"type": "keybinding",
"category": "VEHICLE",
"name": "Aim all turrets",
"bindings": [ { "input_method": "keyboard", "key": "v" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "v" } ]
},
{
"id": "TURRET_SINGLE_FIRE",
"type": "keybinding",
"category": "VEHICLE",
"name": "Aim individual turret",
"bindings": [ { "input_method": "keyboard", "key": "T" } ]
"bindings": [ { "input_method": "keyboard_char", "key": "T" }, { "input_method": "keyboard_code", "key": "t", "mod": [ "shift" ] } ]
},
{
"id": "TURRET_TARGET_MODE",
"type": "keybinding",
"category": "VEHICLE",
"name": "Set turret targeting modes",
"bindings": [ { "input_method": "keyboard", "key": "t" } ]
"bindings": [ { "input_method": "keyboard_any", "key": "t" } ]
}
]
45 changes: 11 additions & 34 deletions doc/src/content/docs/en/dev/explanation/accessibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,14 @@
title: Compatibility with screen readers
---

There are people who uses screen readers to play Cataclysm DDA. In order for screen readers to
announce the most important information in a UI, the terminal cursor has to be placed at the correct
location. This information may be text such as selected item names in a list, etc, and the cursor
has to be placed exactly at the beginning of the text for screen readers to announce it.

`wmove` in `output.h|cpp` is the function to move the cursor to a specific location. After calling
`wmove` with the target `catacurses::window` and cursor position, `wrefresh` needs to be called
immediately afterwards for `wmove` to take effect.

Here is an example of placing the cursor explicitly at the beginning of a piece of text:

```cpp
catacurses::window win = ...; // target window

...

// display code
point cursor_position = ...; // default cursor position

...

cursor_position = point_zero; // record the start position of the text
fold_and_print( win, cursor_position, getmaxx( win ), c_white, _( "This text is important" ) );

...

// at the end of display code
wmove( win, cursor_position );
wrefresh( win );
// no output code should follow as they might change the cursor position
```
As shown in the above example, it is preferable to record the intended cursor position in a variable
when the text is printed, and move the cursor later using the variable to ensure consisitency.
There are people who use screen readers to play Cataclysm Bright Nights. In order for screen readers
to announce the most important information in a UI, the terminal cursor has to be placed at the
correct location. This information may be text such as selected item names in a list, etc, and the
cursor has to be placed exactly at the beginning of the text for screen readers to announce it.

The recommended way to place the cursor is to use `ui_adaptor`. This ensures the desired cursor
position is preserved when subsequent output code changes the cursor position. You can call
`ui_adaptor::set_cursor` and similar methods at any position in a redrawing callback, and the last
cursor position of the topmost UI set via the call will be used as the final cursor position. You
can also call `ui_adaptor::disable_cursor` to prevent a UI's cursor from being used as the final
cursor position.
7 changes: 4 additions & 3 deletions src/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ std::vector<char> keys_bound_to( action_id act, const bool restrict_to_printable
action_id action_from_key( char ch )
{
input_context ctxt = get_default_mode_input_context();
const input_event event( ch, CATA_INPUT_KEYBOARD );
const input_event event( ch, input_event_t::keyboard_char );
const std::string &action = ctxt.input_to_action( event );
return look_up_action( action );
}
Expand Down Expand Up @@ -926,7 +926,8 @@ action_id handle_main_menu()
const auto register_actions = make_register_actions( entries, ctxt );

register_actions( {
ACTION_OPEN_WIKI, ACTION_HELP, ACTION_KEYBINDINGS, ACTION_OPTIONS, ACTION_AUTOPICKUP, ACTION_AUTONOTES,
ACTION_OPEN_WIKI, ACTION_HELP,
ACTION_KEYBINDINGS, ACTION_OPTIONS, ACTION_AUTOPICKUP, ACTION_AUTONOTES,
ACTION_SAFEMODE, ACTION_DISTRACTION_MANAGER, ACTION_COLOR, ACTION_WORLD_MODS,
ACTION_ACTIONMENU, ACTION_QUICKSAVE, ACTION_SAVE, ACTION_DEBUG, ACTION_LUA_CONSOLE,
ACTION_LUA_RELOAD
Expand All @@ -947,7 +948,7 @@ action_id handle_main_menu()

std::optional<tripoint> choose_direction( const std::string &message, const bool allow_vertical )
{
input_context ctxt( "DEFAULTMODE" );
input_context ctxt( "DEFAULTMODE", keyboard_mode::keychar );
ctxt.set_iso( true );
ctxt.register_directions();
ctxt.register_action( "pause" );
Expand Down
Loading

0 comments on commit db18424

Please sign in to comment.