1 /* Copyright (C)2014, 2016 D. R. Commander
2 *
3 * This library is free software and may be redistributed and/or modified under
4 * the terms of the wxWindows Library License, Version 3.1 or (at your option)
5 * any later version. The full license is in the LICENSE.txt file included
6 * with this distribution.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * wxWindows Library License for more details.
12 */
13
14 #ifndef __KEYCODETOKEYSYM_H__
15 #define __KEYCODETOKEYSYM_H__
16
17 #include <X11/Xlib.h>
18
19
KeycodeToKeysym(Display * dpy,KeyCode keycode,int index)20 static KeySym KeycodeToKeysym(Display *dpy, KeyCode keycode, int index)
21 {
22 KeySym ks = NoSymbol, *keysyms; int n = 0;
23
24 keysyms = XGetKeyboardMapping(dpy, keycode, 1, &n);
25 if(keysyms)
26 {
27 if(n >= 1 && index >= 0 && index < n)
28 ks = keysyms[index];
29 XFree(keysyms);
30 }
31
32 return ks;
33 }
34
35 #endif
36