The Battle for Wesnoth  1.15.0+dev
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
joystick_manager Class Reference

#include <joystick.hpp>

Public Member Functions

 joystick_manager ()
 
 ~joystick_manager ()
 
bool init ()
 
bool close ()
 
bool update_highlighted_hex (map_location &highlighted_hex)
 Used for absolute movement of the cursor. More...
 
bool update_highlighted_hex (map_location &highlighted_hex, const map_location &selected_hex)
 Used for relative movement of the cursor. More...
 
std::pair< double, double > get_scroll_axis_pair ()
 
std::pair< double, double > get_cursor_polar_coordinates ()
 TODO fendrin. More...
 
std::pair< double, double > get_mouse_axis_pair ()
 TODO fendrin. More...
 
double get_thrusta_axis ()
 TODO fendrin. More...
 
double get_thrustb_axis ()
 TODO fendrin. More...
 
double get_angle ()
 TODO fendrin. More...
 
std::pair< double, double > get_polar_coordinates (int joystick_xaxis, int xaxis, int joystick_yaxis, int yaxis)
 TODO fendrin. More...
 

Private Types

enum  DIRECTION {
  NORTH, NORTH_EAST, SOUTH_EAST, SOUTH,
  SOUTH_WEST, NORTH_WEST, NDIRECTIONS, WEST,
  EAST
}
 

Private Member Functions

std::pair< int, int > get_axis_pair (int joystick_xaxis, int xaxis, int joystick_yaxis, int yaxis)
 
int get_axis (int joystick_axis, int axis)
 
const map_location get_next_hex (int x_axis, int y_axis, map_location old_hex)
 
const map_location get_direction (const map_location &loc, joystick_manager::DIRECTION direction)
 

Private Attributes

std::vector< SDL_Joystick * > joysticks_
 
int joystick_area_
 
int counter_
 

Detailed Description

Definition at line 22 of file joystick.hpp.

Member Enumeration Documentation

◆ DIRECTION

Enumerator
NORTH 
NORTH_EAST 
SOUTH_EAST 
SOUTH 
SOUTH_WEST 
NORTH_WEST 
NDIRECTIONS 
WEST 
EAST 

Definition at line 84 of file joystick.hpp.

Constructor & Destructor Documentation

◆ joystick_manager()

joystick_manager::joystick_manager ( )

Definition at line 28 of file joystick.cpp.

References init().

◆ ~joystick_manager()

joystick_manager::~joystick_manager ( )

Definition at line 36 of file joystick.cpp.

References close().

Member Function Documentation

◆ close()

bool joystick_manager::close ( )

Definition at line 56 of file joystick.cpp.

References attached(), ERR_JOY, i, joysticks_, LOG_JOY, and name().

Referenced by init(), and ~joystick_manager().

◆ get_angle()

double joystick_manager::get_angle ( )

◆ get_axis()

int joystick_manager::get_axis ( int  joystick_axis,
int  axis 
)
private

Definition at line 254 of file joystick.cpp.

References attached(), and joysticks_.

Referenced by get_thrusta_axis(), and get_thrustb_axis().

◆ get_axis_pair()

std::pair< int, int > joystick_manager::get_axis_pair ( int  joystick_xaxis,
int  xaxis,
int  joystick_yaxis,
int  yaxis 
)
private

◆ get_cursor_polar_coordinates()

std::pair< double, double > joystick_manager::get_cursor_polar_coordinates ( )

◆ get_direction()

const map_location joystick_manager::get_direction ( const map_location loc,
joystick_manager::DIRECTION  direction 
)
private

◆ get_mouse_axis_pair()

std::pair< double, double > joystick_manager::get_mouse_axis_pair ( )

◆ get_next_hex()

const map_location joystick_manager::get_next_hex ( int  x_axis,
int  y_axis,
map_location  old_hex 
)
private

◆ get_polar_coordinates()

std::pair< double, double > joystick_manager::get_polar_coordinates ( int  joystick_xaxis,
int  xaxis,
int  joystick_yaxis,
int  yaxis 
)

TODO fendrin.

Definition at line 218 of file joystick.cpp.

References get_axis_pair().

Referenced by get_cursor_polar_coordinates().

◆ get_scroll_axis_pair()

std::pair< double, double > joystick_manager::get_scroll_axis_pair ( )

◆ get_thrusta_axis()

double joystick_manager::get_thrusta_axis ( )

◆ get_thrustb_axis()

double joystick_manager::get_thrustb_axis ( )

◆ init()

bool joystick_manager::init ( )

◆ update_highlighted_hex() [1/2]

bool joystick_manager::update_highlighted_hex ( map_location highlighted_hex)

Used for absolute movement of the cursor.

Parameters
highlighted_hexwill change if the cursor moved.
Returns
true if the highlighted hex changed.

Definition at line 300 of file joystick.cpp.

References counter_, f, get_axis_pair(), get_next_hex(), joystick_area_, preferences::joystick_cursor_deadzone(), preferences::joystick_cursor_threshold(), preferences::joystick_cursor_xaxis_num(), preferences::joystick_cursor_yaxis_num(), preferences::joystick_num_cursor_xaxis(), and preferences::joystick_num_cursor_yaxis().

Referenced by controller_base::play_slice().

◆ update_highlighted_hex() [2/2]

bool joystick_manager::update_highlighted_hex ( map_location highlighted_hex,
const map_location selected_hex 
)

Used for relative movement of the cursor.

Parameters
highlighted_hexwill change if the cursor moved.
Returns
true if the highlighted hex changed.

Definition at line 265 of file joystick.cpp.

References map_location::add(), get_axis_pair(), preferences::joystick_cursor_xaxis_num(), preferences::joystick_cursor_yaxis_num(), preferences::joystick_num_cursor_xaxis(), and preferences::joystick_num_cursor_yaxis().

Member Data Documentation

◆ counter_

int joystick_manager::counter_
private

Definition at line 97 of file joystick.hpp.

Referenced by update_highlighted_hex().

◆ joystick_area_

int joystick_manager::joystick_area_
private

Definition at line 96 of file joystick.hpp.

Referenced by update_highlighted_hex().

◆ joysticks_

std::vector<SDL_Joystick*> joystick_manager::joysticks_
private

Definition at line 95 of file joystick.hpp.

Referenced by close(), get_axis(), get_axis_pair(), and init().


The documentation for this class was generated from the following files: