AntiMicroX
inputdevicecalibration.h
Go to the documentation of this file.
1 /* antimicrox Gamepad to KB+M event mapper
2  * Copyright (C) 2022 Max Maisel <max.maisel@posteo.de>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13 
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #pragma once
19 
20 #include <QHash>
21 
22 class InputDevice;
23 class QXmlStreamReader;
24 class QXmlStreamWriter;
25 
30 {
34 };
35 
40 {
41  int index;
42  double offsetX;
43  double gainX;
44  double offsetY;
45  double gainY;
46 };
47 
52 {
53  double orientationX;
54  double orientationY;
55  double orientationZ;
56 };
57 
62 {
63  double offsetX;
64  double offsetY;
65  double offsetZ;
66 };
67 
72 {
74  union
75  {
79  };
80 
81  bool referencesSameInput(const CalibrationData &rhs) const;
82 };
83 
88 {
89  public:
90  explicit InputDeviceCalibration(InputDevice *device);
91 
92  void setStickCalibration(int index, double offsetX, double gainX, double offsetY, double gainY);
93  void setAccelerometerCalibration(double orientationX, double orientationY, double orientationZ);
94  void setGyroscopeCalibration(double offsetX, double offsetY, double offsetZ);
95  void applyCalibrations() const;
96 
97  void readConfig(QXmlStreamReader *xml);
98  void writeConfig(QXmlStreamWriter *xml) const;
99 
100  private:
101  void setCalibration(QString id, CalibrationData new_calibration);
102  QHash<QString, QList<CalibrationData>> m_data;
103 
105 };
CalibrationDataType
CalibrationDataType
Defines the possible CalibrationData union types.
Definition: inputdevicecalibration.h:29
InputDeviceCalibration::applyCalibrations
void applyCalibrations() const
Applies all applicable stored calibration values to the individual input elements of the parent contr...
Definition: inputdevicecalibration.cpp:111
CALIBRATION_DATA_STICK
@ CALIBRATION_DATA_STICK
Definition: inputdevicecalibration.h:31
CalibrationData::referencesSameInput
bool referencesSameInput(const CalibrationData &rhs) const
Returns true if the two CalibrationData structs references the same physical, e.g....
Definition: inputdevicecalibration.cpp:28
InputDevice::applyAccelerometerCalibration
void applyAccelerometerCalibration(double offsetX, double offsetY, double offsetZ)
Applies calibration to the specified accelerometer in all sets See JoySensor::setCalibration.
Definition: inputdevice.cpp:1795
InputDeviceCalibration::InputDeviceCalibration
InputDeviceCalibration(InputDevice *device)
Definition: inputdevicecalibration.cpp:43
InputDeviceCalibration::readConfig
void readConfig(QXmlStreamReader *xml)
Reads all calibration values from the given XML stream into the internal calibration data storage.
Definition: inputdevicecalibration.cpp:136
InputDeviceCalibration::m_data
QHash< QString, QList< CalibrationData > > m_data
Definition: inputdevicecalibration.h:102
CalibrationData::type
CalibrationDataType type
Definition: inputdevicecalibration.h:73
StickCalibrationData::offsetX
double offsetX
Definition: inputdevicecalibration.h:42
InputDevice
Abstract class representing a hardware input device, e.g a joystick or controller.
Definition: inputdevice.h:50
InputDeviceCalibration::setAccelerometerCalibration
void setAccelerometerCalibration(double orientationX, double orientationY, double orientationZ)
Updates the stored calibration for the given accelerometer from the parent controller.
Definition: inputdevicecalibration.cpp:77
InputDeviceCalibration
Calibration storage backend which can store multiple calibration items for different controllers.
Definition: inputdevicecalibration.h:87
inputdevicecalibration.h
InputDeviceCalibration::setStickCalibration
void setStickCalibration(int index, double offsetX, double gainX, double offsetY, double gainY)
Updates the stored calibration for the given stick from the parent controller.
Definition: inputdevicecalibration.cpp:56
AccelerometerCalibrationData
The calibration data for an accelerometer.
Definition: inputdevicecalibration.h:51
CALIBRATION_DATA_GYROSCOPE
@ CALIBRATION_DATA_GYROSCOPE
Definition: inputdevicecalibration.h:33
AccelerometerCalibrationData::orientationY
double orientationY
Definition: inputdevicecalibration.h:54
AccelerometerCalibrationData::orientationZ
double orientationZ
Definition: inputdevicecalibration.h:55
GyroscopeCalibrationData
The calibration data for a gyroscope.
Definition: inputdevicecalibration.h:61
InputDeviceCalibration::setGyroscopeCalibration
void setGyroscopeCalibration(double offsetX, double offsetY, double offsetZ)
Updates the stored calibration for the given gyroscope from the parent controller.
Definition: inputdevicecalibration.cpp:95
InputDeviceCalibration::m_device
InputDevice * m_device
Definition: inputdevicecalibration.h:104
InputDevice::applyGyroscopeCalibration
void applyGyroscopeCalibration(double offsetX, double offsetY, double offsetZ)
Applies calibration to the specified gyroscope in all sets See JoySensor::setCalibration.
Definition: inputdevice.cpp:1826
AccelerometerCalibrationData::orientationX
double orientationX
Definition: inputdevicecalibration.h:53
InputDeviceCalibration::writeConfig
void writeConfig(QXmlStreamWriter *xml) const
Writes all stored calibration values from the internal storage into the given XML stream.
Definition: inputdevicecalibration.cpp:182
CalibrationData
Stores the calibration data for one physical device, e.g. a stick or gyroscope.
Definition: inputdevicecalibration.h:71
inputdevice.h
StickCalibrationData::offsetY
double offsetY
Definition: inputdevicecalibration.h:44
CalibrationData::stick
StickCalibrationData stick
Definition: inputdevicecalibration.h:76
StickCalibrationData::index
int index
Definition: inputdevicecalibration.h:41
CalibrationData::gyroscope
GyroscopeCalibrationData gyroscope
Definition: inputdevicecalibration.h:78
GyroscopeCalibrationData::offsetZ
double offsetZ
Definition: inputdevicecalibration.h:65
InputDevice::applyStickCalibration
void applyStickCalibration(int index, double offsetX, double gainX, double offsetY, double gainY)
Applies calibration to the specified stick in all sets See JoyControlStick::setCalibration.
Definition: inputdevice.cpp:1765
CalibrationData::accelerometer
AccelerometerCalibrationData accelerometer
Definition: inputdevicecalibration.h:77
GyroscopeCalibrationData::offsetX
double offsetX
Definition: inputdevicecalibration.h:63
StickCalibrationData::gainX
double gainX
Definition: inputdevicecalibration.h:43
CALIBRATION_DATA_ACCELEROMETER
@ CALIBRATION_DATA_ACCELEROMETER
Definition: inputdevicecalibration.h:32
InputDeviceCalibration::setCalibration
void setCalibration(QString id, CalibrationData new_calibration)
Updated the given CalibrationData structure of the controller with the given ID in the calibration st...
Definition: inputdevicecalibration.cpp:229
number
it is up to the author donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License If the distribution and or use of the Library is restricted in certain countries either by patents or by copyrighted the original copyright holder who places the Library under this License may add an geographical distribution limitation excluding those so that distribution is permitted only in or among countries not thus excluded In such this License incorporates the limitation as if written in the body of this License The Free Software Foundation may publish revised and or new versions of the Lesser General Public License from time to time Such new versions will be similar in spirit to the present but may differ in detail to address new problems or concerns Each version is given a distinguishing version number If the Library specifies a version number of this License which applies to it and any later you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation If the Library does not specify a license version number
Definition: lgpl-2.1.txt:423
GyroscopeCalibrationData::offsetY
double offsetY
Definition: inputdevicecalibration.h:64
StickCalibrationData::gainY
double gainY
Definition: inputdevicecalibration.h:45
InputDevice::getUniqueIDString
virtual QString getUniqueIDString() const =0
StickCalibrationData
The calibration data for a stick.
Definition: inputdevicecalibration.h:39