SuperTuxKart
Loading...
Searching...
No Matches
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.
 
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.
 
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.
 
DeviceConfiggetConfiguration ()
 Returns the configuration for this device.
 
DeviceType getType () const
 Returns the type of this device.
 
StateManager::ActivePlayergetPlayer ()
 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.
 
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.
 
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::ActivePlayerm_player
 Which player is using this device.
 
DeviceConfigm_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.
 

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

◆ processAndMapInput()

bool MultitouchDevice::processAndMapInput ( Input::InputType  type,
const int  id,
InputManager::InputDriverMode  mode,
PlayerAction action,
int *  value = NULL 
)
inlinevirtual

Unused function.

Implements InputDevice.

◆ 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

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