AntiMicroX
Public Member Functions | Protected Slots | Private Member Functions | Private Attributes
GameController Class Reference

Represents a typical gamepad (like PS4 or Xbox gamepad) More...

#include <gamecontroller.h>

Inheritance diagram for GameController:
[legend]
Collaboration diagram for GameController:
[legend]

Public Member Functions

 GameController (SDL_GameController *controller, int deviceIndex, AntiMicroSettings *settings, int counterUniques, QObject *parent)
 
virtual QString getName () override
 
virtual QString getSDLName () override
 
virtual QString getXmlName () const override
 
virtual QString getGUIDString () const override
 
virtual QString getVendorString () const override
 
virtual QString getProductIDString () const override
 
virtual QString getSerialString () const override
 
virtual QString getUniqueIDString () const override
 
virtual QString getRawGUIDString () const override
 
virtual QString getProductVersion () const override
 
virtual QString getRawUniqueIDString () const override
 
virtual QString getRawVendorString () const override
 
virtual QString getRawProductIDString () const override
 
virtual QString getRawProductVersion () const override
 
virtual bool isGameController () override
 Check if device is using the SDL Game Controller API. More...
 
virtual void closeSDLDevice () override
 
virtual SDL_JoystickID getSDLJoystickID () override
 
virtual int getNumberRawButtons () override
 
virtual int getNumberRawAxes () override
 
virtual int getNumberRawHats () override
 
virtual double getRawSensorRate (JoySensorType type) override
 Queries the data rate of the given sensor from SDL. More...
 
virtual bool hasRawSensor (JoySensorType type) override
 Queries if the hardware has the given sensor type. More...
 
void setCounterUniques (int counter) override
 
QString getBindStringForAxis (int index, bool trueIndex=true)
 
QString getBindStringForButton (int index, bool trueIndex=true)
 
SDL_GameControllerButtonBind getBindForAxis (int index)
 
SDL_GameControllerButtonBind getBindForButton (int index)
 
bool isRelevantUniqueID (QString tempUniqueID)
 Check if GUID passed matches the expected GUID for a device. Needed for xinput GUID abstraction. More...
 
void rawButtonEvent (int index, bool pressed)
 
void rawAxisEvent (int index, int value)
 
void rawDPadEvent (int index, int value)
 
const QHash< int, bool > & getRawbuttons ()
 
const QHash< int, int > & getAxisvalues ()
 
const QHash< int, int > & getDpadvalues ()
 
SDL_GameController * getController () const
 
virtual SDL_GameControllerType getControllerType () const override
 Returns the current controller model. More...
 
- Public Member Functions inherited from InputDevice
 InputDevice (SDL_Joystick *joystick, int deviceIndex, AntiMicroSettings *settings, QObject *parent)
 
virtual ~InputDevice ()
 
virtual int getNumberButtons ()
 
virtual int getNumberAxes ()
 
virtual int getNumberHats ()
 
virtual int getNumberSticks ()
 
virtual bool hasSensor (JoySensorType type)
 Checks if this input device has a sensor of given type. More...
 
virtual int getNumberVDPads ()
 
int getJoyNumber ()
 
int getRealJoyNumber ()
 
int getActiveSetNumber ()
 
SetJoystickgetActiveSetJoystick ()
 
SetJoystickgetSetJoystick (int index)
 
void removeControlStick (int index)
 
bool isActive ()
 
int getButtonDownCount ()
 
virtual QString getDescription ()
 
virtual QString getStringIdentifier ()
 
QString getSDLPlatform ()
 
virtual bool isKnownController ()
 
void setButtonName (int index, QString tempName)
 
void setAxisButtonName (int axisIndex, int buttonIndex, QString tempName)
 
void setStickButtonName (int stickIndex, int buttonIndex, QString tempName)
 
void setSensorButtonName (JoySensorType type, JoySensorDirection direction, QString tempName)
 Sets the name of a mapped sensor button in all sets Used during XML loading. More...
 
void setDPadButtonName (int dpadIndex, int buttonIndex, QString tempName)
 
void setVDPadButtonName (int vdpadIndex, int buttonIndex, QString tempName)
 
