ValveSoftware / halflife

Half-Life 1 engine based games
Other
3.69k stars 622 forks source link

Isn't mousethread somewhat pointless? #1558

Open dtugend opened 10 years ago

dtugend commented 10 years ago

Let's assume it was working correctly (without the bugs in thread synchronization):

How could this be different from the delta that we get normally (no mousethread, m_rawinput 0) from GetCursorPos, that is as said above when we assume it wouldn't have those thread synchronization issues?

Yes it can be different in the following situation:

In that situation for mousethread the movement bellow the border would be dropped and potential backwards movement would be accumulated. That (in my opinion) is even worse than just the mouse not moving further.

If we assume a) border of the window is not hit (cursor stays within clip rect) between calls to IN_ResetMouse b) there would be no thread synchronization bugs

Then the result with mousethread should be the same as without!

Now you may argue that a) may not hold valid in some situations: However usually fast movements of the user maintain the same direction, meaning the backward movement won't occur, meaning the result will still be the same. Even if we assume backward movement does occur, then isn't the accumulated result in that case even more awkward?

My conclusion: Either I overlooked s.th. or mousethread in it's current form (not resetting mouse) is pointless and bugged.

Thus I'd vote for removing it and telling the user as reason, that it wasn't effective compared to normal input with m_rawinput 0.

Another option of course would be of course to:

The (easiest) example for synchronization issues:

dtugend commented 10 years ago

Summary of what I am trying to say:

I don't have stats about mouse movement with modern high DPI gaming mice, so I can't say if it's worth fixing mousethread for people using very high DPI settings. As I already said it's not easy to get the thread synchronization right :-(

dtugend commented 10 years ago

Also there is a potential problem with resetting the mouse in the mousethread (SetCursorPos):

According to several comments on the internet calling SetCursorPos will lead to a WM_MOUSEMOVE message.

The big question is: Are those messages accumulated or is it generated for each call?

If it's the latter, then there would be a problem: the mousethread could flood the main HL thread with WM_MOUSEMOVE messages.

I will try to investigate the problem on Windows XP when I have time.

dtugend commented 10 years ago

I investigated the Wine 1.7.28 code first:

Conclusion: At least in wine-1.7.28 WM_MOUSEMOVE messages sent from SetCursorPos will be merged. Meaning there will be no flooding of the message queue in that Wine version. Also the X driver will only be called when the new cursor pos is different from the old one.

Still got to verify on Windows though :-(

dtugend commented 10 years ago

Turns out I am a stupid human:

I forgot that we can just limit the SetCursorPos calls in the mousethread to only occur when the mouse position changed. That way the flooding would be limited by the mouse update rate and even more by the user's mouse movment, which shouldn't be a problem on nowadays PCs :-)

Still the question remains: Is it worth the effort of re-coding the mousethread to have the properties as said in this comment?

djdallmann commented 5 years ago

@mikela-valve, might be worth reviewing this one, it seems pretty important as it impacts user input and experience. Tagging @dtugend to see if he's still around to comment.

dtugend commented 5 years ago

While I personally prefer fixing things I am not sure if it's worth fixing this after 5 years:
People that had problems with it don't use it and people that use it might have gotten used to the bugs / problems, meaning it could potentially annoy the latter if it's fixed.

I haven't looked into it further than what I already posted in this issue so far.

dtugend commented 5 years ago

I forgot I made a pull request related to that: https://github.com/ValveSoftware/halflife/pull/1900