SuperTuxKart
|
Public Member Functions | |
MultitouchDevice () | |
The multitouch device constructor. | |
virtual | ~MultitouchDevice () |
The multitouch device destructor. | |
bool | processAndMapInput (Input::InputType type, const int id, InputManager::InputDriverMode mode, PlayerAction *action, int *value=NULL) |
Unused function. | |
unsigned int | getActiveTouchesCount () |
Returns a number of fingers that are currently in use. | |
void | addButton (MultitouchButtonType type, int x, int y, int width, int height, void(*callback)(unsigned int, bool)=NULL) |
Creates a button of specified type and position. | |
void | clearButtons () |
Deletes all previously created buttons. | |
void | reset () |
Sets all buttons and events to default state. | |
unsigned int | getButtonsCount () |
Returns the number of created buttons. | |
MultitouchButton * | getButton (unsigned int i) |
Returns pointer to the selected button. | |
void | activateAccelerometer () |
Activates accelerometer. | |
void | deactivateAccelerometer () |
Deativates accelerometer. | |
bool | isAccelerometerActive () |
Get accelerometer state. | |
void | activateGyroscope () |
Activates gyroscope. | |
void | deactivateGyroscope () |
Deativates gyroscope. | |
bool | isGyroscopeActive () |
Get gyroscope state. | |
void | updateAxisX (float value) |
void | updateAxisY (float value) |
float | getOrientation () |
Returns device orientation Z angle, in radians, where 0 is landscape orientation parallel to the floor. | |
void | updateOrientationFromAccelerometer (float x, float y) |
Update device orientation from the accelerometer measurements. | |
void | updateOrientationFromGyroscope (float z) |
Update device orientation from the gyroscope measurements. | |
void | updateDeviceState (unsigned int event_id) |
The function that is executed when touch event occurs. | |
void | updateController () |
void | updateConfigParams () |
Updates config parameters i.e. | |
Public Member Functions inherited from InputDevice | |
virtual bool | processAndMapInput (Input::InputType type, const int id, InputManager::InputDriverMode mode, PlayerAction *action, int *value=NULL)=0 |
Invoked when this device it used. | |
void | setPlayer (StateManager::ActivePlayer *owner) |
Sets which players uses this device; or pass NULL to say no player uses it. | |
void | setConfiguration (DeviceConfig *config) |
Sets the configuration to be used by this input device. | |
DeviceConfig * | getConfiguration () |
Returns the configuration for this device. | |
DeviceType | getType () const |
Returns the type of this device. | |
StateManager::ActivePlayer * | getPlayer () |
Returns the player using this device. | |
const std::string & | getName () const |
Returns the name of this device. | |
void | setConnected (bool val) |
bool | isConnected () const |
Public Attributes | |
std::array< MultitouchEvent, NUMBER_OF_MULTI_TOUCHES > | m_events |
The array that contains data for all multitouch input events. | |
Private Member Functions | |
float | getSteeringFactor (float value, float sensitivity) |
Helper function that returns a steering factor for steering button. | |
void | handleControls (MultitouchButton *button) |
Sends proper action for player controller depending on the button type and state. | |
bool | isGameRunning () |
Private Attributes | |
std::vector< MultitouchButton * > | m_buttons |
The list of pointers to all created buttons. | |
Controller * | m_controller |
float | m_deadzone |
The parameter that is used for steering button and determines dead area in a center of button. | |
float | m_sensitivity_x |
A parameter in range that determines the sensitivity for x axis. | |
float | m_sensitivity_y |
A parameter in range that determines the sensitivity for y axis. | |
float | m_orientation |
uint64_t | m_gyro_time |
IrrlichtDevice * | m_irrlicht_device |
Pointer to the irrlicht device. | |
std::map< unsigned, std::vector< MultitouchButton * > > | m_affected_linked_buttons |
Additional Inherited Members | |
Protected Attributes inherited from InputDevice | |
bool | m_connected |
For SDL controller it's set false when it's unplugged. | |
DeviceType | m_type |
Device type (keyboard, gamepad). | |
StateManager::ActivePlayer * | m_player |
Which player is using this device. | |
DeviceConfig * | m_configuration |
The configuration for this device. | |
std::string | m_name |
If device has a name; unused for keyboards since AFAIK we can't tell keyboards apart. | |
void MultitouchDevice::addButton | ( | MultitouchButtonType | type, |
int | x, | ||
int | y, | ||
int | width, | ||
int | height, | ||
void(*)(unsigned int, bool) | callback = NULL |
||
) |
Creates a button of specified type and position.
The button is then updated when touch event occurs and proper action is sent to player controller. Note that it just determines the screen area that is considered as button and it doesn't draw the GUI element on a screen.
type | The button type that determines its behaviour. |
x | Vertical position of the button. |
y | Horizontal position of the button. |
width | Width of the button. |
height | Height of the button. |
callback | Pointer to a function that is executed on button event. |
|
private |
Helper function that returns a steering factor for steering button.
value | The axis value from 0 to 1. |
sensitivity | Value from 0 to 1.0. |
|
private |
Sends proper action for player controller depending on the button type and state.
button | The button that should be handled. |
bool MultitouchDevice::isAccelerometerActive | ( | ) |
Get accelerometer state.
bool MultitouchDevice::isGyroscopeActive | ( | ) |
Get gyroscope state.
|
inlinevirtual |
Unused function.
Implements InputDevice.
void MultitouchDevice::updateConfigParams | ( | ) |
Updates config parameters i.e.
when they are modified in options
void MultitouchDevice::updateDeviceState | ( | unsigned int | event_id | ) |
The function that is executed when touch event occurs.
It updates the buttons state when it's needed.
event_id | The id of touch event that should be processed. |
void MultitouchDevice::updateOrientationFromAccelerometer | ( | float | x, |
float | y | ||
) |
Update device orientation from the accelerometer measurements.
Accelerometer is shaky, so it adjusts the orientation angle slowly.
x | Accelerometer X axis |
y | Accelerometer Y axis |
void MultitouchDevice::updateOrientationFromGyroscope | ( | float | z | ) |
Update device orientation from the gyroscope measurements.
Gyroscope is not shaky and very sensitive, but drifts over time.
x | Gyroscope Z axis |