@@ -37,6 +37,7 @@ This file is part of the PIXHAWK project
*
* @author Lorenz Meier <mavteam@student.ethz.ch>
* @author Andreas Romer <mavteam@student.ethz.ch>
* @author Julian Oes <julian@oes.ch>
*/
#ifndef _JOYSTICKINPUT_H_
...
...
@@ -56,6 +57,8 @@ This file is part of the PIXHAWK project
structJoystickSettings{
QMap<int,bool>axesInverted;///< Whether each axis should be used inverted from what was reported.
QMap<int,bool>axesLimited;///< Whether each axis should be limited to only the positive range. Currently this only applies to the throttle axis, but is kept generic here to possibly support other axes.
QMap<int,float>axesMaxRange;///< The maximum values per axis
QMap<int,float>axesMinRange;///< The minimum values per axis
QMap<int,int>buttonActions;///< The index of the action associated with every button.
};
Q_DECLARE_METATYPE(JoystickSettings)
...
...
@@ -109,6 +112,11 @@ public:
returnisEnabled;
}
boolcalibrating()const
{
returnisCalibrating;
}
intgetMappingThrottleAxis()const
{
returnthrottleAxis;
...
...
@@ -162,16 +170,17 @@ public:
floatgetCurrentValueForAxis(intaxis)const;
boolgetInvertedForAxis(intaxis)const;
boolgetRangeLimitForAxis(intaxis)const;
floatgetAxisRangeLimitMinForAxis(intaxis)const;
floatgetAxisRangeLimitMaxForAxis(intaxis)const;
intgetActionForButton(intbutton)const;
constdoublesdlJoystickMin;
constdoublesdlJoystickMax;
protected:
doublecalibrationPositive[10];
doublecalibrationNegative[10];
boolisEnabled;///< Track whether the system should emit the higher-level signals: joystickChanged & actionTriggered.
boolisCalibrating;///< Track if calibration in progress
booldone;
SDL_Joystick*joystick;
...
...
@@ -287,6 +296,8 @@ public slots:
voidsetActiveUAS(UASInterface*uas);
/** @brief Switch to a new joystick by ID number. Both buttons and axes are updated with the proper signals emitted. */
voidsetActiveJoystick(intid);
/** @brief Switch calibration mode active */
voidsetCalibrating(boolactive);
/**
* @brief Change the control mapping for a given joystick axis.
* @param axisID The axis to modify (0-indexed)
...
...
@@ -300,12 +311,28 @@ public slots:
* @param inverted True indicates inverted from normal. Varies by controller.
*/
voidsetAxisInversion(intaxis,boolinverted);
/**
* @brief Specify that an axis should only transmit the positive values. Useful for controlling throttle from auto-centering axes.
* @param axis Which axis has its range limited.
* @param limitRange If true only the positive half of this axis will be read.
*/
voidsetAxisRangeLimit(intaxis,boollimitRange);
/**
* @brief Specify minimum value for axis.
* @param axis Which axis should be set.
* @param min Value to be set.
*/
voidsetAxisRangeLimitMin(intaxis,floatmin);
/**
* @brief Specify maximum value for axis.
* @param axis Which axis should be set.
* @param max Value to be set.
*/
voidsetAxisRangeLimitMax(intaxis,floatmax);
/**
* @brief Specify a button->action mapping for the given uas.
* This mapping is applied based on UAS autopilot type and UAS system type.