Public Member Functions | |
| mxJoystick (int joy_index=0) | |
| mxJoystick (SDL_Joystick *stick) | |
| ~mxJoystick () | |
| void | initJoystick (int id) |
| void | freeJoystick () |
| const bool | isOpen () const |
| const std::string | joystickName () const |
| const bool | joystickGetButton (int button) const |
| const int | joystickGetAxis (int axis) const |
| const int | joystickGetHat (int hat) const |
| const int | joystickGetBall (int ball, int &x, int &y) |
Static Public Member Functions | |
| static const int | joystickNum () |
| static const void | joystickUpdate () |
Protected Attributes | |
| SDL_Joystick * | stick |
| int | index |
Definition at line 30 of file mxjoystick.h.
| mx::mxJoystick::mxJoystick | ( | int | joy_index = 0 |
) |
default constructor
Definition at line 23 of file mxjoystick.cpp.
References initJoystick(), and stick.
00024 { 00025 stick = 0; 00026 00027 initJoystick(id); 00028 00029 }
| mx::mxJoystick::mxJoystick | ( | SDL_Joystick * | stick | ) |
constructor
| already | opened Joystick |
Definition at line 31 of file mxjoystick.cpp.
References freeJoystick(), and index.
00032 { 00033 00034 if(this->stick != 0) 00035 { 00036 freeJoystick(); 00037 } 00038 00039 this->stick = stick; 00040 index = SDL_JoystickIndex(this->stick); 00041 }
| mx::mxJoystick::~mxJoystick | ( | ) |
destructor
Definition at line 44 of file mxjoystick.cpp.
References freeJoystick().
00045 { 00046 freeJoystick(); 00047 }
| void mx::mxJoystick::freeJoystick | ( | ) |
freeJoystick free the Joystick
Definition at line 66 of file mxjoystick.cpp.
References stick.
Referenced by mxJoystick(), and ~mxJoystick().
| void mx::mxJoystick::initJoystick | ( | int | id | ) |
initJoystick initialize joystick
Definition at line 50 of file mxjoystick.cpp.
Referenced by mxJoystick().
00051 { 00052 00053 stick = SDL_JoystickOpen(id); 00054 SDL_JoystickEventState(SDL_ENABLE); 00055 00056 if(stick == 0) 00057 { 00058 std::cout << "could not open joystick id: " << id << "\n"; 00059 } 00060 00061 index = id; 00062 00063 }
| const bool mx::mxJoystick::isOpen | ( | ) | const [inline] |
isOpen is Joystick already Open?
Definition at line 46 of file mxjoystick.h.
References index.
00046 { return SDL_JoystickOpened(index) ? true : false; }
| const int mx::mxJoystick::joystickGetAxis | ( | int | axis | ) | const |
joystickGetAxis get axis position
| axis | which axis |
Definition at line 77 of file mxjoystick.cpp.
References stick.
00078 { 00079 return static_cast<int>(SDL_JoystickGetAxis(stick, axis)); 00080 }
| const int mx::mxJoystick::joystickGetBall | ( | int | ball, | |
| int & | x, | |||
| int & | y | |||
| ) |
joystickGetBall
| ball | which ball | |
| x | x pos | |
| y | y pos |
Definition at line 87 of file mxjoystick.cpp.
References stick.
00088 { 00089 return static_cast<int>( SDL_JoystickGetBall(stick, ball, &x, &y) ); 00090 }
| const bool mx::mxJoystick::joystickGetButton | ( | int | button | ) | const |
joystickGetButton get if button is down
| button | which button |
Definition at line 72 of file mxjoystick.cpp.
References stick.
00073 { 00074 return SDL_JoystickGetButton(stick, button) ? true : false; 00075 }
| const int mx::mxJoystick::joystickGetHat | ( | int | hat | ) | const |
joystickGetHat get position of hat
| hat | which hat |
Definition at line 82 of file mxjoystick.cpp.
References stick.
00083 { 00084 return static_cast<int>(SDL_JoystickGetHat(stick, hat)); 00085 }
| const std::string mx::mxJoystick::joystickName | ( | ) | const [inline] |
joystickName
Definition at line 48 of file mxjoystick.h.
References index.
00048 { return SDL_JoystickName(index); }
| static const int mx::mxJoystick::joystickNum | ( | ) | [inline, static] |
| static const void mx::mxJoystick::joystickUpdate | ( | ) | [inline, static] |
int mx::mxJoystick::index [protected] |
current joystick index
Definition at line 83 of file mxjoystick.h.
Referenced by initJoystick(), isOpen(), joystickName(), and mxJoystick().
SDL_Joystick* mx::mxJoystick::stick [protected] |
SDL_Joystick * data
Definition at line 81 of file mxjoystick.h.
Referenced by freeJoystick(), initJoystick(), joystickGetAxis(), joystickGetBall(), joystickGetButton(), joystickGetHat(), and mxJoystick().
1.5.8