Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include <vector>
00017 #include "sdl_utils.hpp"
00018 #include "map.hpp"
00019
00020 #ifndef JOYSTICK_HPP_
00021 #define JOYSTICK_HPP_
00022
00023 class joystick_manager {
00024
00025 public:
00026
00027 joystick_manager();
00028
00029 ~joystick_manager();
00030
00031 bool init();
00032 bool close();
00033
00034
00035
00036
00037
00038
00039 bool update_highlighted_hex(map_location& highlighted_hex);
00040
00041
00042
00043
00044
00045
00046 bool update_highlighted_hex(map_location& highlighted_hex, const map_location& selected_hex);
00047
00048
00049
00050
00051 std::pair<double, double> get_scroll_axis_pair();
00052
00053
00054
00055
00056 std::pair<double, double> get_cursor_polar_coordinates();
00057
00058
00059
00060
00061 std::pair<double, double> get_mouse_axis_pair();
00062
00063
00064
00065
00066 double get_thrusta_axis();
00067
00068
00069
00070
00071 double get_thrustb_axis();
00072
00073
00074
00075
00076 double get_angle();
00077
00078
00079
00080
00081 std::pair<double, double> get_polar_coordinates(int joystick_xaxis, int xaxis, int joystick_yaxis, int yaxis);
00082
00083 private:
00084
00085 enum DIRECTION { NORTH, NORTH_EAST, SOUTH_EAST, SOUTH,
00086 SOUTH_WEST, NORTH_WEST, NDIRECTIONS, WEST, EAST };
00087
00088
00089 std::pair<int, int> get_axis_pair(int joystick_xaxis, int xaxis, int joystick_yaxis, int yaxis);
00090 int get_axis(int joystick_axis, int axis);
00091
00092 const map_location get_next_hex(int x_axis, int y_axis, map_location old_hex);
00093
00094 const map_location get_direction(const map_location& loc, joystick_manager::DIRECTION direction);
00095
00096 std::vector<SDL_Joystick*> joysticks_;
00097 int joystick_area_;
00098 int counter_;
00099 };
00100
00101 #endif