void setAxisName (int axisIndex, QString tempName)
 
void setStickName (int stickIndex, QString tempName)
 
void setSensorName (JoySensorType type, QString tempName)
 Sets the name of a sensor in all sets Used during XML loading. More...
 
void setDPadName (int dpadIndex, QString tempName)
 
void setVDPadName (int vdpadIndex, QString tempName)
 
int getDeviceKeyPressTime ()
 
void setIndex (int index)
 
bool isDeviceEdited ()
 
void revertProfileEdited ()
 
void setKeyRepeatStatus (bool enabled)
 
void setKeyRepeatDelay (int delay)
 
void setKeyRepeatRate (int rate)
 
bool isKeyRepeatEnabled ()
 
int getKeyRepeatDelay ()
 
int getKeyRepeatRate ()
 
QString getProfileName ()
 
bool hasCalibrationThrottle (int axisNum)
 
JoyAxis::ThrottleTypes getCalibrationThrottle (int axisNum)
 
void setCalibrationThrottle (int axisNum, JoyAxis::ThrottleTypes throttle)
 
void setCalibrationStatus (int axisNum, JoyAxis::ThrottleTypes throttle)
 
void removeCalibrationStatus (int axisNum)
 
void sendLoadProfileRequest (QString location)
 
AntiMicroSettingsgetSettings ()
 
void activatePossiblePendingEvents ()
 
void activatePossibleControlStickEvents ()
 
void activatePossibleAxisEvents ()
 
void activatePossibleSensorEvents ()
 
void activatePossibleDPadEvents ()
 
void activatePossibleVDPadEvents ()
 
void activatePossibleButtonEvents ()
 
void convertToUniqueMappSett (QSettings *sett, QString gUIDmappGroupSett, QString uniqueIDGroupSett)
 
bool isEmptyUniqueID (QString tempUniqueID)
 Check if the GUID passed is considered empty. More...
 
bool isRelevantUniqueID (QString tempUniqueID)
 Check if GUID passed matches the expected GUID for a device. Needed for xinput GUID abstraction. More...
 
void setRawAxisDeadZone (int deadZone)
 
int getRawAxisDeadZone ()
 
void rawAxisEvent (int index, int value)
 
bool elementsHaveNames ()
 
QMap< int, SetJoystick * > & getJoystick_sets ()
 
SDL_Joystick * getJoyHandle () const
 
InputDeviceCalibrationgetCalibrationBackend ()
 Returns a pointer to the internal calibration storage backend. More...
 
void updateStickCalibration (int index, double offsetX, double gainX, double offsetY, double gainY)
 Updates stored calibration for this controller and applies calibration to the specified stick in all sets See JoyControlStick::setCalibration. More...
 
void applyStickCalibration (int index, double offsetX, double gainX, double offsetY, double gainY)
 Applies calibration to the specified stick in all sets See JoyControlStick::setCalibration. More...
 
void updateAccelerometerCalibration (double offsetX, double offsetY, double offsetZ)
 Applies calibration to the specified accelerometer in all sets See JoySensor::setCalibration. More...
 
void applyAccelerometerCalibration (double offsetX, double offsetY, double offsetZ)
 Applies calibration to the specified accelerometer in all sets See JoySensor::setCalibration. More...
 
void updateGyroscopeCalibration (double offsetX, double offsetY, double offsetZ)
 Updates stored calibration for this controller and applies calibration to the specified gyroscope in all sets See JoySensor::setCalibration. More...
 
void applyGyroscopeCalibration (double offsetX, double offsetY, double offsetZ)
 Applies calibration to the specified gyroscope in all sets See JoySensor::setCalibration. More...
 

Protected Slots

virtual void axisActivatedEvent (int setindex, int axisindex, int value) override
 
virtual void buttonClickEvent (int buttonindex) override
 
virtual void buttonReleaseEvent (int buttonindex) override
 
- Protected Slots inherited from InputDevice
void propogateSetChange (int index)
 
void propogateSetAxisThrottleChange (int index, int originset)
 
void buttonDownEvent (int setindex, int buttonindex)
 
void buttonUpEvent (int setindex, int buttonindex)
 
