-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Report fn key and lock states via HID #55
Open
Jules-Bertholet
wants to merge
2
commits into
FrameworkComputer:fwk-hx20-hx30-4410
Choose a base branch
from
Jules-Bertholet:fn-key-hid
base: fwk-hx20-hx30-4410
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Report fn key and lock states via HID #55
Jules-Bertholet
wants to merge
2
commits into
FrameworkComputer:fwk-hx20-hx30-4410
from
Jules-Bertholet:fn-key-hid
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
By default, this key emits Win+P, which is not portable to non-QWERTY keyboard layouts and non-Windows OSes. This adds an option (off by default, set with 0x3E16 flag) to emit the HID display toggle key instead. This should be exposed in the BIOS settings. Signed-off-by: Jules Bertholet <[email protected]>
Fn key state is reported as "System Function Shift", FnLock *key* (Fn+Esc) state as "System Function Shift Lock", and Fn lock state is reported as "System Function Shift Lock Indicator". This allows the OS to detect when the Fn key is pressed, enabling the user to configure custom keybinds involving it; it also allows the OS to report the state of the Fn lock feature to the user. Signed-off-by: Jules Bertholet <[email protected]>
Ah, thanks for doing this. I worked on this exact thing back in 2022, but I gave up when I realized the kernel would need patching. |
Kernel patch: diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c
index 541d682af15a..8bdf5016b50c 100644
--- a/drivers/hid/hid-debug.c
+++ b/drivers/hid/hid-debug.c
@@ -3349,6 +3349,7 @@ static const char *keys[KEY_MAX + 1] = {
[KEY_FN_F7] = "Fn+F7", [KEY_FN_F8] = "Fn+F8",
[KEY_FN_F9] = "Fn+F9", [KEY_FN_F10] = "Fn+F10",
[KEY_FN_F11] = "Fn+F11", [KEY_FN_F12] = "Fn+F12",
+ [KEY_FNLOCK] = "FnLock",
[KEY_KBDILLUMTOGGLE] = "KbdIlluminationToggle",
[KEY_KBDILLUMDOWN] = "KbdIlluminationDown",
[KEY_KBDILLUMUP] = "KbdIlluminationUp",
@@ -3541,7 +3542,7 @@ static const char *leds[LED_MAX + 1] = {
[LED_KANA] = "Kana", [LED_SLEEP] = "Sleep",
[LED_SUSPEND] = "Suspend", [LED_MUTE] = "Mute",
[LED_MISC] = "Misc", [LED_MAIL] = "Mail",
- [LED_CHARGING] = "Charging",
+ [LED_CHARGING] = "Charging", [LED_FNL] = "FnLock",
};
static const char *repeats[REP_MAX + 1] = {
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index fda9dce3da99..65d1a9b89984 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -812,6 +812,9 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
if ((usage->hid & 0xf0) == 0x90) { /* SystemControl*/
switch (usage->hid & 0xf) {
+ case 0x7: map_key_clear(KEY_FN); break;
+ case 0x8: map_key_clear(KEY_FNLOCK); break;
+ case 0x9: map_led(LED_FNL); break;
case 0xb: map_key_clear(KEY_DO_NOT_DISTURB); break;
default: goto ignore;
}
diff --git a/drivers/input/input-leds.c b/drivers/input/input-leds.c
index 6bbf3806ea37..58bc7d581250 100644
--- a/drivers/input/input-leds.c
+++ b/drivers/input/input-leds.c
@@ -39,6 +39,7 @@ static const struct {
[LED_MISC] = { "misc" },
[LED_MAIL] = { "mail" },
[LED_CHARGING] = { "charging" },
+ [LED_FNL] = { "fnlock" },
};
struct input_led {
diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h
index a4206723f503..ef86fde10baf 100644
--- a/include/uapi/linux/input-event-codes.h
+++ b/include/uapi/linux/input-event-codes.h
@@ -547,6 +547,7 @@
#define KEY_FN_S 0x1e3
#define KEY_FN_B 0x1e4
#define KEY_FN_RIGHT_SHIFT 0x1e5
+#define KEY_FNLOCK 0x1e6
#define KEY_BRL_DOT1 0x1f1
#define KEY_BRL_DOT2 0x1f2
@@ -955,6 +956,7 @@
#define LED_MISC 0x08
#define LED_MAIL 0x09
#define LED_CHARGING 0x0a
+#define LED_FNL 0x0b
#define LED_MAX 0x0f
#define LED_CNT (LED_MAX+1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fn key state is reported as "System Function Shift", FnLock key (Fn+Esc) state as "System Function Shift Lock", and Fn lock state as "System Function Shift Lock Indicator". This allows the OS to detect when the Fn key is pressed, enabling the user to configure custom keybinds involving it; it also allows the OS to report the state of the Fn lock feature to the user.
This PR, by enabling users to configure custom Fn key shortcuts, is a potential alternative to #50, #54, and especially #51.
If this PR is accepted, I plan to follow it with a patch to the Linux kernel to emit the proper input events.
Uses the same HID collection as #49; uses its branch as a base for this reason.