AntiMicroX
joysensoriothreadhelper.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 #pragma once
18 
19 #include "joysensordirection.h"
20 
21 #include <QHash>
22 #include <QObject>
23 
24 class JoyButtonSlot;
25 class JoySensor;
26 
31 class JoySensorIoThreadHelper : public QObject
32 {
33  Q_OBJECT
34 
35  public:
36  explicit JoySensorIoThreadHelper(JoySensor *sensor, QObject *parent = nullptr);
37  void setPendingSlots(QHash<JoySensorDirection, JoyButtonSlot *> *tempSlots);
38  void clearPendingSlots();
39 
40  public slots:
41  void setFromPendingSlots();
43 
44  private:
46  QHash<JoySensorDirection, JoyButtonSlot *> m_pending_slots;
47 };
JoySensorIoThreadHelper::m_sensor
JoySensor * m_sensor
Definition: joysensoriothreadhelper.h:45
JoyButtonSlot::getSlotMode
JoySlotInputAction getSlotMode() const
Definition: joybuttonslot.cpp:114
joysensor.h
JoySensorIoThreadHelper::setFromPendingSlots
void setFromPendingSlots()
Applies pending slot values to the buttons Should be called via QMetaObject::invokeMethod.
Definition: joysensoriothreadhelper.cpp:59
joybuttonslot.h
JoyButtonSlot
Represents action which can be performed after pressing button.
Definition: joybuttonslot.h:37
JoySensorIoThreadHelper::JoySensorIoThreadHelper
JoySensorIoThreadHelper(JoySensor *sensor, QObject *parent=nullptr)
Definition: joysensoriothreadhelper.cpp:26
JoySensorIoThreadHelper::clearPendingSlots
void clearPendingSlots()
Clears pending slot values.
Definition: joysensoriothreadhelper.cpp:53
JoySensorButton
Represents a sensor mapping in a SetJoystick.
Definition: joysensorbutton.h:30
JoyButtonSlot::getSlotCode
int getSlotCode() const
Definition: joybuttonslot.cpp:110
JoySensorIoThreadHelper::clearButtonsSlotsEventReset
void clearButtonsSlotsEventReset()
Calls JoyButton::clearSlotEventReset on all JoyButtons of the underlying sensor. Should be called via...
Definition: joysensoriothreadhelper.cpp:85
JoySensorDirection
JoySensorDirection
A bitfield style enum which encodes all possible three dimensional sensor directions....
Definition: joysensordirection.h:27
JoySensor
Represents one sensor in a SetJoystick and its connections to other parts of the application....
Definition: joysensor.h:39
joysensorbutton.h
JoyButton::setAssignedSlot
bool setAssignedSlot(int code, int alias, int index, JoyButtonSlot::JoySlotInputAction mode=JoyButtonSlot::JoyKeyboard)
Create new JoyButtonSlot with data provided and replace an existing slot in the assignment list if on...
Definition: joybutton.cpp:2134
joysensordirection.h
JoyButtonSlot::getSlotCodeAlias
int getSlotCodeAlias() const
Definition: joybuttonslot.cpp:108
joysensoriothreadhelper.h
JoySensorIoThreadHelper::m_pending_slots
QHash< JoySensorDirection, JoyButtonSlot * > m_pending_slots
Definition: joysensoriothreadhelper.h:46
JoySensor::getDirectionButton
JoySensorButton * getDirectionButton(JoySensorDirection direction)
Get a pointer to the sensor direction button for the desired direction.
Definition: joysensor.cpp:550
JoySensorIoThreadHelper
Some helper methods which run in the IO thread and are called from the GUI thread.
Definition: joysensoriothreadhelper.h:31
JoyButton::clearSlotsEventReset
virtual void clearSlotsEventReset(bool clearSignalEmit=true)
Definition: joybutton.cpp:3069
JoySensorIoThreadHelper::setPendingSlots
void setPendingSlots(QHash< JoySensorDirection, JoyButtonSlot * > *tempSlots)
Sets pending slot values The values are applied to the buttons by calling setFromPendingSlots.
Definition: joysensoriothreadhelper.cpp:39
JoySensor::getButtons
QHash< JoySensorDirection, JoySensorButton * > * getButtons()
Returns a QHash which maps the SensorDirection to the corresponding JoySensorButton.
Definition: joysensor.cpp:541