![]() |
AntiMicroX
|
Represents one sensor in a SetJoystick and its connections to other parts of the application. Receives hardware input events from InputDaemon, processes them and generates GUI as well as Mouse+Keyboard events. More...
#include <joysensor.h>
Public Slots | |
virtual void | reset () |
Resets internal variables back to default. More... | |
void | setDeadZone (double value) |
Sets the dead zone of the sensor to the given value. More... | |
void | setMaxZone (double value) |
Sets the maximum zone of the sensor to the given value. More... | |
void | setDiagonalRange (double value) |
Set the diagonal range value for a sensor. More... | |
void | setSensorDelay (unsigned int value) |
Sets the sensor input delaqy to the given value. More... | |
void | setSensorName (QString tempName) |
Sets the name of this sensor. More... | |
void | establishPropertyUpdatedConnection () |
Signals | |
void | moved (float xaxis, float yaxis, float zaxis) |
void | active (float xaxis, float yaxis, float zaxis) |
void | released (float xaxis, float yaxis, float zaxis) |
void | deadZoneChanged (double value) |
void | diagonalRangeChanged (double value) |
void | maxZoneChanged (double value) |
void | sensorDelayChanged (int value) |
void | sensorNameChanged () |
void | propertyUpdated () |
Public Member Functions | |
JoySensor (JoySensorType type, int originset, SetJoystick *parent_set, QObject *parent) | |
virtual | ~JoySensor () |
void | joyEvent (float *values, bool ignoresets=false) |
Main sensor mapping function. When activated, it generates a "moved" QT event which updates various parts of the UI. Furthermore, it controls the sensor delay timer and calculates the current sensor direction and generates "active" and "released" QT events which enable/disable button highlights in the GUI. Finally, it calls createDeskEvent if the active/released button state has changed. More... | |
void | queuePendingEvent (float *values, bool ignoresets=false) |
Queues next movement event from InputDaemon. More... | |
void | activatePendingEvent () |
Activates previously queued movement event This is called by InputDevice. More... | |
bool | hasPendingEvent () const |
Checks if an event is queued. More... | |
void | clearPendingEvent () |
Clears a previously queued event. More... | |
void | copyAssignments (JoySensor *dest_sensor) |
Copy slots from all sensor buttons and properties from a sensor onto another. More... | |
bool | hasSlotsAssigned () const |
Check if any direction is mapped to a keyboard or mouse event. More... | |
QString | getPartialName (bool forceFullFormat=false, bool displayNames=false) const |
Get the name of this sensor. More... | |
QString | getSensorName () const |
Returns the sensor name. More... | |
JoySensorType | getType () const |
Returns the sensor type. More... | |
JoySensorDirection | getCurrentDirection () const |
Returns the current sensor direction. More... | |
double | getDeadZone () const |
Get the assigned dead zone value. More... | |
double | getDiagonalRange () const |
Get the assigned diagonal range value. More... | |
double | getMaxZone () const |
Get the assigned max zone value. More... | |
unsigned int | getSensorDelay () const |
Get the assigned input delay. More... | |
virtual float | getXCoordinate () const =0 |
virtual float | getYCoordinate () const =0 |
virtual float | getZCoordinate () const =0 |
virtual QString | sensorTypeName () const =0 |
bool | inDeadZone (float *values) const |
Checks if the sensor vector is currently in the dead zone. More... | |
double | getDistanceFromDeadZone () const |
Get current radial distance of the sensor past the assigned dead zone. More... | |
double | getDistanceFromDeadZone (double x, double y, double z) const |
Get radial distance of the sensor past the assigned dead zone based on the passed X, Y and Z axes values associated with the sensor. More... | |
double | calculateXDistanceFromDeadZone () const |
Get current X distance of the sensor past the assigned dead zone. More... | |
double | calculateXDistanceFromDeadZone (double x, double y, double z) const |
Get current X distance of the sensor past the assigned dead zone based on the passed X, Y and Z axes values associated with the sensor. The algorithm checks if an axis parallel line through the current sensor position intersects with the dead zone sphere and subtracts the line segment within the sphere from the distance. The resulting value is not normalized because there is no practical maximum value for a sensor as you can always move it a bit faster. More... | |
double | calculateYDistanceFromDeadZone () const |
Get current Y distance of the sensor past the assigned dead zone. More... | |
double | calculateYDistanceFromDeadZone (double x, double y, double z) const |
Get current Y distance of the sensor past the assigned dead zone based on the passed X, Y and Z axes values associated with the sensor. The algorithm checks if an axis parallel line through the current sensor position intersects with the dead zone sphere and subtracts the line segment within the sphere from the distance. The resulting value is not normalized because there is no practical maximum value for a sensor as you can always move it a bit faster. More... | |
double | calculateZDistanceFromDeadZone () const |
Get current Z distance of the sensor past the assigned dead zone. More... | |
double | calculateZDistanceFromDeadZone (double x, double y, double z) const |
Get current Z distance of the sensor past the assigned dead zone based on the passed X, Y and Z axes values associated with the sensor. The algorithm checks if an axis parallel line through the current sensor position intersects with the dead zone sphere and subtracts the line segment within the sphere from the distance. The resulting value is not normalized because there is no practical maximum value for a sensor as you can always move it a bit faster. More... | |
double | calculateDistance () const |
Get the vector length of the sensor. More... | |
double | calculateDistance (double x, double y, double z) const |
Get the vector length of the sensor based on the passed X, Y and Z axes values associated with the sensor. More... | |
double | calculatePitch () const |
Calculate the pitch angle (in degrees) corresponding to the current position of controller. More... | |
double | calculatePitch (double x, double y, double z) const |
Calculate the pitch angle (in degrees) corresponding to the current passed X, Y and Z axes values associated with the sensor. position of controller. See https://www.nxp.com/files-static/sensors/doc/app_note/AN3461.pdf for a description of the used algorithm. More... | |
double | calculateRoll () const |
Calculate the roll angle (in degrees) corresponding to the current position of controller. More... | |
double | calculateRoll (double x, double y, double z) const |
Calculate the roll angle (in degrees) corresponding to the current passed X, Y and Z axes values associated with the sensor. position of controller. See https://www.nxp.com/files-static/sensors/doc/app_note/AN3461.pdf for a description of the used algorithm. More... | |
double | calculateDirectionalDistance (JoySensorDirection direction) const |
Used to calculate the distance value that should be used by the JoyButton in the given direction. More... | |
bool | isCalibrated () const |
Check if the sensor is calibrated. More... | |
void | resetCalibration () |
Resets the calibration of the sensor back to uncalibrated state. More... | |
virtual void | getCalibration (double *offsetX, double *offsetY, double *offsetZ) const =0 |
virtual void | setCalibration (double offsetX, double offsetY, double offsetZ)=0 |
QHash< JoySensorDirection, JoySensorButton * > * | getButtons () |
Returns a QHash which maps the SensorDirection to the corresponding JoySensorButton. More... | |
JoySensorButton * | getDirectionButton (JoySensorDirection direction) |
Get a pointer to the sensor direction button for the desired direction. More... | |
bool | isDefault () const |
Checks if all sensor settings and button mappings are the their default values. This is used during XML serialization to skip unnecessary objects. More... | |
void | readConfig (QXmlStreamReader *xml) |
Take a XML stream and set the sensor and direction button properties according to the values contained within the stream. More... | |
void | writeConfig (QXmlStreamWriter *xml) const |
Write the status of the properties of a sensor and direction buttons to an XML stream. More... | |
SetJoystick * | getParentSet () const |
Get pointer to the set that a sensor belongs to. More... | |
Static Public Member Functions | |
static double | radToDeg (double value) |
Utility function which converts a given value from radians to degree. More... | |
static double | degToRad (double value) |
Utility function which converts a given value from degree to radians. More... | |
Protected Member Functions | |
void | resetButtons () |
Reset all the properties of the sensor direction buttons. More... | |
virtual void | populateButtons ()=0 |
virtual JoySensorDirection | calculateSensorDirection ()=0 |
virtual void | applyCalibration ()=0 |
void | determineSensorEvent (JoySensorButton **eventbutton) const |
Set buttons for current sensor direction zone. More... | |
void | createDeskEvent (JoySensorDirection direction, bool ignoresets=false) |
Find the position of the three sensor axes, deactivate no longer used sensor direction button and then activate direction buttons for new direction. More... | |
Protected Attributes | |
JoySensorType | m_type |
double | m_dead_zone |
double | m_diagonal_range |
double | m_max_zone |
unsigned int | m_sensor_delay |
bool | m_active |
JoySensorButton * | m_active_button [ACTIVE_BUTTON_COUNT] |
float | m_current_value [3] |
float | m_pending_value [3] |
bool | m_calibrated |
double | m_calibration_value [3] |
bool | m_pending_event |
bool | m_pending_ignore_sets |
int | m_originset |
QString | m_sensor_name |
QTimer | m_delay_timer |
JoySensorDirection | m_current_direction |
SetJoystick * | m_parent_set |
QHash< JoySensorDirection, JoySensorButton * > | m_buttons |
Static Protected Attributes | |
static const size_t | ACTIVE_BUTTON_COUNT = 3 |
Private Slots | |
void | delayTimerExpired () |
Slot called when m_delay_timer has timed out. The method will call createDeskEvent. More... | |
Represents one sensor in a SetJoystick and its connections to other parts of the application. Receives hardware input events from InputDaemon, processes them and generates GUI as well as Mouse+Keyboard events.
|
explicit |
|
virtual |
void JoySensor::activatePendingEvent | ( | ) |
Activates previously queued movement event This is called by InputDevice.
|
signal |
|
protectedpure virtual |
Implemented in JoyAccelerometerSensor, and JoyGyroscopeSensor.
double JoySensor::calculateDirectionalDistance | ( | JoySensorDirection | direction | ) | const |
Used to calculate the distance value that should be used by the JoyButton in the given direction.
direction |
double JoySensor::calculateDistance | ( | ) | const |
Get the vector length of the sensor.
double JoySensor::calculateDistance | ( | double | x, |
double | y, | ||
double | z | ||
) | const |
Get the vector length of the sensor based on the passed X, Y and Z axes values associated with the sensor.
double JoySensor::calculatePitch | ( | ) | const |
Calculate the pitch angle (in degrees) corresponding to the current position of controller.
double JoySensor::calculatePitch | ( | double | x, |
double | y, | ||
double | z | ||
) | const |
Calculate the pitch angle (in degrees) corresponding to the current passed X, Y and Z axes values associated with the sensor. position of controller. See https://www.nxp.com/files-static/sensors/doc/app_note/AN3461.pdf for a description of the used algorithm.
X | axis value |
Y | axis value |
Z | axis value |
double JoySensor::calculateRoll | ( | ) | const |
Calculate the roll angle (in degrees) corresponding to the current position of controller.
double JoySensor::calculateRoll | ( | double | x, |
double | y, | ||
double | z | ||
) | const |
Calculate the roll angle (in degrees) corresponding to the current passed X, Y and Z axes values associated with the sensor. position of controller. See https://www.nxp.com/files-static/sensors/doc/app_note/AN3461.pdf for a description of the used algorithm.
X | axis value |
Y | axis value |
Z | axis value |
|
protectedpure virtual |
Implemented in JoyAccelerometerSensor, and JoyGyroscopeSensor.
double JoySensor::calculateXDistanceFromDeadZone | ( | ) | const |
Get current X distance of the sensor past the assigned dead zone.
double JoySensor::calculateXDistanceFromDeadZone | ( | double | x, |
double | y, | ||
double | z | ||
) | const |
Get current X distance of the sensor past the assigned dead zone based on the passed X, Y and Z axes values associated with the sensor. The algorithm checks if an axis parallel line through the current sensor position intersects with the dead zone sphere and subtracts the line segment within the sphere from the distance. The resulting value is not normalized because there is no practical maximum value for a sensor as you can always move it a bit faster.
X | axis value |
Y | axis value |
Z | axis value |
double JoySensor::calculateYDistanceFromDeadZone | ( | ) | const |
Get current Y distance of the sensor past the assigned dead zone.
double JoySensor::calculateYDistanceFromDeadZone | ( | double | x, |
double | y, | ||
double | z | ||
) | const |
Get current Y distance of the sensor past the assigned dead zone based on the passed X, Y and Z axes values associated with the sensor. The algorithm checks if an axis parallel line through the current sensor position intersects with the dead zone sphere and subtracts the line segment within the sphere from the distance. The resulting value is not normalized because there is no practical maximum value for a sensor as you can always move it a bit faster.
X | axis value |
Y | axis value |
Z | axis value |
double JoySensor::calculateZDistanceFromDeadZone | ( | ) | const |
Get current Z distance of the sensor past the assigned dead zone.
double JoySensor::calculateZDistanceFromDeadZone | ( | double | x, |
double | y, | ||
double | z | ||
) | const |
Get current Z distance of the sensor past the assigned dead zone based on the passed X, Y and Z axes values associated with the sensor. The algorithm checks if an axis parallel line through the current sensor position intersects with the dead zone sphere and subtracts the line segment within the sphere from the distance. The resulting value is not normalized because there is no practical maximum value for a sensor as you can always move it a bit faster.
X | axis value |
Y | axis value |
Z | axis value |
void JoySensor::clearPendingEvent | ( | ) |
Clears a previously queued event.
Copy slots from all sensor buttons and properties from a sensor onto another.
JoySensor | object to be modified. |
|
protected |
Find the position of the three sensor axes, deactivate no longer used sensor direction button and then activate direction buttons for new direction.
Should | set changing operations be ignored. Necessary in the middle of a set change. |
|
signal |
|
static |
Utility function which converts a given value from degree to radians.
|
privateslot |
Slot called when m_delay_timer has timed out. The method will call createDeskEvent.
|
protected |
Set buttons for current sensor direction zone.
Pointer | to an array of three JoySensorButton pointers in which the results are stored. |
|
signal |
|
slot |
QHash< JoySensorDirection, JoySensorButton * > * JoySensor::getButtons | ( | ) |
Returns a QHash which maps the SensorDirection to the corresponding JoySensorButton.
|
pure virtual |
Implemented in JoyAccelerometerSensor, and JoyGyroscopeSensor.
JoySensorDirection JoySensor::getCurrentDirection | ( | ) | const |
Returns the current sensor direction.
double JoySensor::getDeadZone | ( | ) | const |
Get the assigned dead zone value.
double JoySensor::getDiagonalRange | ( | ) | const |
Get the assigned diagonal range value.
JoySensorButton * JoySensor::getDirectionButton | ( | JoySensorDirection | direction | ) |
Get a pointer to the sensor direction button for the desired direction.
Value | of the direction of the sensor. |
double JoySensor::getDistanceFromDeadZone | ( | ) | const |
Get current radial distance of the sensor past the assigned dead zone.
double JoySensor::getDistanceFromDeadZone | ( | double | x, |
double | y, | ||
double | z | ||
) | const |
Get radial distance of the sensor past the assigned dead zone based on the passed X, Y and Z axes values associated with the sensor.
X | axis value |
Y | axis value |
Z | axis value |
double JoySensor::getMaxZone | ( | ) | const |
Get the assigned max zone value.
SetJoystick * JoySensor::getParentSet | ( | ) | const |
Get pointer to the set that a sensor belongs to.
QString JoySensor::getPartialName | ( | bool | forceFullFormat = false , |
bool | displayNames = false |
||
) | const |
Get the name of this sensor.
unsigned int JoySensor::getSensorDelay | ( | ) | const |
Get the assigned input delay.
QString JoySensor::getSensorName | ( | ) | const |
Returns the sensor name.
JoySensorType JoySensor::getType | ( | ) | const |
Returns the sensor type.
|
pure virtual |
Implemented in JoyAccelerometerSensor, and JoyGyroscopeSensor.
|
pure virtual |
Implemented in JoyAccelerometerSensor, and JoyGyroscopeSensor.
|
pure virtual |
Implemented in JoyAccelerometerSensor, and JoyGyroscopeSensor.
bool JoySensor::hasPendingEvent | ( | ) | const |
Checks if an event is queued.
bool JoySensor::hasSlotsAssigned | ( | ) | const |
Check if any direction is mapped to a keyboard or mouse event.
bool JoySensor::inDeadZone | ( | float * | values | ) | const |
Checks if the sensor vector is currently in the dead zone.
bool JoySensor::isCalibrated | ( | ) | const |
Check if the sensor is calibrated.
bool JoySensor::isDefault | ( | ) | const |
Checks if all sensor settings and button mappings are the their default values. This is used during XML serialization to skip unnecessary objects.
void JoySensor::joyEvent | ( | float * | values, |
bool | ignoresets = false |
||
) |
Main sensor mapping function. When activated, it generates a "moved" QT event which updates various parts of the UI. Furthermore, it controls the sensor delay timer and calculates the current sensor direction and generates "active" and "released" QT events which enable/disable button highlights in the GUI. Finally, it calls createDeskEvent if the active/released button state has changed.
|
signal |
|
signal |
|
protectedpure virtual |
Implemented in JoyAccelerometerSensor, and JoyGyroscopeSensor.
|
signal |
void JoySensor::queuePendingEvent | ( | float * | values, |
bool | ignoresets = false |
||
) |
Queues next movement event from InputDaemon.
|
static |
Utility function which converts a given value from radians to degree.
void JoySensor::readConfig | ( | QXmlStreamReader * | xml | ) |
Take a XML stream and set the sensor and direction button properties according to the values contained within the stream.
QXmlStreamReader | instance that will be used to read property values. |
|
signal |
|
virtualslot |
Resets internal variables back to default.
|
protected |
Reset all the properties of the sensor direction buttons.
void JoySensor::resetCalibration | ( | ) |
Resets the calibration of the sensor back to uncalibrated state.
|
signal |
|
signal |
|
pure virtual |
Implemented in JoyAccelerometerSensor, and JoyGyroscopeSensor.
|
pure virtual |
Implemented in JoyAccelerometerSensor, and JoyGyroscopeSensor.
|
slot |
Sets the dead zone of the sensor to the given value.
[in] | value | New sensor dead zone |
|
slot |
Set the diagonal range value for a sensor.
Value | between 1 - 90. |
|
slot |
Sets the maximum zone of the sensor to the given value.
[in] | value | New sensor maximum zone |
|
slot |
Sets the sensor input delaqy to the given value.
[in] | value | New sensor input delay in ms |
|
slot |
Sets the name of this sensor.
[in] | tempName | New sensor name |
void JoySensor::writeConfig | ( | QXmlStreamWriter * | xml | ) | const |
Write the status of the properties of a sensor and direction buttons to an XML stream.
QXmlStreamWriter | instance that will be used to write a profile. |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |