minecraft-linux / mcpelauncher-manifest

The main repository for the Linux and Mac OS Bedrock edition Minecraft launcher.
https://mcpelauncher.readthedocs.io/en/latest/
GNU General Public License v3.0
863 stars 100 forks source link

Controller to Keyboard Delay #848

Open Rqnaway opened 1 year ago

Rqnaway commented 1 year ago

So im on a mac using 10.13 and i play controller but i tried to make a hotkey for obs to save a clip but everytime i click that theres alway a 5 sec delay to be able to play on my controller again is there any fix. im using a wired ps4 controller btw

SilentException commented 11 months ago

Not sure if it is the same issue but I observed the same on Seam Deck. The controller is working normally, then I go and type a chat message using virtual keyboard. After last keyboard input (ENTER) the controller isn't responding for 3-5 seconds. Not sure if this is Steam Deck, APK or launcher issue but I checked on the Android phone with Bluetooth controller - the Android keyboard doesn't block the controller input like that..

ChristopherHX commented 11 months ago

The delay should only be 2secs not 5. This was intentional, but maybe this can be improved.

So I suggest to allow keyboard input in all input modes (Mouse, Gamepad and Touch) and prefer Gamepad input over Mouse input. So the delay will happen from Gamepad to Mouse Input no longer the other way around.

You can test the artifacts of https://github.com/minecraft-linux/mcpelauncher-client/pull/74/checks and tell me if it matches your expectations.

This input filter exists, because some systems send Mouse events from Touch input sources and the Minecraft Game is confused about this fact.

SilentException commented 10 months ago

Hey I tested this version (x64 AppImage) on Steam Deck. After starting Minecraft and not touching any gamepad controls i can move the mouse, select items with the mouse and also with touch. I can also use the mouse and then press a button on control and the switch is instant. But as soon as gamepad input is detected, the mouse does not function any more, same as touch (which I presume emulates mouse). This does not happen on v0.11.2-718 AppImage (latest).

But keyboard input works and also the switch to keyboard and back to gamepad is instant, no delay.

RyzenWarrior commented 10 months ago

I have been having the same problem with my 2.4ghz Astro controller on linux on the newest v0.11.2-718 x64 appimage. Its been causing me issues in game especially when trying to go in my inventory around mobs. Is there a current workaround?

SilentException commented 10 months ago

@ChristopherHX perhaps we could have configuration option or command line switch to completely disable this delay in any direction? Default would be turned on as it is "safe" but in some cases it could be disabled by user without consequences.

ChristopherHX commented 10 months ago

we could have configuration option or command line switch to completely disable this delay in any direction?

Feel free to contribute it. Commandline switches don't have any ui components to configure them. I have only added them to the profile config for users doing edits to the config files directly.

Due to the current amount of code required for adding cli options in the mcpelauncher-ui-qt, we would have to look for a declarative way to bring then into the ui. Otherwise I'm against adding more cli options to the settings.

But as soon as gamepad input is detected, the mouse does not function any more, same as touch (which I presume emulates mouse).

Why does your touch not work it's a priority 0 like in v0.11.2-718 AppImage (latest)?

It does work for me without issues via this test build.

I could consider to only apply input filter for mouse and touch events and let all other events pass regardless of primary touch or mouse mode. But then we have the problem that there is no way to bring the mouse cursor back........

You know it's not easy to find a solution everyone wants, I'm okey how it is now in the releases and I'm the one who writes most code of the launcher at this time myself.

ChristopherHX commented 10 months ago

BTW To switch between input modes

SilentException commented 10 months ago

Due to the current amount of code required for adding cli options in the mcpelauncher-ui-qt, we would have to look for a declarative way to bring then into the ui. Otherwise I'm against adding more cli options to the settings.

Doesn't need to be in the UI IMO.

Why does your touch not work it's a priority 0 like in v0.11.2-718 AppImage (latest)?

Take a look, the first part of the video is using TEST version and the second part is using official release (AppImages both).

https://streamable.com/ohgcbe

You can see that the mouse works just fine but the moment it switches to gamepad the mouse doesn't work anymore, no matter how much i move the cursor (same with touch - nothing registers). In the second part of the video I can switch from mouse to gamepad and vice versa without issues - only with the delay.

Hence why the suggestion to remove any delay altogether with command line switch.

ChristopherHX commented 10 months ago

Your second part of the video isn't using touch at all (not even trying to use it), so I don't know if touch ever worked via any appimage.

