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
43
struct
ControllerButtonBinding
{
44
ControllerButton
button
;
45
uint32_t
controller_index
{ 0 };
46
};
47
52
struct
ControllerAxisBinding
{
53
ControllerAxis
axis
;
54
uint32_t
controller_index
{ 0 };
55
float
threshold
{ 0.5F };
56
bool
positive_direction
{
true
};
57
};
58
60
using
ActionBinding
61
= std::variant<KeyBinding, MouseButtonBinding, ControllerButtonBinding, ControllerAxisBinding>;
62
71
void
bind_action
(std::string_view name,
ActionBinding
binding);
72
77
void
unbind_action
(std::string_view name);
78
81
void
clear_actions
();
82
88
bool
get_action_down
(std::string_view name);
89
95
bool
get_action_up
(std::string_view name);
96
102
bool
get_action
(std::string_view name);
103
113
float
get_action_strength
(std::string_view name);
114
120
void
update_actions
();
121
122
}
// namespace asw::input
123
124
#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:141
asw::input::bind_action
void bind_action(std::string_view name, ActionBinding binding)
Register a binding for a named action.
Definition
action.cpp:126
asw::input::Key
Key
Enumeration of keys in the ASW library.
Definition
input.h:37
asw::input::clear_actions
void clear_actions()
Remove all registered actions and their bindings.
Definition
action.cpp:136
asw::input::ControllerButton
ControllerButton
Mappings from SDL game controller buttons to ASW buttons.
Definition
input.h:403
asw::input::update_actions
void update_actions()
Update cached action states from current raw input.
Definition
action.cpp:165
asw::input::get_action
bool get_action(std::string_view name)
Check if an action is currently held down.
Definition
action.cpp:153
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:159
asw::input::unbind_action
void unbind_action(std::string_view name)
Remove all bindings for a named action.
Definition
action.cpp:131
asw::input::MouseButton
MouseButton
Enumeration of mouse buttons in the ASW library.
Definition
input.h:27
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:60
asw::input::get_action_up
bool get_action_up(std::string_view name)
Check if an action was released this frame.
Definition
action.cpp:147
asw::input::ControllerAxis
ControllerAxis
Mappings from SDL game controller axes to ASW axes.
Definition
input.h:432
asw::input::ControllerAxisBinding
Binding to a controller axis, activated when the axis exceeds a threshold.
Definition
action.h:52
asw::input::ControllerAxisBinding::positive_direction
bool positive_direction
Definition
action.h:56
asw::input::ControllerAxisBinding::controller_index
uint32_t controller_index
Definition
action.h:54
asw::input::ControllerAxisBinding::axis
ControllerAxis axis
Definition
action.h:53
asw::input::ControllerAxisBinding::threshold
float threshold
Definition
action.h:55
asw::input::ControllerButtonBinding
Binding to a controller (gamepad) button.
Definition
action.h:43
asw::input::ControllerButtonBinding::controller_index
uint32_t controller_index
Definition
action.h:45
asw::input::ControllerButtonBinding::button
ControllerButton button
Definition
action.h:44
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