AntiMicroX
Loading...
Searching...
No Matches
qtkeymapperbase.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 QTKEYMAPPERBASE_H
20#define QTKEYMAPPERBASE_H
21
22#include <QHash>
23#include <QObject>
24
41class QtKeyMapperBase : public QObject
42{
44
45 public:
46 explicit QtKeyMapperBase(QObject *parent = nullptr);
47
59
65 virtual int returnVirtualKey(int qkey);
66
73 virtual int returnQtKey(int key, int scancode = 0);
74
80 virtual bool isModifier(int qkey);
81
89
95
97 static const int customQtKeyPrefix = 0x10000000;
98 static const int customKeyPrefix = 0x20000000;
99 static const int nativeKeyPrefix = 0x60000000;
100
102 enum
103 {
106 AntKey_Shift_Lock = 0xffe6 | customKeyPrefix, // XK_Shift_Lock | 0x20000000
137 };
138
139 protected:
145 virtual void populateMappingHashes() = 0;
146
150 virtual void populateCharKeyInformation() = 0;
151
157 QHash<int, charKeyInformation> virtkeyToCharKeyInfo; // Unicode representation -> VK+Modifier information
160};
161
162#endif // QTKEYMAPPERBASE_H
Definition joydpadxml.h:27
JoyDPadXml(T *joydpad, QObject *parent=nullptr)
Definition joydpadxml.cpp:17
Base class for platform-specific Qt key mappers.
Definition qtkeymapperbase.h:42
static const int customQtKeyPrefix
Definition qtkeymapperbase.h:97
virtual void populateCharKeyInformation()=0
Populate virtkeyToCharKeyInfo with character -> VK+modifier info.
QHash< int, int > virtKeyToQtKeyHash
Definition qtkeymapperbase.h:155
@ AntKey_Meta_R
Definition qtkeymapperbase.h:107
@ AntKey_KP_Begin
Definition qtkeymapperbase.h:121
@ AntKey_KP_Multiply
Definition qtkeymapperbase.h:110
@ AntKey_KP_Next
Definition qtkeymapperbase.h:125
@ AntKey_KP_6
Definition qtkeymapperbase.h:133
@ AntKey_Shift_Lock
Definition qtkeymapperbase.h:106
@ AntKey_KP_Right
Definition qtkeymapperbase.h:122
@ AntKey_KP_9
Definition qtkeymapperbase.h:136
@ AntKey_KP_Decimal
Definition qtkeymapperbase.h:113
@ AntKey_Control_R
Definition qtkeymapperbase.h:105
@ AntKey_KP_Subtract
Definition qtkeymapperbase.h:111
@ AntKey_KP_1
Definition qtkeymapperbase.h:128
@ AntKey_KP_7
Definition qtkeymapperbase.h:134
@ AntKey_KP_Divide
Definition qtkeymapperbase.h:109
@ AntKey_KP_5
Definition qtkeymapperbase.h:132
@ AntKey_KP_3
Definition qtkeymapperbase.h:130
@ AntKey_Delete
Definition qtkeymapperbase.h:115
@ AntKey_KP_Up
Definition qtkeymapperbase.h:124
@ AntKey_KP_Delete
Definition qtkeymapperbase.h:116
@ AntKey_KP_2
Definition qtkeymapperbase.h:129
@ AntKey_KP_Down
Definition qtkeymapperbase.h:118
@ AntKey_KP_Prior
Definition qtkeymapperbase.h:119
@ AntKey_Alt_R
Definition qtkeymapperbase.h:108
@ AntKey_KP_Left
Definition qtkeymapperbase.h:120
@ AntKey_KP_Add
Definition qtkeymapperbase.h:112
@ AntKey_KP_Insert
Definition qtkeymapperbase.h:114
@ AntKey_KP_Enter
Definition qtkeymapperbase.h:126
@ AntKey_KP_8
Definition qtkeymapperbase.h:135
@ AntKey_KP_0
Definition qtkeymapperbase.h:127
@ AntKey_KP_End
Definition qtkeymapperbase.h:117
@ AntKey_KP_Home
Definition qtkeymapperbase.h:123
@ AntKey_KP_4
Definition qtkeymapperbase.h:131
@ AntKey_Shift_R
Definition qtkeymapperbase.h:104
virtual int returnQtKey(int key, int scancode=0)
Get Qt key for a given platform virtual key.
Definition qtkeymapperbase.cpp:32
virtual int returnVirtualKey(int qkey)
Get platform virtual key for a given Qt key.
Definition qtkeymapperbase.cpp:39
charKeyInformation getCharKeyInformation(QChar value)
Get key information (virtual key + modifiers) for a character.
Definition qtkeymapperbase.cpp:69
virtual void populateMappingHashes()=0
Populate the Qt <-> platform virtual key mappings. Implementations must fill qtKeyToVirtKeyHash (Qt -...
QHash< int, charKeyInformation > virtkeyToCharKeyInfo
Definition qtkeymapperbase.h:157
QString identifier
Definition qtkeymapperbase.h:159
QString getIdentifier()
Identifier string for this mapper implementation.
Definition qtkeymapperbase.cpp:85
virtual bool isModifier(int qkey)
Check whether the given Qt key is a modifier key.
Definition qtkeymapperbase.cpp:41
QHash< int, int > qtKeyToVirtKeyHash
Definition qtkeymapperbase.h:153
static const int nativeKeyPrefix
Definition qtkeymapperbase.h:99
struct QtKeyMapperBase::_charKeyInformation charKeyInformation
Information about a printable character key.
static const int customKeyPrefix
Definition qtkeymapperbase.h:98
Information about a printable character key.
Definition qtkeymapperbase.h:55
int virtualkey
Definition qtkeymapperbase.h:57
Qt::KeyboardModifiers modifiers
Definition qtkeymapperbase.h:56