Skip to content
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

[Bug]: Media keys are intercepted . #747

Closed
sfantu opened this issue Nov 9, 2024 · 18 comments
Closed

[Bug]: Media keys are intercepted . #747

sfantu opened this issue Nov 9, 2024 · 18 comments

Comments

@sfantu
Copy link

sfantu commented Nov 9, 2024

Problem description

I have a Bluetooth keyboard with media keys , volume . etc. The volume keys work fine , but the media keys don't.
They do work if termux-x11 ain't focused.

What steps will reproduce the bug?

Using a bluetooth keyboard with media keys

What is the expected behavior?

I would have expected the keys to pass through to android , like the volume ones do .

@twaik
Copy link
Member

twaik commented Jan 13, 2025

Completed by fc18466 .

@twaik twaik closed this as completed Jan 13, 2025
@sfantu
Copy link
Author

sfantu commented Jan 13, 2025

Oh wow ... works great . Thank you

@sfantu
Copy link
Author

sfantu commented Jan 16, 2025

Hi just tested it a bit and it looks like next track media key ain't working properly . It just stops the music.
The other keys work fine.

@twaik
Copy link
Member

twaik commented Jan 16, 2025

You mean it does not work properly in Android or in X11 apps?

@twaik
Copy link
Member

twaik commented Jan 19, 2025

Good.

@sfantu
Copy link
Author

sfantu commented Jan 19, 2025

LOL. Damn you were fast.

Sorry . I deleted the previous comment because it was wrong .

So i just realised that the keys are no longer being passed to android.

I'm positive they were working fine last time.

I mean the media keys don't change the song in the android music player. The volume key still modify the android volume.

@twaik
Copy link
Member

twaik commented Jan 19, 2025

Can you please start termux-x11 with TERMUX_X11_DEBUG=1 exported and tell what appears in logs when you press key switching key?
Should be something like Sending key: <N> (<N> <N> <N>) where <N> is some number.

I'll try to patch it.

@sfantu
Copy link
Author

sfantu commented Jan 19, 2025

sorry i don't know how i should do that

@twaik
Copy link
Member

twaik commented Jan 20, 2025

TERMUX_X11_DEBUG=1 termux-x11 :0 <other args...>

@sfantu
Copy link
Author

sfantu commented Jan 20, 2025

I'll try tonight when I'll have a bit of time. Thank you

@sfantu
Copy link
Author

sfantu commented Jan 31, 2025

so i get the output when i press the keys ... loriesomething sending keys ... but if i try to reddirect the output to a file it seems like it doesn't redirect the whole output and the key presses are missing .

output.txt

@twaik
Copy link
Member

twaik commented Jan 31, 2025

You should redirect both stdout and both stderr. Like echo 2>&1 > somefile.

@twaik
Copy link
Member

twaik commented Feb 5, 2025

Any updates?

@sfantu
Copy link
Author

sfantu commented Feb 7, 2025

Sorry had some problems and was busy.

I think i got it now.

output.txt

@twaik
Copy link
Member

twaik commented Feb 7, 2025

The log is 10k lines long. Seems like you used KEYCODE_MUSIC, KEYCODE_MEDIA_PLAY_PAUSE, KEYCODE_MEDIA_STOP, KEYCODE_MEDIA_NEXT, KEYCODE_MEDIA_PREVIOUS. But I can not tell which one key is faulting because you used like ~30 keys in this session.
Termux:X11 prints line like LorieNative: Sending key: 36 (28 66 1) to log and I need exact number of key (the middle in parentheses, 66 in this case) to fix it.

@sfantu
Copy link
Author

sfantu commented Feb 8, 2025

output_GOOD.txt

hi .

Hope this log is better ...
the key for media playback are :
Play Pause - LorieNative: Sending key: 172 (164 85 0)
Next - LorieNative: Sending key: 171 (163 87 0)
And for Previous - it's something with 88 but i din't press that it seems.

@twaik
Copy link
Member

twaik commented Feb 8, 2025

If you are right about the codes they should correspond to KEYCODE_MEDIA_PLAY_PAUSE, KEYCODE_MEDIA_NEXT and KEYCODE_MEDIA_PREVIOUS according to https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/KeyEvent.java#293 .
But in this case termux-x11 must ignore them and pass keypresses to android by default (at least in recent builds). I am not sure what is the problem in your case.

@sfantu
Copy link
Author

sfantu commented Feb 8, 2025

Well ... Then it could be something on my side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants