Merge branch 'latest' into new-cursors-on-3.3-stable

This commit is contained in:
Camilla Löwy 2024-02-23 12:47:46 +01:00
commit e91fa399f1
24 changed files with 211 additions and 115 deletions

2
.github/CODEOWNERS vendored
View File

@ -1,8 +1,6 @@
* @elmindreda
src/wl_* @linkmauve
docs/*.css @glfw/webdev
docs/*.scss @glfw/webdev
docs/*.html @glfw/webdev

View File

@ -12,11 +12,12 @@ jobs:
build-linux-x11-clang:
name: X11 (Linux, Clang)
runs-on: ubuntu-latest
timeout-minutes: 4
env:
CC: clang
CFLAGS: -Werror
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt update
@ -35,11 +36,12 @@ jobs:
build-linux-wayland-clang:
name: Wayland (Linux, Clang)
runs-on: ubuntu-latest
timeout-minutes: 4
env:
CC: clang
CFLAGS: -Werror
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt update
@ -58,11 +60,12 @@ jobs:
build-linux-null-clang:
name: Null (Linux, Clang)
runs-on: ubuntu-latest
timeout-minutes: 4
env:
CC: clang
CFLAGS: -Werror
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt update
@ -81,11 +84,12 @@ jobs:
build-macos-cocoa-clang:
name: Cocoa (macOS, Clang)
runs-on: macos-latest
timeout-minutes: 4
env:
CFLAGS: -Werror
MACOSX_DEPLOYMENT_TARGET: 10.8
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Configure static library
run: cmake -S . -B build-static
@ -100,10 +104,11 @@ jobs:
build-windows-win32-vs2022:
name: Win32 (Windows, VS2022)
runs-on: windows-latest
timeout-minutes: 4
env:
CFLAGS: /WX
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Configure static library
run: cmake -S . -B build-static -G "Visual Studio 17 2022"

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
# The canonical out-of-tree build subdirectory
build
build-*
# Visual Studio clutter
_ReSharper*

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.0...3.20 FATAL_ERROR)
project(GLFW VERSION 3.3.9 LANGUAGES C)
project(GLFW VERSION 3.3.10 LANGUAGES C)
if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)

View File

@ -45,6 +45,7 @@ video tutorials.
- Bailey Cosier
- Noel Cower
- CuriouserThing
- Bill Currie
- Jason Daly
- danhambleton
- Jarrod Davis
@ -129,6 +130,7 @@ video tutorials.
- lo-v-ol
- Eyal Lotem
- Aaron Loucks
- Ned Loynd
- Luflosi
- lukect
- Tristam MacDonald
@ -161,6 +163,7 @@ video tutorials.
- Martins Mozeiko
- James Murphy
- Julian Møller
- NateIsStalling
- ndogxj
- F. Nedelec
- Kristian Nielsen
@ -202,6 +205,7 @@ video tutorials.
- Aleksey Rybalkin
- Mikko Rytkönen
- Riku Salminen
- Anton Samokhvalov
- Brandon Schaefer
- Sebastian Schuberth
- Christian Sdunek
@ -231,6 +235,7 @@ video tutorials.
- Paul Sultana
- Nathan Sweet
- TTK-Bandit
- Nuno Teixeira
- Sergey Tikhomirov
- Arthur Tombs
- TronicLabs
@ -253,6 +258,7 @@ video tutorials.
- Jay Weisskopf
- Frank Wille
- Richard A. Wilkes
- Andy Williams
- Tatsuya Yatagawa
- Ryogo Yoshimura
- Rácz Zalán

View File

@ -2,7 +2,6 @@
[![Build status](https://github.com/glfw/glfw/actions/workflows/build.yml/badge.svg)](https://github.com/glfw/glfw/actions)
[![Build status](https://ci.appveyor.com/api/projects/status/0kf0ct9831i5l6sp/branch/master?svg=true)](https://ci.appveyor.com/project/elmindreda/glfw)
[![Coverity Scan](https://scan.coverity.com/projects/4884/badge.svg)](https://scan.coverity.com/projects/glfw-glfw)
## Introduction
@ -123,33 +122,12 @@ information on what to include when reporting a bug.
## Changelog
- Bugfix: `glfwGetKeyScancode` returned `0` on error when initialized instead of `-1`
- Bugfix: Failure to make a newly created context current could cause segfault (#2327)
- [Win32] Fix pkg-config for dynamic library on Windows (#2386, #2420)
- [Win32] Bugfix: `glfwWaitEventsTimeout` did not return for some sent messages (#2408)
- [Win32] Bugfix: XInput could reportedly provide invalid DPad bit masks (#2291)
- [Cocoa] Bugfix: Compilation failed on OS X 10.8 due to unconditional use of 10.9+
symbols (#2161)
- [Cocoa] Bugfix: Full screen windows were resizable by the user (#2377,#2405)
- [Cocoa] Bugfix: Full screen windows were miniaturized when clicked on macOS
10.15 (#2377,#2405)
- [Cocoa] Bugfix: Querying joystick elements could reportedly segfault on macOS
13 Ventura (#2320)
- [Cocoa] Bugfix: Print Screen key was not correctly reported (#1786,#2169)
- [Wayland] Added improved fallback window decorations via libdecor (#1639,#1693)
- [Wayland] Bugfix: Connecting a mouse after `glfwInit` would segfault (#1450)
- [Wayland] Disabled alpha channel for opaque windows on systems lacking
`EGL_EXT_present_opaque` (#1895)
- [Wayland] Bugfix: Buffer would overrun when storing received drag offer (#2225)
- [Wayland] Bugfix: Joysticks connected after `glfwInit` were not detected (#2198)
- [Wayland] Bugfix: Fallback decorations emitted `GLFW_CURSOR_UNAVAILABLE` errors
- [Wayland] Bugfix: Some events could fail to end wait for new events (#2397)
- [Linux] Bugfix: Joysticks without buttons were ignored (#2042,#2043)
- [Linux] Bugfix: A small amount of memory could leak if initialization failed (#2229)
- [EGL] Added loading of glvnd `libOpenGL.so.0` where available for OpenGL
- [EGL] Bugfix: `EGL_EXT_present_opaque` caused issues on X11 with Nvidia blob (#2365)
- [EGL] Bugfix: Setting `GLFW_CONTEXT_DEBUG` caused creation to fail (#2348)
- [GLX] Added loading of glvnd `libGLX.so.0` where available
- Bugfix: `glfwGetKeyName` emitted `GLFW_INVALID_VALUE` for scancodes with no
key token (#1785,#2214)
- [Wayland] Bugfix: Terminating the library before showing a window could segfault
- [Wayland] Bugfix: Compilation failed on FreeBSD (#2445)
- [Linux] Bugfix: `regfree´ was called on invalid data (#2464)
- [WGL] Bugfix: Context creation failed in Parallels VM (#2191,#2406,#2467)
## Contact
@ -158,13 +136,12 @@ On [glfw.org](https://www.glfw.org/) you can find the latest version of GLFW, as
well as news, documentation and other information about the project.
If you have questions related to the use of GLFW, we have a
[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on
[Libera.Chat](https://libera.chat/).
[forum](https://discourse.glfw.org/).
If you have a bug to report, a patch to submit or a feature you'd like to
request, please file it in the
[issue tracker](https://github.com/glfw/glfw/issues) on GitHub.
Finally, if you're interested in helping out with the development of GLFW or
porting it to your favorite platform, join us on the forum, GitHub or IRC.
porting it to your favorite platform, join us on the forum or GitHub.

View File

@ -23,13 +23,12 @@ Questions about how to use GLFW should be asked either in the [support
section](https://discourse.glfw.org/c/support) of the forum, under the [Stack
Overflow tag](https://stackoverflow.com/questions/tagged/glfw) or [Game
Development tag](https://gamedev.stackexchange.com/questions/tagged/glfw) on
Stack Exchange or in the IRC channel `#glfw` on
[Libera.Chat](https://libera.chat/).
Stack Exchange.
Questions about the design or implementation of GLFW or about future plans
should be asked in the [dev section](https://discourse.glfw.org/c/dev) of the
forum or in the IRC channel. Please don't open a GitHub issue to discuss design
questions without first checking with a maintainer.
forum. Please don't open a GitHub issue to discuss design questions without
first checking with a maintainer.
## Reporting a bug

View File

@ -4,8 +4,7 @@ See the [latest documentation](https://www.glfw.org/docs/latest/) for tutorials,
guides and the API reference.
If you have questions about using GLFW, we have a
[forum](https://discourse.glfw.org/), and the `#glfw` IRC channel on
[Libera.Chat](https://libera.chat/).
[forum](https://discourse.glfw.org/).
Bugs are reported to our [issue tracker](https://github.com/glfw/glfw/issues).
Please check the [contribution

View File

@ -160,20 +160,94 @@ A good general introduction to linking is
David Drysdale.
@subsection build_link_win32 With MinGW or Visual C++ on Windows
@subsection build_link_win32 With Visual C++ and GLFW binaries
The static version of the GLFW library is named `glfw3`. When using this
version, it is also necessary to link with some libraries that GLFW uses.
If you are using a downloaded
[binary archive](https://www.glfw.org/download.html), first make sure you have
the archive matching the architecture you are building for (32-bit or 64-bit),
or you will get link errors. Also make sure you are using the binaries for your
version of Visual C++ or you may get other link errors.
When using MinGW to link an application with the static version of GLFW, you
must also explicitly link with `gdi32`. Other toolchains including MinGW-w64
include it in the set of default libraries along with other dependencies like
`user32` and `kernel32`.
There are two version of the static GLFW library in the binary archive, because
it needs to use the same base run-time library variant as the rest of your
executable.
The link library for the GLFW DLL is named `glfw3dll`. When compiling an
application that uses the DLL version of GLFW, you need to define the @ref
GLFW_DLL macro _before_ any inclusion of the GLFW header. This can be done
either with a compiler switch or by defining it in your source code.
One is named `glfw3.lib` and is for projects with the _Runtime Library_ project
option set to _Multi-threaded DLL_ or _Multi-threaded Debug DLL_. The other is
named `glfw3_mt.lib` and is for projects with _Runtime Library_ set to
_Multi-threaded_ or _Multi-threaded Debug_. To use the static GLFW library you
will need to add `path/to/glfw3.lib` or `path/to/glfw3_mt.lib` to the
_Additional Dependencies_ project option.
If you compiled a GLFW static library yourself then there will only be one,
named `glfw3.lib`, and you have to make sure the run-time library variant
matches.
The DLL version of the GLFW library is named `glfw3.dll`, but you will be
linking against the `glfw3dll.lib` link library. To use the DLL you will need
to add `path/to/glfw3dll.lib` to the _Additional Dependencies_ project option.
All of its dependencies are already listed there by default, but when building
with the DLL version of GLFW, you also need to define the @ref GLFW_DLL. This
can be done either in the _Preprocessor Definitions_ project option or by
defining it in your source code before including the GLFW header.
@code
#define GLFW_DLL
#include <GLFW/glfw3.h>
@endcode
All link-time dependencies for GLFW are already listed in the _Additional
Dependencies_ option by default.
@subsection build_link_mingw With MinGW-w64 and GLFW binaries
This is intended for building a program from the command-line or by writing
a makefile, on Windows with [MinGW-w64](https://www.mingw-w64.org/) and GLFW
binaries. These can be from a downloaded and extracted
[binary archive](https://www.glfw.org/download.html) or by compiling GLFW
yourself. The paths below assume a binary archive is used.
If you are using a downloaded binary archive, first make sure you have the
archive matching the architecture you are building for (32-bit or 64-bit) or you
will get link errors.
Note that the order of source files and libraries matter for GCC. Dependencies
must be listed after the files that depend on them. Any source files that
depend on GLFW must be listed before the GLFW library. GLFW in turn depends on
`gdi32` and must be listed before it.
If you are using the static version of the GLFW library, which is named
`libglfw3.a`, do:
@code{.sh}
gcc -o myprog myprog.c -I path/to/glfw/include path/to/glfw/lib-mingw-w64/libglfw3.a -lgdi32
@endcode
If you are using the DLL version of the GLFW library, which is named
`glfw3.dll`, you will need to use the `libglfw3dll.a` link library.
@code{.sh}
gcc -o myprog myprog.c -I path/to/glfw/include path/to/glfw/lib-mingw-w64/libglfw3dll.a -lgdi32
@endcode
The resulting executable will need to find `glfw3.dll` to run, typically by
keeping both files in the same directory.
When you are building with the DLL version of GLFW, you will also need to define
the @ref GLFW_DLL macro. This can be done in your source files, as long as it
done before including the GLFW header:
@code
#define GLFW_DLL
#include <GLFW/glfw3.h>
@endcode
It can also be done on the command-line:
@code{.sh}
gcc -o myprog myprog.c -D GLFW_DLL -I path/to/glfw/include path/to/glfw/lib-mingw-w64/libglfw3dll.a -lgdi32
@endcode
@subsection build_link_cmake_source With CMake and GLFW source
@ -271,7 +345,10 @@ target_link_libraries(myapp OpenGL::GL)
@endcode
@subsection build_link_pkgconfig With makefiles and pkg-config on Unix
@subsection build_link_pkgconfig With pkg-config and GLFW binaries on Unix
This is intended for building a program from the command-line or by writing
a makefile, on macOS or any Unix-like system like Linux, FreeBSD and Cygwin.
GLFW supports [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/),
and the `glfw3.pc` pkg-config file is generated when the GLFW library is built
@ -322,13 +399,13 @@ OpenGL and IOKit frameworks to the project as dependencies. They can all be
found in `/System/Library/Frameworks`.
@subsection build_link_osx With command-line on macOS
@subsection build_link_osx With command-line or makefile on macOS
It is recommended that you use [pkg-config](@ref build_link_pkgconfig) when
building from the command line on macOS. That way you will get any new
dependencies added automatically. If you still wish to build manually, you need
to add the required frameworks and libraries to your command-line yourself using
the `-l` and `-framework` switches.
using installed GLFW binaries from the command line on macOS. That way you will
get any new dependencies added automatically. If you still wish to build
manually, you need to add the required frameworks and libraries to your
command-line yourself using the `-l` and `-framework` switches.
If you are using the dynamic GLFW library, which is named `libglfw.3.dylib`, do:

View File

@ -97,11 +97,11 @@ On Fedora and derivatives like Red Hat you will need the `wayland-devel`,
sudo dnf install wayland-devel libxkbcommon-devel wayland-protocols-devel extra-cmake-modules
@endcode
On FreeBSD you will need the `wayland`, `libxkbcommon`, `wayland-protocols` and
`kf5-extra-cmake-modules` packages.
On FreeBSD you will need the `wayland`, `libxkbcommon`, `wayland-protocols`,
`evdev-proto` and `kf5-extra-cmake-modules` packages.
@code{.sh}
pkg install wayland libxkbcommon wayland-protocols kf5-extra-cmake-modules
pkg install wayland libxkbcommon wayland-protocols evdev-proto kf5-extra-cmake-modules
@endcode
Once you have the required depdendencies, move on to @ref compile_generate.

View File

@ -322,7 +322,7 @@ Starting with GLFW 3.3.7, events posted with @ref glfwPostEmptyEvent now use a s
unnamed pipe instead of sending an X11 client event to the helper window.
@subsubsection wayland_alpha_34 Frambuffer may lack alpha channel on older Wayland systems
@subsubsection wayland_alpha_33 Framebuffer may lack alpha channel on older Wayland systems
On Wayland, when creating an EGL context on a machine lacking the new
`EGL_EXT_present_opaque` extension, the @ref GLFW_ALPHA_BITS window hint will be

View File

@ -298,7 +298,7 @@ extern "C" {
* release is made that does not contain any API changes.
* @ingroup init
*/
#define GLFW_VERSION_REVISION 9
#define GLFW_VERSION_REVISION 10
/*! @} */
/*! @brief One.
@ -2688,8 +2688,8 @@ GLFWAPI void glfwWindowHintString(int hint, const char* value);
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_API_UNAVAILABLE, @ref
* GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE and @ref
* GLFW_PLATFORM_ERROR.
* GLFW_VERSION_UNAVAILABLE, @ref GLFW_FORMAT_UNAVAILABLE, @ref
* GLFW_NO_WINDOW_CONTEXT and @ref GLFW_PLATFORM_ERROR.
*
* @remark @win32 Window creation will fail if the Microsoft GDI software
* OpenGL implementation is the only one available.
@ -3638,11 +3638,15 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* window, int attrib);
* @param[in] value `GLFW_TRUE` or `GLFW_FALSE`.
*
* @errors Possible errors include @ref GLFW_NOT_INITIALIZED, @ref
* GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE and @ref GLFW_PLATFORM_ERROR.
* GLFW_INVALID_ENUM, @ref GLFW_INVALID_VALUE, @ref GLFW_PLATFORM_ERROR.
*
* @remark Calling @ref glfwGetWindowAttrib will always return the latest
* value, even if that value is ignored by the current mode of the window.
*
* @remark @wayland The [GLFW_FLOATING](@ref GLFW_FLOATING_attrib) window
* attribute is not supported. Setting this will emit @ref
* GLFW_PLATFORM_ERROR.
*
* @thread_safety This function must only be called from the main thread.
*
* @sa @ref window_attribs

View File

@ -1635,14 +1635,15 @@ const char* _glfwPlatformGetScancodeName(int scancode)
{
@autoreleasepool {
if (scancode < 0 || scancode > 0xff ||
_glfw.ns.keycodes[scancode] == GLFW_KEY_UNKNOWN)
if (scancode < 0 || scancode > 0xff)
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
return NULL;
}
const int key = _glfw.ns.keycodes[scancode];
if (key == GLFW_KEY_UNKNOWN)
return NULL;
UInt32 deadKeyState = 0;
UniChar characters[4];

View File

@ -637,7 +637,7 @@ GLFWAPI const char* glfwGetKeyName(int key, int scancode)
GLFWAPI int glfwGetKeyScancode(int key)
{
_GLFW_REQUIRE_INIT_OR_RETURN(-1);
_GLFW_REQUIRE_INIT_OR_RETURN(0);
if (key < GLFW_KEY_SPACE || key > GLFW_KEY_LAST)
{

View File

@ -334,8 +334,6 @@ void _glfwTerminateJoysticksLinux(void)
closeJoystick(js);
}
regfree(&_glfw.linjs.regex);
if (_glfw.linjs.inotify > 0)
{
if (_glfw.linjs.watch > 0)

View File

@ -161,7 +161,7 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
if (ctxconfig->client == GLFW_OPENGL_ES_API)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"NSGL: OpenGL ES is not available on macOS");
"NSGL: OpenGL ES is not available via NSGL");
return GLFW_FALSE;
}

View File

@ -27,13 +27,12 @@
// Please use C89 style variable declarations in this file because VS 2010
//========================================================================
#include "internal.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "internal.h"
static void makeContextCurrentOSMesa(_GLFWwindow* window)
{
if (window)

View File

@ -80,6 +80,23 @@ static int choosePixelFormat(_GLFWwindow* window,
if (_glfw.wgl.ARB_pixel_format)
{
// NOTE: In a Parallels VM WGL_ARB_pixel_format returns fewer pixel formats than
// DescribePixelFormat, violating the guarantees of the extension spec
// HACK: Iterate through the minimum of both counts
const int attrib = WGL_NUMBER_PIXEL_FORMATS_ARB;
int extensionCount;
if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc,
1, 0, 1, &attrib, &extensionCount))
{
_glfwInputErrorWin32(GLFW_PLATFORM_ERROR,
"WGL: Failed to retrieve pixel format attribute");
return 0;
}
nativeCount = _glfw_min(nativeCount, extensionCount);
addAttrib(WGL_SUPPORT_OPENGL_ARB);
addAttrib(WGL_DRAW_TO_WINDOW_ARB);
addAttrib(WGL_PIXEL_TYPE_ARB);

View File

@ -2191,14 +2191,19 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
const char* _glfwPlatformGetScancodeName(int scancode)
{
if (scancode < 0 || scancode > (KF_EXTENDED | 0xff) ||
_glfw.win32.keycodes[scancode] == GLFW_KEY_UNKNOWN)
int key;
if (scancode < 0 || scancode > (KF_EXTENDED | 0xff))
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
return NULL;
}
return _glfw.win32.keynames[_glfw.win32.keycodes[scancode]];
key = _glfw.win32.keycodes[scancode];
if (key == GLFW_KEY_UNKNOWN)
return NULL;
return _glfw.win32.keynames[key];
}
int _glfwPlatformGetKeyScancode(int key)

View File

@ -694,7 +694,7 @@ GLFWAPI float glfwGetWindowOpacity(GLFWwindow* handle)
_GLFWwindow* window = (_GLFWwindow*) handle;
assert(window != NULL);
_GLFW_REQUIRE_INIT_OR_RETURN(1.f);
_GLFW_REQUIRE_INIT_OR_RETURN(0.f);
return _glfwPlatformGetWindowOpacity(window);
}

View File

@ -637,10 +637,15 @@ void _glfwPlatformTerminate(void)
_glfwTerminateEGL();
_glfwTerminateOSMesa();
if (_glfw.wl.libdecor.callback)
wl_callback_destroy(_glfw.wl.libdecor.callback);
if (_glfw.wl.libdecor.context)
{
// Allow libdecor to finish receiving all its requested globals
// and ensure the associated sync callback object is destroyed
while (!_glfw.wl.libdecor.ready)
_glfwPlatformWaitEvents();
libdecor_unref(_glfw.wl.libdecor.context);
}
if (_glfw.wl.libdecor.handle)
{

View File

@ -42,6 +42,7 @@
#include <poll.h>
#include <signal.h>
#include <time.h>
#include <linux/input-event-codes.h>
#define GLFW_BORDER_SIZE 4
#define GLFW_CAPTION_HEIGHT 24
@ -1537,24 +1538,14 @@ static void pointerHandleAxis(void* userData,
wl_fixed_t value)
{
_GLFWwindow* window = _glfw.wl.pointerFocus;
double x = 0.0, y = 0.0;
// Wayland scroll events are in pointer motion coordinate space (think two
// finger scroll). The factor 10 is commonly used to convert to "scroll
// step means 1.0.
const double scrollFactor = 1.0 / 10.0;
if (!window)
return;
assert(axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL ||
axis == WL_POINTER_AXIS_VERTICAL_SCROLL);
// NOTE: 10 units of motion per mouse wheel step seems to be a common ratio
if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
x = -wl_fixed_to_double(value) * scrollFactor;
_glfwInputScroll(window, -wl_fixed_to_double(value) / 10.0, 0.0);
else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
y = -wl_fixed_to_double(value) * scrollFactor;
_glfwInputScroll(window, x, y);
_glfwInputScroll(window, 0.0, -wl_fixed_to_double(value) / 10.0);
}
static const struct wl_pointer_listener pointerListener =
@ -2563,8 +2554,7 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
const char* _glfwPlatformGetScancodeName(int scancode)
{
if (scancode < 0 || scancode > 255 ||
_glfw.wl.keycodes[scancode] == GLFW_KEY_UNKNOWN)
if (scancode < 0 || scancode > 255)
{
_glfwInputError(GLFW_INVALID_VALUE,
"Wayland: Invalid scancode %i",
@ -2573,6 +2563,9 @@ const char* _glfwPlatformGetScancodeName(int scancode)
}
const int key = _glfw.wl.keycodes[scancode];
if (key == GLFW_KEY_UNKNOWN)
return NULL;
const xkb_keycode_t keycode = scancode + 8;
const xkb_layout_index_t layout =
xkb_state_key_get_layout(_glfw.wl.xkb.state, keycode);

View File

@ -2930,14 +2930,16 @@ const char* _glfwPlatformGetScancodeName(int scancode)
if (!_glfw.x11.xkb.available)
return NULL;
if (scancode < 0 || scancode > 0xff ||
_glfw.x11.keycodes[scancode] == GLFW_KEY_UNKNOWN)
if (scancode < 0 || scancode > 0xff)
{
_glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
return NULL;
}
const int key = _glfw.x11.keycodes[scancode];
if (key == GLFW_KEY_UNKNOWN)
return NULL;
const KeySym keysym = XkbKeycodeToKeysym(_glfw.x11.display,
scancode, _glfw.x11.xkb.group, 0);
if (keysym == NoSymbol)

View File

@ -393,24 +393,34 @@ static void scroll_callback(GLFWwindow* window, double x, double y)
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
Slot* slot = glfwGetWindowUserPointer(window);
const char* name = glfwGetKeyName(key, scancode);
if (name)
if (key == GLFW_KEY_UNKNOWN)
{
printf("%08x to %i at %0.3f: Key 0x%04x Scancode 0x%04x (%s) (%s) (with%s) was %s\n",
counter++, slot->number, glfwGetTime(), key, scancode,
get_key_name(key),
name,
get_mods_name(mods),
get_action_name(action));
printf("%08x to %i at %0.3f: Key (%s) Scancode 0x%04x (with%s) was %s\n",
counter++, slot->number, glfwGetTime(),
get_key_name(key), scancode,
get_mods_name(mods),
get_action_name(action));
}
else
{
printf("%08x to %i at %0.3f: Key 0x%04x Scancode 0x%04x (%s) (with%s) was %s\n",
counter++, slot->number, glfwGetTime(), key, scancode,
get_key_name(key),
get_mods_name(mods),
get_action_name(action));
const char* name = glfwGetKeyName(key, scancode);
if (name)
{
printf("%08x to %i at %0.3f: Key 0x%04x (%s) Scancode 0x%04x Name %s (with%s) was %s\n",
counter++, slot->number, glfwGetTime(),
key, get_key_name(key), scancode, name,
get_mods_name(mods),
get_action_name(action));
}
else
{
printf("%08x to %i at %0.3f: Key 0x%04x (%s) Scancode 0x%04x (with%s) was %s\n",
counter++, slot->number, glfwGetTime(),
key, get_key_name(key), scancode,
get_mods_name(mods),
get_action_name(action));
}
}
if (action != GLFW_PRESS)