SuperTuxKart
Loading...
Searching...
No Matches
input_device.hpp
1// SuperTuxKart - a fun racing game with go-kart
2//
3// Copyright (C) 2009-2015 Marianne Gagnon
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 3
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19#ifndef HEADER_INPUT_DEVICE_HPP
20#define HEADER_INPUT_DEVICE_HPP
21
22
23#include "input/input.hpp"
24#include "input/input_manager.hpp"
25#include "states_screens/state_manager.hpp"
26#include "utils/no_copy.hpp"
27
28#include <string>
29
30class DeviceConfig;
31
37{
38 DT_KEYBOARD,
39 DT_GAMEPAD,
40 DT_MULTITOUCH
41};
42
47class InputDevice: public NoCopy
48{
49protected:
52
55
58
61
64 std::string m_name;
65
66public:
67
69 virtual ~InputDevice();
85 virtual bool processAndMapInput(Input::InputType type, const int id,
86 InputManager::InputDriverMode mode,
87 PlayerAction *action, int* value = NULL
88 ) = 0;
89
90 // ------------------------------------------------------------------------
94
95 // ------------------------------------------------------------------------
98
99 // ------------------------------------------------------------------------
102
103 // ------------------------------------------------------------------------
105 DeviceType getType() const { return m_type; };
106
107 // ------------------------------------------------------------------------
110 // ------------------------------------------------------------------------
112 const std::string& getName() const { return m_name; }
113 // ------------------------------------------------------------------------
114 void setConnected(bool val) { m_connected = val; }
115 // ------------------------------------------------------------------------
116 bool isConnected() const { return m_connected; }
117}; // class InputDevice
118
119#endif
contains the key bindings information related to one input device
Definition: device_config.hpp:42
base class for input devices
Definition: input_device.hpp:48
void setPlayer(StateManager::ActivePlayer *owner)
Sets which players uses this device; or pass NULL to say no player uses it.
Definition: input_device.hpp:93
DeviceConfig * getConfiguration()
Returns the configuration for this device.
Definition: input_device.hpp:101
DeviceConfig * m_configuration
The configuration for this device.
Definition: input_device.hpp:60
StateManager::ActivePlayer * getPlayer()
Returns the player using this device.
Definition: input_device.hpp:109
virtual bool processAndMapInput(Input::InputType type, const int id, InputManager::InputDriverMode mode, PlayerAction *action, int *value=NULL)=0
Invoked when this device it used.
void setConfiguration(DeviceConfig *config)
Sets the configuration to be used by this input device.
Definition: input_device.hpp:97
const std::string & getName() const
Returns the name of this device.
Definition: input_device.hpp:112
DeviceType getType() const
Returns the type of this device.
Definition: input_device.hpp:105
StateManager::ActivePlayer * m_player
Which player is using this device.
Definition: input_device.hpp:57
std::string m_name
If device has a name; unused for keyboards since AFAIK we can't tell keyboards apart.
Definition: input_device.hpp:64
DeviceType m_type
Device type (keyboard, gamepad).
Definition: input_device.hpp:54
bool m_connected
For SDL controller it's set false when it's unplugged.
Definition: input_device.hpp:51
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
Represents a player that is currently playing.
Definition: state_manager.hpp:76
DeviceType
Input device type.
Definition: input_device.hpp:37
PlayerAction
types of input events / what actions the players can do
Definition: input.hpp:117