nomlib
Loading...
Searching...
No Matches
InputAction.hpp
1/******************************************************************************
2
3 nomlib - C++11 cross-platform game engine
4
5Copyright (c) 2013, 2014 Jeffrey Carpenter <i8degrees@gmail.com>
6All rights reserved.
7
8Redistribution and use in source and binary forms, with or without
9modification, are permitted provided that the following conditions are met:
10
111. Redistributions of source code must retain the above copyright notice, this
12 list of conditions and the following disclaimer.
132. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16
17THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28******************************************************************************/
29#ifndef NOMLIB_SYSTEM_INPUT_MAPPER_INPUT_ACTION_HPP
30#define NOMLIB_SYSTEM_INPUT_MAPPER_INPUT_ACTION_HPP
31
32#include "nomlib/config.hpp"
33#include "nomlib/system/Event.hpp"
34#include "nomlib/system/GameController.hpp"
35
36namespace nom {
37
42{
43 public:
46
47 virtual ~InputAction();
48
53 virtual const Event& event( void ) const;
54
56 const nom::event_callback& callback( void ) const;
57
58 void set_callback(const nom::event_callback& delegate);
59
61 void operator()(const Event& evt) const;
62
66
67 private:
69 nom::event_callback callback_;
70};
71
74{
75 virtual ~KeyboardAction();
76
82 KeyboardAction(int32 sym, InputState state = InputState::PRESSED);
83
90 KeyboardAction(int32 sym, uint16 mod, InputState state = InputState::PRESSED);
91
98 KeyboardAction( int32 sym, uint16 mod, uint8 repeat,
99 InputState state = InputState::PRESSED );
100};
101
108{
109 virtual ~MouseButtonAction();
110
118 MouseButtonAction(uint8 button, InputState state = InputState::PRESSED);
119
128 MouseButtonAction( uint8 button, uint8 clicks,
129 InputState state = InputState::PRESSED );
130};
131
132enum MouseWheelDirection: uint8
133{
134 MOUSE_WHEEL_INVALID = 0,
135 MOUSE_WHEEL_LEFT = 1,
136 MOUSE_WHEEL_RIGHT = 2,
137 MOUSE_WHEEL_UP = 4,
138 MOUSE_WHEEL_DOWN = 8,
139};
140
143{
144 virtual ~MouseWheelAction();
145
149 MouseWheelAction(MouseWheelDirection dir);
150};
151
154{
155 virtual ~JoystickButtonAction();
156
165 JoystickButtonAction(JoystickID id, uint8 button, InputState state);
166};
167
170{
171 virtual ~JoystickAxisAction();
172
180 JoystickAxisAction(JoystickID id, uint8 axis);
181};
182
185{
186 virtual ~JoystickHatAction();
187
196 JoystickHatAction(JoystickID id, uint8 hat, uint8 value);
197};
198
201{
203
213 InputState state = InputState::PRESSED );
214};
215
230
231} // namespace nom
232
233#endif // include guard defined
Button
Game controller button definitions.
Axis
Game controller axis definitions.
Event event_
The event type and relevant input data; the criteria is used to match against user input.
const nom::event_callback & callback(void) const
Get the callback assigned to the input action.
void operator()(const Event &evt) const
C++ functor; execute the callback assigned for the input action.
virtual const Event & event(void) const
Get the underlying event associated with the input action.
nom::event_callback callback_
The delegate to call upon a successful action to event match.
InputAction()
Default constructor; constructs an invalid action state.
Event handling types.
Definition Event.hpp:457
GameControllerAxisAction(JoystickID id, GameController::Axis axis)
Constructor for initializing an object to a valid action state.
GameControllerButtonAction(JoystickID id, GameController::Button button, InputState state=InputState::PRESSED)
Constructor for initializing an object to a valid action state.
JoystickAxisAction(JoystickID id, uint8 axis)
Constructor for initializing an object to a valid action state.
JoystickButtonAction(JoystickID id, uint8 button, InputState state)
Constructor for initializing an object to a valid action state.
JoystickHatAction(JoystickID id, uint8 hat, uint8 value)
Constructor for initializing an object to a valid action state.
KeyboardAction(int32 sym, uint16 mod, InputState state=InputState::PRESSED)
Constructor for initializing an object to a valid action state.
KeyboardAction(int32 sym, InputState state=InputState::PRESSED)
Constructor for initializing an object to a valid action state.
KeyboardAction(int32 sym, uint16 mod, uint8 repeat, InputState state=InputState::PRESSED)
Constructor for initializing an object to a valid action state.
MouseButtonAction(uint8 button, InputState state=InputState::PRESSED)
Constructor for initializing an object to a valid action state.
MouseButtonAction(uint8 button, uint8 clicks, InputState state=InputState::PRESSED)
Constructor for initializing an object to a valid action state.
MouseWheelAction(MouseWheelDirection dir)
Construct a mouse wheel action.