Commit graph

83 commits

Author SHA1 Message Date
Zack Middleton
e452b7ac04 Fix macOS client/server failing to start from terminal
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.
2023-06-11 11:05:13 -04:00
Zack Middleton
84da6537c4 Fix in_availableJoysticks cvar not updating
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
  "
2022-09-22 10:37:30 -05:00
Zack Middleton
f92c293f7b Add keys for SDL 2.0.14's new gamepad buttons
This fixes the additional buttons triggering binds for ioq3 left
and right joystick direction keys.
2022-09-22 09:18:22 -05:00
Zack Middleton
77d6cde137 Fix compiling against SDL 2.0.17
KMOD_RESERVED was replaced with KMOD_SCROLL.
2021-08-15 12:07:02 -04:00
Zack Middleton
699cbed7c7 Fix mouse grab after toggling fullscreen
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.
2018-04-09 00:05:43 -05:00
Zack Middleton
0d6edd227a Support Unicode characters greater than 0xFF in cl_consoleKeys
Unrelated: make '0x' value be -1 (invalid) instead of 0.

Reported by MAN-AT-ARMS.
2018-02-22 18:15:53 -06:00
Zack Middleton
098d97bdb0 Fix in_nograb not releasing the mouse cursor
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.
2017-09-10 19:11:36 -05:00
Eugene Molotov
e0a367451f ignore window resize event on fullscreen 2017-09-10 14:31:51 +05:00
Zack Middleton
63e07afae9 Make input events use earliest possible time
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.
2017-08-21 22:43:33 -05:00
Zack Middleton
34d0b78754 Improve keys using international key layouts
Always map number row to number keys for AZERTY.
Map Unicode character keys to world keys using scan code.

Based on patches by @mickael9.
2017-08-21 20:21:18 -05:00
SmileTheory
c5c01e771a Fix joystick w/o controller mapping not working with SDL update. 2016-08-16 19:01:18 -07:00
SmileTheory
1cf0b21cda Fix black screen when in_joystick disabled but controller connected. 2016-08-11 00:46:43 -07:00
SmileTheory
6262972488 Fix stricmp usage in previous commit. 2016-08-08 02:43:02 -07:00
SmileTheory
b7f2ebd477 Better gamepad support. 2016-08-08 02:36:10 -07:00
SmileTheory
d09866861e Controller hot plug support. 2016-08-04 21:32:35 -07:00
Victor Roemer
398dea397c Fix Makefile for OSX
Bump base SDK from 10.5 -> 10.7
Just use the builtin __APPLE__
2016-06-12 17:17:33 -04:00
Tim Angus
30c88442b2 Merge pull request #133 from Pan7/SDL_bool
SDL_FALSE/TRUE for SDL_SetWindowGrab
2015-07-26 15:48:59 +01:00
Pan7
9e08cdb16a SDL_FALSE/TRUE for SDL_SetWindowGrab 2015-07-26 03:21:45 +02:00
Tim Angus
605dfabb94 Merge pull request #132 from Pan7/SDL_Init
SDL_Init zero check
2015-07-25 11:54:12 +01:00
Pan7
2a38bca931 SDL_Init zero check 2015-07-24 22:56:00 +02:00
Zack Middleton
5082548bf5 Horizontal scroll should not cause K_MWHEELDOWN key press 2015-05-29 16:38:43 -05:00
Zack Middleton
148603c951 Don't run vid_restart when "resized" to current size 2015-02-28 18:35:41 -06:00
Ensiform
b9e97b3857 Move Event processor call down below the mouse checks.
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.
2015-01-26 02:39:58 -06:00
Zack Middleton
a700b76722 Fix reading 4 byte UTF-8 text input 2014-12-19 21:56:54 -06:00
Zack Middleton
9fbbf4214d Fix Windows key bind name on non-Mac using SDL2
SDL 1.2 sends SDKL_*META (command) and SDLK_*SUPER (windows key).
SDL2 sends SDLK_*GUI for both.
2014-09-11 20:04:28 -05:00
Zack Middleton
878cda6a20 Fix binding 'context menu' key using SDL2
SDL 1.2 converted Windows' VK_APPS and X11 XK_Hyper_R to SDLK_MENU.
SDL2 has it as a separate SDLK_APPLICATION key, so convert it to K_MENU too.
2014-09-11 20:03:54 -05:00
Zack Middleton
1d95ef210e SDL 2 scroll/caps/num lock keys send KEYUP event when key is released 2014-08-28 20:09:37 -05:00
Zack Middleton
077f6bd068 Fix binding KP_NUMLOCK
Restore mapping SDL numlock to quake3 numlock.
2014-08-26 23:01:18 -05:00
Tim Angus
2a3368481d Merge branch 'master' into sdl2
Conflicts:
	Makefile
	code/renderergl2/tr_image.c
