AntiMicroX
Loading...
Searching...
No Matches
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
22class InputDevice;
25
35
40{
41 int index;
42 double offsetX;
43 double gainX;
44 double offsetY;
45 double gainY;
46};
47
57
62{
63 double offsetX;
64 double offsetY;
65 double offsetZ;
66};
67
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
98 void writeConfig(QXmlStreamWriter *xml) const;
99
100 private:
103
105};
Calibration storage backend which can store multiple calibration items for different controllers.
Definition inputdevicecalibration.h:88
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
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
void setGyroscopeCalibration(double offsetX, double offsetY, double offsetZ)
Updates the stored calibration for the given gyroscope from the parent controller.
Definition inputdevicecalibration.cpp:95
void setAccelerometerCalibration(double orientationX, double orientationY, double orientationZ)
Updates the stored calibration for the given accelerometer from the parent controller.
Definition inputdevicecalibration.cpp:77
void writeConfig(QXmlStreamWriter *xml) const
Writes all stored calibration values from the internal storage into the given XML stream.
Definition inputdevicecalibration.cpp:182
InputDevice * m_device
Definition inputdevicecalibration.h:104
void applyCalibrations() const
Applies all applicable stored calibration values to the individual input elements of the parent contr...
Definition inputdevicecalibration.cpp:111
void readConfig(QXmlStreamReader *xml)
Reads all calibration values from the given XML stream into the internal calibration data storage.
Definition inputdevicecalibration.cpp:136
QHash< QString, QList< CalibrationData > > m_data
Definition inputdevicecalibration.h:102
Abstract class representing a hardware input device, e.g a joystick or controller.
Definition inputdevice.h:51
Definition joydpadxml.h:27
CalibrationDataType
Defines the possible CalibrationData union types.
Definition inputdevicecalibration.h:30
@ CALIBRATION_DATA_STICK
Definition inputdevicecalibration.h:31
@ CALIBRATION_DATA_ACCELEROMETER
Definition inputdevicecalibration.h:32
@ CALIBRATION_DATA_GYROSCOPE
Definition inputdevicecalibration.h:33
The calibration data for an accelerometer.
Definition inputdevicecalibration.h:52
double orientationZ
Definition inputdevicecalibration.h:55
double orientationX
Definition inputdevicecalibration.h:53
double orientationY
Definition inputdevicecalibration.h:54
Stores the calibration data for one physical device, e.g. a stick or gyroscope.
Definition inputdevicecalibration.h:72
GyroscopeCalibrationData gyroscope
Definition inputdevicecalibration.h:78
bool referencesSameInput(const CalibrationData &rhs) const
Returns true if the two CalibrationData structs references the same physical, e.g....
Definition inputdevicecalibration.cpp:28
StickCalibrationData stick
Definition inputdevicecalibration.h:76
CalibrationDataType type
Definition inputdevicecalibration.h:73
AccelerometerCalibrationData accelerometer
Definition inputdevicecalibration.h:77
The calibration data for a gyroscope.
Definition inputdevicecalibration.h:62
double offsetX
Definition inputdevicecalibration.h:63
double offsetY
Definition inputdevicecalibration.h:64
double offsetZ
Definition inputdevicecalibration.h:65
The calibration data for a stick.
Definition inputdevicecalibration.h:40
double gainX
Definition inputdevicecalibration.h:43
double gainY
Definition inputdevicecalibration.h:45
int index
Definition inputdevicecalibration.h:41
double offsetX
Definition inputdevicecalibration.h:42
double offsetY
Definition inputdevicecalibration.h:44