AntiMicroX
joystick.h
Go to the documentation of this file.
1 /* antimicrox Gamepad to KB+M event mapper
2  * Copyright (C) 2015 Travis Nickles <nickles.travis@gmail.com>
3  * Copyright (C) 2020 Jagoda Górska <juliagoda.pl@protonmail>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14 
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef JOYSTICK_H
20 #define JOYSTICK_H
21 
22 #include "inputdevice.h"
23 
24 #include <SDL2/SDL_gamecontroller.h>
25 
26 class AntiMicroSettings;
27 
34 class Joystick : public InputDevice
35 {
36  Q_OBJECT
37 
38  public:
39  explicit Joystick(SDL_Joystick *joyhandle, int deviceIndex, AntiMicroSettings *settings, QObject *parent);
40 
41  virtual QString getName() override;
42  virtual QString getSDLName() override;
43  virtual QString getGUIDString() const override; // GUID available on SDL 2.
44  virtual QString getUniqueIDString() const override;
45  virtual QString getVendorString() const override;
46  virtual QString getProductIDString() const override;
47  virtual QString getSerialString() const override;
48  virtual QString getProductVersion() const override;
49 
50  virtual void closeSDLDevice() override;
51  virtual SDL_JoystickID getSDLJoystickID() override;
52 
53  virtual int getNumberRawButtons() override;
54  virtual int getNumberRawAxes() override;
55  virtual int getNumberRawHats() override;
56  virtual double getRawSensorRate(JoySensorType type) override;
57  virtual bool hasRawSensor(JoySensorType type) override;
58 
59  void setCounterUniques(int counter) override;
60 
61  SDL_Joystick *getJoyhandle() const;
62  virtual QString getXmlName() const override;
63 
64  private:
65  SDL_Joystick *m_joyhandle;
66  SDL_GameController *controller;
67  SDL_JoystickID joystickID;
69 };
70 
71 Q_DECLARE_METATYPE(Joystick *)
72 
73 #endif // JOYSTICK_H
Joystick::getSDLName
virtual QString getSDLName() override
Definition: joystick.cpp:51
Joystick::getSerialString
virtual QString getSerialString() const override
Definition: joystick.cpp:108
INFO
#define INFO()
Definition: logger.h:43
Joystick::getSDLJoystickID
virtual SDL_JoystickID getSDLJoystickID() override
Definition: joystick.cpp:175
globalvariables.h
Joystick::joystickID
SDL_JoystickID joystickID
Definition: joystick.h:67
Joystick::getXmlName
virtual QString getXmlName() const override
Definition: joystick.cpp:47
InputDevice
Abstract class representing a hardware input device, e.g a joystick or controller.
Definition: inputdevice.h:50
Joystick::getName
virtual QString getName() override
Definition: joystick.cpp:49
SetJoystick
A set of mapped events which can by switched by a controller event. Contains controller input objects...
Definition: setjoystick.h:39
Joystick::Joystick
Joystick(SDL_Joystick *joyhandle, int deviceIndex, AntiMicroSettings *settings, QObject *parent)
Definition: joystick.cpp:31
Joystick::getJoyhandle
SDL_Joystick * getJoyhandle() const
Definition: joystick.cpp:177
AntiMicroSettings
Definition: antimicrosettings.h:26
Joystick::getProductIDString
virtual QString getProductIDString() const override
Definition: joystick.cpp:92
Joystick::m_joyhandle
SDL_Joystick * m_joyhandle
Definition: joystick.h:65
JoySensorType
JoySensorType
Definition: joysensortype.h:23
joystick.h
InputDevice::getRealJoyNumber
int getRealJoyNumber()
Definition: inputdevice.cpp:60
InputDevice::getDescription
virtual QString getDescription()
Definition: inputdevice.cpp:1310
GlobalVariables::InputDevice::NUMBER_JOYSETS
static const int NUMBER_JOYSETS
Definition: globalvariables.h:104
Joystick
General input device (which is not a typical gamepad like steering wheels, flight sticks etc....
Definition: joystick.h:34
Joystick::getNumberRawAxes
virtual int getNumberRawAxes() override
Definition: joystick.cpp:157
Joystick::counterUniques
int counterUniques
Definition: joystick.h:68
Joystick::controller
SDL_GameController * controller
Definition: joystick.h:66
Joystick::getGUIDString
virtual QString getGUIDString() const override
Definition: joystick.cpp:63
inputdevice.h
Joystick::getProductVersion
virtual QString getProductVersion() const override
Definition: joystick.cpp:122
InputDevice::enableSetConnections
void enableSetConnections(SetJoystick *setstick)
Establishes necessary connections for set change slots.
Definition: inputdevice.cpp:1132
Joystick::getRawSensorRate
virtual double getRawSensorRate(JoySensorType type) override
Definition: joystick.cpp:169
Joystick::getNumberRawHats
virtual int getNumberRawHats() override
Definition: joystick.cpp:163
Joystick::setCounterUniques
void setCounterUniques(int counter) override
Definition: joystick.cpp:173
Joystick::closeSDLDevice
virtual void closeSDLDevice() override
Definition: joystick.cpp:143
Joystick::getVendorString
virtual QString getVendorString() const override
Definition: joystick.cpp:76
Joystick::getNumberRawButtons
virtual int getNumberRawButtons() override
Definition: joystick.cpp:151
GlobalVariables::Joystick::xmlName
static const QString xmlName
Definition: globalvariables.h:201
InputDevice::getJoystick_sets
QMap< int, SetJoystick * > & getJoystick_sets()
Definition: inputdevice.cpp:1715
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
Joystick::hasRawSensor
virtual bool hasRawSensor(JoySensorType type) override
Definition: joystick.cpp:171
antimicrosettings.h
Joystick::getUniqueIDString
virtual QString getUniqueIDString() const override
Definition: joystick.cpp:138