AntiMicroX
Loading...
Searching...
No Matches
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
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
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
Base class for input event handlers.
Definition baseeventhandler.h:33
Represents action which can be performed after pressing button.
Definition joybuttonslot.h:38
Input event handler class using uinput files.
Definition uinputeventhandler.h:35
int openUInputHandle()
Definition uinputeventhandler.cpp:281
void createUInputSpringMouseDevice(int filehandle)
Definition uinputeventhandler.cpp:410
void createUInputMouseDevice(int filehandle)
Definition uinputeventhandler.cpp:394
virtual void sendMouseButtonEvent(JoyButtonSlot *slot, bool pressed) override
Definition uinputeventhandler.cpp:192
void closeUInputDevice(int filehandle)
Definition uinputeventhandler.cpp:434
int getMouseFileHandler()
Definition uinputeventhandler.cpp:586
void initDevice(int &device, QString name, bool &result)
Definition uinputeventhandler.cpp:115
~UInputEventHandler()
Definition uinputeventhandler.cpp:61
virtual bool cleanup() override
Definition uinputeventhandler.cpp:156
virtual void sendMouseEvent(int xDis, int yDis) override
Move cursor to selected relative location (deltax delaty)
Definition uinputeventhandler.cpp:254
virtual void printPostMessages() override
Print extra help messages to stdout.
Definition uinputeventhandler.cpp:472
virtual QString getName() override
Definition uinputeventhandler.cpp:465
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
void setRelMouseEvents(int filehandle)
Definition uinputeventhandler.cpp:335
bool cleanupUinputEvHand()
Definition uinputeventhandler.cpp:158
const QString getUinputDeviceLocation()
Definition uinputeventhandler.cpp:590
virtual void sendKeyboardEvent(JoyButtonSlot *slot, bool pressed) override
Definition uinputeventhandler.cpp:181
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
void createUInputKeyboardDevice(int filehandle)
Definition uinputeventhandler.cpp:378
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
int mouseFileHandler
Definition uinputeventhandler.h:90
QString uinputDeviceLocation
Definition uinputeventhandler.h:92
virtual QString getIdentifier() override
Definition uinputeventhandler.cpp:467
void populateKeyCodes(int filehandle)
Definition uinputeventhandler.cpp:370
void setKeyboardEvents(int filehandle)
Definition uinputeventhandler.cpp:329
void testAndAppend(bool tested, QList< unsigned int > &tempList, unsigned int key)
Definition uinputeventhandler.cpp:575
int getKeyboardFileHandler()
Definition uinputeventhandler.cpp:584
virtual bool init() override
Initialize keyboard and mouse virtual devices. Each device will use its own file handle with various ...
Definition uinputeventhandler.cpp:69
int getSpringMouseFileHandler()
Definition uinputeventhandler.cpp:588
int keyboardFileHandler
Definition uinputeventhandler.h:89
int springMouseFileHandler
Definition uinputeventhandler.h:91
virtual void sendTextEntryEvent(QString maintext) override
Definition uinputeventhandler.cpp:499
void setSpringMouseEvents(int filehandle)
Definition uinputeventhandler.cpp:353