SuperTuxKart
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
MultitouchDevice Class Reference
Inheritance diagram for MultitouchDevice:
Inheritance graph
[legend]

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. More...
 
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.
 
MultitouchButtongetButton (unsigned int i)
 Returns pointer to the selected button.
 
void activateAccelerometer ()
 Activates accelerometer.
 
void deactivateAccelerometer ()
 Deativates accelerometer.
 
bool isAccelerometerActive ()
 Get accelerometer state. More...
 
void activateGyroscope ()
 Activates gyroscope.
 
void deactivateGyroscope ()
 Deativates gyroscope.
 
bool isGyroscopeActive ()
 Get gyroscope state. More...
 
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. More...
 
void updateOrientationFromGyroscope (float z)
 Update device orientation from the gyroscope measurements. More...
 
void updateDeviceState (unsigned int event_id)
 The function that is executed when touch event occurs. More...
 
void updateController ()
 
void updateConfigParams ()
 Updates config parameters i.e. More...
 
- Public Member Functions inherited from InputDevice
void setPlayer (StateManager::ActivePlayer *owner)
 Sets which players uses this device; or pass NULL to say no player uses it. More...
 
void setConfiguration (DeviceConfig *config)
 Sets the configuration to be used by this input device. More...
 
DeviceConfiggetConfiguration ()
 Returns the configuration for this device. More...
 
DeviceType getType () const
 Returns the type of this device. More...
 
StateManager::ActivePlayergetPlayer ()
 Returns the player using this device. More...
 
const std::string & getName () const
 Returns the name of this device. More...
 
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. More...
 
void handleControls (MultitouchButton *button)
 Sends proper action for player controller depending on the button type and state. More...
 
bool isGameRunning ()
 

Private Attributes

std::vector< MultitouchButton * > m_buttons
 The list of pointers to all created buttons.
 
Controllerm_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. More...
 
float m_sensitivity_y
 A parameter in range that determines the sensitivity for y axis. More...
 
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. More...
 
DeviceType m_type
 Device type (keyboard, gamepad). More...
 
StateManager::ActivePlayerm_player
 Which player is using this device. More...
 
DeviceConfigm_configuration
 The configuration for this device. More...
 
std::string m_name
 If device has a name; unused for keyboards since AFAIK we can't tell keyboards apart. More...
 

Member Function Documentation

◆ addButton()

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.

Parameters
typeThe button type that determines its behaviour.
xVertical position of the button.
yHorizontal position of the button.
widthWidth of the button.
heightHeight of the button.
callbackPointer to a function that is executed on button event.

◆ getSteeringFactor()

float MultitouchDevice::getSteeringFactor ( float  value,
float  sensitivity 
)
private

Helper function that returns a steering factor for steering button.

Parameters
valueThe axis value from 0 to 1.
sensitivityValue from 0 to 1.0.

◆ handleControls()

void MultitouchDevice::handleControls ( MultitouchButton button)
private

Sends proper action for player controller depending on the button type and state.

Parameters
buttonThe button that should be handled.

◆ isAccelerometerActive()

bool MultitouchDevice::isAccelerometerActive ( )

Get accelerometer state.

Returns
true if accelerometer is active

◆ isGyroscopeActive()

bool MultitouchDevice::isGyroscopeActive ( )

Get gyroscope state.

Returns
true if gyroscope is active

◆ updateConfigParams()

void MultitouchDevice::updateConfigParams ( )

Updates config parameters i.e.

when they are modified in options

◆ updateDeviceState()

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.

Parameters
event_idThe id of touch event that should be processed.

◆ updateOrientationFromAccelerometer()

void MultitouchDevice::updateOrientationFromAccelerometer ( float  x,
float  y 
)

Update device orientation from the accelerometer measurements.

Accelerometer is shaky, so it adjusts the orientation angle slowly.

Parameters
xAccelerometer X axis
yAccelerometer Y axis

◆ updateOrientationFromGyroscope()

void MultitouchDevice::updateOrientationFromGyroscope ( float  z)

Update device orientation from the gyroscope measurements.

Gyroscope is not shaky and very sensitive, but drifts over time.

Parameters
xGyroscope Z axis

Member Data Documentation

◆ m_sensitivity_x

float MultitouchDevice::m_sensitivity_x
private

A parameter in range that determines the sensitivity for x axis.

◆ m_sensitivity_y

float MultitouchDevice::m_sensitivity_y
private

A parameter in range that determines the sensitivity for y axis.


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