-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Fix mouse grab behavior on Android #16203
Fix mouse grab behavior on Android #16203
Conversation
// If HIDEMOUSE parameters is provided then hide the mourse cursor | ||
// This requires NVIDIA Android extensions (available on NVIDIA Shield), if they are not | ||
// available then nothing will be done | ||
if (retro.hasExtra("HIDEMOUSE")) hideMouseCursor(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to mention - I removed this because it doesn't seem like it's being used anywhere, and it's not referenced anywhere in documentation or anything. This PR uses the input_auto_mouse_grab
config value to determine if it should hide/capture the mouse, which I think is better anyway. Happy to restore it if anyone disagrees, though
Hi there. Thanks for pushing this forward! I kinda lost interest after seeing the remaining issues and the overall inconsistent behavior on Android with a mouse attached versus a desktop PC running RetroArch in fullscreen.
Is this a solution or a workaround?
Last time I noticed the menu does react to mouse movement and clicks but it seems utterly confused about the mouse position or its movement. For me it just jerked the menu around when I tried it back then, is this still the same? Does anyone know how other (non-desktop) platforms handle a mouse? I'm interested in how it runs in something like DRM/KMS, which is Linux without a desktop manager. For example, does Lakka on a RaspberryPi support a USB mouse to control the menu and games? Edit: Also wanted to add thanks to @worleydl who initially took a stab at implementing the interface, otherwise I wouldn't have known where to start :-) |
0159e46
to
e218a96
Compare
@schellingb I think this commit (e218a96) might have the behavior you're looking for, I'm gonna test it and let you know |
2ba7750
to
cd47e27
Compare
@schellingb controlling the menu with a mouse works now, in this commit: cd47e27 🎉 The issue was that I also tested the commit to always capture the mouse on focus, regardless of the We could remove the config option entirely for non-windowed platforms as a part of this PR, but it feels like there's a lot going on here already. What do you think? |
This is a long shot but is there anything specific that made the initial report Android-only aside from the device it was tested on? I believe the same issue exists on iOS and wondering if it could be ported: #15483 (I'm also willing to test). |
@TyroneSlothrop unfortunately everything here is Android-specific (input drivers, frontend drivers, etc), so it can't be ported to iOS. Looking at the input drivers for Cocoa, it seems like iOS is set up for mouse support... I'll ask some questions in that issue you posted |
thank you for working on this.
Screen_Recording_20240207_200915_RetroArch.mp4 |
@LuanVSO thank you for the video - I'm trying to see if it's something I can do to speed up the cursor, but I haven't had any luck yet... @schellingb I ended up reverting that "always capture the mouse regardless of the |
fb08393
to
a4bb625
Compare
{ | ||
/* Adjust mouse speed based on ratio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the code here because it didn't seem to accurately set the mouse speed - it made it significantly slower compared to what you'd expect it, based on the Android system mouse speed settings: #16203 (comment)
Since the user can adjust their mouse speed in Android settings, and/or (sometimes) within core options, I don't think it's really necessary
But
Screen_Recording_20240209_232858_RetroArch.mp4 |
f1df68a
to
9a1c30a
Compare
can move the mouse without issues now |
Hi, should we merge the PR in its current state? |
The mouse capture is good, the remaining issues are marginally related but weren't introduced by this pr. |
@LibretroAdmin I’m good with merging it in it’s current state, I know @schellingb didn’t want the final result to depend on having the |
9a1c30a
to
4f4bdfe
Compare
I would love to have this so i can finally start enjoying some point and click adventures :) |
Makes mouse grabbing and 'Game Focus' work on Android with a real mouse Properly handle relative mouse motion events on Android (SDK 28 and newer)
4f4bdfe
to
b5936db
Compare
@LibretroAdmin I have been using this branch to play point-and-click DOS games and trackball games on Android for a few weeks now, and it works really well. I think it's good to be merged |
Honestly mouse should be captured by default in all platforms. It's the cause of a lot of issues in desktops too when using cores hiding the mouse in windowed RA or fake Fullscreen (vast majority of desktops these days) iirc. There are worse problems (saw a lot of funny behaviors in KMS\DRM Linux because it bypasses the hardware quirks library libinput usually loaded by gnome\window manager), but even if everything else is working, not having it on can cause bugs in those cases... as this pr showed for Android and others showed for Wayland (mouse capture was a no op in Wayland until a recent series of fix commits, so that 'just' allowed mouse capture to do its job IF turned on). |
* Add grab_mouse interface for Android Makes mouse grabbing and 'Game Focus' work on Android with a real mouse Properly handle relative mouse motion events on Android (SDK 28 and newer) * Enable workflow_dispatch on CI Android * Update android_mouse_calculate_deltas callsites * Add RETRO_DEVICE_MOUSE to android_input_get_capabilities * Use Handler to trigger UI events (toggle mouse, immersive mode) with 300ms delay * Enable input_auto_mouse_grab by default for Android * Handle RARCH_DEVICE_MOUSE_SCREEN in Android input driver * Add android.hardware.type.pc to manifest * Don't attempt to set pointer speed via scaling in android_mouse_calculate_deltas * Keep x/y values within viewport resolution for screen mouse * Use video_driver_get_size to get width/height --------- Co-authored-by: Bernhard Schelling <14200249+schellingb@users.noreply.github.com>
Description
In #14016, @schellingb posted a branch (https://github.com/schellingb/RetroArch/tree/android_grab_mouse) that implemented a
grab_mouse
interface for Android. I forked and tested it extensively on an Android 10 device, and ended up refactoring theRetroActivityFuture
a bit so that it worked as expected.I ran into a few things: looking at the ADB logs, I noticed that, for some reason, enabling "Immersive Mode" and attempting to call
requestPointerCapture
on the window's decor view was inconsistently working. One of the only references I could find relating to this behavior was thisImmersiveActivity
example from the Android source code, where they used aHandler
to toggle the UI changes with a 300ms delay. I ended up doing the same thing in theRetroActivityFuture
, using aHandler
to toggle UI changes (including mouse capture and "immersion mode") with a 300ms delay, and it seems to work pretty well.I also made the
input_auto_mouse_grab
config setting default to true, for Android only, based on the conversation in that issue. That way, mouse capture works by default, but you can still disable the setting if (for some reason) you don't want the mouse to be captured by RetroArch.I tested this using the Mame 2003-Plus and FinalBurn Neo cores, directly through the RetroArch APK, and indirectly through the Daijishou front-end, which uses
am start
to launch theRetroActivityFuture
activity. Everything works as expected!Controlling the menu UI with a mouse in Android still doesn't seem to work, however - someone with more experience working in the RetroArch codebase might have an easier time fixing that.Fixed in e60f04cRelated Issues
#14016
Reviewers
@schellingb - thank you very much for co-authoring this in your
android_grab_mouse
branch, and for implementinggrab_mouse
, otherwise I wouldn't have known where to start!