-
Notifications
You must be signed in to change notification settings - Fork 118
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
Use SDL2 mouse input on Windows #443
Conversation
…mouse.h and SDL2_gamecontroller.h
Deleted redundant SDL2 headers Also checked this doesn't affect building and running on Xash3D-FWGS. So it doesn't break anything. |
I wonder what we're going to do when SDL3 will come out. Will Valve upgrade GoldSrc to it? I hope not... Though for us, it has some interesting features I would like to leverage in the engine, mostly supporting multi-monitor setups. But I don't think we will migrate to it anytime soon, as SDL2 will continue to exist and packaged on modern systems, like SDL 1.2 is still required by some software. |
I think there are few more redundant headers:
|
Removed them as well |
I pushed changes that makes the game use SDL2 joystick code on Windows as well. If you want to check if winapi joystick still works, you can change Btw Half-Life anniversary page mentions some changes to mouse and joystick input. I don't know it's something on game library side or in the engine.
|
@a1batross any progress with testing on your side? Can it be merged? |
I will look into that soon. |
I forgot. What exactly I should look for? It builds and runs on Linux versions of GoldSrc and Xash3D just fine. |
The raw mouse input seems to work correctly. If I move camera to the side and back very fast the crosshair ends up approximately at the same position (while without raw input it shifts with every "swing" due to acceleration). I don't have any game controller, so I can't check joystick inputs. |
Everything works. LGTM |
@nekonomicon merge it? |
Dynamically load SDL2 on Windows and use its functions for mouse handling. If SDL2 is not available (i.e. the mod is running on pre-SDL2 version of Half-Life), it fallbacks to the pre-SDL2 mouse input.
USE_SDL2
macro is removed and replaced with dynamic checks for the presence ofsdl2Lib
.Without
SDL_SetRelativeMouseMode
andSDL_GetRelativeMouseState
the raw input doesn't really seem to work, so I decided it could be useful to have this option working in this hlsdk. But we need to figure out the reliable way to check if raw input works without relying on "feelings".Although it works, you can consider this merge request as WIP, because I left joystick input the same as in pre-SDL2 Half-Life versions on Windows regardless of whether SDL2 is available or not. I don't have a joystick currently, so I can't test anything related to it. Someone else can change and test such things and add commits to this PR.
I also haven't tested it on Xash3D-FWGS yet (just to make sure it doesn't cause any troubles while building without GoldSource input support) and on the vanilla Xash3D.
I also added SDL2 headers (copied from valve's repo external/ subdirectory), so the user is not required to install SDL2 headers on Windows. On Linux you still need to download a dev package to SDL2. But we can rely on the headers bundled in the repository for Linux build too.
Thoughts:
We probably can remove some SDL2 .h files to minimize their presence in the repo.