I will add an env variable to pass all input's to the game at the same time (no eta)

It's like return true for hasInputMode based on a special env variable, you can also do it yourself and open a PR.

I think it's good practice to read the env via getenv("MCPELAUNCHER_RAW_INPUT") in the windowcallbacks constructor and store it inside the object. Then add a if(rawinput) { return true; }

If I approve running the workflow, then you automatically get an AppImage for your change. After a second pr, nobody needs to approve the workflow to generate an appimage file

SilentException commented 10 months ago

Hey @ChristopherHX, thanks for adding the possibility. So far I tested using MCPELAUNCHER_CLIENT_RAW_INPUT=1.

After launching I first moved the mouse and the buttons on main reacted to mouse over them (switched grey/green colors). I could also click on the buttons. Next i touched the DPAD so that gamepad activates. There was no delay. After gamepad activation there are additional gamepad helper GUI elements visible (that's Minecraft thing). Next I moved the mouse again which worked without delay, mouse cursor is visible on screen. But the GUI is still showing gamepad elements, main menu buttons do not react to mouse movements, selected button does not change on mouse over it and no matter where I click on screen the button that was selected with gamepad is "clicked". Any idea what might be going on? In windows_callbacks.cpp I noticed useDirectMouseInput variable, could that be related? I can make a video when I get the SD back from kids :) I will also test using MCPELAUNCHER_CLIENT_INPUT_SWITCH_DELAY=0.

ChristopherHX commented 10 months ago

The PR https://github.com/minecraft-linux/mcpelauncher-client/pull/76, contains a big bug with reading env variables. Make shure you aren't using builds of the PR and use nightly snapshots instead. (see Branch Sync workflow in mcpelauncher-manifest)

the GUI is still showing gamepad elements

Not under my control, the game make asumptions of your input method itself. The game sees gamepad events => gamepad controls are shown, the game sees mouse events => mouse controls are shown.

SilentException commented 10 months ago

The PR minecraft-linux/mcpelauncher-client#76, contains a big bug with reading env variables. Make shure you aren't using builds of the PR and use nightly snapshots instead. (see Branch Sync workflow in mcpelauncher-manifest)

You fixed the bug in next commit and it is also only related to integer values, which RAW_INPUT does not use. I was using mcpelauncher-client builds, will switch to mcpelauncher-manifest. The RAW_INPUT variable was recognized correctly in my test.

Not under my control, the game make asumptions of your input method itself. The game sees gamepad events => gamepad controls are shown, the game sees mouse events => mouse controls are shown.

I understand that but that's just visual thing. Bigger problem is that the game doesn't switch back to mouse input at least not fully.

ChristopherHX commented 10 months ago

After launching I first moved the mouse and the buttons on main reacted to mouse over them (switched grey/green colors). I could also click on the buttons. Next i touched the DPAD so that gamepad activates. There was no delay. After gamepad activation there are additional gamepad helper GUI elements visible (that's Minecraft thing). Next I moved the mouse again which worked without delay, mouse cursor is visible on screen. But the GUI is still showing gamepad elements, main menu buttons do not react to mouse movements, selected button does not change on mouse over it and no matter where I click on screen the button that was selected with gamepad is "clicked". Any idea what might be going on?

Yeah that's why rawinput has been replaced in 2021, I forget about this mouse locking issue.

I assume

However it is not a new bug, it was just impossible to use rawinput between 2021 and 2023 (without modding the code).

ChristopherHX commented 10 months ago

PS Mouse works inside Minecraft worlds, because it always locks the mouse and use relative motion.

While Mouse is locked, there are no absolute motion events.

The input filter has code to unlock the mouse if it switches from gamepad / touch modes, but it is impossible to implement for raw_input you can use both at the same time and hope noting goes wrong.

SilentException commented 10 months ago

Tested using MCPELAUNCHER_CLIENT_INPUT_SWITCH_DELAY=0 and it works better. At least the input can be switched between the gamepad and mouse/keyboard.

When using inputModeSwitchDelay=0 then code is gouing through these lines and window.setCursorDisabled(true/false) is executed. Raw input is only returning true and never calling setCursorDisabled method.

The touches at least for me emulate mouse clicks and after using gamepad they are mostly wrong, for example I have PLAY button selected with gamepad and then touch SETTINGS button the play action will be executed. I suppose it is because the game doesn't switch to different mode quickly enough or something. Touches work fine when the game deactivates gamepad input (no extra icons).