2014-08-25 15:00:48 +01:00
Zack Middleton
1d664a3a10 Remove unused cvar in_joystickDebug 2014-07-03 20:59:54 -05:00
Zack Middleton
5994564537 Remove unused array joy_pressed 2014-06-19 20:48:54 -05:00
Zack Middleton
6a33a69795 Disable key repeat if key catcher is 0
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.
2014-05-19 03:45:44 -05:00
Zack Middleton
9f22ae9cb2 Fix ctrl-c etc codes for edit fields 2014-03-17 12:46:09 -05:00
Zack Middleton
952fd0489c Readd backspace char event for UI VM text fields
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).
2013-11-26 17:03:15 -06:00
Zack Middleton
cb153f2aaa Fix warning that SDL_GetKeyboardState return value is used non-const 2013-10-19 00:39:07 -05:00
Zack Middleton
c6a61d212a Fix SDL2 losing event subsystem
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.
2013-10-18 16:31:19 -05:00
cmf028
11c3bed74d Send key up events for the mouse wheel
Previous versions of SDL would send SDL_MOUSEBUTTONUP events for the mouse wheel immediately following the corresponding SDL_MOUSEBUTTONDOWN event
2013-09-23 12:21:21 -05:00
cmf028
7d83bba2d0 Set com_minimized to 0 when the window is restored 2013-09-23 12:21:21 -05:00
Tim Angus
bde7665462 Merge branch 'master' into sdl2
Conflicts:
	code/sdl/sdl_input.c
2013-08-16 23:34:08 +01:00
Zack Middleton
81909bb266 Fix text getting appended to vid_restart in command buffer
I was getting unknown command "vid_restart-button2" warning on OSX when trying to use alt-return to toggle fullscreen.
2013-08-03 17:40:50 -05:00
Zack Middleton
30fcabec65 SDL Mouse Button clean up
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.)
2013-07-09 14:41:56 -05:00
Tim Angus
42586b782b Improve console key situation 2013-01-21 22:20:15 +00:00
Tim Angus
aaea838d39 Convert SDL text input to UTF-32 2013-01-19 21:35:09 +00:00
Tim Angus
61ed67bd1a Make the mousewheel work 2013-01-17 19:04:27 +00:00
Tim Angus
f478761e07 Use SDL 2 instead of SDL 1.2 2013-01-17 18:20:03 +00:00
Zack Middleton
fb1f629bbc Removed unnessicary "!!". 2012-06-01 19:49:07 +00:00
Zack Middleton
021ce233b2 #5484 - Remove unneeded tr_local.h include from sdl_input.c. Patch by Harley Laue. 2012-04-04 17:16:11 +00:00
Zack Middleton
7a1efc19a4 Support up to 16 joystick axes, select which to use with j_*_axis cvars. 2012-02-15 18:26:08 +00:00
Zack Middleton
4113f63a63 Changed the joystick axis to key remap to start at K_JOY17 (fits better with hat_keys and K_JOY16 is used by button). 2011-09-09 21:46:37 +00:00
Zack Middleton
a87b059ab7 Don't grab mouse till UI loads. 2011-08-05 19:47:33 +00:00