The Battle for Wesnoth  1.15.1+dev
joystick.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2018 by Fabian Mueller
3  Part of the Battle for Wesnoth Project https://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 #pragma once
16 
17 #include <vector>
18 #include "map/location.hpp"
19 
20 #include <SDL2/SDL.h>
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 };
std::pair< int, int > get_axis_pair(int joystick_xaxis, int xaxis, int joystick_yaxis, int yaxis)
Definition: joystick.cpp:229
int get_axis(int joystick_axis, int axis)
Definition: joystick.cpp:254
bool update_highlighted_hex(map_location &highlighted_hex)
Used for absolute movement of the cursor.
Definition: joystick.cpp:300
std::pair< double, double > get_scroll_axis_pair()
Definition: joystick.cpp:155
std::pair< double, double > get_polar_coordinates(int joystick_xaxis, int xaxis, int joystick_yaxis, int yaxis)
TODO fendrin.
Definition: joystick.cpp:218
double get_thrusta_axis()
TODO fendrin.
Definition: joystick.cpp:184
double get_angle()
TODO fendrin.
Definition: joystick.cpp:366
Encapsulates the map of the game.
Definition: location.hpp:42
const map_location get_direction(const map_location &loc, joystick_manager::DIRECTION direction)
Definition: joystick.cpp:347
std::vector< SDL_Joystick * > joysticks_
Definition: joystick.hpp:95
double get_thrustb_axis()
TODO fendrin.
Definition: joystick.cpp:196
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:121
std::pair< double, double > get_cursor_polar_coordinates()
TODO fendrin.
Definition: joystick.cpp:208