The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
joystick.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2016 by Fabian Mueller
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #ifndef JOYSTICK_HPP_
16 #define JOYSTICK_HPP_
17 
18 #include <vector>
19 #include "sdl/utils.hpp"
20 #include "map/map.hpp"
21 
23 
24 public:
25 
27 
29 
30  bool init();
31  bool close();
32 
33  /**
34  * Used for absolute movement of the cursor.
35  * @param highlighted_hex will change if the cursor moved.
36  * @return true if the highlighted hex changed.
37  */
38  bool update_highlighted_hex(map_location& highlighted_hex);
39 
40  /**
41  * Used for relative movement of the cursor.
42  * @param highlighted_hex will change if the cursor moved.
43  * @return true if the highlighted hex changed.
44  */
45  bool update_highlighted_hex(map_location& highlighted_hex, const map_location& selected_hex);
46 
47  /**
48  * @return a value in range [-1,+1] representing the gauges of the scroll axes.
49  */
50  std::pair<double, double> get_scroll_axis_pair();
51 
52  /**
53  * TODO fendrin
54  */
55  std::pair<double, double> get_cursor_polar_coordinates();
56 
57  /**
58  * TODO fendrin
59  */
60  std::pair<double, double> get_mouse_axis_pair();
61 
62  /**
63  * TODO fendrin
64  */
65  double get_thrusta_axis();
66 
67  /**
68  * TODO fendrin
69  */
70  double get_thrustb_axis();
71 
72  /**
73  * TODO fendrin
74  */
75  double get_angle();
76 
77  /**
78  * TODO fendrin
79  */
80  std::pair<double, double> get_polar_coordinates(int joystick_xaxis, int xaxis, int joystick_yaxis, int yaxis);
81 
82 private:
83 
86 
87 
88  std::pair<int, int> get_axis_pair(int joystick_xaxis, int xaxis, int joystick_yaxis, int yaxis);
89  int get_axis(int joystick_axis, int axis);
90 
91  const map_location get_next_hex(int x_axis, int y_axis, map_location old_hex);
92 
94 
95  std::vector<SDL_Joystick*> joysticks_;
97  int counter_;
98 };
99 
100 #endif /* JOYSTICK_HPP_ */
std::pair< int, int > get_axis_pair(int joystick_xaxis, int xaxis, int joystick_yaxis, int yaxis)
Definition: joystick.cpp:227
int get_axis(int joystick_axis, int axis)
Definition: joystick.cpp:252
bool update_highlighted_hex(map_location &highlighted_hex)
Used for absolute movement of the cursor.
Definition: joystick.cpp:299
std::pair< double, double > get_scroll_axis_pair()
Definition: joystick.cpp:153
std::pair< double, double > get_polar_coordinates(int joystick_xaxis, int xaxis, int joystick_yaxis, int yaxis)
TODO fendrin.
Definition: joystick.cpp:216
double get_thrusta_axis()
TODO fendrin.
Definition: joystick.cpp:182
double get_angle()
TODO fendrin.
Definition: joystick.cpp:366
Encapsulates the map of the game.
Definition: location.hpp:38
const map_location get_direction(const map_location &loc, joystick_manager::DIRECTION direction)
Definition: joystick.cpp:346
std::vector< SDL_Joystick * > joysticks_
Definition: joystick.hpp:95
double get_thrustb_axis()
TODO fendrin.
Definition: joystick.cpp:194
const map_location get_next_hex(int x_axis, int y_axis, map_location old_hex)
Definition: joystick.cpp:387
std::pair< double, double > get_mouse_axis_pair()
TODO fendrin.
Definition: joystick.cpp:119
std::pair< double, double > get_cursor_polar_coordinates()
TODO fendrin.
Definition: joystick.cpp:206