AntiMicroX
sdleventreader.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 SDLEVENTREADER_H
20 #define SDLEVENTREADER_H
21 
22 #include "joystick.h"
23 
24 class InputDevice;
25 class AntiMicroSettings;
26 
27 class SDLEventReader : public QObject
28 {
29  Q_OBJECT
30 
31  public:
32  explicit SDLEventReader(QMap<SDL_JoystickID, InputDevice *> *joysticks, AntiMicroSettings *settings,
33  QObject *parent = nullptr);
35 
36  bool isSDLOpen();
37 
38  QMap<SDL_JoystickID, InputDevice *> *getJoysticks() const;
40  QTimer const &getPollRateTimer();
41 
42  protected:
43  void initSDL();
44  void closeSDL();
45  void clearEvents();
46  int eventStatus();
47 
48  signals:
49  void eventRaised();
50  void finished();
51  void sdlStarted();
52  void sdlClosed();
53 
54  public slots:
55  void performWork();
56  void stop();
57  void refresh();
58  void updatePollRate(int tempPollRate); // (unsigned)
59  void resetJoystickMap();
60  void quit();
61  void closeDevices();
62  void haltServices();
63 
64  private slots:
65  void secondaryRefresh();
66 
67  private:
68  QMap<SDL_JoystickID, InputDevice *> *joysticks;
69  bool sdlIsOpen;
71  int pollRate;
72  QTimer pollRateTimer;
73 
75 };
76 
77 #endif // SDLEVENTREADER_H
SDLEventReader::pollRateTimer
QTimer pollRateTimer
Definition: sdleventreader.h:72
InputDevice::closeSDLDevice
virtual void closeSDLDevice()=0
SDLEventReader::isSDLOpen
bool isSDLOpen()
Definition: sdleventreader.cpp:170
SDLEventReader::haltServices
void haltServices()
Method to block activity on the SDLEventReader object and its thread event loop.
Definition: sdleventreader.cpp:246
DEBUG
#define DEBUG()
Definition: logger.h:41
SDLEventReader::SDLEventReader
SDLEventReader(QMap< SDL_JoystickID, InputDevice * > *joysticks, AntiMicroSettings *settings, QObject *parent=nullptr)
Definition: sdleventreader.cpp:34
SDLEventReader::quit
void quit()
Definition: sdleventreader.cpp:218
globalvariables.h
SDLEventReader::finished
void finished()
SDLEventReader::initSDL
void initSDL()
Definition: sdleventreader.cpp:60
InputDevice
Abstract class representing a hardware input device, e.g a joystick or controller.
Definition: inputdevice.h:50
SDLEventReader::sdlClosed
void sdlClosed()
AntiMicroSettings::getLock
QMutex * getLock()
Definition: antimicrosettings.cpp:95
SDLEventReader::sdlStarted
void sdlStarted()
SDLEventReader::stop
void stop()
Definition: sdleventreader.cpp:130
AntiMicroSettings
Definition: antimicrosettings.h:26
SDLEventReader::~SDLEventReader
~SDLEventReader()
Definition: sdleventreader.cpp:52
joystick.h
PadderCommon::lockInputDevices
void lockInputDevices()
Definition: common.cpp:158
SDLEventReader::settings
AntiMicroSettings * settings
Definition: sdleventreader.h:70
SDLEventReader
Definition: sdleventreader.h:27
SDLEventReader::refresh
void refresh()
Definition: sdleventreader.cpp:142
SDLEventReader::getPollRateTimer
const QTimer & getPollRateTimer()
Definition: sdleventreader.cpp:280
SDLEventReader::closeDevices
void closeDevices()
Definition: sdleventreader.cpp:227
SDLEventReader::updatePollRate
void updatePollRate(int tempPollRate)
Definition: sdleventreader.cpp:201
inputdevice.h
SDLEventReader::loadSdlMappingsFromDatabase
void loadSdlMappingsFromDatabase()
Loading additional gamepad mappings from database.
Definition: sdleventreader.cpp:256
SDLEventReader::getJoysticks
QMap< SDL_JoystickID, InputDevice * > * getJoysticks() const
Definition: sdleventreader.cpp:276
SDLEventReader::eventRaised
void eventRaised()
SDLEventReader::performWork
void performWork()
Definition: sdleventreader.cpp:121
SDLEventReader::pollRate
int pollRate
Definition: sdleventreader.h:71
SDLEventReader::secondaryRefresh
void secondaryRefresh()
Definition: sdleventreader.cpp:151
common.h
GlobalVariables::AntimicroSettings::defaultSDLGamepadPollRate
static const int defaultSDLGamepadPollRate
Definition: globalvariables.h:98
SDLEventReader::closeSDL
void closeSDL()
Definition: sdleventreader.cpp:101
SDLEventReader::sdlIsOpen
bool sdlIsOpen
Definition: sdleventreader.h:69
SDLEventReader::resetJoystickMap
void resetJoystickMap()
Definition: sdleventreader.cpp:216
PadderCommon::unlockInputDevices
void unlockInputDevices()
Definition: common.cpp:160
SDLEventReader::clearEvents
void clearEvents()
Definition: sdleventreader.cpp:159
antimicrosettings.h
SDLEventReader::joysticks
QMap< SDL_JoystickID, InputDevice * > * joysticks
Definition: sdleventreader.h:68
SDLEventReader::getSettings
AntiMicroSettings * getSettings() const
Definition: sdleventreader.cpp:278
SDLEventReader::eventStatus
int eventStatus()
Definition: sdleventreader.cpp:172
sdleventreader.h