virtual void axisActivatedEvent (int setindex, int axisindex, int value)
 
virtual void axisReleasedEvent (int setindex, int axisindex, int value)
 
virtual void axisButtonDownEvent (int setindex, int axisindex, int buttonindex)
 
virtual void axisButtonUpEvent (int setindex, int axisindex, int buttonindex)
 
virtual void dpadButtonDownEvent (int setindex, int dpadindex, int buttonindex)
 
virtual void dpadButtonUpEvent (int setindex, int dpadindex, int buttonindex)
 
virtual void stickButtonDownEvent (int setindex, int stickindex, int buttonindex)
 
virtual void stickButtonUpEvent (int setindex, int stickindex, int buttonindex)
 
virtual void sensorButtonDownEvent (int setindex, JoySensorType type, JoySensorDirection direction)
 
virtual void sensorButtonUpEvent (int setindex, JoySensorType type, JoySensorDirection direction)
 
void updateSetButtonNames (int index)
 
void updateSetAxisButtonNames (int axisIndex, int buttonIndex)
 
void updateSetStickButtonNames (int stickIndex, int buttonIndex)
 
void updateSetSensorButtonNames (JoySensorType type, JoySensorDirection direction)
 Rename mapped sensor button in all sets to the name in the active set. More...
 
void updateSetDPadButtonNames (int dpadIndex, int buttonIndex)
 
void updateSetVDPadButtonNames (int vdpadIndex, int buttonIndex)
 
void updateSetAxisNames (int axisIndex)
 
void updateSetStickNames (int stickIndex)
 
void updateSetSensorNames (JoySensorType type)
 Rename sensor in all sets to the name in the current set. More...
 
void updateSetDPadNames (int dpadIndex)
 
void updateSetVDPadNames (int vdpadIndex)
 

Private Member Functions

void enableSensors ()
 

Private Attributes

QHash< int, bool > rawbuttons
 
QHash< int, int > axisvalues
 
QHash< int, int > dpadvalues
 
int counterUniques
 
SDL_JoystickID joystickID
 
SDL_GameController * controller
 
SDL_GameControllerType m_controller_type
 

Additional Inherited Members

- Public Slots inherited from InputDevice
void reset ()
 
void transferReset ()
 Obtain current joystick element values, create new SetJoystick objects, and then transfer most recent joystick element values to new current set. More...
 
void reInitButtons ()
 
void resetButtonDownCount ()
 
void setActiveSetNumber (int index)
 
void changeSetButtonAssociation (int button_index, int originset, int newset, int mode)
 
void changeSetAxisButtonAssociation (int button_index, int axis_index, int originset, int newset, int mode)
 
void changeSetStickButtonAssociation (int button_index, int stick_index, int originset, int newset, int mode)
 
void changeSetSensorButtonAssociation (JoySensorDirection direction, JoySensorType type, int originset, int newset, int mode)
 Creates reverse set change button mapping for toggle and while-hold set change mappings. More...
 
void changeSetDPadButtonAssociation (int button_index, int dpad_index, int originset, int newset, int mode)
 
void changeSetVDPadButtonAssociation (int button_index, int dpad_index, int originset, int newset, int mode)
 
void setDeviceKeyPressTime (int newPressTime)
 
void profileEdited ()
 
void setProfileName (QString value)
 
void haltServices ()
 
void finalRemoval ()
 
virtual void buttonClickEvent (int buttonindex)
 
virtual void buttonReleaseEvent (int buttonindex)
 
virtual void dpadButtonClickEvent (int buttonindex)
 
virtual void dpadButtonReleaseEvent (int buttonindex)
 
void establishPropertyUpdatedConnection ()
 
void disconnectPropertyUpdatedConnection ()
 
- Signals inherited from InputDevice
void setChangeActivated (int index)
 
void setAxisThrottleActivated (int index)
 
void clicked (int index)
 
void released (int index)
 
void rawButtonClick (int index)
 
void rawButtonRelease (int index)
 
void rawAxisButtonClick (int axis, int buttonindex)
 
void rawAxisButtonRelease (int axis, int buttonindex)
 
