Skip to content

Kernel+Userland: Better media keys support#26678

Open
bplaat wants to merge 11 commits intoSerenityOS:masterfrom
bplaat:media-keys
Open

Kernel+Userland: Better media keys support#26678
bplaat wants to merge 11 commits intoSerenityOS:masterfrom
bplaat:media-keys

Conversation

@bplaat
Copy link
Copy Markdown
Member

@bplaat bplaat commented Mar 22, 2026

This PR improves media key support across the entire OS.

At the kernel level, it enhances media key handling in the USB HID, PS/2, and virtio input drivers, ensuring more reliable detection of key events. On the user space side, all media applications now respond to the Play/Pause media key.

Additionally, the WindowManager is now integrated with the AudioServer. It handles volume up/down and mute key presses, and displays a volume overlay to provide user feedback.

One limitation remains: since the AudioServer runs under the desktop user while the WindowServer runs as root / window group, the system currently determines the active user session by querying the first open window. This approach works but is not ideal and could be improved in the future.

Demo video

media-keys-sped-up.mp4

This video is sped up, I used qemu monitor to enter media keys that was quite slow so video is a bit weird but it shows the working in GUI of entered media keys

@github-actions github-actions bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label Mar 22, 2026
Copy link
Copy Markdown
Member

@spholz spholz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only skimmed the last WindowServer commit, as I'm not particularly knowledgeable about GUI stuff.

Base/etc/group Outdated
lookup:x:10:anon
window:x:13:anon
users:x:100:anon
users:x:100:anon,window
Copy link
Copy Markdown
Member

@spholz spholz Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong. The users group should (I think) be for normal users, and not include systems users, like window.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I have chosen a different approach:

  • Add SocketGroup option to SystemServer
  • AudioServer running as user creates the audio socket with the audio group and permission 0660
  • window user is part of the audio group and can connect

};
// clang-format on

// clang-format off
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, did you test this? And where did you get these mappings from? OSDev wiki?
In QEMU on linux at least only volume control keys work (and only with the SDL display backend).

Copy link
Copy Markdown
Member Author

@bplaat bplaat Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are from https://wiki.osdev.org/PS/2_Keyboard, and all audio keys work with PS/2 in my tests in qemu x86_64 on macOS

@bplaat bplaat force-pushed the media-keys branch 2 times, most recently from 0e2735d to f32a3a8 Compare March 24, 2026 17:28
@bplaat
Copy link
Copy Markdown
Member Author

bplaat commented Mar 24, 2026

@spholz thanks for the review, I've addressed all of your points where I could. As you probably know, I'm not really a kernel developer and I really don't know anything about USB HID specs, but hopefully you can maybe fix that on top of this work, to make it better in the future.

Also add volume overlay which visualizes volume changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

👀 pr-needs-review PR needs review from a maintainer or community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants