3#include <initializer_list>
11 std::string_view prefix, std::string_view name, std::initializer_list<ActionBinding> bindings)
13 std::string action { prefix };
17 for (
const auto& binding : bindings) {
30 return { .axis = axis,
33 .positive_direction = positive };
41 nav.
up =
bind(prefix,
"up",
43 stick(ControllerAxis::LeftY,
false) });
46 stick(ControllerAxis::LeftY,
true) });
49 stick(ControllerAxis::LeftX,
false) });
51 {
KeyBinding { Key::Right },
pad(ControllerButton::DPadRight),
52 stick(ControllerAxis::LeftX,
true) });
54 =
bind(prefix,
"next", {
KeyBinding { Key::Tab },
pad(ControllerButton::RightShoulder) });
55 nav.
prev =
bind(prefix,
"prev", {
pad(ControllerButton::LeftShoulder) });
Action binding system for the ASW library.
std::string bind(std::string_view prefix, std::string_view name, std::initializer_list< ActionBinding > bindings)
ControllerAxisBinding stick(ControllerAxis axis, bool positive)
ControllerButtonBinding pad(ControllerButton button)
Navigation bind_default_navigation(std::string_view prefix="ui_")
Bind keyboard and controller actions for UI navigation and return their names. Calling it again repla...
Action based navigation for the ASW UI module.
Action names the UI reads for focus navigation, see asw/modules/action.h.
std::string down
Move focus down.
std::string back
Go back, sent to the focused widget and then Root::on_back.
std::string right
Move focus right.
std::string prev
Move focus to the previous widget.
std::string up
Move focus up.
std::string activate
Press the focused widget.
std::string next
Move focus to the next widget. Holding Shift makes it go back, so Shift+Tab still works when Tab is b...
std::string left
Move focus left.