Joystick control of a Craft, joystick calibration. More...
#include <_src_control_joystick.hh>
Classes | |
| class | AxisMap |
| Remaps joystick axises and indicates which axis had an event. Calling the If*() methods effectively remaps the axises (that is, remapping isn't done by changing the Event struct). More... | |
| class | ButtonMap |
| Remaps buttons. More... | |
| struct | Calibration |
| Defines a range of axis values for calibration. Roll/pitch/yaw axises have two ranges with a deadzone in between. Throttle axis has one range. More... | |
Public Member Functions | |
| DEFINE_GetInstance (Joystick) bool Enable(const bool enable | |
| bool | IfEnabled (void) |
| void | SetCalibration (const Calibration &calibration) |
| Calibration | GetCalibration (void) |
| bool | MapAxis (const uint axisLogical, const uint axisReal) |
| bool | MapButton (const uint buttonLogical, const uint buttonReal) |
| void | EnableAutofire (bool f) |
| int | GetAxisValue (const uint axis) |
| bool | GetButtonValue (const uint button) |
Public Attributes | |
| CLASS_CONST uint | MAX_AXIS = 4 |
| pitch,roll,yaw,throttle = 4 | |
| CLASS_CONST uint | MAX_BUTTONS = 8 |
| base::Event< input::JoystickEvent > | mEventButton |
Private Types | |
| enum | eMove { eMove_AT_CENTER, eMove_PITCH_UP, eMove_PITCH_DOWN, eMove_ROLL_LEFT, eMove_ROLL_RIGHT, eMove_YAW_LEFT, eMove_YAW_RIGHT, eMove_THROTTLE } |
Private Member Functions | |
| void | Poll (void) |
| void | ProcessAxisEvent (const input::JoystickEvent &event) |
| void | ProcessButtonEvent (const input::JoystickEvent &eventUnmapped) |
| fp | ComputeFraction (const input::JoystickEvent &event, const uint axis, const Calibration::AxisRange &axisRange, const int dir) |
| DECLARE_SINGLETON_CLASS_VARS (Joystick) bool mEnabledBefore | |
| if joystick was really enabled before | |
Private Attributes | |
| Calibration | mCalibration |
| defines range of axis values | |
| AxisMap | mAxisMap |
| to configure axises | |
| ButtonMap | mButtonMap |
| to configure buttons | |
| input::JoystickEvent | mEvent |
| current event | |
| input::JoystickEvent | mPrevEvent |
| updated only if buttons changed or autofire | |
| bool | mAutofire |
| TinyArray< MAX_AXIS, int > | mAxisValues |
| for calibration (not used internally) | |
| TinyArray< MAX_BUTTONS, bool > | mButtonValues |
| for calibration (not used internally) | |
| fp | mRollFraction |
| these continue axis movement | |
| fp | mPitchFraction |
| until axis is moved to dead-zone | |
| fp | mYawFraction |
| const Milliseconds | mTickFreq |
Friends | |
| class | AxisMap |
Joystick control of a Craft, joystick calibration.
This is the client of the lower-level input::JoystickDevice. This handles axis events: the current Craft is rotated by axis events. This doesn't handle button events, rather, it defers them to a listener.
This class isn't derived from input::JoystickDevice. Instead, this class is a layer over it.
To register a button handler, register an event listener with Joystick::mEventButton (see base/event.hh).
Event classes: base::Event is an object for broadcasting to listeners. JoystickEvent is a simple struct.
enum control::Joystick::eMove [private] |
| fp control::Joystick::ComputeFraction | ( | const input::JoystickEvent & | event, | |
| const uint | axis, | |||
| const Calibration::AxisRange & | axisRange, | |||
| const int | dir | |||
| ) | [private] |
| event | ||
| axis | AXIS_ROLL/PITCH/YAW | |
| axisRange | Calibration.AxisRange | |
| dir | +-1 which can reverse direction of axis. |
| control::Joystick::DECLARE_SINGLETON_CLASS_VARS | ( | Joystick | ) | [private] |
if joystick was really enabled before
| control::Joystick::DEFINE_GetInstance | ( | Joystick | ) | const |
| void control::Joystick::EnableAutofire | ( | bool | f | ) |
Enable/disable autofire.
| int control::Joystick::GetAxisValue | ( | const uint | axis | ) |
| bool control::Joystick::GetButtonValue | ( | const uint | button | ) |
| Joystick::Calibration control::Joystick::GetCalibration | ( | void | ) |
| bool control::Joystick::IfEnabled | ( | void | ) |
Map a joystick axis.
| void control::Joystick::Poll | ( | void | ) | [private] |
Poll joystick axises and buttons.
| void control::Joystick::ProcessAxisEvent | ( | const input::JoystickEvent & | event | ) | [private] |
Process a joystick axis event.
Continuing axis movements: Imagine the joystick moved to top-left corner then moved up and down. The leftward movement remains in effect while the new events are occurring for up/down movements. Therefore, persistent variables are used to continue axis movement until the axis is moved to its dead-zone.
Remapping axises: Remapping an axis is done effectively by calling AxisMap::If*() (remapping isn't done by changing the Event struct).
| void control::Joystick::ProcessButtonEvent | ( | const input::JoystickEvent & | eventUnmapped | ) | [private] |
Process a joystick button event.
| void control::Joystick::SetCalibration | ( | const Calibration & | calibration | ) |
Set/get calibration.
friend class AxisMap [friend] |
bool control::Joystick::mAutofire [private] |
| CLASS_CONST uint control::Joystick::MAX_AXIS = 4 |
pitch,roll,yaw,throttle = 4
| CLASS_CONST uint control::Joystick::MAX_BUTTONS = 8 |
AxisMap control::Joystick::mAxisMap [private] |
to configure axises
TinyArray<MAX_AXIS,int> control::Joystick::mAxisValues [private] |
for calibration (not used internally)
ButtonMap control::Joystick::mButtonMap [private] |
to configure buttons
TinyArray<MAX_BUTTONS,bool> control::Joystick::mButtonValues [private] |
for calibration (not used internally)
Calibration control::Joystick::mCalibration [private] |
defines range of axis values
current event
fp control::Joystick::mPitchFraction [private] |
until axis is moved to dead-zone
updated only if buttons changed or autofire
fp control::Joystick::mRollFraction [private] |
these continue axis movement
const Milliseconds control::Joystick::mTickFreq [private] |
fp control::Joystick::mYawFraction [private] |
Palomino Flight Simulator documents generated by doxygen 1.7.1 on Tue May 15 2012 22:40:11