Made the X keyboard extension required.
This commit is contained in:
parent
9bfb925d1a
commit
be8856af65
@ -156,8 +156,9 @@ if (_GLFW_X11)
|
|||||||
|
|
||||||
# Check for Xkb (X keyboard extension)
|
# Check for Xkb (X keyboard extension)
|
||||||
if (X11_Xkb_FOUND)
|
if (X11_Xkb_FOUND)
|
||||||
set(_GLFW_HAS_XKB 1)
|
|
||||||
list(APPEND glfw_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH})
|
list(APPEND glfw_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH})
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "The X keyboard extension was not found")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_library(RT_LIBRARY rt)
|
find_library(RT_LIBRARY rt)
|
||||||
|
@ -62,9 +62,6 @@
|
|||||||
// Define this to 1 if Xf86VidMode is available
|
// Define this to 1 if Xf86VidMode is available
|
||||||
#cmakedefine _GLFW_HAS_XF86VIDMODE
|
#cmakedefine _GLFW_HAS_XF86VIDMODE
|
||||||
|
|
||||||
// Define this to 1 if Xkb is available
|
|
||||||
#cmakedefine _GLFW_HAS_XKB
|
|
||||||
|
|
||||||
// Define this to 1 if glXGetProcAddress is available
|
// Define this to 1 if glXGetProcAddress is available
|
||||||
#cmakedefine _GLFW_HAS_GLXGETPROCADDRESS
|
#cmakedefine _GLFW_HAS_GLXGETPROCADDRESS
|
||||||
// Define this to 1 if glXGetProcAddressARB is available
|
// Define this to 1 if glXGetProcAddressARB is available
|
||||||
|
@ -51,11 +51,7 @@ static int keyCodeToGLFWKeyCode(int keyCode)
|
|||||||
// Note: This way we always force "NumLock = ON", which is intentional
|
// Note: This way we always force "NumLock = ON", which is intentional
|
||||||
// since the returned key code should correspond to a physical
|
// since the returned key code should correspond to a physical
|
||||||
// location.
|
// location.
|
||||||
#if defined(_GLFW_HAS_XKB)
|
|
||||||
keySym = XkbKeycodeToKeysym(_glfw.x11.display, keyCode, 1, 0);
|
keySym = XkbKeycodeToKeysym(_glfw.x11.display, keyCode, 1, 0);
|
||||||
#else
|
|
||||||
keySym = XKeycodeToKeysym(_glfw.x11.display, keyCode, 1);
|
|
||||||
#endif
|
|
||||||
switch (keySym)
|
switch (keySym)
|
||||||
{
|
{
|
||||||
case XK_KP_0: return GLFW_KEY_KP_0;
|
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
|
// Now try pimary keysym for function keys (non-printable keys). These
|
||||||
// should not be layout dependent (i.e. US layout and international
|
// should not be layout dependent (i.e. US layout and international
|
||||||
// layouts should give the same result).
|
// layouts should give the same result).
|
||||||
#if defined(_GLFW_HAS_XKB)
|
|
||||||
keySym = XkbKeycodeToKeysym(_glfw.x11.display, keyCode, 0, 0);
|
keySym = XkbKeycodeToKeysym(_glfw.x11.display, keyCode, 0, 0);
|
||||||
#else
|
|
||||||
keySym = XKeycodeToKeysym(_glfw.x11.display, keyCode, 0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (keySym)
|
switch (keySym)
|
||||||
{
|
{
|
||||||
case XK_Escape: return GLFW_KEY_ESCAPE;
|
case XK_Escape: return GLFW_KEY_ESCAPE;
|
||||||
@ -230,20 +221,16 @@ static int keyCodeToGLFWKeyCode(int keyCode)
|
|||||||
|
|
||||||
static void updateKeyCodeLUT(void)
|
static void updateKeyCodeLUT(void)
|
||||||
{
|
{
|
||||||
int keyCode;
|
int i, keyCode, keyCodeGLFW;
|
||||||
|
char name[XkbKeyNameLength + 1];
|
||||||
|
XkbDescPtr descr;
|
||||||
|
|
||||||
// Clear the LUT
|
// Clear the LUT
|
||||||
for (keyCode = 0; keyCode < 256; keyCode++)
|
for (keyCode = 0; keyCode < 256; keyCode++)
|
||||||
_glfw.x11.keyCodeLUT[keyCode] = -1;
|
_glfw.x11.keyCodeLUT[keyCode] = -1;
|
||||||
|
|
||||||
#if defined(_GLFW_HAS_XKB)
|
// Use XKB to determine physical key locations independently of the current
|
||||||
// If the Xkb extension is available, use it to determine physical key
|
// keyboard layout
|
||||||
// locations independently of the current keyboard layout
|
|
||||||
if (_glfw.x11.xkb.available)
|
|
||||||
{
|
|
||||||
int i, keyCodeGLFW;
|
|
||||||
char name[XkbKeyNameLength + 1];
|
|
||||||
XkbDescPtr descr;
|
|
||||||
|
|
||||||
// Get keyboard description
|
// Get keyboard description
|
||||||
descr = XkbGetKeyboard(_glfw.x11.display,
|
descr = XkbGetKeyboard(_glfw.x11.display,
|
||||||
@ -320,8 +307,6 @@ static void updateKeyCodeLUT(void)
|
|||||||
|
|
||||||
// Free the keyboard description
|
// Free the keyboard description
|
||||||
XkbFreeKeyboard(descr, 0, True);
|
XkbFreeKeyboard(descr, 0, True);
|
||||||
}
|
|
||||||
#endif /* _GLFW_HAS_XKB */
|
|
||||||
|
|
||||||
// Translate the un-translated key codes using traditional X11 KeySym
|
// Translate the un-translated key codes using traditional X11 KeySym
|
||||||
// lookups
|
// lookups
|
||||||
@ -530,19 +515,19 @@ static GLboolean initDisplay(void)
|
|||||||
#endif /*_GLFW_HAS_XRANDR*/
|
#endif /*_GLFW_HAS_XRANDR*/
|
||||||
|
|
||||||
// Check if Xkb is supported on this display
|
// Check if Xkb is supported on this display
|
||||||
#if defined(_GLFW_HAS_XKB)
|
|
||||||
_glfw.x11.xkb.versionMajor = 1;
|
_glfw.x11.xkb.versionMajor = 1;
|
||||||
_glfw.x11.xkb.versionMinor = 0;
|
_glfw.x11.xkb.versionMinor = 0;
|
||||||
_glfw.x11.xkb.available =
|
if (!XkbQueryExtension(_glfw.x11.display,
|
||||||
XkbQueryExtension(_glfw.x11.display,
|
|
||||||
&_glfw.x11.xkb.majorOpcode,
|
&_glfw.x11.xkb.majorOpcode,
|
||||||
&_glfw.x11.xkb.eventBase,
|
&_glfw.x11.xkb.eventBase,
|
||||||
&_glfw.x11.xkb.errorBase,
|
&_glfw.x11.xkb.errorBase,
|
||||||
&_glfw.x11.xkb.versionMajor,
|
&_glfw.x11.xkb.versionMajor,
|
||||||
&_glfw.x11.xkb.versionMinor);
|
&_glfw.x11.xkb.versionMinor))
|
||||||
#else
|
{
|
||||||
_glfw.x11.xkb.available = GL_FALSE;
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||||
#endif /* _GLFW_HAS_XKB */
|
"X11: The keyboard extension is not available");
|
||||||
|
return GL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
// Update the key code LUT
|
// Update the key code LUT
|
||||||
// FIXME: We should listen to XkbMapNotify events to track changes to
|
// 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)
|
#if !defined(_GLFW_HAS_XRANDR) && !defined(_GLFW_HAS_XF86VIDMODE)
|
||||||
" no-mode-switching-support"
|
" no-mode-switching-support"
|
||||||
#endif
|
#endif
|
||||||
#if defined(_GLFW_HAS_XKB)
|
|
||||||
" Xkb"
|
|
||||||
#endif
|
|
||||||
#if defined(_GLFW_HAS_GLXGETPROCADDRESS)
|
#if defined(_GLFW_HAS_GLXGETPROCADDRESS)
|
||||||
" glXGetProcAddress"
|
" glXGetProcAddress"
|
||||||
#elif defined(_GLFW_HAS_GLXGETPROCADDRESSARB)
|
#elif defined(_GLFW_HAS_GLXGETPROCADDRESSARB)
|
||||||
|
@ -49,9 +49,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// The Xkb extension provides improved keyboard support
|
// The Xkb extension provides improved keyboard support
|
||||||
#if defined(_GLFW_HAS_XKB)
|
|
||||||
#include <X11/XKBlib.h>
|
#include <X11/XKBlib.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_GLFW_GLX)
|
#if defined(_GLFW_GLX)
|
||||||
#define _GLFW_X11_CONTEXT_VISUAL window->glx.visual
|
#define _GLFW_X11_CONTEXT_VISUAL window->glx.visual
|
||||||
@ -155,7 +153,6 @@ typedef struct _GLFWlibraryX11
|
|||||||
} randr;
|
} randr;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
GLboolean available;
|
|
||||||
int majorOpcode;
|
int majorOpcode;
|
||||||
int eventBase;
|
int eventBase;
|
||||||
int errorBase;
|
int errorBase;
|
||||||
|
Loading…
Reference in New Issue
Block a user