1 /*
2  * Strawberry Music Player
3  * Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net>
4  *
5  * Strawberry 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  * Strawberry 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 Strawberry.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  */
19 
20 #ifndef KEYMAPPER_X11_H
21 #define KEYMAPPER_X11_H
22 
23 #include "config.h"
24 
25 #include <QtGlobal>
26 #include <QMap>
27 
28 #define XK_MISCELLANY
29 #define XK_XKB_KEYS
30 #define XK_LATIN1
31 
32 #ifdef HAVE_KEYSYMDEF_H
33 #  include <X11/keysymdef.h>
34 #else
35 #  warning "Missing X11/keysymdef.h"
36 #endif
37 #ifdef HAVE_XF86KEYSYM_H
38 #  include <X11/XF86keysym.h>
39 #endif
40 
41 namespace KeyMapperX11 {
42 static const QMap<Qt::Key, quint32> keymapper_x11_ = {  // clazy:exclude=non-pod-global-static
43 
44 #ifdef HAVE_KEYSYMDEF_H
45 
46     { Qt::Key_0,                  XK_0 },
47     { Qt::Key_1,                  XK_1 },
48     { Qt::Key_2,                  XK_2 },
49     { Qt::Key_3,                  XK_3 },
50     { Qt::Key_4,                  XK_4 },
51     { Qt::Key_5,                  XK_5 },
52     { Qt::Key_6,                  XK_6 },
53     { Qt::Key_7,                  XK_7 },
54     { Qt::Key_8,                  XK_8 },
55     { Qt::Key_9,                  XK_9 },
56 
57     { Qt::Key_A,                  XK_A },
58     { Qt::Key_B,                  XK_B },
59     { Qt::Key_C,                  XK_C },
60     { Qt::Key_D,                  XK_D },
61     { Qt::Key_E,                  XK_E },
62     { Qt::Key_F,                  XK_F },
63     { Qt::Key_G,                  XK_G },
64     { Qt::Key_H,                  XK_H },
65     { Qt::Key_I,                  XK_I },
66     { Qt::Key_J,                  XK_J },
67     { Qt::Key_K,                  XK_K },
68     { Qt::Key_L,                  XK_L },
69     { Qt::Key_M,                  XK_M },
70     { Qt::Key_N,                  XK_N },
71     { Qt::Key_O,                  XK_O },
72     { Qt::Key_P,                  XK_P },
73     { Qt::Key_Q,                  XK_Q },
74     { Qt::Key_R,                  XK_R },
75     { Qt::Key_S,                  XK_S },
76     { Qt::Key_T,                  XK_T },
77     { Qt::Key_U,                  XK_U },
78     { Qt::Key_V,                  XK_V },
79     { Qt::Key_W,                  XK_W },
80     { Qt::Key_X,                  XK_X },
81     { Qt::Key_Y,                  XK_Y },
82     { Qt::Key_Z,                  XK_Z },
83 
84     { Qt::Key_Escape,             XK_Escape },
85     { Qt::Key_Tab,                XK_Tab },
86     { Qt::Key_Backtab,            XK_ISO_Left_Tab },
87     { Qt::Key_Backspace,          XK_BackSpace },
88     { Qt::Key_Return,             XK_Return },
89     { Qt::Key_Enter,              XK_KP_Enter },
90     { Qt::Key_Insert,             XK_Insert },
91     { Qt::Key_Delete,             XK_Delete },
92     { Qt::Key_Pause,              XK_Pause },
93     { Qt::Key_Print,              XK_Print },
94     { Qt::Key_Clear,              XK_Clear },
95     { Qt::Key_Home,               XK_Home },
96     { Qt::Key_End,                XK_End },
97     { Qt::Key_Left,               XK_Left },
98     { Qt::Key_Up,                 XK_Up },
99     { Qt::Key_Right,              XK_Right },
100     { Qt::Key_Down,               XK_Down },
101     { Qt::Key_PageUp,             XK_Prior },
102     { Qt::Key_PageDown,           XK_Next },
103     { Qt::Key_Space,              XK_space },
104     { Qt::Key_Exclam,             XK_exclam },
105     { Qt::Key_QuoteDbl,           XK_quotedbl },
106     { Qt::Key_NumberSign,         XK_numbersign },
107     { Qt::Key_Dollar,             XK_dollar },
108     { Qt::Key_Percent,            XK_percent },
109     { Qt::Key_Ampersand,          XK_ampersand },
110     { Qt::Key_Apostrophe,         XK_apostrophe },
111     { Qt::Key_ParenLeft,          XK_parenleft },
112     { Qt::Key_ParenRight,         XK_parenright },
113     { Qt::Key_Asterisk,           XK_asterisk },
114     { Qt::Key_Plus,               XK_plus },
115     { Qt::Key_Comma,              XK_comma },
116     { Qt::Key_Minus,              XK_minus },
117     { Qt::Key_Period,             XK_period },
118     { Qt::Key_Slash,              XK_slash },
119     { Qt::Key_Colon,              XK_colon },
120     { Qt::Key_Semicolon,          XK_semicolon },
121     { Qt::Key_Less,               XK_less },
122     { Qt::Key_Equal,              XK_equal },
123     { Qt::Key_Greater,            XK_greater },
124     { Qt::Key_Question,           XK_question },
125     { Qt::Key_BracketLeft,        XK_bracketleft },
126     { Qt::Key_Backslash,          XK_backslash },
127     { Qt::Key_BracketRight,       XK_bracketright },
128     { Qt::Key_AsciiCircum,        XK_asciicircum },
129     { Qt::Key_Underscore,         XK_underscore },
130     { Qt::Key_QuoteLeft,          XK_quoteleft },
131     { Qt::Key_BraceLeft,          XK_braceleft },
132     { Qt::Key_Bar,                XK_bar },
133     { Qt::Key_BraceRight,         XK_braceright },
134     { Qt::Key_AsciiTilde,         XK_asciitilde },
135     { Qt::Key_nobreakspace,       XK_nobreakspace },
136     { Qt::Key_exclamdown,         XK_exclamdown },
137     { Qt::Key_cent,               XK_cent },
138     { Qt::Key_sterling,           XK_sterling },
139     { Qt::Key_currency,           XK_currency },
140     { Qt::Key_yen,                XK_yen },
141     { Qt::Key_brokenbar,          XK_brokenbar },
142     { Qt::Key_section,            XK_section },
143     { Qt::Key_diaeresis,          XK_diaeresis },
144     { Qt::Key_copyright,          XK_copyright },
145     { Qt::Key_ordfeminine,        XK_ordfeminine },
146     { Qt::Key_guillemotleft,      XK_guillemotleft },
147     { Qt::Key_notsign,            XK_notsign },
148     { Qt::Key_hyphen,             XK_hyphen },
149     { Qt::Key_registered,         XK_registered },
150     { Qt::Key_macron,             XK_macron },
151     { Qt::Key_degree,             XK_degree },
152     { Qt::Key_plusminus,          XK_plusminus },
153     { Qt::Key_twosuperior,        XK_twosuperior },
154     { Qt::Key_threesuperior,      XK_threesuperior },
155     { Qt::Key_acute,              XK_acute },
156     { Qt::Key_mu,                 XK_mu },
157     { Qt::Key_paragraph,          XK_paragraph },
158     { Qt::Key_periodcentered,     XK_periodcentered },
159     { Qt::Key_cedilla,            XK_cedilla },
160     { Qt::Key_onesuperior,        XK_onesuperior },
161     { Qt::Key_masculine,          XK_masculine },
162     { Qt::Key_guillemotright,     XK_guillemotright },
163     { Qt::Key_onequarter,         XK_onequarter },
164     { Qt::Key_onehalf,            XK_onehalf },
165     { Qt::Key_threequarters,      XK_threequarters },
166     { Qt::Key_questiondown,       XK_questiondown },
167     { Qt::Key_Agrave,             XK_Agrave },
168     { Qt::Key_Aacute,             XK_Aacute },
169     { Qt::Key_Acircumflex,        XK_Acircumflex },
170     { Qt::Key_Atilde,             XK_Atilde },
171     { Qt::Key_Adiaeresis,         XK_Adiaeresis },
172     { Qt::Key_Aring,              XK_Aring },
173     { Qt::Key_AE,                 XK_AE },
174     { Qt::Key_Ccedilla,           XK_Ccedilla },
175     { Qt::Key_Egrave,             XK_Egrave },
176     { Qt::Key_Eacute,             XK_Eacute },
177     { Qt::Key_Ecircumflex,        XK_Ecircumflex },
178     { Qt::Key_Ediaeresis,         XK_Ediaeresis },
179     { Qt::Key_Igrave,             XK_Igrave },
180     { Qt::Key_Iacute,             XK_Iacute },
181     { Qt::Key_Icircumflex,        XK_Icircumflex },
182     { Qt::Key_Idiaeresis,         XK_Idiaeresis },
183     { Qt::Key_ETH,                XK_ETH },
184     { Qt::Key_Ntilde,             XK_Ntilde },
185     { Qt::Key_Ograve,             XK_Ograve },
186     { Qt::Key_Oacute,             XK_Oacute },
187     { Qt::Key_Ocircumflex,        XK_Ocircumflex },
188     { Qt::Key_Otilde,             XK_Otilde },
189     { Qt::Key_Odiaeresis,         XK_Odiaeresis },
190     { Qt::Key_multiply,           XK_multiply },
191     { Qt::Key_Ooblique,           XK_Ooblique },
192     { Qt::Key_Ugrave,             XK_Ugrave },
193     { Qt::Key_Uacute,             XK_Uacute },
194     { Qt::Key_Ucircumflex,        XK_Ucircumflex },
195     { Qt::Key_Udiaeresis,         XK_Udiaeresis },
196     { Qt::Key_Yacute,             XK_Yacute },
197     { Qt::Key_THORN,              XK_THORN },
198     { Qt::Key_ssharp,             XK_ssharp },
199     { Qt::Key_division,           XK_division },
200     { Qt::Key_ydiaeresis,         XK_ydiaeresis },
201     { Qt::Key_Multi_key,          XK_Multi_key },
202     { Qt::Key_Codeinput,          XK_Codeinput },
203     { Qt::Key_SingleCandidate,    XK_SingleCandidate },
204     { Qt::Key_MultipleCandidate,  XK_MultipleCandidate },
205     { Qt::Key_PreviousCandidate,  XK_PreviousCandidate },
206     { Qt::Key_Mode_switch,        XK_Mode_switch },
207 #endif
208 
209 #ifdef HAVE_XF86KEYSYM_H
210     { Qt::Key_Back,               XF86XK_Back },
211     { Qt::Key_Forward,            XF86XK_Forward },
212     { Qt::Key_Stop,               XF86XK_Stop },
213     { Qt::Key_Refresh,            XF86XK_Refresh },
214     { Qt::Key_VolumeDown,         XF86XK_AudioLowerVolume },
215     { Qt::Key_VolumeMute,         XF86XK_AudioMute },
216     { Qt::Key_VolumeUp,           XF86XK_AudioRaiseVolume },
217     { Qt::Key_MediaPlay,          XF86XK_AudioPlay },
218     { Qt::Key_MediaStop,          XF86XK_AudioStop },
219     { Qt::Key_MediaPrevious,      XF86XK_AudioPrev },
220     { Qt::Key_MediaNext,          XF86XK_AudioNext },
221     { Qt::Key_MediaRecord,        XF86XK_AudioRecord },
222     { Qt::Key_MediaPause,	  XF86XK_AudioPause },
223     { Qt::Key_HomePage,           XF86XK_HomePage },
224     { Qt::Key_Favorites,          XF86XK_Favorites },
225     { Qt::Key_Search,             XF86XK_Search },
226     { Qt::Key_Standby,            XF86XK_Standby },
227     { Qt::Key_OpenUrl,            XF86XK_OpenURL },
228     { Qt::Key_LaunchMail,         XF86XK_Mail },
229     { Qt::Key_LaunchMedia,        XF86XK_AudioMedia },
230     { Qt::Key_Launch0,            XF86XK_MyComputer },
231     { Qt::Key_Launch1,            XF86XK_Calculator },
232     { Qt::Key_Launch2,            XF86XK_Launch0 },
233     { Qt::Key_Launch3,            XF86XK_Launch1 },
234     { Qt::Key_Launch4,            XF86XK_Launch2 },
235     { Qt::Key_Launch5,            XF86XK_Launch3 },
236     { Qt::Key_Launch6,            XF86XK_Launch4 },
237     { Qt::Key_Launch7,            XF86XK_Launch5 },
238     { Qt::Key_Launch8,            XF86XK_Launch6 },
239     { Qt::Key_Launch9,            XF86XK_Launch7 },
240     { Qt::Key_LaunchA,            XF86XK_Launch8 },
241     { Qt::Key_LaunchB,            XF86XK_Launch9 },
242     { Qt::Key_LaunchC,            XF86XK_LaunchA },
243     { Qt::Key_LaunchD,            XF86XK_LaunchB },
244     { Qt::Key_LaunchE,            XF86XK_LaunchC },
245     { Qt::Key_LaunchF,            XF86XK_LaunchD },
246     { Qt::Key_LaunchG,            XF86XK_LaunchE },
247     { Qt::Key_LaunchH,            XF86XK_LaunchF },
248 #endif
249 
250     {Qt::Key(0),                  0}
251 
252 };
253 }  // namespace
254 
255 #endif  // KEYMAPPER_X11_H
256