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

Volume buttons not working on Android? #2432

Closed
Hoodad opened this issue Aug 16, 2022 · 2 comments
Closed

Volume buttons not working on Android? #2432

Hoodad opened this issue Aug 16, 2022 · 2 comments

Comments

@Hoodad
Copy link
Contributor

Hoodad commented Aug 16, 2022

Hello!

I have done some investigation on the topic of volume buttons and why they are not working on Android. I thought it could be related to how types of input events was handled by winit's Android implementation (source) but no. I also suspected it could be related to being in fullscreen mode but that does not appear to be it either. Then I stumbled upon mention by @msiglreith in issue #2010 mentioning that some buttons are marked as handled. So I figure I post a question here and see if anyone has good ideas on where to start looking?

I have tried using Android Studio and intercepting key events there and I was able to prevent the UI to appear. See comment in code below. However I'm not able to achieve similar things in Rust.

    public boolean dispatchKeyEvent(KeyEvent event){
        int keyCode = event.getKeyCode();
        if(event.getAction() == KeyEvent.ACTION_DOWN){
            switch (keyCode) {

                case KeyEvent.KEYCODE_VOLUME_UP:
                    return false;  // If changed to true the media volume button does not appear
                case KeyEvent.KEYCODE_VOLUME_DOWN:
                    return false;  // If changed to true the media volume button does not appear

                default:
                    return super.dispatchKeyEvent(event);
            }
        }
        return super.dispatchKeyEvent(event);
    }

Goal is to have the "media volume panel" appear when pressing the volume buttons, so that the application does not have to reimplement that UI and the volume should change according to the pressed buttons.

@msiglreith
Copy link
Member

Hi, for volume buttons there is PR which would do this already #1919. In general as mentioned it would be probably good to expose some feedback option/filtering for these button events on Android.

@Hoodad
Copy link
Contributor Author

Hoodad commented Aug 16, 2022

Oh, I didn't see that PR only searched in issues 😢

That's about exactly the fix what I tried with no success, however looking again at my attempt I found the issue! Thanks now it works as expected 👍

Closing this issue as the PR exists.

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

No branches or pull requests

2 participants