joystick.hpp

Go to the documentation of this file.
00001 /* $Id: joystick.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2011 - 2012 by Fabian Mueller
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
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      * Used for absolute movement of the cursor.
00036      * @param highlighted_hex will change if the cursor moved.
00037      * @return true if the highlighted hex changed.
00038      */
00039     bool update_highlighted_hex(map_location& highlighted_hex);
00040 
00041     /**
00042      * Used for relative movement of the cursor.
00043      * @param highlighted_hex will change if the cursor moved.
00044      * @return true if the highlighted hex changed.
00045      */
00046     bool update_highlighted_hex(map_location& highlighted_hex, const map_location& selected_hex);
00047 
00048     /**
00049      * @return a value in range [-1,+1] representing the gauges of the scroll axes.
00050      */
00051     std::pair<double, double> get_scroll_axis_pair();
00052 
00053     /**
00054      * TODO fendrin
00055      */
00056     std::pair<double, double> get_cursor_polar_coordinates();
00057 
00058     /**
00059      * TODO fendrin
00060      */
00061     std::pair<double, double> get_mouse_axis_pair();
00062 
00063     /**
00064      * TODO fendrin
00065      */
00066     double get_thrusta_axis();
00067 
00068     /**
00069      * TODO fendrin
00070      */
00071     double get_thrustb_axis();
00072 
00073     /**
00074      * TODO fendrin
00075      */
00076     double get_angle();
00077 
00078     /**
00079      * TODO fendrin
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 /* JOYSTICK_HPP_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:03 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs