The macOS client and server were completely unusable when run from a
terminal. They blocked forever in `[NSApp run];` which was called by
Sys_InitProtocolHandler(). `applicationDidFinishLaunching` was never
called to exit the NSApp run loop.
Use SDL's SDL_DROPFILE event to receive URLs to handle on macOS instead.
This also handles URLs while the game is running (connect to new server)
instead of nothing happening when clicking a link while the game is
running.
When in_restart is called or SDL controller added/remove event is
received, IN_InitJoystick() tried to update the list but instead
of updating the cvar Cvar_Get() just printed a developer message:
Warning: cvar "in_availableJoysticks" given initial values:
"first joystick
", "first joystick
second joystick
"
cls.glconfig.isFullscreen was not updated when changing r_fullscreen
without a vid_restart. Starting in fullscreen and switching to
windowed mode would not release the mouse.
Mods calling trap_GetGlconfig() after a fullscreen toggle now get
the correct value for isFullscreen. (Note: Mods already got the
correct value at start up and after vid_restart.)
Reported by Mickaƫl "mickael9" Thomas.
Disable SDL relative mouse mode when in_nograb is enabled. Relative
mouse mode hides the cursor and it cannot exit the window regardless
of the window's grab state.
This wasn't always the case. SDL before 2.0.4 on GNU/Linux released
the mouse cursor in relative mode. However, SDL 2.0.3/4 on Windows
does not. (I did not test other Windows versions.) So I think SDL
2.0.4 made GNU/Linux X11 behavior consistent with other platforms.
This fixes mouse input being unusable when debuging client crashes
in gdb.
SDL doesn't provide exact the exact time that input events happen
so use the earliest possible time that an event could happen.
This make sub-frame input actions such as walking take affect
immediately instead of in the next frame.
Based on patch by Alexander "wareya" Nadeau.
Only send mouse events if both values are non-zero.
Hopefully this helps with the event overflow spam that can sometimes
happen on loads or laggy situations.
SDL1.2 branch disables key repeat when key catcher is 0.
Presumably to prevent binds from executing multiple times.
SDL2 replaced being able to disabled key repeat using SDL_EnableKeyRepeat
with a non-zero repeat value in the key event.
UI VMs expect a backspace char event, but sdl2 branch only was only sending a key event.
Revert cl_keys.c to master branch (it would cause backspace to happen twice in console).
Quiting SDL Video or Joystick subsystem implies quiting the Event subsystem in SDL2.
SDL keeps track of number of init and shutdown calls for each subsystem.
Shuting down video or joystick more or equal to number of times they're inited will lead to event shutdown.
Toggling in and out of fullscreen or running in_restart twice causes SDL event subsystem to shutdown, making input not work.
If the console is closed, IN_GobbleMotionEvents gets stuck in a loop. SDL_PeepEvents returns -1 when there is an error, but we assume non-0 means read more events.
IN_ShutdownJoystick needs to check if joystick subsystem was inited before quitting it, otherwise we may cause SDL event subsystem to shutdown.
Make 'b' variable an int so that key values more than 255 will work (not currently an issue in ioq3 afaik).
Use SDL_BUTTON_* for easier transition to SDL2.
(SDL2 doesn't have SDL_BUTTON_WHEELUP or SDL_BUTTON_WHEELDOWN, X1/X2 are different values.)