void rawDPadButtonClick (int dpad, int buttonindex)
 
void rawDPadButtonRelease (int dpad, int buttonindex)
 
void rawAxisActivated (int axis, int value)
 
void rawAxisReleased (int axis, int value)
 
void rawAxisMoved (int axis, int value)
 
void profileUpdated ()
 
void propertyUpdated ()
 
void profileNameEdited (QString text)
 
void requestProfileLoad (QString location)
 
void requestWait ()
 
- Protected Member Functions inherited from InputDevice
void enableSetConnections (SetJoystick *setstick)
 Establishes necessary connections for set change slots. More...
 
QHash< int, JoyAxis::ThrottleTypes > & getCali ()
 
SDL_JoystickID * getJoystickID ()
 
- Protected Attributes inherited from InputDevice
int rawAxisDeadZone
 
int keyPressTime
 
QString profileName
 
InputDeviceCalibration m_calibrations
 

Detailed Description

Represents a typical gamepad (like PS4 or Xbox gamepad)

It represents typical gamepads with two analog sticks, one dpad, two shoulder buttons on each side (one of them possibly a trigger axis and not just a button), 4 buttons on the right and some buttons in the middle of the pad.

SDL2 maps the axis and buttons of devices it knows (and XInput Devices on Windows) to standardized button/axis names based on xbox360/xinput controllers. It often uses SDL bindings to figure out how gamepad should look like. Every device in this category releases events SDL_CONTROLLER... (like SDL_CONTROLLERBUTTONUP)

Each SDL Gamecontroller device can also be used as a bit more general-purposed Joystick device.

See also
https://wiki.libsdl.org/CategoryGameController
https://wiki.libsdl.org/SDL_IsGameController

Constructor & Destructor Documentation

◆ GameController()

GameController::GameController ( SDL_GameController *  controller,
int  deviceIndex,
AntiMicroSettings settings,
int  counterUniques,
QObject *  parent 
)
explicit
Here is the call graph for this function:

Member Function Documentation

◆ axisActivatedEvent

void GameController::axisActivatedEvent ( int  setindex,
int  axisindex,
int  value 
)
overrideprotectedvirtualslot

◆ buttonClickEvent

void GameController::buttonClickEvent ( int  buttonindex)
overrideprotectedvirtualslot

◆ buttonReleaseEvent

void GameController::buttonReleaseEvent ( int  buttonindex)
overrideprotectedvirtualslot

◆ closeSDLDevice()

void GameController::closeSDLDevice ( )
overridevirtual

Implements InputDevice.

◆ enableSensors()

void GameController::enableSensors ( )
private
Here is the caller graph for this function:

◆ getAxisvalues()

const QHash< int, int > & GameController::getAxisvalues ( )
Here is the caller graph for this function:

◆ getBindForAxis()

SDL_GameControllerButtonBind GameController::getBindForAxis ( int  index)
Here is the caller graph for this function:

◆ getBindForButton()

SDL_GameControllerButtonBind GameController::getBindForButton ( int  index)
Here is the caller graph for this function:

◆ getBindStringForAxis()

QString GameController::getBindStringForAxis ( int  index,
bool  trueIndex = true 
)
Here is the caller graph for this function:

◆ getBindStringForButton()

QString GameController::getBindStringForButton ( int  index,
bool  trueIndex = true 
)

◆ getController()

SDL_GameController * GameController::getController ( ) const
Here is the caller graph for this function:

◆ getControllerType()

SDL_GameControllerType GameController::getControllerType ( ) const
overridevirtual

Returns the current controller model.

Reimplemented from InputDevice.

◆ getDpadvalues()

const QHash< int, int > & GameController::getDpadvalues ( )
Here is the caller graph for this function:

◆ getGUIDString()

QString GameController::getGUIDString ( ) const
overridevirtual

Implements InputDevice.

Here is the call graph for this function:

◆ getName()

QString GameController::getName ( )
overridevirtual

Implements InputDevice.

Here is the call graph for this function:

◆ getNumberRawAxes()

int GameController::getNumberRawAxes ( )
overridevirtual

Implements InputDevice.

◆ getNumberRawButtons()

