#include <controller.hpp>
Inherited by CodeController.
Public Types | |
enum | Control { LEFT = 0, RIGHT, UP, DOWN, JUMP, ACTION, PAUSE_MENU, MENU_SELECT, CONSOLE, PEEK_LEFT, PEEK_RIGHT, PEEK_UP, PEEK_DOWN, CONTROLCOUNT } |
Public Member Functions | |
Controller () | |
virtual | ~Controller () |
void | set_control (Control control, bool value) |
bool | hold (Control control) |
returns true if the control is pressed down | |
bool | pressed (Control control) |
returns true if the control has just been pressed down this frame | |
bool | released (Control control) |
returns true if the control has just been released this frame | |
virtual void | reset () |
virtual void | update () |
Static Public Attributes | |
static const char * | controlNames [] |
Protected Attributes | |
bool | controls [CONTROLCOUNT] |
current control status | |
bool | oldControls [CONTROLCOUNT] |
control status at last frame |
Definition at line 20 of file controller.hpp.
enum Controller::Control |
LEFT | |
RIGHT | |
UP | |
DOWN | |
JUMP | |
ACTION | |
PAUSE_MENU | |
MENU_SELECT | |
CONSOLE | |
PEEK_LEFT | |
PEEK_RIGHT | |
PEEK_UP | |
PEEK_DOWN | |
CONTROLCOUNT |
Definition at line 25 of file controller.hpp.
00025 { 00026 LEFT = 0, 00027 RIGHT, 00028 UP, 00029 DOWN, 00030 00031 JUMP, 00032 ACTION, 00033 00034 PAUSE_MENU, 00035 MENU_SELECT, 00036 00037 CONSOLE, 00038 00039 PEEK_LEFT, 00040 PEEK_RIGHT, 00041 PEEK_UP, 00042 PEEK_DOWN, 00043 00044 CONTROLCOUNT 00045 };
Controller::Controller | ( | ) |
Controller::~Controller | ( | ) | [virtual] |
void Controller::set_control | ( | Control | control, | |
bool | value | |||
) |
Definition at line 54 of file controller.cpp.
References controls.
Referenced by JoystickKeyboardController::process_key_event(), JoystickKeyboardController::process_menu_key_event(), and JoystickKeyboardController::set_joy_controls().
00055 { 00056 controls[control] = value; 00057 }
bool Controller::hold | ( | Control | control | ) |
returns true if the control is pressed down
Definition at line 60 of file controller.cpp.
References controls.
Referenced by Player::bounce(), Trampoline::collision(), Player::handle_horizontal_input(), Player::handle_input(), Player::handle_input_climbing(), Player::handle_input_ghost(), Player::handle_vertical_input(), GameSession::process_events(), Player::stop_climbing(), Player::try_grab(), TextScroller::update(), Menu::update(), and worldmap::Tux::updateInputDirection().
00061 { 00062 return controls[control]; 00063 }
bool Controller::pressed | ( | Control | control | ) |
returns true if the control has just been pressed down this frame
Definition at line 66 of file controller.cpp.
References controls, and oldControls.
Referenced by Player::collision(), Player::handle_input(), Player::handle_vertical_input(), worldmap::WorldMap::update(), TextScroller::update(), LevelIntro::update(), GameSession::update(), and Menu::update().
00067 { 00068 return !oldControls[control] && controls[control]; 00069 }
bool Controller::released | ( | Control | control | ) |
returns true if the control has just been released this frame
Definition at line 72 of file controller.cpp.
References controls, and oldControls.
Referenced by Player::handle_input().
00073 { 00074 return oldControls[control] && !controls[control]; 00075 }
void Controller::reset | ( | ) | [virtual] |
Definition at line 45 of file controller.cpp.
References CONTROLCOUNT, controls, and oldControls.
Referenced by Controller(), and JoystickKeyboardController::reset().
00046 { 00047 for(int i = 0; i < CONTROLCOUNT; ++i) { 00048 controls[i] = false; 00049 oldControls[i] = false; 00050 } 00051 }
void Controller::update | ( | ) | [virtual] |
Reimplemented in CodeController.
Definition at line 78 of file controller.cpp.
References CONTROLCOUNT, controls, and oldControls.
Referenced by JoystickKeyboardController::update(), and CodeController::update().
00079 { 00080 for(int i = 0; i < CONTROLCOUNT; ++i) 00081 oldControls[i] = controls[i]; 00082 }
const char * Controller::controlNames [static] |
Definition at line 23 of file controller.hpp.
Referenced by Player::do_scripting_controller(), JoystickKeyboardController::read(), and JoystickKeyboardController::write().
bool Controller::controls[CONTROLCOUNT] [protected] |
current control status
Definition at line 63 of file controller.hpp.
Referenced by hold(), CodeController::press(), pressed(), released(), reset(), set_control(), update(), and CodeController::update().
bool Controller::oldControls[CONTROLCOUNT] [protected] |
control status at last frame
Definition at line 65 of file controller.hpp.
Referenced by pressed(), released(), reset(), and update().