-
Notifications
You must be signed in to change notification settings - Fork 639
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
Input code fixes #1559
Input code fixes #1559
Conversation
Fixes ValveSoftware#1546 - fixed m_rawinput 1 mouse trapped inside a rectangle - fixed thirdperson camera not working as it should Fixes ValveSoftware#1558 - recoded mousethread and made it somewhat useful for very fast mouse movements (will reset CursorPos now) and thus also fixed some thread synchronization issues (hopefully) Further fixes: - Fixed IN_JoyMove doing nothing on Linux for ricochet client - Limited mouse thread sleep to sane values between 0 and 1000
This fixes the mouse getting trapped inside a rectangle issue for me, but for some reason makes my mouse clicks register intermittently. I'll do some more testing and play with the code and see if there's anything weird going on with my environment though I'm using OSX 10.9, with the following environment info:
But I'll look into this and see if I can get it to work for me. |
Hmm :-( What do you mean by "intermittently"? Can you please check the following:
|
Btw I cannot reproduce your problem, neither on Linux nor on Windows :-(( |
Huh, I actually just built the thing again and was able to properly determine what was going on. Sorry, it's not actually a problem with your code. Basically, I was getting confused because just after spawning with the crowbar, clicking did not actually swing the crowbar until after the first time I stand right next to a surface and make an impact on there. That same thing happens in HL without your code applied, so it's not an issue. Sorry for the trouble, and thanks for all the awesome work you've been doing on the engine so far! |
Thanks for reporting back. Btw.: i have to correct myself too a bit: When using primusrun without vblank_mode=0 environment variable set (vblank_mode=0 means vsync forced off), then (mouse) input lag happens, but that is a problem with primusrun afaik and happens in CS:GO (Counter-Strike: Global Offensive) and default Half-Life too. |
Made a quick test on a clean SDK, nothing wrong to report. Great job ! |
Thanks, always good to have someone else test it or look through the code. I am mostly worried about making mistakes in thread synchronization on Windows builds (with -mousethread launch option and m_rawinput 0), but I hope I didn't introduce new ones and fixed the old ones. PS: The reason why I coded InterlockedExchange* variable access despite using a lock mechanism is because the Windows Documentation didn't say anything about how the memory barrier works for the functions WaitForSingleObject and SetEvent (i.e. I can't know from the documentation if it affects all memory access or only interlocked memory access). The InterlockedExchange functions used in the code make sure there is a memory barrier (which is a lot more than just declaring a variable as volatile does). I used volatile for the mouse_thread_sleep variable though, because I thought the side effects don't matter there (the user might only observe a very small additional random delay until the changes in that variable are applied to the thread). PPS: |
Okay I found a problem, which is not a problem yet, but will become one as soon as someone uses ISO C++ 11: In cl_dll/inputw32.cpp line 88
would work fine in Visual Studio 2010 and lots of earlier versions, however it might not work in ISO C++ 11 anymore, because the struct cannote be copied in one instruction: A possible solution would be to instead make the access on the float value volatile, meaning change line 215 to:
But that still would be not standard conform, because the Micrsoft documentation (linked above) says: I am very confused now. Anyone an idea? |
Okay fixed it, see commit above. |
Fix for mouse disappearing on tabbing out/back into the game: YaLTeR/OpenAG@8e60ac3 |
I re-submited this as #1900, since I didn't want this to sit on the "master" branch of our repository, which shall reflect the master of ValveSoftware/halflife instead.