ValveSoftware / gamescope

SteamOS session compositing window manager
Other
3.01k stars 198 forks source link

Mouse position in game window does not change when moving mouse if game does not grab mouse #909

Open chinese-wzq opened 1 year ago

chinese-wzq commented 1 year ago

On the latest git version (version number on my package manager is 3.12.0.beta10.r10.g2dd8236-1), I launch Minecraft with the parameters gamescope -h 540 -w 960 -H 810 -W 1440 -F fsr -o 1 -b --.

When I move the mouse, the “virtual mouse” in the game window stays centered and does not move (and I can move the mouse out of the window without Alt+Tab).

But when I try to enter the game with the keyboard, the mouse can control the camera rotation (this is when the game is grabbing the mouse).

However, when the game stops grabbing the mouse (for example, when opening the inventory or entering a GUI), the mouse becomes centered again and cannot be controlled.

On version 3.11.51-1, the mouse is always grabbed by the window (not the same concept as “game” mentioned above), and I can only leave the window by pressing Alt+Tab. In this case, I can play the game normally (parameters are gamescope -h 540 -w 960 -H 810 -W 1440 -U -o 1 -b --).

On the latest git version, if I add the--force-grab-cursor parameter, all behaviors are the same as version 3.11.51-1.

I think that the behavior of the latest git version (the mouse can move out of the window without Alt+Tab) is correct, but the behavior of not being able to control the mouse when the game does not grab it is wrong.

The latter should be fixed and the former should be kept, so that it is more convenient to move the mouse out of the window.

Update: When using 1920x1080 resolution (same as my screen resolution) (parameters are gamescope -h 540 -w 960 -H 1080 -W 1920 -F fsr -o 1 -b -f --), the latter is fixed and the former does not change. Here is my computer information:

Operating System: Arch Linux 
KDE Plasma Version: 5.27.6
KDE Frameworks Version: 5.108.0
Qt Version: 5.15.10
Kernel Version: 6.4.2-arch1-1 (64-bit)
Graphics Platform: X11
Processors: 12 × Intel® Core™ i7-9750H CPU @ 2.60GHz
Memory: 46.8 GiB of RAM
Graphics Processor: NVIDIA GeForce GTX 1650/PCIe/SSE2
NVIDIA driver version: 535.54.03
The above text was translated by NewBing. To prevent any deviation in meaning between the original and the translated text, here is the original Chinese text:

以下是一名用户在github上gamescope仓库发送的issue,请你把它们地道地翻译成英文,通过调整语句顺序以避免翻译腔。不要使翻译结果与原文本表达出不同的信息。 标题:当游戏不抓取鼠标时,移动鼠标无法改变游戏窗口中的鼠标位置 内容:在最新的git版本(版本号在我的包管理器上为3.12.0.beta10.r10.g2dd8236-1)上,当我使用`gamescope -h 540 -w 960 -H 810 -W 1440 -F fsr -o 1 -b -- `参数启动Minecraft时,移动鼠标,游戏窗口中的“虚拟鼠标”却不受控制、保持居中(并且鼠标可以无需Alt+Tab键移出窗口),但是当用键盘尝试进入游戏时,鼠标便可以操控游戏的视角转动(此时游戏正在抓取鼠标)。但是当游戏不再抓取鼠标时(例如打开背包等进入GUI界面时),鼠标再次居中无法控制。 在3.11.51-1版本上,鼠标一直被窗口(与上文提到的“游戏”不是同一概念)抓取,只有按Alt+Tab键鼠标才可以离开窗口,这种情况下可以完全正常的玩游戏(参数为`gamescope -h 540 -w 960 -H 810 -W 1440 -U -o 1 -b -- `)。而在最新git版本上,添加`--force-grab-cursor`参数后,所有行为便与3.11.51-1版本相同。 我认为最新git版的行为(鼠标可以无需Alt+Tab键移出窗口)是正确的,但是当游戏不抓取鼠标时便无法控制鼠标的行为是错误的。应该修复后者的行为,保留前者,这样可以更方便地将鼠标移出窗口。 更新:当使用1920x1080分辨率(与我的屏幕分辨率相同)时(参数为`gamescope -h 540 -w 960 -H 1080 -W 1920 -F fsr -o 1 -b -f -- `),后者被修复了,而且前者也没有改变。以下是我的电脑信息: ``` Operating System: Arch Linux KDE Plasma Version: 5.27.6 KDE Frameworks Version: 5.108.0 Qt Version: 5.15.10 Kernel Version: 6.4.2-arch1-1 (64-bit) Graphics Platform: X11 Processors: 12 × Intel® Core™ i7-9750H CPU @ 2.60GHz Memory: 46.8 GiB of RAM Graphics Processor: NVIDIA GeForce GTX 1650/PCIe/SSE2 NVIDIA driver version: 535.54.03 ```

https://github.com/ValveSoftware/gamescope/assets/40971680/1d33312b-1976-425f-b2a2-b7bfb937e0fd

https://github.com/ValveSoftware/gamescope/assets/40971680/5013b407-643e-4359-b7ad-18a094dac177

mumblerit commented 1 year ago

thanks this flag helped when using steam controller

chinese-wzq commented 1 year ago

The bug is serious. Please fix it as soon as possible.

kisak-valve commented 1 year ago

gamescope no longer grabs mouse

Issue transferred from https://github.com/ValveSoftware/gamescope/issues/926. @dconz13 posted on 2023-08-10T05:23:36:

Version 3.12.0-1 does not properly grab the cursor for games launched through gamescope. The gamescope instance is also rendered with a tool bar at the top rather than just a borderless window. If I use version 3.11.51 the mouse is properly captured (I have to alt tab to leave the window) and the gamescope instance defaults to a borderless window.

Not sure if it makes a difference but the 3.12 version is installed through pacman and the 3.11.51 is the deprecated com.valvesoftware.Steam.Utility.gamescope flatpak still used by bottles. For 3.12 I am trying to launch through terminal / steam and seeing the issue. For 3.11.51 I'm launching games through bottles and getting the expected behavior.

EDIT: I switched from a wayland session to x11 and the 3.12 version properly grabs the mouse. I think this issue is wayland related?

System specs: OS: Arch Linux x86_64 Host: B550M Steel Legend Kernel: 6.4.9-arch1-1 DE: Plasma 5.27.7 WM: kwin CPU: AMD Ryzen 5 5600X (12) @ 3.700GHz GPU: AMD ATI Radeon RX 7900 XT/7900 XTX Memory: 5439MiB / 32018MiB

dconz13 commented 1 year ago

Replying to https://github.com/ValveSoftware/gamescope/issues/909#issuecomment-1673024871

Update: I downgraded to gamescope 3.11.51-1 with pacman. When I launch gamescope -- vkcube and click on the window, the mouse is properly being captured in a wayland session. The gamescope window still has the title bar so I don't think that bit is related (bottles must set -b as a launch option by default or something).

imavlr commented 1 year ago

This also seems to have broken games that expect the cursor to be reset to the middle when performing actions such as "circle menus", where you just move the mouse towards the option, whenever the cursor is released/shown by the game, it will usually be at one of the edges, and trying to go to the option you want, will often result in the cursor leaving the game

--force-grab-cursor fixes this, too.

for-lack-of-a-better-name-j commented 1 month ago

I'm also having this issue, Arch Linux, the issue just began for me as well. I'm new to GitHub so if someone has information they want (package versions, Arch versions, etc.) comment/reply and I will add it.

for-lack-of-a-better-name-j commented 1 month ago

the --force-grab-cursor fixed it for me as well. For detail I also disabled the steam overlay in-game.