AntiMicroX
gamecontrollermappingdialog.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 GAMECONTROLLERMAPPINGDIALOG_H
20 #define GAMECONTROLLERMAPPINGDIALOG_H
21 
24 
25 #include <QDialog>
26 
27 class InputDevice;
28 class AntiMicroSettings;
29 class QWidget;
30 class QAbstractButton;
31 
32 namespace Ui {
34 }
35 
36 class GameControllerMappingDialog : public QDialog
37 {
38  Q_OBJECT
39 
40  public:
41  explicit GameControllerMappingDialog(InputDevice *device, AntiMicroSettings *settings, QWidget *parent = nullptr);
43 
44  static QHash<int, QString> tempaliases;
45  static QHash<SDL_GameControllerButton, int> buttonPlacement;
46  static QHash<SDL_GameControllerAxis, int> axisPlacement;
47 
48  protected:
53  QString generateSDLMappingString();
55 
56  QString bindingString(SDL_GameControllerButtonBind bind);
57  QList<QVariant> bindingValues(SDL_GameControllerButtonBind bind);
58 
59  private:
60  Ui::GameControllerMappingDialog *ui;
61 
62  signals:
63  void mappingUpdate(QString mapping, InputDevice *device);
64 
65  private slots:
66  void buttonAssign(int buttonindex);
67  void axisAssign(int axis, int value);
68  void dpadAssign(int dpad, int buttonindex);
69  void buttonRelease(int buttonindex);
70  void axisRelease(int axis, int value);
71  void dpadRelease(int dpad, int buttonindex);
72  void saveChanges();
73  void discardMapping(QAbstractButton *button);
74  void enableButtonEvents(int code);
75  void obliterate();
76  void changeButtonDisplay();
77  void changeAxisDeadZone(int index);
78  void updateLastAxisLineEdit(JoyAxis *tempAxis, int value);
79  void updateLastAxisLineEditRaw(int index, int value);
80 
81  private:
83  QList<int> &getEventTriggerAxesLocal();
84 
88  QList<int> eventTriggerAxes;
92 };
93 
94 #endif // GAMECONTROLLERMAPPINGDIALOG_H
InputDevice::isGameController
virtual bool isGameController()
Check if device is using the SDL Game Controller API.
Definition: inputdevice.cpp:1341
GameControllerMappingDialog::removeControllerMapping
void removeControllerMapping()
Definition: gamecontrollermappingdialog.cpp:469
GameControllerMappingDialog::device
InputDevice * device
Definition: gamecontrollermappingdialog.h:85
GameControllerMappingDialog::buttonRelease
void buttonRelease(int buttonindex)
TODO: Possibly remove. This was used for decrementing a reference count.
Definition: gamecontrollermappingdialog.cpp:596
GameControllerMappingDialog::enableButtonEvents
void enableButtonEvents(int code)
Definition: gamecontrollermappingdialog.cpp:506
code
the intent is to exercise the right to control the distribution of derivative or collective works based on the Library In mere aggregation of another work not based on the Library with the you must alter all the notices that refer to this so that they refer to the ordinary GNU General Public instead of to this it is irreversible for that so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy This option is useful when you wish to copy part of the code of the Library into a program that is not a library You may copy and distribute the which must be distributed under the terms of Sections and above on a medium customarily used for software interchange If distribution of object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code
Definition: lgpl-2.1.txt:237
GameControllerMappingDialog::populateGameControllerBindings
void populateGameControllerBindings(GameController *controller)
Definition: gamecontrollermappingdialog.cpp:344
gamecontroller.h
GameControllerMappingDialog::dpadAssign
void dpadAssign(int dpad, int buttonindex)
Definition: gamecontrollermappingdialog.cpp:275
JoyAxis::getIndex
int getIndex()
Definition: joyaxis.cpp:317
GameControllerMappingDialog::buttonPlacement
static QHash< SDL_GameControllerButton, int > buttonPlacement
Definition: gamecontrollermappingdialog.h:45
JoyAxis
Represents single axis of of joystick (or other input)
Definition: joyaxis.h:40
JoyAxis::getRealJoyIndex
int getRealJoyIndex()
Definition: joyaxis.cpp:251
GameControllerMappingDialog::populateAxisDeadZoneComboBox
void populateAxisDeadZoneComboBox()
Definition: gamecontrollermappingdialog.cpp:610
initAliases
static QHash< int, QString > initAliases()
Definition: gamecontrollermappingdialog.cpp:38
InputDevice::rawDPadButtonRelease
void rawDPadButtonRelease(int dpad, int buttonindex)
GameControllerMappingDialog::bindingValues
QList< QVariant > bindingValues(SDL_GameControllerButtonBind bind)
Definition: gamecontrollermappingdialog.cpp:416
InputDevice::getNumberAxes
virtual int getNumberAxes()
Definition: inputdevice.cpp:567
InputDevice::getGUIDString
virtual QString getGUIDString() const =0
InputDevice::rawButtonRelease
void rawButtonRelease(int index)
InputDevice
Abstract class representing a hardware input device, e.g a joystick or controller.
Definition: inputdevice.h:50
GameControllerMappingDialog::changeAxisDeadZone
void changeAxisDeadZone(int index)
Definition: gamecontrollermappingdialog.cpp:619
InputDevice::rawButtonClick
void rawButtonClick(int index)
AntiMicroSettings::getLock
QMutex * getLock()
Definition: antimicrosettings.cpp:95
InputDevice::rawDPadButtonClick
void rawDPadButtonClick(int dpad, int buttonindex)
InputDevice::rawAxisActivated
void rawAxisActivated(int axis, int value)
GameControllerMappingDialog::axisRelease
void axisRelease(int axis, int value)
TODO: Possibly remove. This was used for decrementing a reference count.
Definition: gamecontrollermappingdialog.cpp:585
AntiMicroSettings
Definition: antimicrosettings.h:26
initAxisPlacement
static QHash< SDL_GameControllerAxis, int > initAxisPlacement()
Definition: gamecontrollermappingdialog.cpp:86
GameControllerMappingDialog::generateSDLMappingString
QString generateSDLMappingString()
Definition: gamecontrollermappingdialog.cpp:519
PadderCommon::lockInputDevices
void lockInputDevices()
Definition: common.cpp:158
invoked
and distribute a copy of this License along with the Library You may charge a fee for the physical act of transferring a and you may at your option offer warranty protection in exchange for a fee You may modify your copy or copies of the Library or any portion of thus forming a work based on the and copy and distribute such modifications or work under the terms of Section provided that you also meet all of these other than as an argument passed when the facility is invoked
Definition: lgpl-2.1.txt:178
InputDevice::getRealJoyNumber
int getRealJoyNumber()
Definition: inputdevice.cpp:60
gamecontrollermappingdialog.h
GameControllerMappingDialog::tempaliases
static QHash< int, QString > tempaliases
Definition: gamecontrollermappingdialog.h:44
gamecontrollermappingdialoghelper.h
GameControllerMappingDialogHelper
Definition: gamecontrollermappingdialoghelper.h:27
InputDevice::rawAxisMoved
void rawAxisMoved(int axis, int value)
GameControllerMappingDialog::dpadRelease
void dpadRelease(int dpad, int buttonindex)
TODO: Possibly remove. This was used for decrementing a reference count.
Definition: gamecontrollermappingdialog.cpp:604
GameControllerMappingDialog::enableDeviceConnections
void enableDeviceConnections()
Definition: gamecontrollermappingdialog.cpp:484
InputDevice::getSDLName
virtual QString getSDLName()=0
Ui
Definition: aboutdialog.h:26
GameControllerMappingDialog::discardMapping
void discardMapping(QAbstractButton *button)
Definition: gamecontrollermappingdialog.cpp:443
InputDevice::getSDLPlatform
QString getSDLPlatform()
Definition: inputdevice.cpp:1331
InputDevice::rawAxisReleased
void rawAxisReleased(int axis, int value)
GameControllerMappingDialog::getHelperLocal
GameControllerMappingDialogHelper & getHelperLocal()
Definition: gamecontrollermappingdialog.cpp:659
GameControllerMappingDialog::ui
Ui::GameControllerMappingDialog * ui
Definition: gamecontrollermappingdialog.h:60
GameController::getBindStringForAxis
QString getBindStringForAxis(int index, bool trueIndex=true)
Definition: gamecontroller.cpp:232
GameControllerMappingDialog::bindingString
QString bindingString(SDL_GameControllerButtonBind bind)
Definition: gamecontrollermappingdialog.cpp:390
inputdevice.h
GameControllerMappingDialog::disableDeviceConnections
void disableDeviceConnections()
Definition: gamecontrollermappingdialog.cpp:495
InputDevice::getNumberButtons
virtual int getNumberButtons()
Definition: inputdevice.cpp:565
GameControllerMappingDialog::eventTriggerAxes
QList< int > eventTriggerAxes
Definition: gamecontrollermappingdialog.h:88
GameControllerMappingDialog
Definition: gamecontrollermappingdialog.h:36
GameController
Represents a typical gamepad (like PS4 or Xbox gamepad)
Definition: gamecontroller.h:44
GameControllerMappingDialog::saveChanges
void saveChanges()
Definition: gamecontrollermappingdialog.cpp:320
GameControllerMappingDialog::helper
GameControllerMappingDialogHelper helper
Definition: gamecontrollermappingdialog.h:89
common.h
InputDevice::convertToUniqueMappSett
void convertToUniqueMappSett(QSettings *sett, QString gUIDmappGroupSett, QString uniqueIDGroupSett)
Definition: inputdevice.cpp:1695
GameControllerMappingDialog::getEventTriggerAxesLocal
QList< int > & getEventTriggerAxesLocal()
Definition: gamecontrollermappingdialog.cpp:661
GameControllerMappingDialog::mappingUpdate
void mappingUpdate(QString mapping, InputDevice *device)
GameControllerMappingDialog::buttonAssign
void buttonAssign(int buttonindex)
Definition: gamecontrollermappingdialog.cpp:165
GameControllerMappingDialog::buttonGrabs
int buttonGrabs
Definition: gamecontrollermappingdialog.h:87
initButtonPlacement
static QHash< SDL_GameControllerButton, int > initButtonPlacement()
Definition: gamecontrollermappingdialog.cpp:65
PadderCommon::unlockInputDevices
void unlockInputDevices()
Definition: common.cpp:160
GameControllerMappingDialog::axisPlacement
static QHash< SDL_GameControllerAxis, int > axisPlacement
Definition: gamecontrollermappingdialog.h:46
GameControllerMappingDialog::obliterate
void obliterate()
Definition: gamecontrollermappingdialog.cpp:568
GameControllerMappingDialog::settings
AntiMicroSettings * settings
Definition: gamecontrollermappingdialog.h:86
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
GameControllerMappingDialog::changeButtonDisplay
void changeButtonDisplay()
Definition: gamecontrollermappingdialog.cpp:574
InputDevice::getUniqueIDString
virtual QString getUniqueIDString() const =0
GameControllerMappingDialog::updateLastAxisLineEditRaw
void updateLastAxisLineEditRaw(int index, int value)
Definition: gamecontrollermappingdialog.cpp:649
antimicrosettings.h
GameController::getBindForButton
SDL_GameControllerButtonBind getBindForButton(int index)
Definition: gamecontroller.cpp:283
GameControllerMappingDialog::GameControllerMappingDialog
GameControllerMappingDialog(InputDevice *device, AntiMicroSettings *settings, QWidget *parent=nullptr)
Definition: gamecontrollermappingdialog.cpp:103
GameControllerMappingDialog::usingGameController
bool usingGameController
Definition: gamecontrollermappingdialog.h:91
GameControllerMappingDialog::axisAssign
void axisAssign(int axis, int value)
Definition: gamecontrollermappingdialog.cpp:211
GameControllerMappingDialog::updateLastAxisLineEdit
void updateLastAxisLineEdit(JoyAxis *tempAxis, int value)
Definition: gamecontrollermappingdialog.cpp:630
GameControllerMappingDialog::currentDeadZoneValue
int currentDeadZoneValue
Definition: gamecontrollermappingdialog.h:90
GameControllerMappingDialog::~GameControllerMappingDialog
~GameControllerMappingDialog()
Definition: gamecontrollermappingdialog.cpp:163
GameController::getBindForAxis
SDL_GameControllerButtonBind getBindForAxis(int index)
Definition: gamecontroller.cpp:278