int GameController::getNumberRawButtons ( )
overridevirtual

Implements InputDevice.

◆ getNumberRawHats()

int GameController::getNumberRawHats ( )
overridevirtual

Implements InputDevice.

◆ getProductIDString()

QString GameController::getProductIDString ( ) const
overridevirtual

Implements InputDevice.

Here is the call graph for this function:

◆ getProductVersion()

QString GameController::getProductVersion ( ) const
overridevirtual

Implements InputDevice.

Here is the call graph for this function:

◆ getRawbuttons()

const QHash< int, bool > & GameController::getRawbuttons ( )
Here is the caller graph for this function:

◆ getRawGUIDString()

QString GameController::getRawGUIDString ( ) const
overridevirtual

Reimplemented from InputDevice.

Here is the caller graph for this function:

◆ getRawProductIDString()

QString GameController::getRawProductIDString ( ) const
overridevirtual

Reimplemented from InputDevice.

Here is the caller graph for this function:

◆ getRawProductVersion()

QString GameController::getRawProductVersion ( ) const
overridevirtual

Reimplemented from InputDevice.

Here is the caller graph for this function:

◆ getRawSensorRate()

double GameController::getRawSensorRate ( JoySensorType  type)
overridevirtual

Queries the data rate of the given sensor from SDL.

Returns
Data rate in events per second or zero if data rate is unavailable.

Implements InputDevice.

◆ getRawUniqueIDString()

QString GameController::getRawUniqueIDString ( ) const
overridevirtual

Reimplemented from InputDevice.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRawVendorString()

QString GameController::getRawVendorString ( ) const
overridevirtual

Reimplemented from InputDevice.

Here is the caller graph for this function:

◆ getSDLJoystickID()

SDL_JoystickID GameController::getSDLJoystickID ( )
overridevirtual

Implements InputDevice.

◆ getSDLName()

QString GameController::getSDLName ( )
overridevirtual

Implements InputDevice.

◆ getSerialString()

QString GameController::getSerialString ( ) const
overridevirtual

Implements InputDevice.

Here is the caller graph for this function:

◆ getUniqueIDString()

QString GameController::getUniqueIDString ( ) const
overridevirtual

Implements InputDevice.

Here is the call graph for this function:

◆ getVendorString()

QString GameController::getVendorString ( ) const
overridevirtual

Implements InputDevice.

Here is the call graph for this function:

◆ getXmlName()

QString GameController::getXmlName ( ) const
overridevirtual

Implements InputDevice.

◆ hasRawSensor()

bool GameController::hasRawSensor ( JoySensorType  type)
overridevirtual

Queries if the hardware has the given sensor type.

Returns
True if the sensor is present, false otherwise.

Implements InputDevice.

◆ isGameController()

bool GameController::isGameController ( )
overridevirtual

Check if device is using the SDL Game Controller API.

Returns
Status showing if device is using the Game Controller API

Reimplemented from InputDevice.

◆ isRelevantUniqueID()

bool GameController::isRelevantUniqueID ( QString  tempUniqueID)

Check if GUID passed matches the expected GUID for a device. Needed for xinput GUID abstraction.

Parameters
GUIDstring
Returns
if GUID is considered a match.
Here is the call graph for this function:

◆ rawAxisEvent()

void GameController::rawAxisEvent ( int  index,
int  value 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rawButtonEvent()

void GameController::rawButtonEvent ( int  index,
bool  pressed 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rawDPadEvent()

void GameController::rawDPadEvent ( int  index,
int  value 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setCounterUniques()

void GameController::setCounterUniques ( int  counter)
overridevirtual

Implements InputDevice.

Field Documentation

◆ axisvalues

QHash<int, int> GameController::axisvalues
private

◆ controller

SDL_GameController* GameController::controller
private

◆ counterUniques

int GameController::counterUniques
private

◆ dpadvalues

QHash<int, int> GameController::dpadvalues
private

◆ joystickID

SDL_JoystickID GameController::joystickID
private

◆ m_controller_type

SDL_GameControllerType GameController::m_controller_type
private

◆ rawbuttons

QHash<int, bool> GameController::rawbuttons
private

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