ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
include
asw
modules
action.h
Go to the documentation of this file.
1
20
21
#ifndef ASW_ACTION_H
22
#define ASW_ACTION_H
23
24
#include <string>
25
#include <string_view>
26
#include <variant>
27
28
#include "
./input.h
"
29
30
namespace
asw::input
{
31
33
struct
KeyBinding
{
34
Key
key
;
35
};
36
38
struct
MouseButtonBinding
{
39
MouseButton
button
;
40
};
41
44
struct
ControllerButtonBinding
{
45
ControllerButton
button
;
46
uint32_t
controller_index
{ 0 };
47
};
48
57
struct
ControllerAxisBinding
{
58
ControllerAxis
axis
;
59
uint32_t
controller_index
{ 0 };
60
float
threshold
{ 0.5F };
61
bool
positive_direction
{
true
};
62
};
63
65
using
ActionBinding
66
= std::variant<KeyBinding, MouseButtonBinding, ControllerButtonBinding, ControllerAxisBinding>;
67
76
void
bind_action
(std::string_view name,
ActionBinding
binding);
77
82
void
unbind_action
(std::string_view name);
83
86
void
clear_actions
();
87
93
bool
get_action_down
(std::string_view name);
94
100
bool
get_action_up
(std::string_view name);
101
107
bool
get_action
(std::string_view name);
108
118
float
get_action_strength
(std::string_view name);
119
126
void
update_actions
();
127
128
}
// namespace asw::input
129
130
#endif
// ASW_ACTION_H
input.h
Input module for the ASW library.
asw::input
Definition
action.h:30
asw::input::get_action_down
bool get_action_down(std::string_view name)
Check if an action was triggered (first pressed) this frame.
Definition
action.cpp:168
asw::input::bind_action
void bind_action(std::string_view name, ActionBinding binding)
Register a binding for a named action.
Definition
action.cpp:151
asw::input::Key
Key
Enumeration of keys in the ASW library.
Definition
input.h:38
asw::input::clear_actions
void clear_actions()
Remove all registered actions and their bindings.
Definition
action.cpp:163
asw::input::ControllerButton
ControllerButton
Mappings from SDL game controller buttons to ASW buttons.
Definition
input.h:459
asw::input::update_actions
void update_actions()
Update cached action states from current raw input.
Definition
action.cpp:192
asw::input::get_action
bool get_action(std::string_view name)
Check if an action is currently held down.
Definition
action.cpp:180
asw::input::get_action_strength
float get_action_strength(std::string_view name)
Get the analogue strength of an action (0.0 – 1.0).
Definition
action.cpp:186
asw::input::unbind_action
void unbind_action(std::string_view name)
Remove all bindings for a named action.
Definition
action.cpp:156
asw::input::MouseButton
MouseButton
Enumeration of mouse buttons in the ASW library.
Definition
input.h:28
asw::input::ActionBinding
std::variant< KeyBinding, MouseButtonBinding, ControllerButtonBinding, ControllerAxisBinding > ActionBinding
A single input binding — keyboard, mouse button, controller button, or controller axis.
Definition
action.h:65
asw::input::get_action_up
bool get_action_up(std::string_view name)
Check if an action was released this frame.
Definition
action.cpp:174
asw::input::ControllerAxis
ControllerAxis
Mappings from SDL game controller axes to ASW axes.
Definition
input.h:488
asw::input::ControllerAxisBinding
Binding to a controller axis, activated when the axis exceeds a threshold.
Definition
action.h:57
asw::input::ControllerAxisBinding::positive_direction
bool positive_direction
Definition
action.h:61
asw::input::ControllerAxisBinding::controller_index
uint32_t controller_index
Definition
action.h:59
asw::input::ControllerAxisBinding::axis
ControllerAxis axis
Definition
action.h:58
asw::input::ControllerAxisBinding::threshold
float threshold
Definition
action.h:60
asw::input::ControllerButtonBinding
Binding to a controller (gamepad) button. Set controller_index to ANY_CONTROLLER to accept every conn...
Definition
action.h:44
asw::input::ControllerButtonBinding::controller_index
uint32_t controller_index
Definition
action.h:46
asw::input::ControllerButtonBinding::button
ControllerButton button
Definition
action.h:45
asw::input::KeyBinding
Binding to a keyboard key.
Definition
action.h:33
asw::input::KeyBinding::key
Key key
Definition
action.h:34
asw::input::MouseButtonBinding
Binding to a mouse button.
Definition
action.h:38
asw::input::MouseButtonBinding::button
MouseButton button
Definition
action.h:39
Generated by
1.12.0