From bb34c40193c3c34dea5567d9567bc688f64d661c Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Tue, 3 Nov 2026 16:21:12 -0500 Subject: [PATCH] fix(windows): preserve remapped volume keys --- tests/unit/test_keyboard.cpp | 27 +++++++++++++++++++++++++-- third-party/libvirtualhid | 2 +- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/tests/unit/test_keyboard.cpp b/tests/unit/test_keyboard.cpp index 20c002cdb2b..48407ac6548 100644 --- a/tests/unit/test_keyboard.cpp +++ b/tests/unit/test_keyboard.cpp @@ -13,8 +13,8 @@ * that only compile on their own platform. * * These tests record keyboard output instead of delivering it, so they never type into the - * machine running the suite. One test deliberately clears the recorder to prove the real - * delivery path still reaches the virtual keyboard. + * machine running the suite. Tests that clear the recorder exercise the real delivery path + * through the platform adapter to a fake virtual keyboard, including F17/F18 volume remapping. */ // test includes @@ -706,6 +706,29 @@ TEST_F(KeyboardPassthroughTest, EmitsRemappedKeycodesFromKeybindings) { EXPECT_EQ(taken(), (std::vector {pressed(VKEY_A), released(VKEY_A)})); } +TEST_F(KeyboardPassthroughTest, RemapsFunctionKeysToVolumeKeysThroughThePlatformAdapter) { + // Issue #4981: F17/F18 must reach the backend as volume keys, with no client extended bit. + config::input.keybindings = {{0x80, 0xAE}, {0x81, 0xAF}}; + input::testing::set_keyboard_sink({}); + + for (const auto flags : {0U, static_cast(SS_KBE_FLAG_NON_NORMALIZED)}) { + for (const auto &[client, host] : config::input.keybindings) { + SCOPED_TRACE(hex(client)); + SCOPED_TRACE(flags); + const auto prior_count = fake_keyboard().submit_count(); + press(client, 0, flags); + auto event = fake_keyboard().last_submitted_event(); + EXPECT_EQ(event.key_code, host); + EXPECT_TRUE(event.pressed); + release(client, 0, flags); + event = fake_keyboard().last_submitted_event(); + EXPECT_EQ(event.key_code, host); + EXPECT_FALSE(event.pressed); + EXPECT_EQ(fake_keyboard().submit_count(), prior_count + 2U); + } + } +} + TEST_F(KeyboardPassthroughTest, DoesNotInjectSyntheticAltWhenAltIsRemappedToMeta) { // Regression test for the Cmd+Space report: a macOS host swaps Super and Alt so a PC keyboard // gets positional Option and Command. shortcutFlags is compared against the client's modifier diff --git a/third-party/libvirtualhid b/third-party/libvirtualhid index bac32371e38..9f4cac3fff7 160000 --- a/third-party/libvirtualhid +++ b/third-party/libvirtualhid @@ -1 +1 @@ -Subproject commit bac32371e383723af12ba7198ab56ca3bd3f7807 +Subproject commit 9f4cac3fff75430c028ef8bb8ddc4459968949f8