mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 02:38:52 -05:00
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)
|
||||
if (X11_Xkb_FOUND)
|
||||
set(_GLFW_HAS_XKB 1)
|
||||
list(APPEND glfw_INCLUDE_DIR ${X11_Xkb_INCLUDE_PATH})
|
||||
else()
|
||||
message(FATAL_ERROR "The X keyboard extension was not found")
|
||||
endif()
|
||||
|
||||
find_library(RT_LIBRARY rt)
|
||||
|
|
|
@ -62,9 +62,6 @@
|
|||
// Define this to 1 if Xf86VidMode is available
|
||||
#cmakedefine _GLFW_HAS_XF86VIDMODE
|
||||
|
||||
// Define this to 1 if Xkb is available
|
||||
#cmakedefine _GLFW_HAS_XKB
|
||||
|
||||
// Define this to 1 if glXGetProcAddress is available
|
||||
#cmakedefine _GLFW_HAS_GLXGETPROCADDRESS
|
||||
// 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
|
||||
// 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)
|
||||
|
|
|
@ -49,9 +49,7 @@
|
|||
#endif
|
||||
|
||||
// The Xkb extension provides improved keyboard support
|
||||
#if defined(_GLFW_HAS_XKB)
|
||||
#include <X11/XKBlib.h>
|
||||
#endif
|
||||
|
||||
#if defined(_GLFW_GLX)
|
||||
#define _GLFW_X11_CONTEXT_VISUAL window->glx.visual
|
||||
|
@ -155,7 +153,6 @@ typedef struct _GLFWlibraryX11
|
|||
} randr;
|
||||
|
||||
struct {
|
||||
GLboolean available;
|
||||
int majorOpcode;
|
||||
int eventBase;
|
||||
int errorBase;
|
||||
|
|
Loading…
Reference in New Issue
Block a user