Yellow-Dog-Man / Resonite-Issues

Issue repository for Resonite.
https://resonite.com
141 stars 2 forks source link

[Linux, Screen] Radiant Menu Location Follows Mouse Even When Closed #47

Open yoshiyoshyosh opened 1 year ago

yoshiyoshyosh commented 1 year ago

Describe the bug?

On screen mode in native Linux, the position of the radiant menu appears to follow the movement of the mouse when it is closed. This behavior is not observed on Proton.

To Reproduce

  1. Launch the client on Linux Native screen mode
  2. Move mouse
  3. Open radiant menu

Expected behavior

The radiant menu appears in the middle of the screen, like Proton.

Screenshots

https://github.com/Yellow-Dog-Man/Resonite-Issues/assets/36683489/a842e9c0-3271-4a52-9e51-6d83ed5cec35

Resonite Version Number

2023.10.13.743

What Platforms does this occur on?

Linux

What headset if any do you use?

No response

Log Files

Resonite log

Unity Player.log

Additional Context

No response

Reporters

yosh

shiftyscales commented 1 year ago

Based on the report, it sounds like the underyling issue is that the cursor isn't being recentered properly. The context menu opens at whatever the current cursor position is- it just happens that usually on the Windows build that the cursor is recentered- thus the menu opens at the center of the screen if the user does not move their cursor while it is being opened.

What desktop environment/distro are you using, @yoshiyoshyosh? Is it replicable on all environments, e.g. SteamOS/Steam Deck as well (if you have access to one)?

MegaShinySnivy commented 1 year ago

Can replicate on vanilla SteamOS in a VM, along with an arch linux native system on wayland

shiftyscales commented 1 year ago

Thank you for verifying, @MegaShinySnivy.

Frooxius commented 1 year ago

This is a bit of a tricky issue. Unity on Linux doesn't seem to support locking the cursor, so our request to lock the cursor are simply ignored.

I don't think we'll be able to address this easily until we switch away from Unity.

ljoonal commented 10 months ago

Unity on Linux doesn't seem to support locking the cursor

I'm not sure what exactly isn't supposedly supported... Starting with Unity 2019.2 the documentation explicitly states that it is supported on linux, and I suspect it is supported even earlier but just not documented explicitly:

This is only supported on Windows and Linux standalone builds.

Constantly locking the Cursor & on context menu open unlocking the Cursor and then calling Mouse.current.WarpCursorPosition has worked for me for ages too to also center the mouse on the wheel, dating back to NeosVR, where I have a faint memory of hearing someone claim that that wouldn't be supported either... (and in case lawyers think such a little code snippet is somehow copyrightable, I'll grant Frooxius/YellowManStudios the linked file's code under a CC0/MIT license :P ). Though of course worksOnMyMachineTM doesn't mean it'll work across all distros I guess...

Frooxius commented 10 months ago

The reason why we state that is because the Linux build is using exact same codepath and API as on Windows, but it just doesn't work. We are not excluding or skipping the API while on Linux - same things are being called as on Windows, but the issue is still present.

The lockCursor position does seem to work on Linux, but the other part - WarpCursorPosition, which is responsible for re-centering the cursor does not seem to do anything.

The code snippet is a bit odd, since it seems to run this in the context menu? Rather than the mouse driver, which normally handles this generically for Resonite.

Are you able to actually get the WarpCursorPosition to position the cursor arbitrarily on Linux?

ljoonal commented 10 months ago

The lockCursor position does seem to work on Linux, but the other part - WarpCursorPosition, which is responsible for re-centering the cursor does not seem to do anything.

I suspect that that's because the cursor is locked...? I don't exactly remember for sure, but I also have no clue why in my old code I'd have set it to be unlocked before warping if it wasn't the case...

The code snippet is a bit odd, since it seems to run this in the context menu? Rather than the mouse driver, which normally handles this generically for Resonite.

... I mean, once I get a mod to work I usually just commit that. It might not be optimal, but if it works don't fix it tm xD

Are you able to actually get the WarpCursorPosition to position the cursor arbitrarily on Linux?

Yup seems like it, though I've not tried any other coordinates than centering :stuck_out_tongue: I posted videos to the official resonite #linux-build channel, a video without any mods, and a video with the LinuxFixes mod.

So it does mostly fix it on my system at least (used to be i3 during Neos, now hyprland), although towards the end can see that when am already moving my mouse whilst menu is still closing the menu opens to a weird place still, so it does still have a few issues when being too fast. But works in 99% of the cases (aka not trying to spam-open the menu).