From: Benjamin Tissoires <bentiss@kernel.org>
To: Jiri Kosina <jikos@kernel.org>,
Peter Hutterer <peter.hutterer@who-t.net>
Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
Benjamin Tissoires <bentiss@kernel.org>,
Werner Sembach <wse@tuxedocomputers.com>
Subject: [PATCH 2/7] HID: bpf: Suppress bogus F13 trigger on Sirius keyboard full fan shortcut
Date: Fri, 07 Feb 2025 14:55:58 +0100 [thread overview]
Message-ID: <20250207-bpf-import-2025-02-07-v1-2-6048fdd5a206@kernel.org> (raw)
In-Reply-To: <20250207-bpf-import-2025-02-07-v1-0-6048fdd5a206@kernel.org>
The TUXEDO Sirius 16 Gen1 and the TUXEDO Sirius 16 Gen2 Notebooks have an
additional "fan" key next to F12.
Pressing it alone sends a F14 key press which can be bound by user space.
Pressing it while holding the FN key triggers two things:
- The EC firmware locks the fan speed of the internal fans at 100%
- F13 key press is registered which by default is already bound in xkb and
desktop environments (e.g. in KDE Plasma it launches system settings)
To avoid this unexpected double duty of the FN shortcut, this bpf program
suppresses the F13 key press.
Signed-off-by: Werner Sembach <wse@tuxedocomputers.com>
Link: https://gitlab.freedesktop.org/libevdev/udev-hid-bpf/-/merge_requests/166
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
---
.../progs/TUXEDO__Sirius-16-Gen1-and-Gen2.bpf.c | 47 ++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/drivers/hid/bpf/progs/TUXEDO__Sirius-16-Gen1-and-Gen2.bpf.c b/drivers/hid/bpf/progs/TUXEDO__Sirius-16-Gen1-and-Gen2.bpf.c
new file mode 100644
index 0000000000000000000000000000000000000000..a123003fb5fdd0a27bc204b9b393da52b0956cfa
--- /dev/null
+++ b/drivers/hid/bpf/progs/TUXEDO__Sirius-16-Gen1-and-Gen2.bpf.c
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/* Copyright (c) 2025 TUXEDO Computers GmbH
+ */
+
+#include "vmlinux.h"
+#include "hid_bpf.h"
+#include "hid_bpf_helpers.h"
+#include <bpf/bpf_tracing.h>
+
+HID_BPF_CONFIG(
+ HID_DEVICE(BUS_USB, HID_GROUP_GENERIC, 0x048D, 0x8910)
+);
+
+SEC(HID_BPF_DEVICE_EVENT)
+int BPF_PROG(ignore_key_fix_event, struct hid_bpf_ctx *hid_ctx)
+{
+ const int expected_length = 37;
+ const int expected_report_id = 1;
+ __u8 *data;
+ int i;
+
+ if (hid_ctx->size < expected_length)
+ return 0;
+
+ data = hid_bpf_get_data(hid_ctx, 0, expected_length);
+ if (!data || data[0] != expected_report_id)
+ return 0;
+
+ // Zero out F13 (HID usage ID: 0x68) key press.
+ // The first 6 parallel key presses (excluding modifier keys) are
+ // encoded in an array containing usage IDs.
+ for (i = 3; i < 9; ++i)
+ if (data[i] == 0x68)
+ data[i] = 0x00;
+ // Additional parallel key presses starting with the 7th (excluding
+ // modifier keys) are encoded as a bit flag with the offset being
+ // the usage ID.
+ data[22] &= 0xfe;
+
+ return 0;
+}
+
+HID_BPF_OPS(ignore_button) = {
+ .hid_device_event = (void *)ignore_key_fix_event,
+};
+
+char _license[] SEC("license") = "GPL";
--
2.47.0
next prev parent reply other threads:[~2025-02-07 13:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-07 13:55 [PATCH 0/7] HID: bpf: sync with udev-hid-bpf Benjamin Tissoires
2025-02-07 13:55 ` [PATCH 1/7] HID: bpf: Add support for the default firmware mode of the Huion K20 Benjamin Tissoires
2025-02-07 13:55 ` Benjamin Tissoires [this message]
2025-02-07 13:55 ` [PATCH 3/7] HID: bpf: Added updated Kamvas Pro 19 descriptor Benjamin Tissoires
2025-02-07 13:56 ` [PATCH 4/7] HID: bpf: add support for the XP-Pen Artist Pro 19 (gen2) Benjamin Tissoires
2025-02-07 13:56 ` [PATCH 5/7] HID: bpf: import new kfunc from v6.10 & v6.11 Benjamin Tissoires
2025-02-07 13:56 ` [PATCH 6/7] HID: bpf: new hid_bpf_async.h common header Benjamin Tissoires
2025-02-07 13:56 ` [PATCH 7/7] HID: bpf: add a v6.11+ compatible BPF fixup for the XPPen ACK05 remote Benjamin Tissoires
2025-02-07 14:49 ` [PATCH 0/7] HID: bpf: sync with udev-hid-bpf Jiri Kosina
2025-02-24 8:35 ` Benjamin Tissoires
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250207-bpf-import-2025-02-07-v1-2-6048fdd5a206@kernel.org \
--to=bentiss@kernel.org \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peter.hutterer@who-t.net \
--cc=wse@tuxedocomputers.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).