SuperTuxKart
Loading...
Searching...
No Matches
input.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2007-2015 Robert Schuster <robertschuster@fsfe.org>
4// Copyright (C) 2012-2015 SuperTuxKart-Team
5//
6// This program is free software; you can redistribute it and/or
7// modify it under the terms of the GNU General Public License
8// as published by the Free Software Foundation; either version 3
9// of the License, or (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20#ifndef HEADER_INPUT_HPP
21#define HEADER_INPUT_HPP
22
28#include <string>
29#include <irrString.h>
30
34struct Input
35{
36 static const int MAX_VALUE = 32768;
37
38 static const int HAT_H_ID = 100;
39 static const int HAT_V_ID = 101;
40
41 enum AxisDirection
42 {
43 AD_NEGATIVE,
44 AD_POSITIVE,
45 AD_NEUTRAL
46 };
47
48 enum AxisRange
49 {
50 AR_HALF,
51 AR_FULL
52 };
53
54 enum InputType
55 {
56 IT_NONE = 0,
57 IT_KEYBOARD,
58 IT_STICKMOTION,
59 IT_STICKBUTTON,
60 //IT_STICKHAT,
61 IT_MOUSEMOTION,
62 IT_MOUSEBUTTON
63 };
64 static const int IT_LAST = IT_MOUSEBUTTON;
65
66 InputType m_type;
67 int m_device_id;
68 int m_button_id; // or axis ID for gamepads axes
69 int m_axis_direction;
70 int m_axis_range;
71 wchar_t m_character;
72
73 Input()
74 : m_type(IT_NONE), m_device_id(0), m_button_id(0),
75 m_axis_direction(0), m_axis_range(Input::AR_FULL), m_character(0)
76 {
77 // Nothing to do.
78 }
79
103 Input(InputType ntype, int deviceID , int btnID = 0, int axisDirection= 0)
104 : m_type(ntype), m_device_id(deviceID), m_button_id(btnID),
105 m_axis_direction(axisDirection), m_axis_range(Input::AR_FULL)
106 {
107 // Nothing to do.
108 }
109
110}; // struct Input
111
117{
118 PA_BEFORE_FIRST = -1,
119
120 PA_STEER_LEFT = 0,
121 PA_STEER_RIGHT,
122 PA_ACCEL,
123 PA_BRAKE,
124 PA_NITRO,
125 PA_DRIFT,
126 PA_RESCUE,
127 PA_FIRE,
128 PA_LOOK_BACK,
129 PA_PAUSE_RACE,
130
131 PA_MENU_UP,
132 PA_MENU_DOWN,
133 PA_MENU_LEFT,
134 PA_MENU_RIGHT,
135 PA_MENU_SELECT,
136 PA_MENU_CANCEL,
137
138 PA_COUNT
139};
140
141const PlayerAction PA_FIRST_GAME_ACTION = PA_STEER_LEFT;
142const PlayerAction PA_LAST_GAME_ACTION = PA_PAUSE_RACE;
143const PlayerAction PA_FIRST_MENU_ACTION = PA_MENU_UP;
144const PlayerAction PA_LAST_MENU_ACTION = PA_MENU_CANCEL;
145
150static std::string KartActionStrings[PA_COUNT] = {std::string("steerLeft"),
151 std::string("steerRight"),
152 std::string("accel"),
153 std::string("brake"),
154 std::string("nitro"),
155 std::string("drift"),
156 std::string("rescue"),
157 std::string("fire"),
158 std::string("lookBack"),
159 std::string("pauserace"),
160 std::string("menuUp"),
161 std::string("menuDown"),
162 std::string("menuLeft"),
163 std::string("menuRight"),
164 std::string("menuSelect"),
165 std::string("menuCancel")
166 };
167
168#endif
PlayerAction
types of input events / what actions the players can do
Definition: input.hpp:117
static std::string KartActionStrings[PA_COUNT]
human-readable strings for each PlayerAction
Definition: input.hpp:150
Definition: input.hpp:35
Input(InputType ntype, int deviceID, int btnID=0, int axisDirection=0)
Creates an Input instance which represents an arbitrary way of getting game input using a type specif...
Definition: input.hpp:103