AntiMicroX
uinputeventhandler.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 UINPUTEVENTHANDLER_H
20 #define UINPUTEVENTHANDLER_H
21 
22 #include "baseeventhandler.h"
23 
35 {
36  Q_OBJECT
37 
38  public:
39  explicit UInputEventHandler(QObject *parent = nullptr);
41 
42  virtual bool init() override;
43  virtual bool cleanup() override;
44  virtual void sendKeyboardEvent(JoyButtonSlot *slot, bool pressed) override;
45  virtual void sendMouseButtonEvent(JoyButtonSlot *slot, bool pressed) override;
46  virtual void sendMouseEvent(int xDis, int yDis) override;
47  virtual void sendMouseAbsEvent(int xDis, int yDis, int screen) override;
48 
49  virtual void sendMouseSpringEvent(int xDis, int yDis, int width, int height) override;
50 
51  virtual QString getName() override;
52  virtual QString getIdentifier() override;
53  virtual void printPostMessages() override;
54 
55  virtual void sendTextEntryEvent(QString maintext) override;
56 
58  int getMouseFileHandler();
60  const QString getUinputDeviceLocation();
61 
62  protected:
63  int openUInputHandle();
64  void setKeyboardEvents(int filehandle);
65  void setRelMouseEvents(int filehandle);
66  void setSpringMouseEvents(int filehandle);
67  void populateKeyCodes(int filehandle);
68  void createUInputKeyboardDevice(int filehandle);
69  void createUInputMouseDevice(int filehandle);
70  void createUInputSpringMouseDevice(int filehandle);
71  void closeUInputDevice(int filehandle);
81  void write_uinput_event(int filehandle, int type, int code, int value, bool syn = true);
82 
83  private slots:
84 #ifdef WITH_X11
85  void x11ResetMouseAccelerationChange();
86 #endif
87 
88  private:
93 #if defined(Q_OS_UNIX)
94  bool is_problem_with_opening_uinput_present;
95 #endif
96 
97  bool cleanupUinputEvHand();
98  void testAndAppend(bool tested, QList<unsigned int> &tempList, unsigned int key);
99  void initDevice(int &device, QString name, bool &result);
100 };
101 
102 #endif // UINPUTEVENTHANDLER_H
X11Extras::getGroup1KeySym
int getGroup1KeySym(int virtualkey)
Definition: x11extras.cpp:605
x11extras.h
UInputEventHandler::getName
virtual QString getName() override
Definition: uinputeventhandler.cpp:465
PadderCommon::mouseDeviceName
const QString mouseDeviceName("antimicrox Mouse Emulation")
UInputEventHandler::cleanup
virtual bool cleanup() override
Definition: uinputeventhandler.cpp:156
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
QtKeyMapperBase::getCharKeyInformation
charKeyInformation getCharKeyInformation(QChar value)
Definition: qtkeymapperbase.cpp:69
PadderCommon::springMouseDeviceName
const QString springMouseDeviceName("antimicrox Abs Mouse Emulation")
UInputEventHandler::sendMouseEvent
virtual void sendMouseEvent(int xDis, int yDis) override
Move cursor to selected relative location (deltax delaty)
Definition: uinputeventhandler.cpp:254
UInputEventHandler::UInputEventHandler
UInputEventHandler(QObject *parent=nullptr)
Definition: uinputeventhandler.cpp:50
logger.h
PRINT_STDERR
#define PRINT_STDERR()
Definition: logger.h:39
PadderCommon::keyboardDeviceName
const QString keyboardDeviceName("antimicrox Keyboard Emulation")
JoyButtonSlot::getSlotMode
JoySlotInputAction getSlotMode() const
Definition: joybuttonslot.cpp:114
antkeymapper.h
JoyButtonSlot::JoyMouseButton
@ JoyMouseButton
Definition: joybuttonslot.h:45
UInputEventHandler::getKeyboardFileHandler
int getKeyboardFileHandler()
Definition: uinputeventhandler.cpp:584
springMouseDeviceName
static const QString springMouseDeviceName
Definition: uinputeventhandler.cpp:38
UInputEventHandler::~UInputEventHandler
~UInputEventHandler()
Definition: uinputeventhandler.cpp:61
QtUInputKeyMapper
Definition: qtuinputkeymapper.h:24
UInputEventHandler::getUinputDeviceLocation
const QString getUinputDeviceLocation()
Definition: uinputeventhandler.cpp:590
UInputEventHandler::springMouseFileHandler
int springMouseFileHandler
Definition: uinputeventhandler.h:91
UInputEventHandler::write_uinput_event
void write_uinput_event(int filehandle, int type, int code, int value, bool syn=true)
Write uinput event to selected file uinput file.
Definition: uinputeventhandler.cpp:440
QtKeyMapperBase::returnQtKey
virtual int returnQtKey(int key, int scancode=0)
Definition: qtkeymapperbase.cpp:32
UInputEventHandler::uinputDeviceLocation
QString uinputDeviceLocation
Definition: uinputeventhandler.h:92
UInputEventHandler::keyboardFileHandler
int keyboardFileHandler
Definition: uinputeventhandler.h:89
joybuttonslot.h
UInputEventHandler::getSpringMouseFileHandler
int getSpringMouseFileHandler()
Definition: uinputeventhandler.cpp:588
JoyButtonSlot
Represents action which can be performed after pressing button.
Definition: joybuttonslot.h:37
AntKeyMapper
Definition: antkeymapper.h:36
BaseEventHandler
Base class for input event handlers.
Definition: baseeventhandler.h:32
UInputEventHandler::sendMouseSpringEvent
virtual void sendMouseSpringEvent(int xDis, int yDis, int width, int height) override
Do nothing by default. Useful for child classes to define behavior.
Definition: uinputeventhandler.cpp:268
JoyButtonSlot::JoyKeyboard
@ JoyKeyboard
Definition: joybuttonslot.h:44
UInputEventHandler::getIdentifier
virtual QString getIdentifier() override
Definition: uinputeventhandler.cpp:467
AntKeyMapper::getInstance
static AntKeyMapper * getInstance(QString handler="")
Definition: antkeymapper.cpp:80
UInputEventHandler::sendKeyboardEvent
virtual void sendKeyboardEvent(JoyButtonSlot *slot, bool pressed) override
Definition: uinputeventhandler.cpp:181
QtKeyMapperBase::returnVirtualKey
virtual int returnVirtualKey(int qkey)
Definition: qtkeymapperbase.cpp:39
UInputEventHandler::cleanupUinputEvHand
bool cleanupUinputEvHand()
Definition: uinputeventhandler.cpp:158
JoyButtonSlot::getSlotCode
int getSlotCode() const
Definition: joybuttonslot.cpp:110
UInputEventHandler::sendTextEntryEvent
virtual void sendTextEntryEvent(QString maintext) override
Definition: uinputeventhandler.cpp:499
UInputEventHandler::closeUInputDevice
void closeUInputDevice(int filehandle)
Definition: uinputeventhandler.cpp:434
UInputEventHandler::init
virtual bool init() override
Initialize keyboard and mouse virtual devices. Each device will use its own file handle with various ...
Definition: uinputeventhandler.cpp:69
keyboardDeviceName
static const QString keyboardDeviceName
Definition: uinputeventhandler.cpp:37
UInputEventHandler::sendMouseButtonEvent
virtual void sendMouseButtonEvent(JoyButtonSlot *slot, bool pressed) override
Definition: uinputeventhandler.cpp:192
baseeventhandler.h
X11Extras::x11ResetMouseAccelerationChange
void x11ResetMouseAccelerationChange()
Definition: x11extras.cpp:691
BaseEventHandler::lastErrorString
QString lastErrorString
Definition: baseeventhandler.h:64
common.h
UInputEventHandler::setSpringMouseEvents
void setSpringMouseEvents(int filehandle)
Definition: uinputeventhandler.cpp:353
UInputEventHandler::sendMouseAbsEvent
virtual void sendMouseAbsEvent(int xDis, int yDis, int screen) override
Move cursor to selected absolute location (x, y) on selected display.
Definition: uinputeventhandler.cpp:260
UInputEventHandler::createUInputMouseDevice
void createUInputMouseDevice(int filehandle)
Definition: uinputeventhandler.cpp:394
X11Extras::getInstance
static X11Extras * getInstance()
Definition: x11extras.cpp:73
UInputEventHandler
Input event handler class using uinput files.
Definition: uinputeventhandler.h:34
UInputEventHandler::setRelMouseEvents
void setRelMouseEvents(int filehandle)
Definition: uinputeventhandler.cpp:335
UInputEventHandler::initDevice
void initDevice(int &device, QString name, bool &result)
Definition: uinputeventhandler.cpp:115
UInputEventHandler::createUInputKeyboardDevice
void createUInputKeyboardDevice(int filehandle)
Definition: uinputeventhandler.cpp:378
UInputEventHandler::openUInputHandle
int openUInputHandle()
Definition: uinputeventhandler.cpp:281
uinputeventhandler.h
JoyButtonSlot::JoySlotInputAction
JoySlotInputAction
Definition: joybuttonslot.h:42
QtKeyMapperBase::_charKeyInformation::virtualkey
int virtualkey
Definition: qtkeymapperbase.h:35
AntKeyMapper::getNativeKeyMapper
QtKeyMapperBase * getNativeKeyMapper() const
Definition: antkeymapper.cpp:108
AntKeyMapper::getKeyMapper
QtKeyMapperBase * getKeyMapper() const
Definition: antkeymapper.cpp:110
UInputEventHandler::testAndAppend
void testAndAppend(bool tested, QList< unsigned int > &tempList, unsigned int key)
Definition: uinputeventhandler.cpp:575
UInputEventHandler::mouseFileHandler
int mouseFileHandler
Definition: uinputeventhandler.h:90
UInputEventHandler::createUInputSpringMouseDevice
void createUInputSpringMouseDevice(int filehandle)
Definition: uinputeventhandler.cpp:410
QtKeyMapperBase::_charKeyInformation::modifiers
Qt::KeyboardModifiers modifiers
Definition: qtkeymapperbase.h:34
QtKeyMapperBase::_charKeyInformation
Definition: qtkeymapperbase.h:32
UInputEventHandler::populateKeyCodes
void populateKeyCodes(int filehandle)
Definition: uinputeventhandler.cpp:370
QtX11KeyMapper
Definition: qtx11keymapper.h:24
UInputEventHandler::printPostMessages
virtual void printPostMessages() override
Print extra help messages to stdout.
Definition: uinputeventhandler.cpp:472
UInputEventHandler::setKeyboardEvents
void setKeyboardEvents(int filehandle)
Definition: uinputeventhandler.cpp:329
mouseDeviceName
static const QString mouseDeviceName
Definition: uinputeventhandler.cpp:36
UInputEventHandler::getMouseFileHandler
int getMouseFileHandler()
Definition: uinputeventhandler.cpp:586