Compare commits

...

6 Commits

Author SHA1 Message Date
Mason Remaley
e5f7fa7cab
Merge 9ae058b208 into 506c11ba43 2025-07-05 14:09:06 -05:00
Jan Schürkamp
506c11ba43
Wayland: Ignore key repeat events when no window has keyboard focus (#2732)
* Wayland: Ignore key repeat events when no window has keyboard focus
2025-07-05 19:16:08 +02:00
Doug Binks
d30d63313c Examples: disable MSVC warning C5287 in nuklear.h
Latest MSVC has a warning `operands are different enum types` which this disables until upstream nuklear fixes this
2025-07-05 19:12:15 +02:00
Mason Remaley
9ae058b208 Slightly adjusts button mappings for compatibility with SDL game controller database 2024-07-05 22:11:59 -07:00
Mason Remaley
6836e650bc Remaps indices of buttons below the previous minimum
This prevents us from missing their inputs, while also maintaining
backwards compatibility with previous indices
2024-07-05 21:56:00 -07:00
Mason Remaley
5e1ec2444f Fixes an out of bounds joystick array access
Testing with an Xbox Series X controller. The extra button they
added directly under the Xbox button emits 0xA7 for me, which is
lower than BTN_MISC. As a result, when pressed, handleKeyEvent
was indexing an array with a negative index.

This commit adds a bounds check preventing the negative index, and
adds a second bounds check to a similar function preemptively.

It's possible that the better fix for this is to extend the range of
the buttons array so that this button can be mapped, but that may
need some disucssion first.
2024-07-05 20:17:02 -07:00
6 changed files with 39 additions and 13 deletions

View File

@ -229,7 +229,7 @@ video tutorials.
- Brandon Schaefer
- Sebastian Schuberth
- Scr3amer
- Jan Schuerkamp
- Jan Schürkamp
- Christian Sdunek
- Matt Sealey
- Steve Sexton

View File

@ -129,6 +129,7 @@ information on what to include when reporting a bug.
- [Wayland] Bugfix: The fractional scaling related objects were not destroyed
- [Wayland] Bugfix: `glfwInit` would segfault on compositor with no seat (#2517)
- [Wayland] Bugfix: A drag entering a non-GLFW surface could cause a segfault
- [Wayland] Bugfix: Ignore key repeat events when no window has keyboard focus (#2727)
- [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631)
- [Null] Added Vulkan 'window' surface creation via `VK_EXT_headless_surface`
- [Null] Added EGL context creation on Mesa via `EGL_MESA_platform_surfaceless`

5
deps/nuklear.h vendored
View File

@ -423,6 +423,11 @@ NK_STATIC_ASSERT(sizeof(nk_rune) >= 4);
NK_STATIC_ASSERT(sizeof(nk_size) >= sizeof(void*));
NK_STATIC_ASSERT(sizeof(nk_ptr) >= sizeof(void*));
#if defined(_MSC_VER)
/* disable `operands are different enum types` warning on MSVC */
#pragma warning( disable: 5287 )
#endif
/* ============================================================================
*
* API

View File

@ -50,7 +50,7 @@
static void handleKeyEvent(_GLFWjoystick* js, int code, int value)
{
_glfwInputJoystickButton(js,
js->linjs.keyMap[code - BTN_MISC],
js->linjs.keyMap[code],
value ? GLFW_PRESS : GLFW_RELEASE);
}
@ -190,12 +190,28 @@ static GLFWbool openJoystickDevice(const char* path)
int axisCount = 0, buttonCount = 0, hatCount = 0;
for (int code = BTN_MISC; code < KEY_CNT; code++)
// This loop should stop at KEY_CNT instead of KEY_MAX. However, we are
// terminating the loop one iteration early to maintain compatibility with
// the SDL gamepad mappings.
for (int code = BTN_JOYSTICK; code < KEY_MAX; code++)
{
if (!isBitSet(code, keyBits))
continue;
linjs.keyMap[code - BTN_MISC] = buttonCount;
linjs.keyMap[code] = buttonCount;
buttonCount++;
}
// Originally, this range was not mapped, but some controllers now output
// these values. Appending them to the end of the list maintains both
// backwards compatibility with older versions of GLFW, and with the SDL
// gamepad mappings.
for (int code = 0; code < BTN_JOYSTICK; code++)
{
if (!isBitSet(code, keyBits))
continue;
linjs.keyMap[code] = buttonCount;
buttonCount++;
}

View File

@ -37,7 +37,7 @@ typedef struct _GLFWjoystickLinux
{
int fd;
char path[PATH_MAX];
int keyMap[KEY_CNT - BTN_MISC];
int keyMap[KEY_CNT];
int absMap[ABS_CNT];
struct input_absinfo absInfo[ABS_CNT];
int hats[4][2];

View File

@ -1267,17 +1267,21 @@ static void handleEvents(double* timeout)
if (read(_glfw.wl.keyRepeatTimerfd, &repeats, sizeof(repeats)) == 8)
{
for (uint64_t i = 0; i < repeats; i++)
if(_glfw.wl.keyboardFocus)
{
_glfwInputKey(_glfw.wl.keyboardFocus,
translateKey(_glfw.wl.keyRepeatScancode),
_glfw.wl.keyRepeatScancode,
GLFW_PRESS,
_glfw.wl.xkb.modifiers);
inputText(_glfw.wl.keyboardFocus, _glfw.wl.keyRepeatScancode);
for (uint64_t i = 0; i < repeats; i++)
{
_glfwInputKey(_glfw.wl.keyboardFocus,
translateKey(_glfw.wl.keyRepeatScancode),
_glfw.wl.keyRepeatScancode,
GLFW_PRESS,
_glfw.wl.xkb.modifiers);
inputText(_glfw.wl.keyboardFocus, _glfw.wl.keyRepeatScancode);
}
event = GLFW_TRUE;
}
event = GLFW_TRUE;
}
}