1 /* antimicro Gamepad to KB+M event mapper 2 * Copyright (C) 2015 Travis Nickles <nickles.travis@gmail.com> 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 #ifndef JOYBUTTONSLOT_H 19 #define JOYBUTTONSLOT_H 20 21 #include <QObject> 22 #include <QElapsedTimer> 23 #include <QTime> 24 #include <QMetaType> 25 #include <QXmlStreamReader> 26 #include <QXmlStreamWriter> 27 #include <QVariant> 28 29 class JoyButtonSlot : public QObject 30 { 31 Q_OBJECT 32 public: 33 enum JoySlotInputAction {JoyKeyboard=0, JoyMouseButton, JoyMouseMovement, 34 JoyPause, JoyHold, JoyCycle, JoyDistance, 35 JoyRelease, JoyMouseSpeedMod, JoyKeyPress, JoyDelay, 36 JoyLoadProfile, JoySetChange, JoyTextEntry, JoyExecute}; 37 38 enum JoySlotMouseDirection {MouseUp=1, MouseDown, MouseLeft, MouseRight}; 39 enum JoySlotMouseWheelButton {MouseWheelUp=4, MouseWheelDown=5, 40 MouseWheelLeft=6, MouseWheelRight=7}; 41 enum JoySlotMouseButton {MouseLB=1, MouseMB, MouseRB}; 42 43 explicit JoyButtonSlot(QObject *parent = 0); 44 explicit JoyButtonSlot(int code, JoySlotInputAction mode, QObject *parent=0); 45 explicit JoyButtonSlot(int code, unsigned int alias, JoySlotInputAction mode, QObject *parent=0); 46 explicit JoyButtonSlot(JoyButtonSlot *slot, QObject *parent=0); 47 explicit JoyButtonSlot(QString text, JoySlotInputAction mode, QObject *parent=0); 48 49 void setSlotCode(int code); 50 int getSlotCode(); 51 void setSlotMode(JoySlotInputAction selectedMode); 52 JoySlotInputAction getSlotMode(); 53 QString movementString(); 54 void setMouseSpeed(int value); 55 void setDistance(double distance); 56 double getMouseDistance(); 57 QElapsedTimer* getMouseInterval(); 58 void restartMouseInterval(); 59 QString getXmlName(); 60 QString getSlotString(); 61 void setSlotCode(int code, unsigned int alias); 62 unsigned int getSlotCodeAlias(); 63 void setPreviousDistance(double distance); 64 double getPreviousDistance(); 65 bool isModifierKey(); 66 67 bool isEasingActive(); 68 void setEasingStatus(bool isActive); 69 QTime* getEasingTime(); 70 71 void setTextData(QString textData); 72 QString getTextData(); 73 74 void setExtraData(QVariant data); 75 QVariant getExtraData(); 76 77 bool isValidSlot(); 78 79 virtual void readConfig(QXmlStreamReader *xml); 80 virtual void writeConfig(QXmlStreamWriter *xml); 81 82 static const int JOYSPEED; 83 static const QString xmlName; 84 85 protected: 86 int deviceCode; 87 unsigned int qkeyaliasCode; 88 JoySlotInputAction mode; 89 double distance; 90 double previousDistance; 91 QElapsedTimer mouseInterval; 92 QTime easingTime; 93 bool easingActive; 94 QString textData; 95 QVariant extraData; 96 97 static const int MAXTEXTENTRYDISPLAYLENGTH; 98 99 signals: 100 101 public slots: 102 103 }; 104 105 Q_DECLARE_METATYPE(JoyButtonSlot*) 106 Q_DECLARE_METATYPE(JoyButtonSlot::JoySlotInputAction) 107 108 109 #endif // JOYBUTTONSLOT_H 110