|
|
|
@ -51,11 +51,7 @@ static int keyCodeToGLFWKeyCode(int keyCode) |
|
|
|
|
// Note: This way we always force "NumLock = ON", which is intentional
|
|
|
|
|
// since the returned key code should correspond to a physical
|
|
|
|
|
// location.
|
|
|
|
|
#if defined(_GLFW_HAS_XKB) |
|
|
|
|
keySym = XkbKeycodeToKeysym(_glfw.x11.display, keyCode, 1, 0); |
|
|
|
|
#else |
|
|
|
|
keySym = XKeycodeToKeysym(_glfw.x11.display, keyCode, 1); |
|
|
|
|
#endif |
|
|
|
|
switch (keySym) |
|
|
|
|
{ |
|
|
|
|
case XK_KP_0: return GLFW_KEY_KP_0; |
|
|
|
@ -78,12 +74,7 @@ static int keyCodeToGLFWKeyCode(int keyCode) |
|
|
|
|
// Now try pimary keysym for function keys (non-printable keys). These
|
|
|
|
|
// should not be layout dependent (i.e. US layout and international
|
|
|
|
|
// layouts should give the same result).
|
|
|
|
|
#if defined(_GLFW_HAS_XKB) |
|
|
|
|
keySym = XkbKeycodeToKeysym(_glfw.x11.display, keyCode, 0, 0); |
|
|
|
|
#else |
|
|
|
|
keySym = XKeycodeToKeysym(_glfw.x11.display, keyCode, 0); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
switch (keySym) |
|
|
|
|
{ |
|
|
|
|
case XK_Escape: return GLFW_KEY_ESCAPE; |
|
|
|
@ -230,20 +221,16 @@ static int keyCodeToGLFWKeyCode(int keyCode) |
|
|
|
|
|
|
|
|
|
static void updateKeyCodeLUT(void) |
|
|
|
|
{ |
|
|
|
|
int keyCode; |
|
|
|
|
int i, keyCode, keyCodeGLFW; |
|
|
|
|
char name[XkbKeyNameLength + 1]; |
|
|
|
|
XkbDescPtr descr; |
|
|
|
|
|
|
|
|
|
// Clear the LUT
|
|
|
|
|
for (keyCode = 0; keyCode < 256; keyCode++) |
|
|
|
|
_glfw.x11.keyCodeLUT[keyCode] = -1; |
|
|
|
|
|
|
|
|
|
#if defined(_GLFW_HAS_XKB) |
|
|
|
|
// If the Xkb extension is available, use it to determine physical key
|
|
|
|
|
// locations independently of the current keyboard layout
|
|
|
|
|
if (_glfw.x11.xkb.available) |
|
|
|
|
{ |
|
|
|
|
int i, keyCodeGLFW; |
|
|
|
|
char name[XkbKeyNameLength + 1]; |
|
|
|
|
XkbDescPtr descr; |
|
|
|
|
// Use XKB to determine physical key locations independently of the current
|
|
|
|
|
// keyboard layout
|
|
|
|
|
|
|
|
|
|
// Get keyboard description
|
|
|
|
|
descr = XkbGetKeyboard(_glfw.x11.display, |
|
|
|
@ -320,8 +307,6 @@ static void updateKeyCodeLUT(void) |
|
|
|
|
|
|
|
|
|
// Free the keyboard description
|
|
|
|
|
XkbFreeKeyboard(descr, 0, True); |
|
|
|
|
} |
|
|
|
|
#endif /* _GLFW_HAS_XKB */ |
|
|
|
|
|
|
|
|
|
// Translate the un-translated key codes using traditional X11 KeySym
|
|
|
|
|
// lookups
|
|
|
|
@ -530,19 +515,19 @@ static GLboolean initDisplay(void) |
|
|
|
|
#endif /*_GLFW_HAS_XRANDR*/ |
|
|
|
|
|
|
|
|
|
// Check if Xkb is supported on this display
|
|
|
|
|
#if defined(_GLFW_HAS_XKB) |
|
|
|
|
_glfw.x11.xkb.versionMajor = 1; |
|
|
|
|
_glfw.x11.xkb.versionMinor = 0; |
|
|
|
|
_glfw.x11.xkb.available = |
|
|
|
|
XkbQueryExtension(_glfw.x11.display, |
|
|
|
|
if (!XkbQueryExtension(_glfw.x11.display, |
|
|
|
|
&_glfw.x11.xkb.majorOpcode, |
|
|
|
|
&_glfw.x11.xkb.eventBase, |
|
|
|
|
&_glfw.x11.xkb.errorBase, |
|
|
|
|
&_glfw.x11.xkb.versionMajor, |
|
|
|
|
&_glfw.x11.xkb.versionMinor); |
|
|
|
|
#else |
|
|
|
|
_glfw.x11.xkb.available = GL_FALSE; |
|
|
|
|
#endif /* _GLFW_HAS_XKB */ |
|
|
|
|
&_glfw.x11.xkb.versionMinor)) |
|
|
|
|
{ |
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR, |
|
|
|
|
"X11: The keyboard extension is not available"); |
|
|
|
|
return GL_FALSE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Update the key code LUT
|
|
|
|
|
// FIXME: We should listen to XkbMapNotify events to track changes to
|
|
|
|
@ -698,9 +683,6 @@ const char* _glfwPlatformGetVersionString(void) |
|
|
|
|
#if !defined(_GLFW_HAS_XRANDR) && !defined(_GLFW_HAS_XF86VIDMODE) |
|
|
|
|
" no-mode-switching-support" |
|
|
|
|
#endif |
|
|
|
|
#if defined(_GLFW_HAS_XKB) |
|
|
|
|
" Xkb" |
|
|
|
|
#endif |
|
|
|
|
#if defined(_GLFW_HAS_GLXGETPROCADDRESS) |
|
|
|
|
" glXGetProcAddress" |
|
|
|
|
#elif defined(_GLFW_HAS_GLXGETPROCADDRESSARB) |
|
|
|
|