Commit Graph

6274 Commits (d71df6448b04d756555d9d9d285ba4c36b7e9f61)

Author SHA1 Message Date
Sylvain 85e6500065
X11 Segmentation fault with multiple windows and renderers (see #5256) 2022-02-11 11:08:08 +01:00
Sylvain a75041e8dd
Fixed bug #2140: basic support to convert 16 colors palette PIXELFORMAT_INDEX4, to allow conversion to SDL_Texture 2022-02-10 13:44:59 +01:00
Wouter Wijsman abc8198a1f Render all sides when drawing rect on PSP 2022-02-09 09:36:19 -08:00
Frank Praznik 228db35287 audio: pipewire: Tidy up formatting 2022-02-08 14:33:34 -05:00
Frank Praznik 9da9e85cba audio: pipewire: Reset all hotplug values and pointers on shutdown
Ensure that all hotplug variables and pointers are reset to NULL or their original value when shutting down.
2022-02-08 14:33:34 -05:00
Frank Praznik 5b36a527ed audio: pipewire: Remove redundant locks
The io_list_check_add() and io_list_remove() functions are only ever called from within the Pipewire thread loop, so the locks are redundant.  io_list_sort() is called from within a lock in the device detection function, so those additional locks are redundant as well.
2022-02-08 14:33:34 -05:00
Frank Praznik 48b4d1c412 audio: pipewire: Convert atomic hotplug conditional variables to SDL_bool
The hotplug loop condition variables are always guarded by the loop mutex while the loop is running, so they don't need to be atomic.
2022-02-08 14:33:34 -05:00
Ozkan Sezer 67f12ede3b move bug #5333 fix to headers 2022-02-08 21:32:50 +03:00
Wouter Wijsman 54304b971d Fix rotation direction and center point on PSP 2022-02-08 09:47:10 -08:00
Wouter Wijsman 2b572dff88 Make RenderCopyEx rotate around center
This still isn't perfect. The rotation is the wrong way around and the
images are upside down.
2022-02-08 09:47:10 -08:00
Ozkan Sezer 7935cfacc5 SDL_mfijoystick.m: use __typeof instead of typeof.
Fixes https://github.com/libsdl-org/SDL/issues/5319
2022-02-08 18:55:10 +03:00
Ozkan Sezer 9b817248c5 SDL_spinlock.c: define HAVE_GCC_ATOMICS for windows/clang builds,
... if not already defined.
Fixes https://github.com/libsdl-org/SDL/issues/5333

diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c
index bdd347e..4f10741 100644
--- a/src/atomic/SDL_spinlock.c
+++ b/src/atomic/SDL_spinlock.c
@@ -28,6 +28,12 @@
 #include "SDL_mutex.h"
 #include "SDL_timer.h"

+#if defined(__WIN32__) && defined(__clang__)
+# ifndef HAVE_GCC_ATOMICS
+# define HAVE_GCC_ATOMICS 1
+# endif
+#endif
+
 #if !defined(HAVE_GCC_ATOMICS) && defined(__SOLARIS__)
 #include <atomic.h>
 #endif
2022-02-08 18:50:02 +03:00
Sylvain e7e44df039
Dynapi: add SDL_GetTouchName() entry 2022-02-08 11:34:41 +01:00
Sylvain 34d4f5b14e
Fixed bug #2032: add SDL_GetTouchName to expose the driver name of the device (Thanks @mgerhardy!) 2022-02-08 11:32:20 +01:00
Frank Praznik 53091e36a3 audio: pipewire: Remove the hard upper bound on rates and buffer sizes
Remove the hard upper limit of 8192 samples and instead use the buffer sizes provided by Pipewire to determine the size of the intermediate input buffer and whether double buffering is required for output streams. This allows for higher latency streams to potentially avoid double-buffering in the output case, and we can guarantee that the intermediate input buffer will always be large enough to handle whatever Pipewire may deliver.

As the buffer size calculations occur in a callback in the Pipewire processing thread itself, the stream readiness check has been modified to wait on two distinct flags set when the buffers have been configured and when the stream is ready and running.
2022-02-07 15:11:31 -05:00
Frank Praznik 66866249a2 audio: pipewire: Condition variable doesn't need to be atomic
The condition variable is guarded by a mutex, so no need for it to be atomic.
2022-02-07 15:11:31 -05:00
Sylvain b0dd4c7d36 SDL_Render OpenGL: do batching like in the GLES2 backend (with no VBO) 2022-02-07 14:02:20 -05:00
Sylvain 90f0d2ce49 Revert OpenGL point drawing performance, do to proper batching 2022-02-07 14:02:20 -05:00
waddlesplash 423feac69b haiku: Actually remove BDirectWindow and fix OpenGL handling.
This provides the other half of 05c72b113c830392f8b08532317ef07972b29a2e.
2022-02-06 19:19:21 -05:00
pionere 6d5592a201 minor cleanup of SDL_CreateRenderer 2022-02-05 10:05:25 -05:00
Ozkan Sezer e8c48981f9 pthread/SDL_systhread.c: always include errno.h
fixes build for several targets after commit 87b02d3 for bug #5283.
2022-02-05 08:56:56 +03:00
Sam Lantinga 5c4fff7f63 Don't fail to get battery status if the upower refresh call fails 2022-02-04 14:02:44 -08:00
Ozkan Sezer c8cee0b8ca OS2_HasClipboardText: store the boolean result before closing clipboard.
just in case..
2022-02-04 23:28:56 +03:00
Ozkan Sezer c93e552068 minor update to winrt/SDL_sysurl.cpp
from: https://github.com/microsoft/vcpkg/blob/master/ports/sdl2/0006-Update-SDL_sysurl.cpp.patch
2022-02-04 20:03:50 +03:00
Ozkan Sezer 3b9e6c1cec SDL_os2video.c: fixed HasClipboardText() semantics.
Empty string in clipboard is expected to give FALSE by SDL_HasClipboardText.
Noticed in a commit by josch1710 in bitwiseworks' os/2 fork.
2022-02-04 19:50:20 +03:00
Joshua Ashton 86b7a0642f Add additional VID/PIDs for Anne Pro II
This thing changes its VID/PID on firmware revisions...
2022-02-04 08:45:19 -08:00
Sam Lantinga dd69c28d6f Added a mapping for the Xbox Series X controller, firmware version 5.11.3118.0, connected to Linux via Bluetooth 2022-02-03 18:01:34 -08:00
Temdog007 b59e75c259 Handle menu button press from controller 2022-02-02 21:21:44 -08:00
pionere 2cfc83eab7
sync D3D_RenderReadPixels with D3D11_RenderReadPixels
- use the result of SDL_ConvertPixels to propagate error
- get rid of the verbose error message of D3D11_RenderReadPixels in case SDL_ConvertPixels failed
2022-02-02 14:56:38 -05:00
pionere 3bef4a5da6
cleanup error-handling in SDL_egl.c
- always set error message in SDL_EGL_ChooseConfig / SDL_EGL_CreateContext
- assume SDL_EGL_DeleteContext does not alter the error message
- sync generic error message of SDL_EGL_MakeCurrent with SDL_EGL_Get/SetSwapInterval
- do not overwrite error message of SDL_EGL_ChooseConfig in WINRT_CreateWindow
2022-02-02 14:56:21 -05:00
pionere b5c5052608
cleanup error-handling in SDL_bmp.c
- add missing error-message in SDL_LoadBMP_RW
- check return value of SDL_RWtell in SDL_LoadBMP_RW
- use standard SDL_EFREAD error instead of custom strings
+ adjust return type of readRlePixels
2022-02-02 14:55:36 -05:00
pionere 19df4af2aa
simplify SDL_DUMMY/OFFSCREEN_CreateWindowFramebuffer 2022-02-02 14:45:48 -05:00
SonicMastr ecd922b5cf Fix touch holding detection after #5244 changes 2022-02-02 08:55:26 -08:00
Sylvain df0d696a62
RISCOS: attempt to fix compilation ERANGE 2022-02-02 15:22:14 +01:00
Sylvain 87b02d3795
Linux thread name limitation: test for ERANGE (see bug #5283) 2022-02-02 15:09:29 +01:00
Sylvain 220a9596f3
Remove testing instruction (see bug #5283) 2022-02-02 10:01:11 +01:00
Sylvain 9e46a512b1
Fixed bug #5283 - limit thread name to 16 characters when using pthread_setname_np() 2022-02-02 09:58:15 +01:00
Weng Xuetian b11dfd7611 Only generate key repetition for keys that should repeat on wayland.
This fix repetition on modifier keys, e.g. Control.
2022-02-01 17:56:04 -05:00
Weng Xuetian a90a2e7582 Fix text_input_v3 preedit string
For every batch of text_input_v3 updates, if there is no preedit in this
batch, preedit should be cleared.
2022-02-01 15:51:26 -05:00
Sam Lantinga 03c4405b3b Fixed D-Bus battery refresh call 2022-02-01 09:33:18 -08:00
Sylvain d224a63bda
Fix compilation for non Android 2022-02-01 11:34:01 +01:00
Sylvain fe2ed6cf6f
Fixed bug #5221 - Add SDL_AndroidSendMessage() 2022-02-01 11:30:43 +01:00
pionere 97269e143d adjustments to ime_candidates
- allocate ime_candidates on demand
- allow write to the whole allocated memory of ime_candidates
- ensure ime_candcount is set to zero in case the candidates can not be queried for any reason
2022-01-31 22:06:26 -05:00
pionere 6f404d0f04 cleanup IME_GetCandidateList / UILess_GetCandidateList
- move IME_ShowCandidateList, ImmGetContext and ImmReleaseContext to this function
- set ime_candpgsize to MAX_CANDLIST if dwPageSize is zero
- comment out deselection of ime_candsel in case of korean language for the moment (LANG_CHT does not work anyway)
2022-01-31 22:06:26 -05:00
Sam Lantinga ec8e3104c8 Refresh the battery state before we query it on Linux 2022-01-31 17:01:08 -08:00
Frank Praznik 0b34f18045 audio: pipewire: Don't double free properties on init failure
The context and stream creation functions will destroy the passed properties object on failure, so no need to do it manually.

The pw_properties_free() function pointer is no longer needed, so it can be removed.
2022-01-30 23:23:03 -05:00
Sylvain f7d3abddba
Fixed bug #964 - SDL_RenderCopy stretch loses proportion on viewport.
Handle the case when there is blending
2022-01-29 10:19:08 +01:00
pionere a5c610b0a3 revert 'Changed to use 0xFE instead of 0xFF for better sound quality.' 2022-01-28 20:40:19 -05:00
Ryan C. Gordon 43f0271b4e Revert "fix compiler warnings in SDL_windows_gaming_input.c"
This reverts commit ca36cdb185f2f26241598068927821896f36b904.

The older Windows SDK's headers are wrong, and this change would crash if
you hotplug a device.
2022-01-28 20:40:19 -05:00
pionere a70bb259c7 drop handle parameter of OpenDevice 2022-01-28 20:40:19 -05:00
pionere 47ddb04e17 cleanup/sync the main loop of *_OpenDevice functions to pick audio format II. 2022-01-28 20:40:19 -05:00
pionere 2eafe4340c cleanup/sync the main loop of *_OpenDevice functions to pick audio format 2022-01-28 20:40:19 -05:00
pionere 3939ef72f8 cleanup SDL_GetAudioDeviceSpec
- drop unnecessary hascapture check
- call SDL_InvalidParamError and return -1 in case the index is out of range
- do not zfill SDL_AudioSpec
- adjust documentation to reflect the behavior
2022-01-28 20:40:19 -05:00
pionere 113109f839 cleanup SDL_GetAudioDeviceName
- drop unnecessary hascapture check
- call SDL_InvalidParamError in case the index is out of range
2022-01-28 20:40:19 -05:00
pionere f91211eb17 cleanup WASAPI_PrepDevice
- reorganize the loop which checks for the right wave-format
- use the return value of UpdateAudioStream
- ensure SetError is called in SDL_NewAudioStream
2022-01-28 20:40:19 -05:00
pionere c9e8d1573a re-use return value of SDL_SetError/WIN_SetErrorFromHRESULT/SDL_OutOfMemory II. 2022-01-28 20:40:19 -05:00
pionere 1043dd8c0d adjust handling of iscapture
- drop iscapture parameter of OpenDevice
- use SDL_bool for iscapture
2022-01-28 20:40:19 -05:00
pionere e2f70a2dff cleanup SDL_EventState 2022-01-28 20:40:19 -05:00
pionere 32c7d5d352 cleanup IME_UpdateInputLocale
- do not store the HKL in a static variable
- always set the ime_candvertical value in case the HKL is changed
2022-01-28 20:40:19 -05:00
pionere 25aa7244dc cleanup IME_GetId
- use assert instead of a check (it is a static function with constant parameter)
- assume it is called with 0 first (simplifies the logic)
- reuse dwLang value instead of a new 'call' to LANG()
2022-01-28 20:40:19 -05:00
pionere 60deadba59 re-use return value of SDL_SetError/WIN_SetErrorFromHRESULT/SDL_OutOfMemory 2022-01-28 20:40:19 -05:00
pionere ebdd536676 use SDL_InvalidParamError or SDL_assert instead of custom SDL_SetError 2022-01-28 20:40:19 -05:00
pionere 4a17612bff get rid of BeginLoopIteration 2022-01-28 20:40:19 -05:00
pionere 0770c5829c get rid of PrepareToClose 2022-01-28 20:40:19 -05:00
Ryan C. Gordon e0236c02ce audio: Removed an unnecessary commented-out line. 2022-01-28 20:40:19 -05:00
pionere 0dda8a7f4c cleanup init functions of audio
- use SDL_bool if possible
- assume NULL/SDL_FALSE filled impl
- skip zfill of current_audio at the beginning of SDL_AudioInit (done before the init() calls)
2022-01-28 20:40:19 -05:00
pionere 6fcfcc3d6f get rid of SkipMixerLock 2022-01-28 20:40:19 -05:00
pionere 3c85cef46c cleanup SDL_RegisterApp
- fix memory leak when RegisterClassEx fails
- set style according to the documentation
- eliminate duplicated SDL_Instance setter
2022-01-28 20:40:19 -05:00
pionere 014e2bbdb2 use SDL_COMPILE_TIME_ASSERT instead of SDL_STATIC_ASSERT 2022-01-28 20:40:19 -05:00
pionere 95f30c7a48 fix compiler warnings in video/uikit 2022-01-28 20:40:19 -05:00
pionere 176941a4fb allow MacOS build without SDL_FILE 2022-01-28 20:40:19 -05:00
pionere eb80f2c65a sync handling of subsystems II. 2022-01-28 20:40:19 -05:00
pionere 942b01a54c do not use RWOps in WIN_SetWindowIcon 2022-01-28 20:40:19 -05:00
pionere bf66720a4d fix mixing of U16 audio 2022-01-28 20:40:19 -05:00
pionere 905e2e22ef cleanup of SDL_MixAudioFormat 2022-01-28 20:40:19 -05:00
pionere d7110b4490 fix compiler warnings in SDL_windows_gaming_input.c 2022-01-28 20:40:19 -05:00
pionere e11ba0f5d9 do not load/unload opengl library when SDL_WINDOW_METAL flag is changed 2022-01-28 20:40:19 -05:00
Sylvain f5911bdc59 GLES2: disable texcoord when not using it (see bug #5235)
similar to opengl backend code:
- glDisableVertexAttribArray doesn't need to depend on 'drawstate.texture' value
- move binding code to SetCopyState()
2022-01-28 19:25:40 +01:00
Sylvain 096fe37bb2 GLES2: revert 7bf8c5a388 2022-01-28 19:25:40 +01:00
Sylvain a988ce5544
Fixed bug #964 - SDL_RenderCopy stretch loses proportion on viewport boundaries 2022-01-28 17:24:59 +01:00
Sylvain 7bf8c5a388 GLES2: disable texcoord when not using it (see bug #5235) 2022-01-27 21:49:05 -05:00
Vitaliy Zhmurikov 5b74459255 Update SDL_joystick.c
Add Logitech Momo Racing Wheel VID & PID  to SDL_IsJoystickProductWheel function
2022-01-27 12:30:41 -08:00
Ryan C. Gordon 19ae71b2db
video: Don't add SDL_WINDOW_(METAL|OPENGL) to new windows if unsupported.
Fixes #4656.

(Better than the previous fix in 3044310518dbb2d4814b32c6521f332b8d69aae5.)
2022-01-27 11:49:15 -05:00
Ivan Epifanov d7e0c54dde PSVita: send initial SDL_JOYDEVICEADDED events 2022-01-27 08:47:53 -08:00
Cameron Gutman cc40f732f9 wayland: Round the refresh rate rather than truncating it
A 59999 mHz monitor should be reported as 60 Hz, not 59 Hz.
2022-01-26 21:27:13 -06:00
Ryan C. Gordon 3044310518 video: Don't add SDL_WINDOW_METAL to new windows if not using Cocoa or UIKit.
Fixes #4656.
2022-01-26 21:10:15 -05:00
Cameron Gutman 77a9ca6ba0 wayland: Fix SDL_SetWindowSize() being dropped right after exiting fullscreen
If we get a SDL_SetWindowSize() call right after SDL_SetWindowFullscreen() but
before we've gotten a new configure event from the compositor, the attempt to
set our window size will silently fail (when libdecor is enabled).

Fix this by remembering that we need to commit a new size, so we can do that
in decoration_frame_configure().
2022-01-26 19:48:16 -05:00
Cameron Gutman c6ec5a07f1 d3d11: Respect SDL_HINT_RENDER_DIRECT3D_THREADSAFE when creating device 2022-01-26 18:44:29 -06:00
Ryan C. Gordon f37e4a94d3
video: Don't check if we can use a "texture framebuffer" until needed.
This prevents SDL from making an OpenGL context and maybe throwing it away
immediately by default. It will now only do it when trying to request a
window framebuffer directly, or creating an SDL_Renderer with the "software"
backend, which makes that request itself.

The way SDL decides if it should use a "texture framebuffer" needs dramatic
updating, but this solves the immediate problem.

Reference Issue #4624.
2022-01-26 17:06:25 -05:00
Ethan Lee 8ceba27d62 video: Prefer Wayland over X11 2022-01-26 12:32:45 -05:00
Ethan Lee 68a71f91c6 wayland: Try to avoid committing before the window is shown 2022-01-25 17:19:19 -05:00
Sam Lantinga 84320266f2 Fixed the queue filling up with sentinel events when the WaitEvent call is passed NULL for the event
The use case is an application that waits for events on the main thread and dispatches them on a separate thread.
2022-01-25 12:37:43 -08:00
Ethan Lee f0e768da43 wayland: Call SetFullscreen directly in ShowWindow.
This cuts out an extra flush when getting the first configure event.
2022-01-25 13:07:00 -05:00
Sylvain 8c660ccb6f
Fixed bug #5256: X11 Segmentation fault with multiple windows and renderers
First window is created and it triggers and 'EnterNotify' event
which calls SDL_SetMouseFocus() and X11_ShowCursor() while the second
windows hasn't finished to be created  (eg window->driverdata isn't set)
Just check for a valid 'driverdata'
2022-01-25 17:18:40 +01:00
Ethan Lee e2d74bcbe5 wayland: Detach hidden surfaces in HideWindow, not ShowWindow 2022-01-25 11:16:09 -05:00
ulatekh 57bc90403e Add hint to optionally forcibly raise the window under MS Windows. 2022-01-24 11:10:57 -08:00
ulatekh d7873e656b Disable tablet flicks under MS Windows. 2022-01-22 08:52:46 -08:00
Charlie Birks 15ebad6e7d emscripten: Implement SDL_OpenURL 2022-01-22 13:31:11 +00:00
Charlie Birks 99af3281ee timer: Fix Emscripten declaration-after-statement error 2022-01-22 12:27:54 +00:00
ulatekh 53df0e6619 Fix the erroneous generation of mouse-down events from touch-move events.
The issue is that MS Windows synthesizes a mouse-move event in response
to touch-move events, and those mouse-move events are NOT labeled as
coming from a touch (e.g. GetMouseMessageSource() will not return
SDL_MOUSE_EVENT_SOURCE_TOUCH for those synthesized mouse-move events).

In addition, there seems to be no way to prevent this from happening;
https://gist.github.com/vbfox/1339671 claims to demonstrate a technique
to prevent it, but in my experience, it doesn't work.

Because of this, the "fallthrough" case can't test that the synthesized
mouse-move came from a touch-move, and starts erroneously pressing down
the mouse-button, leading to massive confusion in the client
application.
2022-01-21 17:23:59 -08:00
ulatekh 8f8b14cbb6 Synthesize a missing touch-up event.
If a touch-down event is received for an existing touch-ID, that
probably means the operating system lost it, and that the missing
touch-up should be synthesized, to keep the client state coherent.
2022-01-21 17:23:11 -08:00
Ozkan Sezer d2456b6e4c os2, geniconv: default functions pointers to Uni*() API,
In case they get accessed before SDL_Init() was called.
2022-01-21 11:50:40 +03:00
Sam Lantinga 67cb548bef Fixed build error with C90 compilers 2022-01-20 19:31:54 -08:00
Carl Glave a23b3c767f Add support for correlating trigger input 2022-01-20 17:43:35 -08:00
Ethan Lee e1b4761c62 wayland: Avoid calling SetFullscreen in libdecor ShowWindow.
This caused some weird stuff to happen in the libdecor path, probably because
the window hasn't actually been mapped yet. It ends up calling stuff that
should not yet apply, and so fullscreen in particular would have a really
messed up titlebar.

The good news is, libdecor is good about tracking fullscreen state, so we can
let the callback do this for us. Keep this for xdg_shell because we actually
map the window ourselves, so we know this call is valid for that path.
2022-01-20 14:10:58 -05:00
Ethan Lee ed3442d7a5 wayland: Fix building with SDL_OPENGL=OFF 2022-01-19 15:47:52 -05:00
Ryan C. Gordon 426c1f4b85
opengles2: fix comment about client-side arrays. 2022-01-19 14:28:30 -05:00
Frank Praznik b3984df1c6 audio: pipewire: Use client config files instead of module names
Pipewire, as of 0.3.22, uses client config files to load modules instead of explicitly specifying them (PW_KEY_CONTEXT_PROFILE_MODULES is deprecated).  Use the new method to load the realtime module to boost the audio thread priority.
2022-01-19 14:20:19 -05:00
Sam Lantinga a0e3c884d4 Updated to version 2.0.21 for development 2022-01-17 15:32:27 -08:00
Cameron Gutman d3952a8a2c wayland: Avoid spurious resize events 2022-01-17 11:30:03 -06:00
Sam Lantinga b06866ef97 Entirely remove Xbox axis filtering, we don't want this at all. 2022-01-16 09:44:28 -08:00
Sam Lantinga 09aed1020b Don't send output reports to the Victrix Pro FS v2
It'll hang on reboot if it gets output reports, and it doesn't have functionality that requires them, so skip it.
2022-01-16 09:23:58 -08:00
Sam Lantinga 85961b61a1 Disable Xbox axis deadzone handling by default
Fixes https://github.com/libsdl-org/SDL/issues/5227
2022-01-16 09:01:56 -08:00
Mathieu Eyraud 2a0cde8fd5 Always send SDL_WINDOWEVENT_SIZE_CHANGED when window is resized
SDL_WINDOWEVENT_SIZE_CHANGED is now sent even if the resulting size of the window does not match the requested size.
2022-01-16 08:49:48 -08:00
Sam Lantinga 1a50334c46 Fixed Xbox One trigger axis zero point 2022-01-14 15:04:26 -08:00
Ozkan Sezer e9511f7136 hidapi, libusb: don't use iconv on OS/2, it lacks wchar_t functionality.
Taken from a patch by Silvan Scherrer at bitwiseworks' OS/2 fork.
2022-01-14 14:39:04 +03:00
Ethan Lee 9a2bbd8acb wayland: Convert URI to local path for DropFile 2022-01-12 13:01:05 -05:00
Ozkan Sezer 0abc0a6f32 SDL_string.c: tidy-up gcc2 va_copy defines after previous haiku commit. 2022-01-12 20:37:32 +03:00
kenmays d37c9777b9 haiku: updated for Haiku 2022-01-12 09:32:56 -08:00
kenmays bff867013e haiku: updated for Haiku 2022-01-12 09:32:56 -08:00
kenmays 094e94402d haiku: Remove BDirectWindow, fix OpenGL handling.
From e6cc4e7f4b8189be55dd3b0e13e54e59f73d7672 Mon Sep 17 00:00:00 2001
From: X512 <danger_mail@list.ru>
Date: Thu, 30 Jan 2020 04:01:58 +0900
Subject: libsdl2: Remove BDirectWindow, fix OpenGL handling.

* BDirectWindow changed to BWindow.
* Implemented fullscreen.
* Introduced view for non-OpenGL drawing.
* Drawing thread removed, window thread is used instead.
* Use BGLView as OpenGL context. Implement proper context switching and OpenGL
  locking. Only one context per window is supported. BGLView should be not
  deleted when window is closed, it deleted when deleting context.
2022-01-12 09:32:56 -08:00
Ozkan Sezer 5b6e2d69a5 SDL_os2messagebox.c (_makeDlg): remove unnecessary casts 2022-01-12 11:01:02 +03:00
Ryan C. Gordon 42302d0a59
x11: Let apps specify a custom _NET_WM_WINDOW_TYPE.
Fixes #5185.
2022-01-11 21:17:21 -05:00
Ryan C. Gordon f9b918ff40 opengles2: Use client-side arrays on everything but Emscripten.
Turns out they're much faster!

Fixes #5206.
2022-01-11 19:41:41 -05:00
Ozkan Sezer ea0bca573d SDL_cocoamodes.m: fix build against older SDKs.
Fixes https://github.com/libsdl-org/SDL/issues/5208
2022-01-11 14:56:56 +03:00
Ozkan Sezer 7527c8d3d7 hidapi, libusb: provide a wcsdup implementation if it is not available.
similar to mac and android versions..
2022-01-11 11:33:02 +03:00
Ozkan Sezer c6c4d4211b pthread: disable SetThreadPriority for OS/2 too 2022-01-11 11:33:02 +03:00
Sam Lantinga d8129c5698 Mark internal function as static 2022-01-10 10:50:59 -08:00
Ethan Lee 3e1b3bc344
wayland: Horizontal wheel values do not need to be inverted 2022-01-10 10:07:44 -05:00
Sam Lantinga a29d3acc9e Updated Bresenham line drawing to match software renderer output 2022-01-09 11:12:13 -08:00
Ozkan Sezer b9d98331c5 os2joystick: fix uninitialized use of local var 'maxdevs' 2022-01-09 20:33:32 +03:00
Ozkan Sezer 17da60068d os2joystick: fix -Wsequence-point issues. 2022-01-09 20:33:32 +03:00
Ozkan Sezer f14c7bb443 added missing hidapi stuff for os/2 with libusb 2022-01-09 20:33:32 +03:00
Sam Lantinga 1f32dd8edc Fixed overdraw with duplicate points, fixed not drawing single point lines 2022-01-09 06:36:18 -08:00
Ryan C. Gordon 5d07c03613
psp: Force channels to stereo if user requested anything other than mono.
Before it would only clamp to stereo if it also had to resample, which would
fail if the app specified 44100Hz and surround sound.
2022-01-09 08:13:34 -05:00
Ryan C. Gordon c275436f56
opengles2: Batching lines/points used wrong var for summing vertex counts.
Fixed this in the vitagxm backend too, but I don't know what the state of
that code is otherwise.

Reference Issue #5061.
2022-01-09 00:39:02 -05:00
Joan Bruguera 9e6249fa54 wayland: Avoid spurious key repeats when not pumping events
Previous to this commit, key repeats events were typically generated when
pumping events, based on the time of when the events are pumped. However,
if an application doesn't call `SDL_PumpEvents` for some seconds, this time
can be multiple seconds in the future compared to the actual key up event time,
and generates key repeats even if a key was pressed only for an instant.

In practice, this can happen when the user presses a key which causes the
application to do something without pumping events (e.g. load a level).
In Crispy Doom & PrBoom+, when the user presses the key bound to "Restart
level/demo", the game doesn't pump events during the "screen melt" effect,
and the level is restarted multiple times due to spurious repeats.

To fix this, if the key up event is among the events to be pumped, we generate
the key repeats there, since in the Wayland callback we receive the time when
the key up event happened. Otherwise, we know no key up event happened and we
can generate as many repeats as necessary after pumping.

Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
2022-01-08 14:10:22 -08:00
Joan Bruguera 461724d287 wayland: Refactor time fields in SDL_WaylandKeyboardRepeat
Refactorization with no functional changes.

Instead of `next_repeat_ms` containing a timestamp based on SDL ticks, we make
it zero-based relative to the key press time, and we store the key press time in
SDL ticks in a new field.

This refactorization is groundwork for future commits which need to use the
key press and release timestamps provided by the Wayland API, which are also
expressed in milliseconds, but whose base does not match the one for SDL ticks.

Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
2022-01-08 14:10:22 -08:00
Joan Bruguera fb0c3040c0 wayland: Avoid infinite loop in keyboard_repeat_handle
If `repeat_info->next_repeat_ms` overflows, many key presses will be generated.
In the worst case, `now = 0xFFFFFFFFU` and the loop will never terminate.

Rearrange the comparison in order to gracefully handle the overflow case.

Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
2022-01-08 14:10:22 -08:00
Sam Lantinga 3b083b9911 Fixed compile warning 2022-01-08 14:07:42 -08:00
Sam Lantinga b82af9dfbf Improved OpenGL point drawing performance (thanks @slime73!)
We'll do proper call batching for the SDL 2.0.22 release
2022-01-08 14:05:50 -08:00
Sam Lantinga 1a73c45a08 Fixed incorrect color in the OpenGL driver 2022-01-08 13:35:17 -08:00
Sylvain 3cdda8f8ab
PSP: use 'data' variable which is alread the driver data 2022-01-08 21:58:26 +01:00
Sam Lantinga 4ef2529bf9 More efficient calculation of render_count 2022-01-08 12:37:57 -08:00
Sam Lantinga 5346c93b62 Fixed assertion on number of points rendered 2022-01-08 12:28:43 -08:00
Sam Lantinga 4b71962031 Prevent overdraw with connected line segments 2022-01-08 12:02:30 -08:00
Sam Lantinga 09ece861d1 Added the hint SDL_HINT_RENDER_LINE_METHOD to select the line rendering method 2022-01-08 11:36:52 -08:00
Sam Lantinga c1e6079836 As an optimization, draw horizontal and vertical lines using rectangles 2022-01-08 11:09:11 -08:00
Sam Lantinga 3da7c6305a Assert that we have drawn the expected number of points 2022-01-08 11:07:03 -08:00
Sam Lantinga 9f56faeedc Added line drawing using Bresenham's line algorithm (thanks @rtrussell!) 2022-01-08 10:59:31 -08:00
Sam Lantinga fe3a33a092 Use RenderGeometry for drawing lines at all scales 2022-01-08 10:10:18 -08:00
Sam Lantinga 1694782b2a Remove redundant work when render scale is 1.0 2022-01-08 09:32:23 -08:00
Sam Lantinga 2026a78dc2 Don't flush in RenderDraw*WithRects()
This allows these functions to be reused in the future for other primitives
2022-01-08 09:23:58 -08:00
Sam Lantinga 18e4d9fed1 Re-enable line drawing path in render drivers
This is still used for scaled line drawing in RenderDrawLinesWithRects()
2022-01-08 09:02:25 -08:00
Sam Lantinga dca281e810 Fixed getting different results for SDL_PollEvent(NULL) and SDL_PollEvent(&event) 2022-01-08 08:49:34 -08:00
Ozkan Sezer 4472b83129 PSP_RunCommandQueue: fix argument to PSP_SetBlendState()
src/render/psp/SDL_render_psp.c: In function 'PSP_RunCommandQueue':
src/render/psp/SDL_render_psp.c:1200: warning: passing argument 1 of 'PSP_SetBlendState' from incompatible pointer type
2022-01-08 11:56:56 +03:00
Ozkan Sezer df1474b46e psp/SDL_sysfilesystem.c: fixed a minor compiler warning.
src/filesystem/psp/SDL_sysfilesystem.c: In function 'SDL_GetPrefPath':
src/filesystem/psp/SDL_sysfilesystem.c:71: warning: passing argument 1 of 'free' discards qualifiers from pointer target type
2022-01-08 11:55:10 +03:00
Sam Lantinga 9294634840 Updated to version 2.0.20 for release 2022-01-07 18:29:40 -08:00
Ryan C. Gordon cc2013378d
render: Fixed some compiler warnings.
Fixes #5197.
2022-01-07 20:22:51 -05:00
Sam Lantinga 289c3fbb64 Revert "We only need to add the sentinel at the top of SDL_WaitEventTimeout()"
This reverts commit c477768e6f.

We want to add the sentinel anytime we pump inside SDL_WaitEventTimeout() to avoid pumping again the next time through, as a performance optimization.
2022-01-07 17:07:22 -08:00
Sam Lantinga 1085c317a5 Use the requested cursor size instead of the default cursor size
CopyImage() will scale based on the system accessibility settings automatically.

Fixes https://github.com/libsdl-org/SDL/issues/5198
2022-01-07 16:45:18 -08:00
Ryan C. Gordon 6d3b5d66cd
psp: draw lines with RenderGeometry, same as with the other renderers. 2022-01-07 18:18:53 -05:00
Sylvain 9cb2c549fa Remove QueueDrawLines from D3D, D3D11 2022-01-07 14:10:23 -08:00
Sylvain b88b6b3c23 Remove QueueDrawLines from METAL 2022-01-07 14:10:23 -08:00
Sylvain 9aac55317d Remove QueueDrawLines from GL, GLES, GLES2 2022-01-07 14:10:23 -08:00
Sylvain 8ea8b2e697 Use QueueDrawLine if provided, otherwise use RenderGeometry 2022-01-07 14:10:23 -08:00
Sylvain Becker c498727471
render: Use RenderGeometry to draw lines
This patch is from @1bsyl

Fixes #5061.
2022-01-07 16:14:28 -05:00
Sam Lantinga 4b38d4c96b Leave the Metal view active on the window when recreating the Metal renderer
Fixes https://github.com/libsdl-org/SDL/issues/5140

Also move the metal tag definition to SDL_syswm.h so it can be used by applications
2022-01-07 12:38:45 -08:00
Ryan C. Gordon 88ac517df0
opengles2: Fix point drawing. 2022-01-07 15:04:04 -05:00
Sam Lantinga 957c48b4c7 Fixed detecting focus change to child dialogs
Fixes https://github.com/libsdl-org/SDL/issues/5157
2022-01-07 10:58:04 -08:00
Sam Lantinga c477768e6f We only need to add the sentinel at the top of SDL_WaitEventTimeout() 2022-01-06 18:58:30 -08:00
Cameron Gutman e9134b045a events: Only add sentinels for pumping done inside SDL_WaitEventTimeout()
We don't want to catch explicit SDL_PumpEvents() calls by the application with
our polling check to avoid stale data. If the call to SDL_PumpEvents() produced
no events, there will be a sentinel sitting in the queue that will cause
SDL_PollEvent() to immediately return 0 next time it is called.

Our SDL_WaitEventTimeout() implementation avoids this issue by always popping
an event after calling SDL_PumpEvents(). This will remove the new sentinel if
we didn't get any new events.
2022-01-06 18:35:23 -08:00
Sam Lantinga 954858846d Move special sentinel handling inside SDL_PeepEvents() 2022-01-06 14:05:22 -08:00
Sam Lantinga 2592e6219b Clarify that timeout == 0 is handled at the top of SDL_WaitEventTimeout() 2022-01-06 14:05:22 -08:00
Sam Lantinga 8ff2166855 Only return from SDL_PollEvent() if the last sentinel is consumed 2022-01-06 14:05:22 -08:00
Sam Lantinga c9ff90b949 Clarify comment
Co-authored-by: Simon McVittie <smcv@debian.org>
2022-01-06 14:05:22 -08:00
Sam Lantinga 31f8c3ef44 Fixed event pump starvation if the application frequently pushes its own events 2022-01-06 14:05:22 -08:00
Wouter Wijsman 515b5f2a39 Fix build errors in PSP port 2022-01-06 10:17:05 -08:00
Wouter Wijsman 34e34ad5a5 Remove debug code from PSP renderer 2022-01-06 10:17:05 -08:00
stdgregwar 520c89a00a cleaning 2022-01-06 10:17:05 -08:00
stdgregwar 09f4711f40 Fix LRU when destroying texture. 2022-01-06 10:17:05 -08:00
stdgregwar c3ec62d6a6 PSP lazier blend states, display mode report with 16bit option 2022-01-06 10:17:05 -08:00
stdgregwar 0f5368fe11 PSP cached blending and texturing state, ABGR1555 stencil hack 2022-01-06 10:17:05 -08:00
stdgregwar fe405eb27b fixed LRU cache code 2022-01-06 10:17:05 -08:00
stdgregwar c1f152292b Spill render targets to ram on PSP 2022-01-06 10:17:05 -08:00
stdgregwar 77d874e3c0 Attempt to make render to texture work on PSP 2022-01-06 10:17:05 -08:00
Francisco Javier Trujillo Mata f3255df9c0 Improve audio compatibility in PSP. Now it supports more formats and frequencies 2022-01-05 19:15:41 -05:00
Sam Lantinga 16f5b9e3c3 Filter jitter on Xbox One controllers when using raw input reports 2022-01-05 11:07:52 -08:00
Wouter Wijsman 6d46e30fed Remove extra / in PSP GetPrefPath 2022-01-05 08:29:35 -08:00
Wouter Wijsman 33dccbb381 Make sure GetPrefPath also works without org 2022-01-05 08:29:35 -08:00
Cameron Gutman 419ae29d90 joystick: Move WGI driver initialization after Windows driver
WGI calls SDL_DINPUT_JoystickPresent() so we need to be sure DInput remains
initialized for the lifetime of the WGI driver to avoid a crash or duplicated
joysticks between DInput and WGI.
2022-01-04 15:53:39 -08:00
Cameron Gutman d73bd0d2f6 dinput: Don't crash in SDL_DINPUT_JoystickPresent if DInput init failed
The WGI driver will call this regardless of whether our init succeeded.
2022-01-04 15:53:39 -08:00
Ozkan Sezer 565ef63873 SDL_rwops.c: simplify `foo <= 0` checks to `!foo` with unsigned types. 2022-01-04 11:40:04 +03:00
Cameron Gutman 8f924b82d9 kmsdrm: Remove gbm_bo_get_offset()
It is not present on some older libgbm versions that we still
support and has been unused since 85e8adf.
2022-01-03 16:41:03 -06:00
Sam Lantinga 120c76c84b Updated copyright for 2022 2022-01-03 09:40:21 -08:00
Sylvain 8622eda9e9
SDL_RenderGeometry / software: TRIANGLE_GET_TEXTCOORD interpolates up to the max values included, so reduce by 1 2022-01-02 22:34:56 +01:00
Ozkan Sezer 4b112620a3 SDL_cocoamodes.m (Cocoa_GetDisplayDPI): fix build using older toolchains
Fixes https://github.com/libsdl-org/SDL/issues/5162
2022-01-02 19:11:50 +03:00
Francisco Javier Trujillo Mata 13a9cd4797 Adding sysfilesystem driver to PSP 2022-01-02 08:06:04 -08:00
rohlem 0403fa8aa6 X11_WaitEventTimeout: remove unreachable return
If that condition was reachable, the return value should be negative to indicate that waiting for the timeout failed.
Otherwise, SDL_WaitEventTimeout would incorrectly return early.
2022-01-02 08:04:13 -08:00
e d0de4c625a Android: fixes build NDK 21d 2021-12-31 11:12:21 -08:00
Sam Lantinga 8f81699868 Only clear IME display options if SDL_HINT_IME_SHOW_UI is off (thanks opxdo!)
Fixes https://github.com/libsdl-org/SDL/issues/5153
2021-12-31 08:49:28 -08:00
Ryan C. Gordon e4000c0284
video: SDL_GL_GetAttribute needs to operate on FBO 0.
If a different FBO is bound, this would return incorrect results.

Fixes #5082.
2021-12-31 10:32:39 -05:00
Sam Lantinga ab6d0d4d50 Fixed undefined behavior in SDL_memset() (thanks andrewrk!)
Fixes https://github.com/libsdl-org/SDL/issues/5147
2021-12-28 15:58:15 -08:00
shinyquagsire23 6a7b63802c Fix macOS cursor jumping to corner on first titlebar click 2021-12-28 13:38:23 -08:00
Edward Li a35a7d2507 Fix SigSegV from displayInfoInvalidate when changing resolution 2021-12-28 09:33:44 -08:00
Edward Li 1c41b53551 macOS: Calculate correct DPI by not using backingScaleFactor 2021-12-28 09:33:44 -08:00
Alex Szpakowski 724468ae2c GL renderer uses glDrawArrays instead of glBegin/glEnd.
Also change internal colors sent to GL to use unorm8 components instead of float, for improved performance.
2021-12-27 10:52:47 -05:00
Sylvain a1e992b110
Fixed bug #5118 - [Android] PointerIcon leak in Cursor API 2021-12-21 22:07:17 +01:00
Ozkan Sezer 840339c49d SDL_utf8strlcpy: store trailing_bytes explicity as unsigned type. 2021-12-18 14:01:02 +03:00
Ozkan Sezer 507d4bcd68 SDL_utf8strlen: run bit-test explicitly on unsigned char 2021-12-18 14:01:02 +03:00
Ozkan Sezer 82fc67ae4d SDL_joystick.c: cast the arguments to nibble() to unsigned char. 2021-12-18 14:01:02 +03:00
Ozkan Sezer 47d3e96b43 SDL_joystick.c: (unsigned char) cast to SDL_tolower() parameters. 2021-12-18 14:01:02 +03:00
Sam Lantinga c31a40246d Fix audio memory leaks due to invalid init (thanks Janiszewski!)
SDL_Init(SDL_INIT_AUDIO) did not take into account that functions like
SDL_AddAudioDevice do register events, which will need final cleanup
and only gets fired when events were actually initialised.

Sample call stack of a malloc missing its free (Linux + PA):
    SDL_malloc_REAL (SDL_malloc.c:5328)
    SDL_AddEvent (SDL_events.c:445)
    SDL_PeepEvents_REAL (SDL_events.c:531)
    SDL_PushEvent_REAL (SDL_events.c:762)
    SDL_AddAudioDevice (SDL_audio.c:443)
    SourceInfoCallback (SDL_pulseaudio.c:681)
    context_get_source_info_callback (introspect.c:534)
    run_action (pdispatch.c:288)
    pa_pdispatch_run (pdispatch.c:341)
    pstream_packet_callback (context.c:349)
    do_read (pstream.c:1012)

Fixes https://github.com/libsdl-org/SDL/issues/3005
2021-12-17 19:04:39 -08:00
Erik Soma 71e3998d6c Make SDL_VideoInit cleanup when errors occur before video driver creation. 2021-12-17 18:55:49 -08:00
Francisco Javier Trujillo Mata 8ed0cc4300 Fix wrong value for thread priorities following official PSP Docs 2021-12-17 13:57:22 -08:00
Sylvain 44c84c0d8e
GLES2/Big-endian: don´t swap datas for yuv textures (Thanks 0x1F9F1 !) 2021-12-17 17:44:34 +01:00
Sylvain 3a69828e87
Fixed GLES2 back-end on Big Endian Platform (see #5093) 2021-12-17 13:15:39 +01:00
Ozkan Sezer 61107494a1 SDL_gamecontroller.c: (unsigned char) cast to SDL_isdigit() parameters. 2021-12-17 07:40:02 +03:00
Ozkan Sezer ced442cd38 SDL_test_common.c: (unsigned char) cast to SDL_isdigit() parameter. 2021-12-17 07:33:10 +03:00
Ozkan Sezer 48d1ef8fad another unsigned char cast in os2cp.c. code clean-up in os/2 geniconv. 2021-12-17 07:33:10 +03:00
Ozkan Sezer dac6516057 os2iconv.c (_createUconvObj): cast to unsigned char, to be safe. 2021-12-17 02:50:40 +03:00
Ozkan Sezer 2052b5bc3e os2messagebox: use proper UCHAR* typecast in assignment, just in case. 2021-12-17 01:10:10 +03:00
Sam Lantinga ca18bf11ee Don't compare raw mouse button state with windows message button state
When mouse buttons are swapped, right mouse button down is the same value as raw mouse button up, and conceptually the two systems use different button masks, so never cache state between the two.

Fixes https://github.com/libsdl-org/SDL/issues/5108
2021-12-16 12:01:18 -08:00
Sylvain 3d5fcb5da6 Fix warning 2021-12-16 09:19:53 -08:00
Sylvain 4342e6bd21 SDL_render.c: lighten the cast syntax 2021-12-16 09:19:53 -08:00
Sylvain 50d49c63ed GLES2 backend: cast with SDL_Vertex and SDL_VertexSolid 2021-12-16 09:19:53 -08:00
Ethan Lee 4c9966eed6
wayland: Add a note for why we check 0,0 for fullscreen configurations 2021-12-16 10:22:27 -05:00
Sylvain 6101499c7c
BigEndian: fix code that generates illegal instruction with gcc-4.9.2 on powerpc
Program received signal SIGILL, Illegal instruction.
X11_InitKeyboard (_this=0x1001f8f0)
    at /home/sdl/SDL_git/src/video/x11/SDL_x11keyboard.c:273
273	    XKeyboardState values = { .global_auto_repeat = AutoRepeatModeOff };
2021-12-16 09:07:31 +01:00
stdgregwar 0b7b0977fc fix PSP texure artifacts 2021-12-15 18:00:28 -08:00
Francisco Javier Trujillo Mata 996f30b0e4 Use lightweight mutex 2021-12-15 13:59:08 -08:00
Francisco Javier Trujillo Mata 0341ec93fe Improve performance when vsync is enabled and the game is not reaching the 60 FPS 2021-12-15 11:29:49 -08:00
Sam Lantinga 67c4b99639 Fixed enabling udev hotplug detection on Linux 2021-12-15 10:39:42 -08:00
Sam Lantinga c326ff7c6f Re-enabled the O_CLOEXEC definition so config headers can be fixed 2021-12-14 12:42:39 -08:00
Alex Szpakowski 3a5e148b13 Renderer backends use SDL_Color instead of int for geometry colors. 2021-12-14 12:19:16 -08:00
Sam Lantinga 086c74556d Fixed build warning on iOS 2021-12-14 12:08:36 -08:00
Sam Lantinga b08e57e926 Don't try to create a vbo if we aren't using any vertices 2021-12-14 09:32:05 -08:00
Sylvain b7885abc44
Fixed bug #5087: SDL_RenderGeometryRaw() passes colors as int* instead of SDL_Color* 2021-12-14 10:31:55 +01:00
Alex Szpakowski 323ba6c008 d3d11 renderer: reduce vertex bandwidth and calculations. 2021-12-13 15:14:33 -08:00
thfrwn 2b6b69fb12 fix assertion failure in sndio audio caused by the recent hotplugging support 2021-12-13 11:26:35 -08:00
Sylvain 8927d73b1c
RenderGeometry: simplify casting (Thanks Daniel Gibson) 2021-12-12 09:55:23 +01:00
Sylvain d7f66ba1ec
Remove strict aliasing warning in opengles2 backend 2021-12-11 20:04:53 +01:00
Sylvain 3e43d6e34b
SDL_RenderGeometry: remove some warning "dereferencing type-punned pointer might break strict-aliasing" 2021-12-11 17:19:00 +01:00
David Redondo e2ade2bfc4 Fix build against wayland 1.20
Fixes #5088
2021-12-10 08:59:20 -08:00
David Gow 9da93d074b video: x11: Set XImage's byte_order field (fix #5081)
If the X server's byte order is different from the client, things might
display in the wrong colour.

Apparently we can just set the byte_order field to the client's byte
order, and the X server will adjust everything automatically:
https://xorg.freedesktop.narkive.com/GbSD1aPq/ximage-s-byte-order-field
2021-12-09 20:40:12 -08:00
Hanseul Jun e7f84c20bc Fix a typo in comment. 2021-12-09 11:05:23 -08:00
Hanseul Jun 66fbf00e7d Temporarily ignore gl_config.driver_loaded check in Cocoa_GLES_SetupWindow. 2021-12-09 11:05:23 -08:00
Valentin Hăloiu cb8fa5f9c3 wayland: fix keycodes of swapped xkb modifier keys 2021-12-09 09:30:58 -08:00
Ozkan Sezer 615f7b4453 more updates to os2 makefile for libiconv 2021-12-08 23:51:56 +03:00
Ozkan Sezer 8d14e6ea44 replaced use of _MAX_PATH with CCHMAXPATH in os/2 code,
it now compiles without HAVE_LIBC
2021-12-08 14:01:02 +03:00
Sylvain 1940d289bf
SW Renderer: fix invalid read if VSYNC hint is initially set with an empty value (eg "")
because:
- GeHint return a value pointer.
- SetHint free internally the pointer
- The -now invalid- pointer is re-read

==9363== Invalid read of size 1
==9363==    at 0x4946860: SW_CreateRenderer (SDL_render_sw.c:1044)
==9363==    by 0x48F0EC3: SDL_CreateRenderer_REAL (SDL_render.c:938)
==9363==    by 0x48C5921: SDL_CreateRenderer (SDL_dynapi_procs.h:332)
==9363==    by 0x401584: main (main.c:421)
==9363==  Address 0x9c24040 is 0 bytes inside a block of size 1 free'd
==9363==    at 0x484621F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==9363==    by 0x494E403: SDL_free_REAL (SDL_malloc.c:5432)
==9363==    by 0x48A6153: SDL_SetHintWithPriority_REAL (SDL_hints.c:76)
==9363==    by 0x48A6254: SDL_SetHint_REAL (SDL_hints.c:101)
2021-12-08 09:41:33 +01:00
Ozkan Sezer 9409642e08 fix some warnings from vita builds (missing includes)
also some tidy-up to whitespace.
2021-12-07 21:24:24 +03:00
stdgregwar 21d46b7e0c PSP renderer fixed 2021-12-07 20:55:04 +03:00
Sergio Padrino 6f6382f8d0 Fix SDL_GameController API for PSP (#3)
- Add missing mapping
- Make sure the only window has the keyboard focus (so no `SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS` is needed)
2021-12-07 09:04:05 -08:00
Cameron Gutman da0f76de6d cocoa: Don't round scroll deltas from trackpads
Rounding the scroll deltas from trackpads causes jerky scrolling behavior
by artificially amplifying the effects of very small scroll movements.

We should only round events from devices with discrete scroll wheels,
because we know the smallest unit of movement there is a single tick.
2021-12-07 09:02:35 -08:00
Ozkan Sezer 8cee50eea5 removed stdlib.h from SDL_psp_main.c now that exit() is gone. 2021-12-07 19:32:56 +03:00
Ozkan Sezer 00014dc2ac fix some warnings from psp builds (missing includes.) 2021-12-07 18:47:10 +03:00
Wouter Wijsman da5dbb4763
Fix SDL2main on PSP (#5076)
- Fix SDL2main on PSP
  SDL2main was not working for PSP, because it wasn't being activated and
  it wasn't unsetting the main. Besides that a debug screen being started
  was causing issues with joystick input and the sceKernelExitGame calli
  is no longer needed with the current PSPDEV SDK.
- Clean up imports in PSP main
- Set PSP GPU and user modes in main
- Fix exit callback in PSP main
2021-12-07 18:43:50 +03:00
Cameron Gutman 2d673e5b56 evdev: Add support for REL_WHEEL_HI_RES and REL_HWHEEL_HI_RES
If supported, these come alongside the regular REL_WHEEL and REL_HWHEEL
events so it's important that we only process one or the other.
2021-12-07 07:00:31 -08:00
Ozkan Sezer f266d92286 psp/SDL_sysjoystick.c: fix -Wshadow warnings. 2021-12-07 14:04:32 +03:00
Ozkan Sezer 801dcbc5ef SDL_render_sw.c: fix -Wshadow warnings. 2021-12-07 14:04:10 +03:00
Wouter Wijsman e17a3154ed Fix build issue 2021-12-07 14:03:00 +03:00
Wouter Wijsman 7266cf66c7 Clean up PSP render code to fit C standard used better 2021-12-07 14:03:00 +03:00
Wouter Wijsman 07608bf45f Fix ISO C90 violations in psp render code 2021-12-07 14:03:00 +03:00
Wouter Wijsman a79b642638 Make SDL2 able to build or PSP with cmake 2021-12-07 14:03:00 +03:00
Wouter Wijsman 21fd0047e3 Initial for building PSP version with CMake 2021-12-07 14:03:00 +03:00
Sylvain d09f80ef18
SDL_DrawPointsF: fix error message typo 2021-12-07 11:31:57 +01:00
Sylvain 6dafc85017
SDL_DrawLines: minor simpification:
- scale is  1.0f, don't need to multiply
- typo in error message
- remap SDL_DrawLines to SDL_DrawLinesF
2021-12-07 10:44:12 +01:00
Sylvain a0818a63e3
Fixed bug #5071 - Float conversion warnings in SDL_render.c (see also #5003) 2021-12-07 10:07:15 +01:00
Cameron Gutman 9ae56cb353 events: Add logging for SDL_MOUSEWHEEL preciseX/Y fields 2021-12-06 21:18:23 -06:00
Ozkan Sezer 03019c912a autotools, cmake: tighten Xfixes check && explicitly test BarrierEventID
Apparently the older versions of libXi doesn't have it.  Fixes the build
break issue reported at:
4b42c05ba1 (commitcomment-61427659)
2021-12-06 20:37:52 +03:00
David Gow a709b5b602 video: wayland: Handle 0x0 xdg_toplevel_configure in fullscreen
The xdg_shell spec seems to state[1] that xdg_toplevel_configure events can
always provide a 0×0 width/height to signal that the compositor doesn't
care. SDL previously assumed the provided width/height was always valid
for fullscreen windows, and so applied it as-is.

This broke SDL applications on KDE/KWin 5.23, which now sends 0×0
configure events (and, in 5.23.3, 1×1 events for some reason), breaking
all SDL applications in fullscreen[2].

[1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/6
[2]: https://bugs.kde.org/show_bug.cgi?id=444962#c6
2021-12-06 09:09:37 -08:00
ALittleDruid 2f0edc2906 IAudioClient::SetEventHandle Parameter eventHandle Should not be NULL 2021-12-06 09:02:31 -08:00
Ozkan Sezer a887b8e28b SDL_test_common.c: replaced all printf() calls with SDL_Log()
Otherwise, if one builds libSDL2_test using a new mingw but builds
the test programs using an older mingw, a link failure happens:

/opt/local/x86_64-w64-mingw32/lib/libSDL2_test.a(SDL_test_common.o): In function `printf':
/opt/local/x86_64-w64-mingw32/include/stdio.h:372: undefined reference to `__imp___acrt_iob_func'
collect2: ld returned 1 exit status
2021-12-03 20:03:10 +03:00
Weng Xuetian 5056b29b0f Fix the wrong int size for fcitx capability. 2021-12-03 04:31:24 -08:00
Sylvain e14d10263c Change viewport and cliprect to float version: from SDL_Rect to SDL_FRect 2021-12-02 10:01:50 +01:00
Sylvain 7828362da9 SDL_Renderer software, D3D11: don't use "renderer->viewport" in back-ends, but use the one from SETVIEWPORT cmd 2021-12-02 10:01:50 +01:00
Ozkan Sezer a2b13e585c SDL_iconv_string: avoid memory leak if realloc() fails. 2021-12-02 02:28:24 +03:00
Ozkan Sezer f14a8bfa4e fix whitespace. 2021-12-01 21:33:02 +03:00
Ozkan Sezer b71bfdaafb SDL_iconv.c (encodings): mark "WCHAR_T" as ENCODING_UTF16LE for OS/2 too
whcar_t is unsigned short in os/2, like windows
2021-12-01 20:50:40 +03:00
Davis Mosenkovs 66b0a6ee15 workaround for libmali gbm_device_get_fd()
gbm_device_get_fd() in at least some libmali versions duplicates handle.
Other implementations do not do duplication. To prevent handle leak save
drm_fd in SDL_DisplayData.
2021-11-30 16:20:24 -08:00
Ozkan Sezer 662ea5abe4 minor correction after previous patch and minor tidy-up. 2021-12-01 01:40:24 +03:00
Ozkan Sezer 70c5e91d0f os/2 optionally builds against libiconv. 2021-12-01 01:20:10 +03:00
Ozkan Sezer b20484e803 minor os/2 reorganization for iconv 2021-12-01 01:20:02 +03:00
Sam Lantinga 8c91cf7dba Always create a full 256-entry map in case color values are out of range
Fixes https://github.com/libsdl-org/SDL/issues/5042
2021-11-30 12:37:39 -08:00
Sam Lantinga a4c04ad230 Fixed building with iOS SDK prior to 13.0
Fixes https://github.com/libsdl-org/SDL/pull/5045
2021-11-30 10:32:39 -08:00
Sam Lantinga 8589134f16 Fixed potential buffer overflow in YUV conversion
Fixes https://github.com/libsdl-org/SDL/issues/5043
2021-11-30 10:23:21 -08:00
Ozkan Sezer 09465a9083 hidapi, windows: replace a strncpy() with plain memcpy()
mainstream has a similar change, already.
2021-11-30 21:10:10 +03:00
Sam Lantinga 5fc901d4f3 Updated to version 2.0.19 for development 2021-11-30 09:58:21 -08:00
Cameron Gutman 715d481271 windows: Fix GUI key state when grabbing the keyboard
When our keyboard grab hook is installed, GetKeyState() will return 0 for the
GUI keys even when they are pressed. This leads to spurious key up events when
holding down the GUI keys and the inability to use any key combos involving
those modifier keys.
2021-11-29 20:07:19 -08:00
Sam Lantinga b6bc3a6b0e Added a mapping for the PS4 touchpad button on Windows
Fixes https://github.com/libsdl-org/SDL/issues/5035
2021-11-29 09:00:54 -08:00
David Gow f6fdbc1e37 video: x11: Fix an invalid SDL_LogError() call
This fixes a compile warning — and possible invalid memory read —
introduced in 9c03d255 ("Add back X11 legacy WM_NAME encodings"), which
was part of PR #5029, fixing Bug #4924.

The issue is with one of the added warnings in X11_GetWindowTitle().
Basically, the "title" variable passed to SDL_LogError() hasn't been
initialised yet: we could pass propdata in directly, but it's better to
move the SDL_LogError() call until after title is set, IMHO.

This fixes the following warning from gcc (SUSE Linux) 11.2.1:
In file included from /home/david/Development/SDL/src/video/x11/../../SDL_internal.h:45,
                 from /home/david/Development/SDL/src/video/x11/SDL_x11window.c:21:
/home/david/Development/SDL/src/video/x11/SDL_x11window.c: In function 'X11_GetWindowTitle':
/home/david/Development/SDL/src/video/x11/../../dynapi/SDL_dynapi_overrides.h:33:22: warning: '%s' directive argument is null [-Wformat-overflow=]
   33 | #define SDL_LogDebug SDL_LogDebug_REAL
/home/david/Development/SDL/src/video/x11/SDL_x11window.c:720:13: note: in expansion of macro 'SDL_LogDebug'
  720 |             SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Failed to convert WM_NAME title expecting UTF8! Title: %s", title);
      |             ^~~~~~~~~~~~
2021-11-29 07:13:25 -08:00
Sam Lantinga 3ba9276aff Don't fail the sensor init if we couldn't create a sensor manager (i.e. we're running on Wine)
Fixes https://github.com/libsdl-org/SDL/issues/5031
2021-11-28 21:14:02 -08:00
Sam Lantinga 6872cb12e6 null-terminate the message buffer if FormatMessage() fails 2021-11-28 21:10:46 -08:00
Fredrick Brennan b5d47aa297 Fix comment style for old compilers (`//`⇒`/**/`) 2021-11-28 21:00:29 -08:00
Fredrick Brennan 367684b0c2 Add patches suggested by @slouken in round 1 review 2021-11-28 21:00:29 -08:00
Fredrick Brennan 9c03d25543 Add back X11 legacy WM_NAME encodings
Closes #4924.

Based on patches of the past, such as this work by James Cloos in July
2010:
d7d98751b7,
as well as code comments in the Perl module X11::Protocol::WM
(https://metacpan.org/pod/X11::Protocol::WM) and even the code to Xlib
itself, which taught me that we should never have been using
`XStoreName`, all it does is call `XChangeProperty`, hardcoded to
`XA_STRING`!

What can I say, when the task is old school, the sources are too 😂
2021-11-28 21:00:29 -08:00
Ethan Lee 72e53e4b87 wayland: Clear driverdata before calling ResetDisplayModes 2021-11-28 19:25:22 -05:00
Sam Lantinga 942973dd86 Use mouse ID 0 for raw mouse events
We don't track state for each mouse individually, so we should just use the global mouse ID for all events.

Fixes https://github.com/libsdl-org/SDL/issues/5026
2021-11-28 09:27:28 -08:00
Sam Lantinga dd2f91118e Fixed warnings with Windows SDK 10.0.19041
Fixes https://github.com/libsdl-org/SDL/issues/4998
Also breaks https://github.com/libsdl-org/SDL/issues/4998 for older SDKs, but we're going to ignore them, they're just incorrect.
2021-11-27 20:18:29 -08:00
Sam Lantinga c2904c8ce7 Fixed compile warnings and errors
Fixes https://github.com/libsdl-org/SDL/issues/4998
2021-11-27 11:16:15 -08:00
Ozkan Sezer 8f17af5e21 hidapi: mark libusb function pointers with LIBUSB_CALL. 2021-11-27 11:02:04 -08:00
Sam Lantinga a6cbe0ab87 Controllers are always centered at zero using XInput and WGI 2021-11-27 10:58:12 -08:00
Sam Lantinga 09b7ca27d6 Get the current WGI controller list at startup
On Win32 this list is empty and we always get controller added events. On UWP, this list is populated and we don't get controlle added events for currently connected controllers.
2021-11-27 10:53:20 -08:00
Sam Lantinga 12895eca1a Fixed WGI initialization on Win32 2021-11-27 10:52:58 -08:00
Sam Lantinga 110e4e1334 Use WGI instead of XInput for Windows 10 UWP apps
Fixes https://github.com/libsdl-org/SDL/issues/5017
2021-11-27 10:24:32 -08:00
Sam Lantinga e04a0221e3 Fixed crash running SDL test programs on UWP 2021-11-27 10:22:37 -08:00
Ozkan Sezer 5a0ea7fb17 Check for O_CLOEXEC definition in fcntl.h at configuration time,
If not available, define it internally as 0 (in SDL_internal.h).
Define it as available for macOS >= 10.7 in SDL_config_macosx.h.
2021-11-27 19:23:10 +03:00
Cameron Gutman f903a39e13
haptic: Fix SDL_MouseIsHaptic() always returning SDL_TRUE on Android 2021-11-27 19:18:41 +03:00
Sam Lantinga 11a9cd6344 Fixed building SDL on UWP 2021-11-27 08:14:50 -08:00
Mathieu Eyraud 02021ae753 Return capabitlities from RawInput joystick 2021-11-27 07:26:10 -05:00
Eric Wasylishen b786c10013 SDL_render_gl.c: GL_RunCommandQueue: always set viewport_dirty on macOS
Without this, moving the window changes the viewport and causes contents
to render stretched.

Fixes #1504
2021-11-27 07:12:34 -05:00
Sam Lantinga 4f683f01d4 Fixed potentially truncated entry in stack trace 2021-11-26 17:27:07 -08:00
Sam Lantinga 4e5839a5f4 Fixed compiling for Raspberry Pi 2021-11-26 13:45:08 -08:00
Ryan C. Gordon 86c0cf2bb1
software: Draw a single pixel for a line with the same start/end point.
Otherwise it would drop it, which seems like a bug to me, as it normally
fills the endpoint on lines.

Reference #2006.
2021-11-26 14:34:51 -05:00
Sam Lantinga a2e8565230 The Google Pixel fingerprint sensor isn't actually a joystick
Fixes https://github.com/libsdl-org/SDL/issues/4971
2021-11-26 11:04:15 -08:00
Sam Lantinga 67b5de5b41 Fixed build warnings 2021-11-26 10:18:08 -08:00
Sam Lantinga 2ca2ad76da Fixed build warnings 2021-11-26 10:13:45 -08:00
Sam Lantinga f90164a62f Fixed mapping for the G-Shark GS-GP702
Fixes https://github.com/libsdl-org/SDL/issues/5006
2021-11-26 09:02:12 -08:00
Sam Lantinga 7242075b2b Updated version to 2.0.18 for release 2021-11-26 08:12:45 -08:00
Sam Lantinga d861820465 SDL_JoystickGetAttached() doesn't need to be noisy for NULL joystick
Fixes https://github.com/libsdl-org/SDL/issues/5008
2021-11-26 07:57:48 -08:00
Sam Lantinga 30f04d63e6 HIDAPI is only reliable on Android 4.3 and newer
Fixes https://github.com/libsdl-org/SDL/issues/4955
2021-11-26 07:15:46 -08:00
Ryan C. Gordon d713a68071
pulseaudio: wait until at least 1/8th (!) of the mixbuffer is available.
This is to workaround systems where we hang in playback because the buffer
does not report the space for whatever reason. The system will instead block
in PlayDevice, which always immediately follows WaitDevice in modern times
so this works out, and it seems to keep the device moving forward.

For a future revision, we are either going to clean this up more properly,
or attempt to move to PulseAudio's pa_stream_set_write_callback() API, but
this will do for SDL 2.0.18.

Reference #4387 for discussion and further information.
2021-11-25 22:32:40 -05:00
Ozkan Sezer 53aa8eec5f minor cleanup for watcom _inline keyword. 2021-11-25 17:00:24 +03:00
Sylvain d5813776db Release UDEV ressources 2021-11-25 07:24:18 -05:00
Cameron Gutman b99510836e SDL_mfijoystick.m: Fix -Wshadow warning 2021-11-24 13:04:50 -06:00
DarkContact e77cfb9a11 Fixed d3d11 renderer creation 2021-11-24 10:11:35 -05:00
Sam Lantinga 57366285d8 Only send display events for hotplugged displays, not the initial state 2021-11-23 20:14:18 +00:00
Sam Lantinga a3c05d2f34 Added debug output for display connect/disconnect events 2021-11-23 19:43:01 +00:00
Ozkan Sezer f8900583e5 removed windows winmm joystick driver 2021-11-23 17:04:40 +03:00
Sylvain 381f99a3fd
Fix warnings: re-add enum forward declaration 2021-11-23 10:58:04 +01:00
Sylvain dd6817b3b7
Fix warnings: static function, {} initializier, un-needed enum forward declaration 2021-11-23 10:47:34 +01:00
Sylvain fae7034901
Fix warnings: static, include, un-initialized vairables 2021-11-23 10:33:12 +01:00
Sylvain 2a24418bd3
More "Integer overflow generates Illegal instruction under sanitizers" (see bug #4995) 2021-11-23 09:44:37 +01:00
Sylvain 9c72adc86c
More "Integer overflow generates Illegal instruction under sanitizers" (see bug #4995) 2021-11-23 09:41:01 +01:00
Sylvain 8dd6edec00
Fixed bug #3232 - Integer overflow generates Illegal instruction under sanitizers + see bug #4995 2021-11-23 09:30:42 +01:00
Ozkan Sezer e18be04bc6 Fixed undefined behavior in QueueCmdSetDrawColor()
Fixes https://github.com/libsdl-org/SDL/issues/4995
Patch from Andrew Kelley
2021-11-23 08:01:02 +03:00
Sylvain c878d9a0aa Haiku: comment this should not be SDL_free() 2021-11-22 08:38:46 -08:00
Sylvain aef7105408 Use SDL_free 2021-11-22 08:38:46 -08:00
Sylvain 2004aaf3bb SDL_wave: use SDL_free 2021-11-22 08:38:46 -08:00
Sylvain 0445c13aae Remove 'malloc' from comment 2021-11-22 08:38:46 -08:00
Sylvain 155db97d14 Remove 'malloc' from comment 2021-11-22 08:38:46 -08:00
Sylvain c3633d2c99 Haiku: use SDL_malloc 2021-11-22 08:38:46 -08:00
Sylvain 79b37cc55f Pandora: use SDL_malloc 2021-11-22 08:38:46 -08:00
Sylvain 10ffcbb115 QNX: use SDL_malloc 2021-11-22 08:38:46 -08:00
Sylvain e72beeb2a0 Remove 'malloc' from comment 2021-11-22 08:38:46 -08:00
Sylvain 38cfe25bc5 Remove 'malloc' from comment 2021-11-22 08:38:46 -08:00
Sylvain 4d566e5d5d VITA, PSP: use SDL_malloc 2021-11-22 08:38:46 -08:00
Sylvain 9fcc630fb3 X11: use SDL_malloc 2021-11-22 08:38:46 -08:00
Sylvain 19bf36db15 DirectFB: use SDL_malloc 2021-11-22 08:38:46 -08:00
Sylvain 8fb19d212e Vita: unneeded include 2021-11-22 08:38:46 -08:00
Sylvain e702a4e520 PSP: un needed include 2021-11-22 08:38:46 -08:00
Sylvain 8e851a277d Remove malloc from comment 2021-11-22 08:38:46 -08:00
Sylvain 0ef9d26622 cpuinfo: remove malloc from comments 2021-11-22 08:38:46 -08:00
Sylvain 30338beb61 Minor comment 2021-11-22 08:38:46 -08:00
Sylvain fb218e582a PSP: use SDL_malloc/SDL_free 2021-11-22 08:38:46 -08:00
Sylvain 5a7a7ba570 Don't use "realloc" in comment so that it doesn't show up 2021-11-22 08:38:46 -08:00
Sylvain b4aeaa30a1 Use SDL_calloc / SDL_free 2021-11-22 08:38:46 -08:00
Sylvain cb9f85e8d0 Don't use "round", so that it's doesn't show up while searching for the function 2021-11-22 08:38:46 -08:00
Sylvain 6fb50bd0a6 Don't use "exp" as a name so that it's doesn´t show up with searching for the function 2021-11-22 08:38:46 -08:00
Sylvain 161dd83c9a Don´t use "trunc" as var name, since it's also a function 2021-11-22 08:38:46 -08:00
Sylvain d31251b014 use SDL's functions version inplace of libc version 2021-11-22 08:38:46 -08:00
Ozkan Sezer ee2afa00ba SDL_mfijoystick.m: fix build using older toolchains
Fixes https://github.com/libsdl-org/SDL/issues/4992
Fixes https://github.com/libsdl-org/SDL/issues/4958
2021-11-22 05:11:10 +03:00
Sam Lantinga c97b721868 Added SDL_PremultiplyAlpha() to premultiply alpha on a block of SDL_PIXELFORMAT_ARGB8888 pixels 2021-11-21 12:18:10 -08:00
Sylvain 49369142bd
Fixed bug #4625: with integer scale, viewport (as reported by SDL_RenderGetViewport) becomes -2147483648x-2147483648
0 isn't valid scale. Min integer scale is 1.0f
2021-11-21 17:40:48 +01:00
Sylvain a0cb079a42
Fixed bug #4982 - Failed to open audio_device on OpenSLES / Android 5.x with freq 96khz+ 2021-11-21 15:45:08 +01:00
Ryan C. Gordon ceb9e9a809 cocoa: Removed a debug printf call. 2021-11-21 00:21:41 -05:00
Ryan C. Gordon 18715acb55 cocoa: Position non-left mouse button events in background windows correctly.
Fixes #4828.
2021-11-21 00:14:18 -05:00
Cameron Gutman 343fa61215 hid: fix inconsistent indentation 2021-11-20 13:17:59 -06:00
Cameron Gutman db60b27188 hid: Only enumerate IOHIDDevices that are likely to be joysticks
Touching HID devices with keyboard usages will trigger a keyboard capture
permission prompt on macOS 11+. See #4887

Like the IOKit joystick backend, we accept HID devices that have joystick,
gamepad, or multi-axis controller usages. We also allow the Valve VID for
the Steam Controller, just like the Windows HIDAPI implementation does.
2021-11-20 13:13:17 -06:00
Ryan C. Gordon 23b7bdef87
offscreen: Don't fail to create a window because of driver_loaded politics.
Fixes #4922.
2021-11-20 14:12:11 -05:00
Ozkan Sezer 504e7aa59b minor tidy-up for ifdefs & co. 2021-11-20 21:51:10 +03:00
Sylvain b6e8651ae9
Audio 6.1 should be allowed now (see #4974) 2021-11-20 15:31:21 +01:00
Ozkan Sezer 990fb668f7 tests: several -Wwrite-strings fixes. 2021-11-20 01:02:02 +03:00
Sam Lantinga 665865eda2 If the hardware is in an error state, the final page flip may not come.
We should either put a timeout on the wait when destroying the window, or skip it entirely.
2021-11-19 09:58:13 -08:00
Sam Lantinga 6828955ddf Trim any extra platform strings from mappings when they're returned to the application 2021-11-19 09:58:11 -08:00
Cameron Gutman 881a674926 rawinput: Only access SDL_RAWINPUT_mutex if initialized
We can also ditch the lock in RAWINPUT_JoystickQuit() now that the joystick
subsystem quits drivers in reverse order. There's no chance of a racing call
to RAWINPUT_WindowProc() anymore.
2021-11-19 08:19:30 -06:00
Cameron Gutman 1237142be3 joystick: Quit drivers in reverse order to ensure dependencies are not broken
SDL_WINDOWS_JoystickDriver depends on callbacks in SDL_RAWINPUT_JoystickDriver
and SDL_HIDAPI_JoystickDriver being available. It also manages the common
WindowProc used for joystick detection in both WINDOWS and RAWINPUT drivers.

If we don't tear them down backwards, there's a window of time where we could
invoke RAWINPUT_WindowProc() after RAWINPUT_JoystickQuit() was called.
2021-11-19 08:19:30 -06:00
Ozkan Sezer b67965979a SDL_hidapi.c: fix SDL_udev.h include path
fixes https://github.com/libsdl-org/SDL/issues/4981
2021-11-19 11:55:50 +03:00
Ethan Lee a7a54e6452 wayland: Add support for display connect/disconnect events 2021-11-18 00:44:08 -05:00
Sylvain 5be8a22113 Add audio conversion from/to 61 2021-11-17 16:04:54 -08:00
Ozkan Sezer d2cf191936 hidapi, linux: merged a minor warning + code style fix from mainstream. 2021-11-17 10:00:10 +03:00
Ethan Lee 5cc23868ed wayland: Add support for SDL_DisplayOrientation 2021-11-16 11:58:23 -08:00
Sam Lantinga 40d808620d SDL_classic_joysticks defaults off 2021-11-15 20:17:14 -08:00
Sam Lantinga 66058bbbd5 Fixed exception accessing Bluetooth devices on Android 12
Since accessing Bluetooth prompts the user for permission on both Android and iOS, and we only need it for Steam Controller support, we'll leave it off by default. You can enable it by setting the hint SDL_HINT_JOYSTICK_HIDAPI_STEAM to "1" before calling SDL_Init()

Fixes https://github.com/libsdl-org/SDL/issues/4952
2021-11-15 16:52:56 -08:00
Sam Lantinga be5b4d980d Added nativeGetHintBoolean for Java code 2021-11-15 16:52:54 -08:00
Sam Lantinga 9ec2b35147 Fixed the GLES2 shader count to be in sync with the enum 2021-11-15 13:45:53 -08:00
Sylvain b649314d62
Add comment to audio clipping (see bug #4104) 2021-11-15 13:43:40 +01:00
Sylvain d4df5d33c5
GLES2: prevent batching if blend mode changes (see bug #4964) 2021-11-15 09:43:44 +01:00
Sylvain 92f2fdfc84
GLES2: batch non joined lines (see #4964) 2021-11-15 09:36:18 +01:00
Sylvain 17f156fae5
Fixed bug #4964 - opengles2 & batching = conjoined lines
put back the initial switch case because groups of joined lines cannot be batched.
2021-11-15 09:08:09 +01:00
Sylvain d8888e468e
Fixed bug #4964 - opengles2 & batching = conjoined lines 2021-11-15 08:37:49 +01:00
Sam Lantinga cc094f4d7c Fixed building with the macOS 10.8 SDK 2021-11-14 20:15:48 -08:00
Cameron Gutman d7d67af441 mouse: Fix Y value in motion events when confinement is active 2021-11-14 17:52:41 -06:00
Zack Middleton 1cd3e83756 cocoa: Fix abort on touch event types without a subtype
macOS 10.6 has some touch NSEvents which do not have a subtype
(Begin/EndGesture, Magnify, Rotate, Swipe) and cause an uncaught
exception which triggers SIGABRT and the program exits.

As it is, none of the macOS 10.6 touch events are detected as a
trackpad (including Gesture due to using different subtypes).
2021-11-14 15:21:51 -08:00
Ozkan Sezer 781caec2b2 SDL_waylandevents.c (keyboard_handle_keymap): silenced -Wwrite-strings . 2021-11-15 00:55:24 +03:00
Ozkan Sezer 5c067906ba wasapi: AvSetMmThreadCharacteristicsW takes an LPCWSTR param, not LPWSTR 2021-11-15 00:55:04 +03:00
Ozkan Sezer 3eb9bfac7a win32 rawinput & wgi joystick: avoid -Werror=declaration-after-statement 2021-11-14 22:22:50 +03:00
Sam Lantinga c55ab9631f Added a hint for alternate OpenGL NV12 data format 2021-11-13 22:21:57 -08:00
Ozkan Sezer 8a6e48d46d constified SDL_RegisterApp() 2021-11-14 04:40:50 +03:00
Ozkan Sezer 7dfd22ac5e fix XGetDefault signature - its first and second params are _Xconst 2021-11-14 02:32:00 +03:00
Ozkan Sezer c7aa04d03e SDL_test_harness.c: avoid -Wwrite-strings 2021-11-14 02:31:20 +03:00
Ozkan Sezer be7b663c2c audio/winmm/SDL_winmm.c (SetMMerror): constify. 2021-11-14 02:30:56 +03:00
Ozkan Sezer e4aa608a5c change (char*) casts to (const char*) in WIN_UTF8 macros 2021-11-14 02:30:34 +03:00
Cameron Gutman 674f361dec wayland: Fix memory leaks in clipboard code 2021-11-13 11:44:36 -06:00
Cameron Gutman c8061ed2d1 alsa: Fix possible uninitialized string 2021-11-13 10:33:37 -06:00
Ozkan Sezer a2c27d39cf SDL_hidapi_switch.c (ConstructSubcommand): lose use of '&' on rumbleData
SwitchCommonOutputPacket_t->rumbleData is an array.
2021-11-13 17:56:28 +03:00
Ozkan Sezer 6ad0fb8462 SDL_hidapi_ps4.c, SDL_hidapi_ps5.c: use SDL_zeroa() 2021-11-13 17:55:10 +03:00
Sylvain 70c8d20a46
Revert previous commit a50ca98e2b (see bug #4625) 2021-11-13 15:04:19 +01:00
Sylvain a50ca98e2b
Fixed bug #4625 - SDL_RenderSetLogicalSize issues
viewport becomes -2147483648x-2147483648 when logical_w/h is greater than window size.
division should be done with floats
2021-11-13 14:48:36 +01:00
Ozkan Sezer a948ff8494 SDL_hidapijoystick.c: worked around a bogus 'unreachable code' warning. 2021-11-13 11:50:02 +03:00
Cameron Gutman eb3f1462b8 x11: Fix memory leak in X11_CreatePixmapCursor() 2021-11-12 18:26:26 -06:00
Cameron Gutman 704edf6323 audio: Fix crash calling SDL_OpenAudio() after SDL_AudioInit() fails
The SDL_WasInit() checks don't work when using SDL_AudioInit() directly,
which is exactly what audio_initOpenCloseQuitAudio() in testautomation
does.
2021-11-12 17:07:22 -06:00
Cameron Gutman 78013aeef9 alsa: Fix use-after-free when reinitializing 2021-11-12 16:57:24 -06:00
Ozkan Sezer 3dc7813ae4 more whitespace tidy-ups in SDL_os2messagebox.c 2021-11-12 20:47:02 +03:00
Sam Lantinga c2dd50a9a0 Fixed whitespace 2021-11-12 08:28:02 -08:00
Sam Lantinga 074e613bbb Fixed typo 2021-11-12 03:04:11 -08:00
Sam Lantinga 35d90f17e1 Better implementation of SDL_SetWindowMouseGrab() and SDL_SetWindowMouseRect() on macOS 2021-11-12 03:04:11 -08:00
Mathieu Eyraud 5fc7a90a8b Fix refcounting in SDL_hid_exit 2021-11-12 01:25:15 -08:00
Sam Lantinga 162772aa63 Fixed build warnings on Android 2021-11-11 20:50:54 -08:00
Cameron Gutman 50971577e4 dinput: Fix memory leak when SDL_DINPUT_JoystickPresent() returns true 2021-11-11 22:35:41 -06:00
Misa 3bf7994fe2 Add and use `SDL_FALLTHROUGH` for fallthroughs
Case fallthrough warnings can be suppressed using the __fallthrough__
compiler attribute. Unfortunately, not all compilers have this
attribute, or even have __has_attribute to check if they have the
__fallthrough__ attribute. [[fallthrough]] is also available in C++17
and the next C2x, but not everyone uses C++17 or C2x.

So define the SDL_FALLTHROUGH macro to deal with those problems - if we
are using C++17 or C2x, it expands to [[fallthrough]]; else if the
compiler has __has_attribute and has the __fallthrough__ attribute, then
it expands to __attribute__((__fallthrough__)); else it expands to an
empty statement, with a /* fallthrough */ comment (it's a do {} while
(0) statement, because users of this macro need to use a semicolon,
because [[fallthrough]] and __attribute__((__fallthrough__)) require a
semicolon).

Clang before Clang 10 and GCC before GCC 7 have problems with using
__attribute__ as a sole statement and warn about a "declaration not
declaring anything", so fall back to using the /* fallthrough */ comment
if we are using those older compiler versions.

Applications using SDL are also free to use this macro (because it is
defined in begin_code.h).

All existing /* fallthrough */ comments have been replaced with this
macro. Some of them were unnecessary because they were the last case in
a switch; using SDL_FALLTHROUGH in those cases would result in a compile
error on compilers that support __fallthrough__, for having a
__attribute__((__fallthrough__)) statement that didn't immediately
precede a case label.
2021-11-12 07:26:14 +03:00
Sam Lantinga 9c3bcf8e8a Added SDL_hid_ble_scan() for pairing Steam Controllers on iOS and tvOS 2021-11-11 17:31:14 -08:00
Sam Lantinga abc12a832c Revert "Add and use `SDL_FALLTHROUGH` for fallthroughs"
This reverts commit 66a08aa391.

This causes problems with older compilers:
https://github.com/libsdl-org/SDL/pull/4791#issuecomment-966630997
2021-11-11 15:58:44 -08:00
Sam Lantinga 36b2690e40 Moved SDL HIDAPI functions into a single block for the ABI 2021-11-11 15:48:56 -08:00
Cameron Gutman fe09a4930a joystick: Add APIs to query rumble support 2021-11-11 15:10:08 -08:00
Cameron Gutman afccabb881 joystick: Add capability flags for rumble and trigger rumble
When API limitations force us to guess, we favor a false positive (reporting
support when it doesn't exist) compared to a false negative.
2021-11-11 15:10:08 -08:00
Cameron Gutman 1ccfbf963e joystick: Convert HasLED() into a generic GetCapabilities() function 2021-11-11 15:10:08 -08:00
Sam Lantinga 911d91c55c Retry hid_send_feature_report() if the ioctl() fails with EPIPE (e.g. the device stalled) 2021-11-11 14:36:05 -08:00
Sam Lantinga b15e880e73 Fixed open functions in the SDL_hidapi.h header 2021-11-11 13:50:16 -08:00
Sam Lantinga b9b0df40bf Fixed Linux build 2021-11-11 12:52:40 -08:00
Sam Lantinga c9ada1c142 Made HIDAPI device change notifications available via SDL_hid_device_change_count() 2021-11-11 12:46:10 -08:00
Ethan Lee 63ae103cd1 wayland: QTWAYLAND_CONTENT_ORIENTATION can support multiple values as bitmasks 2021-11-11 13:16:34 -05:00
Sam Lantinga ebed961cb2 Fixed build with older Linux kernel headers 2021-11-11 09:51:39 -08:00
Sam Lantinga 11ae43ca16 Only lock the pointer for mouse relative mode, there isn't really a concept of grab and confinement on iOS
Locking the pointer prevents the on-screen cursor from moving, which isn't what we want with a grab behavior.

Fixes https://github.com/libsdl-org/SDL/issues/4941
2021-11-11 07:51:34 -08:00
Misa 66a08aa391 Add and use `SDL_FALLTHROUGH` for fallthroughs
Case fallthrough warnings can be suppressed using the __fallthrough__
compiler attribute. Unfortunately, not all compilers have this
attribute, or even have __has_attribute to check if they have the
__fallthrough__ attribute. [[fallthrough]] is also available in C++17
and the next C2x, but not everyone uses C++17 or C2x.

So define the SDL_FALLTHROUGH macro to deal with those problems - if we
are using C++17 or C2x, it expands to [[fallthrough]]; else if the
compiler has __has_attribute and has the __fallthrough__ attribute, then
it expands to __attribute__((__fallthrough__)); else it expands to an
empty statement, with a /* fallthrough */ comment (it's a do {} while
(0) statement, because users of this macro need to use a semicolon,
because [[fallthrough]] and __attribute__((__fallthrough__)) require a
semicolon).

Applications using SDL are also free to use this macro (because it is
defined in begin_code.h).

All existing /* fallthrough */ comments have been replaced with this
macro. Some of them were unnecessary because they were the last case in
a switch; using SDL_FALLTHROUGH in those cases would result in a compile
error on compilers that support __fallthrough__, for having a
__attribute__((__fallthrough__)) statement that didn't immediately
precede a case label.
2021-11-11 07:23:25 -08:00
Sam Lantinga 828a0a4a10 Fixed mapping for PS4 controller when using the classic Joystick
interface on Linux
2021-11-11 07:13:29 -08:00
Sam Lantinga dc9de1e2bd Get the correct USB VID/PID information for /dev/input/js* devices 2021-11-11 07:03:30 -08:00
Sam Lantinga bd92a95f22 Cleanup for the /dev/js* support (thanks @meyraud705) 2021-11-11 06:30:36 -08:00
Mathieu Eyraud 3090812e1e Convert last SDL_IOReady()'s 2nd parameter to flags
Conversion missed in https://github.com/libsdl-org/SDL/pull/4897
2021-11-11 06:17:26 -08:00
Sam Lantinga 1c78b08007 Added support for /dev/input/js* on Linux
Added the hint SDL_HINT_LINUX_JOYSTICK_CLASSIC to control whether /dev/input/js* or /dev/input/event* are used as joystick devices

Added the hint SDL_HINT_JOYSTICK_DEVICE to allow the user to specify devices t
hat will be opened in addition to the normal joystick detection

Fixes https://github.com/libsdl-org/SDL/issues/1314
Fixes https://github.com/libsdl-org/SDL/issues/1727
Fixes https://github.com/libsdl-org/SDL/issues/1981
Closes https://github.com/libsdl-org/SDL/pull/4727
2021-11-10 20:02:25 -08:00
Sam Lantinga 65a50b2430 Re-enable udev joystick enumeration by default 2021-11-10 16:15:22 -08:00
Sam Lantinga dfb834d3d4 Track button state for each mouse input source separately
This way we'll get button down and up events for each mouseID
individually.

Fixes https://github.com/libsdl-org/SDL/issues/4518
2021-11-10 13:44:29 -08:00
Sam Lantinga eda4c40732 Make sure the X event is an Xkb event before checking the Xkb event type 2021-11-10 12:48:09 -08:00
Sam Lantinga 98c9836287 Don't clobber the error in SDL_ShowMessageBox() if one has been set at
the platform level

Fixes https://github.com/libsdl-org/SDL/issues/4760
2021-11-10 11:04:51 -08:00
Sam Lantinga dc4c7d9539 Fixed infinite loop in SDL_vsnprintf() if the format string is too large for the output buffer
Fixes https://github.com/libsdl-org/SDL/issues/4940
2021-11-10 09:48:49 -08:00
Sam Lantinga d5032582e0 Use consistent language between SDLTest_AssertPass() and SDLTest_AssertCheck() 2021-11-10 09:45:56 -08:00
Sam Lantinga 6c4b4ee7a6 Don't assert on API parameters
This causes lots of spam in test automation and it's not clear it's useful to developers. If we need this level of validation, we should add a log category for it.
2021-11-10 09:41:43 -08:00
Sam Lantinga fed857787a Update the orientation and display modes when the display settings change on Windows
Fixes https://github.com/libsdl-org/SDL/issues/1061
2021-11-10 08:47:39 -08:00
Sam Lantinga c0f1109bd0 Implemented querying the orientation of displays on Windows 2021-11-10 06:03:01 -08:00
Sam Lantinga 3a31a45028 End the scene before resetting the D3D device, since we'll start with BeginScene after that.
If we don't do this, we'll end up with unbalanced Begin/End scene pairs which causes D3DERR_INVALIDCALL in the present.

Fixes https://github.com/libsdl-org/SDL/issues/4933
2021-11-10 05:24:31 -08:00
Cameron Gutman 6b64c47b69 haptics: Enumerate XInput/DInput joysticks after haptic init
Since the haptic subsystem is usually initialized after the joystick subsystem,
the initial calls to HapticMaybeAddDevice() from inside SDL_JoystickInit() will
arrive too early to be handled by the haptic subsystem. We need to add those
haptic devices for those already present joysticks ourselves.
2021-11-09 23:46:34 -06:00
Eric Wasylishen 0d98793693
testwm2: Fix video modes menu hit detection when highdpi or logical size used (#4936)
* SDLTest_CommonDrawWindowInfo: log SDL_RenderGetScale, SDL_RenderGetLogicalSize

* testwm2: fix video modes menu hit detection in High DPI cases

- also when logical size is specified, e.g.
  `--logical 640x480 --resizable --allow-highdpi`

* add function to determine logical coordinates of renderer point when given window point

* change since to the targeted milestone

* fix typo

* rename for consistency

* Change logical coordinate type to float, since we can render with floating point precision.

* add function to convert logical to window coordinates

* testwm2: use new SDL_RenderWindowToLogical

* SDL_render.c: alternate SDL_RenderWindowToLogical/SDL_RenderLogicalToWindow

Co-authored-by: John Blat <johnblat64@protonmail.com>
Co-authored-by: John Blat <47202511+johnblat64@users.noreply.github.com>
2021-11-09 21:03:42 -08:00
Sam Lantinga 27ce914463 Send absolute mouse motion when in normal mouse mode and relative mouse motion when in relative mode on iOS
This keeps the SDL cursor in sync with the visible cursor when in normal mouse mode.
2021-11-09 20:51:42 -08:00
Sam Lantinga 19c129faba Added documentation that the UIApplicationSupportsIndirectInputEvents key must be set to true
in your application's Info.plist in order to get real Bluetooth mouse events.
2021-11-09 20:32:16 -08:00
Sam Lantinga 7681929cb4 Don't send the initial joystick axis event if the application is in the background 2021-11-09 12:30:37 -08:00
Sam Lantinga d31f90d9e1 Don't send game controller touchpad or sensor events unless the application has focus
Fixes https://github.com/libsdl-org/SDL/issues/4891
2021-11-09 12:09:01 -08:00
Sam Lantinga d2f756360e When making the window centered it should use windowed mode size since it doesn't affect fullscreen windows
Fixes bug https://github.com/libsdl-org/SDL/issues/4750
2021-11-09 11:55:02 -08:00
Susko3 1fc25bd839 Properly position the IME window(s) on windows 2021-11-09 11:00:46 -08:00
Ryan C. Gordon 04f42e0468 metal: Deal better with -[CAMetalLayer nextDrawable] returning nil.
Fixes #4863.
2021-11-09 12:03:12 -05:00
Sam Lantinga 0f2bf62935 Fixed building hidapi when libusb is available 2021-11-09 06:20:46 -08:00
Sylvain e8731933cc
Fixed warning: macro is not used 2021-11-09 13:33:25 +01:00
Sylvain c7065bf42f
Fix warning: declaration shadows a local variable 2021-11-09 13:33:24 +01:00
Cameron Gutman 715e7bda22 haptic: Don't enumerate joysticks if the joystick subsystem is active
The joystick subsystem has complex precedence logic to deal multiple competing
backends like XInput, RawInput, and WGI. Let it fire the MaybeAdd callbacks
for joystick devices, since it knows which backend will end up managing them.

This resolves a situation where the RawInput joystick backend would take
control of an XInput device but the XInput haptic backend would still create
a haptic device. Since the XInput joystick backend didn't own the underlying
joystick device, we'd end up with an orphaned haptic device that didn't work
with SDL_HapticOpenFromJoystick() on the associated joystick device.
2021-11-09 01:43:44 -06:00
Ethan Lee ae67c7d2da Implemented SDL_SetWindowMouseRect() on Wayland 2021-11-09 01:34:02 -05:00
Sam Lantinga 18e69827aa Fixed Linux build 2021-11-08 22:29:02 -08:00
Yufei Huang 881f747d5c Always destroy icon 2021-11-08 22:20:50 -08:00
Yufei Huang 7fea557b99 SDL_windowsmouse.c: Remove LR_COPYDELETEORG flag 2021-11-08 22:20:50 -08:00
Sam Lantinga 67c42cb44c Fixed Windows build 2021-11-08 22:16:01 -08:00
Sam Lantinga fd79607eb0 Added SDL_GetWindowMouseRect()
Also guarantee that we won't get mouse movement outside the confining area, even if the OS implementation allows it (e.g. macOS)
2021-11-08 21:34:48 -08:00
Sam Lantinga 4db546b092 Implemented SDL_SetWindowMouseRect() on macOS 2021-11-08 20:35:56 -08:00
Cameron Gutman 9c95c2491c x11: Use XCheckIfEvent() instead of XNextEvent() for thread-safety
A racing reader could read from our fd between SDL_IOReady()/X11_Pending()
and our call to XNextEvent() which will cause XNextEvent() to block for
more data. Avoid this by using XCheckIfEvent() which will never block.

This also fixes a bug where we could poll() for data, even when events were
already read and pending in the queue. Unlike the Wayland implementation,
this isn't totally thread-safe because nothing prevents a racing reader
from reading events into the queue between our XCheckIfEvent() and
SDL_IOReady() calls, but I think this is the best we can do with Xlib.
2021-11-08 19:17:18 -08:00
Sam Lantinga 2d23d66a61 Fixed SetWindowMouseRect return value on Windows 2021-11-08 16:33:50 -08:00
Sam Lantinga 7d21322df1 Implemented SDL_SetWindowMouseRect() on Windows 2021-11-08 16:29:19 -08:00
Ethan Lee 4b42c05ba1 video: Add SDL_SetWindowMouseRect.
This API and implementation comes from the Unreal Engine branch of SDL, which
originally called this "SDL_ConfineCursor".

Some minor cleanup and changes for consistency with the rest of SDL_video, but
there are two major changes:

1. The coordinate system has been changed so that `rect` is _window_ relative
   and not _screen_ relative, making it easier to implement without having
   global access to the display.
2. The UE version unset all rects when passing `NULL` as a parameter for
   `window`, this has been removed as it was an unused feature anyhow.

Currently this is only implemented for X, but can be supported on Wayland and
Windows at minimum too.
2021-11-08 14:16:54 -08:00
Sam Lantinga a3e8fd49e6 Cancel any accumulated mouse wheel motion in the opposite direction when the wheel direction changes
Fixes https://github.com/libsdl-org/SDL/issues/2912
2021-11-08 09:58:11 -08:00
Sam Lantinga 5dbbc8e61f Added mouse wheel deltas with floating point precision
Fixes https://github.com/libsdl-org/SDL/issues/4888
2021-11-08 09:44:31 -08:00
Sam Lantinga d95a52c9a5 Fixed comment typo 2021-11-08 09:39:21 -08:00
Ethan Lee fc998b8ec9
wayland: Return true for HasScreenKeyboardSupport only if no physical keyboard exists 2021-11-08 12:37:10 -05:00
Sam Lantinga b8327a4a48 Added SDL_HIDAPI_DISABLED so it can be disabled like other SDL subsystems 2021-11-08 07:19:45 -08:00
Sam Lantinga 2a6feb5011 Removed accidental debugging commit (thanks @DomGries!) 2021-11-08 07:10:38 -08:00
Sam Lantinga 6c56e27511 Set both _NET_WM_NAME and WM_NAME so SDL windows can be shared in the browser.
Fixes https://github.com/libsdl-org/SDL/issues/4924
2021-11-08 07:05:17 -08:00
Yufei Huang 301819cd1d SDL_windowsmouse.c: Fix WIN_CreateCursor does not scale with system cursor size preference 2021-11-08 06:59:36 -08:00
Sam Lantinga f61b10dcf1 Do more robust validation of devices passed to the SDL HIDAPI functions 2021-11-08 06:34:32 -08:00
Ozkan Sezer dd8c354843 SDL_hidapi.c: avoid possible NULL pointer dereferences. 2021-11-08 17:00:56 +03:00
Sam Lantinga 5b646cd19e Build hidapi code into SDL as a new public API
This prevents conflicts with hidapi linked with applications, as well as allowing applications to make use of HIDAPI on Android and other platforms that might not normally have an implementation available.
2021-11-07 23:00:59 -08:00
Thomas Ballinger 94c1276a5f
emscripten: Decrease vertical scroll speed by using deltaMode
Reference issue #4623.
2021-11-07 20:50:07 -05:00
Cameron Gutman f6dc47caef WGI/DInput: Fix SDL_IsXInputDevice() checks when RawInput is enabled
Enabling the RawInput backend causes SDL_XINPUT_Enabled() to return false.
That causes WGI and DInput backends to take ownership of XInput-compatible
controllers, because they think there's no XInput-specific backend enabled.

In WGI's case, it will actually race with RawInput to open the device. By
properly excluding XInput devices from WGI, we can ensure that the sets of
devices managed by WGI and RawInput don't intersect. This makes the race
harmless, since they'll never both go after the same device.
2021-11-07 16:14:33 -06:00
Sam Lantinga 301389cecc Fixed iOS build 2021-11-07 13:53:12 -08:00
Cameron Gutman b3e909dc41 WGI: Fix SDL_IsXInputDevice() for Xbox One controllers
The Xbox One driver stack doesn't propagate the VID/PID down to the
HID devices that end up in the GetRawInputDeviceList() output. This
means we end up matching against the wrong VID/PID and can't properly
exclude Xbox One controllers from WGI.

Fortunately, it is possible to walk back up the device tree to find
the parent with the matching VID/PID.
2021-11-07 13:33:18 -08:00
Sam Lantinga b8c00bf914 Allow opening joysticks that are read-only on Linux
Fixes https://github.com/libsdl-org/SDL/issues/4713
2021-11-07 13:11:29 -08:00
Sam Lantinga 0323d983c6 Add the platform to the game controller mapping so it can be read back in without changes
Fixes https://github.com/libsdl-org/SDL/issues/4848
2021-11-07 12:52:48 -08:00
Charlie Birks d950b9e2d9
emscripten: Make timers work (if used with emscripten_set_main_loop)
Co-authored-by: aidanhs <aidanhs@cantab.net>
2021-11-07 15:40:54 -05:00
Sam Lantinga fe2fe29049 Backed out accidentally committed PR https://github.com/libsdl-org/SDL/pull/4849 2021-11-07 11:48:16 -08:00
Sam Lantinga 86bc65a741 Fixed non-Apple builds 2021-11-07 11:35:12 -08:00
Sam Lantinga 637bcd0b72 Fixed build warnings 2021-11-07 11:19:07 -08:00
Sam Lantinga e14358265e Cleanup sfSymbolName support and add them to the dynamic API functions 2021-11-07 11:16:48 -08:00
Patrick Hogan 149e5c656a Support returning sfSymbolsName for gamepad controls on macOS / iOS / tvOS 2021-11-07 10:58:37 -08:00
Ryan C. Gordon 3acb172531 stdlib: SDL_snprintf now adds decimal places for ("%f", 0.0).
This patch was from @Markvy (thanks!).

Fixes #4795.
2021-11-07 09:34:55 -08:00
Eric Wasylishen 2008f2a8a6 SDL_test_font.c: fix type of SDLTest_CharTextureCacheList 2021-11-07 08:42:09 -08:00
Eric Wasylishen a0e055a7f9 testwm2: add mode menu, click on a mode to call SDL_SetWindowDisplayMode 2021-11-07 08:42:09 -08:00
Eric Wasylishen 70f7ebe635 SDL_test_font.c: add ability to draw on different SDL_Renderers
fixes `testwm2 --windows 2`
2021-11-07 08:42:09 -08:00
Cameron Gutman 6312aaea0f WGI: Add workaround for delayed callbacks after WGI_JoystickQuit() 2021-11-06 21:35:01 -07:00
Sam Lantinga 2248a54937 Update the focus in case we changed focus to a child window and then away from the application
In this case we'll get WM_KILLFOCUS when the child window is focused, but we'll retain focus on the top level window, but when we Alt-Tab away, we won't get another WM_KILLFOCUS or WM_NCACTIVATE, we get WM_ACTIVATE instead, so we need to check for focus updates in response to that as well.
2021-11-05 22:52:18 -07:00
Ozkan Sezer 6407d4b0a8 remove unnecessary parentheses from SDL_abs() 2021-11-05 17:10:02 +03:00
Kevin Colour 6cbee0634e include: Swap parameter names in atan2 functions 2021-11-05 17:04:00 +03:00
Cameron Gutman 2371b247ff windows: improve feature detection consistency between CMake and non-CMake builds 2021-11-03 08:41:36 -07:00
superzazu 839ca0ea64
SDL_OpenURL (macOS): try to open path if the url cannot be opened (#4830)
* SDL_OpenURL (macOS): try to open path if the url cannot be opened

* SDL_OpenURL (macOS): use CFURLCreateWithBytes & LSOpenCFURLRef to correctly escape input

* fix type casting + indentation
2021-11-03 08:35:24 -07:00
Sam Lantinga 8593076da7 Fixed whitespace 2021-11-02 16:04:36 -07:00
Brick 62629c2b5d Fix 64-bit timeval/timespec delta calculations 2021-11-02 16:02:18 -07:00
Sam Lantinga 6d5edfa733 Fixed crash on Android 8, due to bugs in AAudio implementation 2021-11-02 15:59:26 -07:00
Frank Praznik 43ddc59fa8
Export SDL_LinuxSetThreadPriorityAndPolicy() function (#4877)
It's marked as being a public symbol internally, however, it was missing from the header files and not visible in the shared library.  This adds it to the necessary headers and to the DynAPI list to expose it for use by applications.

Co-authored-by: Frank Praznik <frank.praznik@oh.rr.com>
2021-11-02 13:56:14 -07:00
Ivan Epifanov 848d7b1254 Vita: Implement command batching 2021-11-02 13:43:22 -07:00
Ivan Epifanov 3f7a94fc94 Vita: Remove FillRects 2021-11-02 13:43:22 -07:00
Cameron Gutman f73376ae24 events: Add logging for SDL_CONTROLLERTOUCHPAD*, SDL_CONTROLLERSENSORUPDATE, and SDL_SENSORUPDATE events 2021-11-02 00:31:25 -05:00
Ryan C. Gordon 2379c52849 os/2: Don't try to be clever with the 32-bit GetTicks fallback. 2021-11-01 14:28:00 -04:00
Ryan C. Gordon cca79d32a2 android: Patched SDL_GetTicks64() to compile. 2021-11-01 14:28:00 -04:00
Ryan C. Gordon affb183ea4 unix: Fixed SDL_GetTicks64 function signature. 2021-11-01 14:28:00 -04:00
Ryan C. Gordon 99c9727dc0 timer: Added SDL_GetTicks64(), for a timer that doesn't wrap every ~49 days.
Note that this removes the timeGetTime() fallback on Windows; it is a
32-bit counter and SDL2 should never choose to use it, as it only is needed
if QueryPerformanceCounter() isn't available, and QPC is _always_ available
on Windows XP and later.

OS/2 has a similar situation, but since it isn't clear to me that similar
promises can be made about DosTmrQueryTime() even in modern times, I decided
to leave the fallback in, with some heroic measures added to try to provide a
true 64-bit tick counter despite the 49-day wraparound. That approach can
migrate to Windows too, if we discover some truly broken install that doesn't
have QPC and still depends on timeGetTime().

Fixes #4870.
2021-11-01 14:28:00 -04:00
Northfear fba82ad1cb Remove sceGxmFinish from RenderPresent on Vita. Make sure that rendering is finished on render texture during locking 2021-10-31 09:17:13 -04:00
Sam Lantinga a01aaf053c Fixed compiler warning 2021-10-30 21:42:07 -07:00
Cameron Cawley 4d3da5b75b riscos: Disable the mouse pointer for now 2021-10-30 21:25:01 -07:00
Cameron Cawley 1c256b892e riscos: Fix enumerating screen modes 2021-10-30 21:25:01 -07:00
Cameron Cawley 5a3c97f3a3 riscos: Fix detection of the current mode 2021-10-30 21:25:01 -07:00
Cameron Cawley 53b3db0c5d Handle the KMOD_SCROLL modifier on RISC OS 2021-10-30 21:25:01 -07:00
Cameron Cawley 1268984edc Implement mouse input on RISC OS 2021-10-30 21:25:01 -07:00
Cameron Cawley f7f54f0d04 Implement keyboard input on RISC OS
Partially based on a patch from http://www.riscos.info/websvn/listing.php?repname=gccsdk&path=%2Ftrunk%2Fautobuilder%2Flibraries%2Fsdl%2Flibsdl2%2F&rev=7174#a6401c766f408f1ea356e6977894cc6a5
Currently lacks support for mapping scancodes to keycodes.
2021-10-30 21:25:01 -07:00
Cameron Cawley f8a8ca3e1f Support proper mode switching on RISC OS 2021-10-30 21:25:01 -07:00
Cameron Cawley fe9bb74764 riscos: Refactor framebuffer code 2021-10-30 21:25:01 -07:00
Cameron Cawley 25c71748ad Add a barebones RISC OS video driver 2021-10-30 21:25:01 -07:00
Cameron Gutman a559864968 x11/wayland: Fix signal handling while blocking in WaitEventTimeout()
Add a new flag to avoid suppressing EINTR in SDL_IOReady(). Pass the
flag in WaitEventTimeout() to ensure that a SIGINT will wake up
SDL_WaitEvent() without another event coming in.
2021-10-30 21:23:45 -07:00
Cameron Gutman c97c46877f core: Convert SDL_IOReady()'s 2nd parameter to flags 2021-10-30 21:23:45 -07:00
Ryan C. Gordon 8a4a282aaa
alsa: Make hotplug thread optional.
Even without the thread, it'll do an initial hardware detection at startup,
but there won't be any further hotplug events after that. But for many cases,
that is likely complete sufficient.

In either case, this cleaned up the code to no longer need a semaphore at
startup.

Fixes #4862.
2021-10-30 16:02:12 -04:00
Sam Lantinga 26706319d7 Ignore the ASRock LED controller, it's not a joystick 2021-10-30 05:53:12 -07:00
Cameron Gutman ac54d57aa5 event: Check subsystem initialization before events or devices
SDL_WasInit() is cheaper SDL_NumJoysticks()/SDL_NumSensors().
2021-10-27 22:35:56 -05:00
Cameron Gutman 1bc6dc3ea0 event: Cap maximum wait time if sensor or joystick subsystems are active
Joystick and sensor subsystems require periodic polling to detect new devices.
2021-10-27 22:35:56 -05:00
Cameron Gutman 2bf36bfac4 wayland: Implement WaitEventTimeout() and SendWakeupEvent()
We can have spurious wakeups in WaitEventTimeout() due to Wayland events
that don't end up causing us to generate an SDL event. Fortunately for us,
SDL_WaitEventTimeout_Device() handles this situation properly by calling
WaitEventTimeout() again with an adjusted timeout.
2021-10-27 19:16:53 -05:00
Ivan Epifanov 9c799802c9 Vita: fix IME input languages 2021-10-26 08:29:56 -07:00
David Gow c57bcb47b1 test: Fix building with libunwind under autotools
There are two issues which are stopping the SDL tests from building on
my machine:
- libunwind is not being linked
- Even if it is, it is missing several symbols.

The first is fixed by having the test programs link against libunwind if
available. Technically, SDL2_test should be linking against it, as it's
used in SDL_test_memory.c, but as SDL2_test is a static library, it
can't itself import libunwind. We just assume that if it's present on
the system, we should link it directly to the test programs. This should
strictly be an improvement, as the only case where this'd fail is if
SDL2 was compiled when libunwind was present, but the tests are being
compiled without it, and that'd fail anyway.

The second is fixed by #define-ing UNW_LOCAL_ONLY before including
libunwind.h: this is required to make libunwind link to predicatable
symbols, in what can only be described as a bit of a farce. There are a
few more details in the libunwind man page, but the gist of it is that
it disables support for "remote unwinding": unwinding stack frames in a
different process (and possibly from a different architecture?):
http://www.nongnu.org/libunwind/man/libunwind(3).html

Note that I haven't tried this with CMake: I suspect that it'll work,
though, as the CMakeLists.txt seems to have SDL2 link against libunwind if
it's present. This adds an ugly extra dependency to SDL2, but does mean
that issue 1 isn't present. The UNW_LOCAL_ONLY change shouldn't be
build-system-specific.
2021-10-25 11:28:20 -07:00
Cameron Gutman 408a93a1ec wayland: Use multi-thread event reading APIs
Wayland provides the prepare_read()/read_events() family of APIs for
reading from the display fd in a deadlock-free manner across multiple
threads in a multi-threaded application. Let's use those instead of
trying to roll our own solution using a mutex.

This fixes an issue where a call to SDL_GL_SwapWindow() doesn't swap
buffers if it happens to collide with SDL_PumpEvents() in the main
thread. It also allows coexistence with other code or toolkits in
our process that may want read and dispatch events themselves.
2021-10-25 12:00:35 -04:00
Sylvain 4960cc3dcb
Fixed a few warnings 2021-10-25 16:18:40 +02:00
Sylvain b793394590
SDL_Renderer: make clear that we use render geometry for fillrect/copy/copyex when there is no specific back-end implementation (currently software, PSP, directfb) 2021-10-25 13:46:40 +02:00
Ozkan Sezer b3f9d8f38d remove unused local vars after the latest commits. 2021-10-25 07:05:50 +03:00
Sylvain 502e9c3b45 SDL_Renderer simplifications:
- Factorize PrepQueueCmdDraw{,DrawTexture,Solid) into one single function
- Change SDL_Texture/Renderer r,g,b,a Uint8 into an SDL_Color, so that it can be passed directly to RenderGeometry
- Don't automatically queue a SET_DRAW_COLOR cmd for RenderGeometry (and update GLES2 renderer)
2021-10-24 22:27:56 -04:00
Sylvain 23e252bfc5 DirectFB: provide RenderCopyEx via RenderGeometry 2021-10-24 22:27:56 -04:00
Sylvain 79732c9d1e Remove FillRects from back-end, where RenderGeometry can be used 2021-10-24 22:27:56 -04:00
Sylvain f02ad2820f Remove FillRects from back-end, where RenderGeometry can be used 2021-10-24 22:27:56 -04:00
Sylvain 70b10c753d Use correct indices when using RenderGeometry / FillRects 2021-10-24 22:27:56 -04:00
Sylvain 16beed9aeb Less code since color is constant when done with triangles 2021-10-24 22:27:56 -04:00
Sylvain 99a346439c OpenGLES2: LINES and POINTS successive commands are combined into a single draw call
(using the same case for DRAW_GEOMETRY)
2021-10-24 22:27:56 -04:00
Sylvain f0cdc1d0f6 OpenGLES2: remove FillRects, since it's can be done with RenderGeometry 2021-10-24 22:27:56 -04:00
Sylvain 37c39d5cb4 Use geometry to implement FillRects 2021-10-24 22:27:56 -04:00
Sylvain b0eef52fe1 GLES2 batching: probably need to check for blendMode changes 2021-10-24 22:27:56 -04:00
Sylvain c27e1249e1 Remove SDL_HAVE_RENDER_GEOMETRY define 2021-10-24 22:27:56 -04:00
Sylvain 77026f673b Metal: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain 0e5160a056 VITA: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain 73f4ab4c13 Direct3D11: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain ab758398af Direct3D: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain 1fe7e3616b OpenGL: a few opengl functions become unused 2021-10-24 22:27:56 -04:00
Sylvain 88548070a5 OpenGLES: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain d192515428 OpenGL: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain b92056bbea OpenGLES2: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain 76f9fb96d9 Use RenderGeometry to implement RenderCopy and RenderCopyEx at higher level 2021-10-24 22:27:56 -04:00
Ryan C. Gordon 08797adaef opengles2: Attempt to batch RenderCopy calls into a single glDrawArrays call. 2021-10-24 22:27:56 -04:00
Tanuj Bagaria 1f0eb03a76
Fix PS5 mapping with HID-PLAYSTATION driver (#4675)
* add missing PS5 Linux GUID for Bluetooth

* Fix PS5 Mapping to work with HID-Playstation driver
2021-10-24 17:54:26 -05:00
Cameron Gutman f499168c2c x11: Use SDL_IOReady() instead of calling select() directly
SDL_IOReady() properly handles EINTR and can use poll() if available.
2021-10-24 15:54:57 -05:00
Alex Szpakowski ba4ef461ea macOS: Fix implicit integer downcast warnings 2021-10-23 17:45:27 -04:00
Ryan C. Gordon d9d8f51eec
wikiheaders.pl: Add support for deprecated functions. 2021-10-23 14:41:23 -04:00
David Gow a76b73dd2c kmsdrm: Use SDL_PremultiplySurfaceAlphaToARGB8888() for cursor surface
Instead of taking a direct copy of the mouse cursor surface, and then
premultiplying on every BO upload (using the custom
legacy_alpha_premultiply_ARGB8888 function), use the new
SDL_PremultiplySurfaceAlphaToARGB8888() function, which converts a whole
surface at a time, once and save the result.

The already-premultiplied data is then copied from that to the BO on
each upload, adjusting for the stride (which the previous implementation
required to be equal to the width), thereby making the extra copy
slightly useful..

This also adds support for non-SDL_PIXELFORMAT_ARGB8888 surfaces.
2021-10-22 05:50:00 -07:00
David Gow b528d48446 wayland: Wayland cursors should use premultiplied alpha
It turns out that Wayland's WL_SHM_FORMAT_ARGB8888 format (and, indeed,
all wayland RGBA formats) should be treated as premultiplied. SDL
surfaces tend not to be premultiplied, and this is assumed by other
backends when dealing with cursors.

This change premultiplies the cursor surface in Wayland_CreateCursor()
using the new SDL_PremultiplySurfaceAlphaToARGB8888(). In so doing, it
also adds support for a wider range of input surfaces, including those
with non-ARGB8888 pixel formats, and those which don't have
pitch==width.

This should fix #4856
2021-10-22 05:50:00 -07:00
David Gow 84808ea4bb video: Add SDL_PremultiplySurfaceAlphaToARGB8888()
A number of video backends need to get ARGB8888 formatted surfaces with
premultiplied alpha, typically for mouse cursors. Add a new function to
do this, based loosely on legacy_alpha_premultiply_ARGB8888() from the
KMSDRM backend.

The new function, SDL_PremultiplySurfaceAlphaToARGB8888() takes two
arguments:
- src: an SDL_Surface to be converted.
- dst: a buffer which is filled with premultiplied ARGB8888 data of the
  same size as the surface (assuming pitch = w).

This is not heavily optimised: it just repeatedly calls SDL_GetRGBA() to
do the conversion, but should do for now.
2021-10-22 05:50:00 -07:00
uyjulian 007b5463e8 video/uikit: Do not use setNeedsUpdateOfPrefersPointerLocked on iOS SDKs older than 14 2021-10-21 21:21:57 -07:00
Sam Lantinga b360965d0d Added a hint for alternate OpenGL NV12 data format 2021-10-21 20:48:05 -07:00
Cacodemon345 19dee1cd16
Add SDL_GetWindowICCProfile(). (#4314)
* Add SDL_GetWindowICCProfile

* Add new SDL display events

* Implement ICC profile change event for macOS

* Implement ICC profile notification for Windows

* Fix SDL_GetWindowICCProfile() for X11

* Fix compile errors
2021-10-21 17:37:20 -07:00
Sam Lantinga a34fe8161f Added the ability to bind NV12 textures in the OpenGL renderer 2021-10-21 12:28:35 -07:00
Sam Lantinga f3fd1ffb99 Fixed crash if SDL API functions are called on a disconnected controller on iOS 2021-10-20 15:18:03 -07:00
Sam Lantinga a43d3f6931 Don't detect the ROG Chakram mouse as a joystick 2021-10-20 15:19:22 -07:00
Sam Lantinga bfd2f8993f Fixed grab handling when focus changes between windows in the same application 2021-10-19 17:29:23 -07:00
James Howard d9c44b6537 Allow Cocoa_VideoInit to succeed when current display mode has invalid flags
This fixes a specific issue seen on macOS 10.14.6 where a DELL E248WFP
Display connected to a 2014 Mac Mini with a scaled 1920x1080 resolution
selected and SDL_Init(SDL_INIT_VIDEO) failed with the error: "The video
driver did not add any displays".

The underlying cause was that the current 1080p display mode did not
have the flag kDisplayModeSafeFlag, the check for which was added in
a963e36, with the idea that certain display modes should not be
candidates for switching to in fullscreen exclusive mode. That may well
be the right thing to do for filtering down a list of candidate modes,
but it doesn't pay to be so picky about the current mode. After all,
this current mode was set by System Preferences, the picture does appear
correctly on screen, and other non-SDL based applications launch and run
correctly in this mode.

Therefore the fix is to have GetDisplayMode only filter out a mode based
on flags if it's part of a candidate list, but if it's the current mode
and it can possibly be converted to an SDL_DisplayMode, do so.
2021-10-19 15:50:21 -07:00
Sylvain 649a33ae47
X11: remove redundant 'wakeup_lock' mutex creation 2021-10-18 23:00:43 +02:00
Ozkan Sezer c4bac66b74 os2, geniconv: replaced many uses of libc calls with SDL_ counterparts.
FIXME: figure out a way to handle errno checks properly.
2021-10-18 14:11:20 +03:00
Ozkan Sezer 0a0f685473 SDL_os2video.c: missed replacing a use of libc function 2021-10-18 14:10:56 +03:00
Ozkan Sezer 8e9ea2e362 SDL_os2joystick.c: missed replacing a use of libc function 2021-10-18 14:10:37 +03:00
Sylvain 8b1a2fe860
backout SDL_AndroidSetInputType() 2021-10-17 23:47:59 +02:00
Sylvain 6ef3bc5688
Add Dynapi for SDL_AndroidSetInputType() 2021-10-17 23:40:36 +02:00
Sylvain ccb12457f9
Fixed bug #4843 - Can not get the ime candidatelist like chinese/japaness input method 2021-10-17 23:17:54 +02:00
Sam Lantinga 7fb4364391 Don't process WM_INPUT when handling relative mode by warping the mouse cursor 2021-10-17 13:56:31 -07:00
DomGries 06824b18fd Cleanup windows events after recent changes
Improves clarity without any functional changes
2021-10-17 13:36:42 -07:00
Sylvain 50f969c1b2
Fixed bug #4841 - Out of bounds read (by 1 byte) in yuvnv12_rgb24_sseu 2021-10-17 22:02:19 +02:00
shaquan-omari ea97ab6164 Add mapping for HORI Fighting Commander OCTA controller on Linux 2021-10-16 15:25:38 -07:00
Sam Lantinga 1c5b3e0e16 Don't center the mouse when gaining focus unless we're using relative mode warping
This is necessary now that we actually change the mouse position when calling SDL_WarpMouseInWindow() in relative mode.
2021-10-15 18:12:18 -07:00
Sam Lantinga a70a94e0b3 Don't send a mouse leave event if the mouse is outside the window when gaining focus and in relative mode. 2021-10-15 18:11:19 -07:00
Ozkan Sezer c583055acb SDL_windowsevents.c (WIN_WindowProc): remove SAFE_AREA_X and SAFE_AREA_Y
Not used since commit a1fabca162
2021-10-15 10:11:24 +03:00
Sam Lantinga d5700ed20b Don't log SDL_POLLSENTINEL, it's purely for internal bookkeeping 2021-10-15 00:01:39 -07:00
Sam Lantinga dd5d89505d Fixed whitespace 2021-10-14 23:53:41 -07:00
Brick 8bf32e12d8
Improved SDL_PollEvent usage (#4794)
* Avoid unnecessary SDL_PumpEvents calls in SDL_WaitEventTimeout

* Add a sentinel event to avoid infinite poll loops

* Move SDL_POLLSENTINEL to new internal event category

* Tweak documentation to indicate SDL_PumpEvents isn't always called

* Avoid shadowing event variable

* Ignore poll sentinel if more (user) events have been added after

Co-authored-by: Sam Lantinga <slouken@libsdl.org>
2021-10-14 22:26:10 -07:00
Sam Lantinga 88e9f7765c Fixed relative mouse mode using warping after 82793ac279 2021-10-14 18:37:27 -07:00
Sam Lantinga a1fabca162 Removed mouse warping for local mice and improved warp handling for mouse over RDP 2021-10-14 16:52:21 -07:00
Sam Lantinga 82793ac279 Fixed mouse warping while in relative mode
We should get a mouse event with an absolute position and no relative motion and shouldn't change the OS cursor position at all
2021-10-14 14:26:21 -07:00
Sylvain 072e3fdfc4
Fixed bug #4534: NEON implementation of Convert51ToStereo (Thanks Ryan!) 2021-10-14 23:17:08 +02:00
Sam Lantinga 5e89b3c89e Don't need to use raw input to track the mouse during mouse capture (thanks Brick!) 2021-10-14 11:46:07 -07:00
Brick 0b6a821188 Messages posted on the same tick are not new 2021-10-14 09:05:38 -07:00
Rémy Tassoux 0789610cfb Add SDL_HINT_WINDOW_NO_ACTIVATION_WHEN_SHOWN 2021-10-14 08:39:48 -07:00
Sam Lantinga 1fa154fda3 Fix weak enforcement of timeouts in SDL_WaitEventTimeout_Device. This will loop pumping events and waiting for a system event to come in. However not all system events will turn into an SDL event. It's not unusual for a Windows message to be some internal thing that SDL doesn't convert into a message. In that case the loop will simple circle but not exit. As long as such messages are coming in the loop will continue to run regardless of the timeout. When messages finally stop it'll still wait for the full timeout so you can have arbitrarily long delays.
Instead do an absolute elapsed time check since the start of the wait.  If that is exceeded during any iteration the routine exits as the timeout has elapsed.
2021-10-13 09:33:54 -07:00
Sam Lantinga 2423c51471 Work around hang in AAudioStream_write() during extended shared object loading while running in a debugger. Observed on a OnePlus 8T (KB2005) running Oxygen OS 11.0.10.10.KB05AA.
The observed behavior is that any nonzero timeout value would hang until the device was paused and resumed. And a zero timeout value would always return 0 frames written even when audio fragments could be heard. Making a manual timeout system unworkable.
None of the straightforward systems imply that there's a detectable problem before the call to AAudioStream_write(). And the callback set within AAudioStreamBuilder_setErrorCallback() does not get called as we enter the hang state.
I've found that AAudioStream_getTimestamp() will report an error state from another thread. So this change codifies that behavior a bit until a better fix or more root cause can be found.
2021-10-13 09:33:51 -07:00
Erik Soma 0e294e90ae
Ensure that SDL_InitSubSystem quits subsystems after an error. (#4834)
* Ensure that SDL_InitSubSystem quits subsystems after an error.

* Fix unnecessary change.
2021-10-12 15:55:31 -07:00
Ozkan Sezer 6149e60136 remove IsWin10FCUorNewer() -- not used since commit 40ed9f75c9 2021-10-13 00:03:56 +03:00
Ozkan Sezer 311671a029 fixed build after commit 6e356e20ad 2021-10-12 23:50:02 +03:00
Rémy Tassoux 6e356e20ad Fix mouse focus being set to null when a captured mouse cursor leaves the window. 2021-10-12 13:30:46 -07:00
Cameron Cawley 9ee6942e79 Improve RISC OS implementations of SDL_GetBasePath and SDL_GetPrefPath 2021-10-12 13:07:52 -07:00
Cameron Cawley 3db898c5b6 riscos: Implement SDL_GetPrefPath() 2021-10-12 13:07:52 -07:00
Sam Lantinga 40ed9f75c9 Workaround for Windows occasionally ignoring SetCursorPos() calls
Also, since we're flushing mouse motion before and including the warp, we don't need the isWin10FCUorNewer hack to simulate mouse warp motion.

Fixes https://github.com/libsdl-org/SDL/issues/4339 and https://github.com/libsdl-org/SDL/issues/4165
2021-10-08 10:05:27 -07:00
Sam Lantinga 373216ae5b Added support for touchpads in the Linux evdev code (thanks Francisco!) 2021-10-07 18:14:16 -07:00
Sam Lantinga 16aeb8d0f5 Guarantee that we don't dispatch any mouse motion from before or including the last mouse warp 2021-10-07 15:04:06 -07:00
Sam Lantinga 649466f491 Flush any pending mouse motion when warping the mouse cursor
Fixes https://github.com/libsdl-org/SDL/issues/4165
2021-10-07 13:28:44 -07:00
Väinö Mäkelä ad5205739e wayland: Only dispatch frame events in Wayland_GLES_SwapWindow
Dispatching all events in Wayland_GLES_SwapWindow leads to resizes being
acked before the program has a chance to handle the resize. This change
reduces jumping on fullscreen transition with apps that call
SDL_PollEvent before issuing any render calls.
2021-10-07 05:12:00 -04:00
Sam Lantinga dd95c9c8a2 Moved focus click check into WIN_UpdateFocus() so we have the correct state when setting keyboard focus
Fixes https://github.com/libsdl-org/SDL/issues/4817
2021-10-06 09:09:39 -07:00
Sam Lantinga 1ec409c214 Don't warp the mouse within a window while it's minimized 2021-10-06 09:09:09 -07:00
DomGries 0d541e5a88 Revert "Fixed relative mode mouse events stopping if you click on the title bar"
This has been better fixed by b28ed02 or another related relative mouse mode change of @slouken in SDL 2.0.17 and as such can be reverted to reduce unneeded processing in WM_MOUSEMOVE
2021-10-05 15:46:12 -07:00
Sam Lantinga c542de9213 React to WM_NCACTIVATE instead of WM_SETFOCUS or WM_ACTIVATE for focus changes
See https://github.com/libsdl-org/SDL/pull/4293 and https://github.com/libsdl-org/SDL/issues/4450 for details
2021-10-05 14:09:52 -07:00
Sylvain f080273acd
PSP: add implementation for RenderGeometry 2021-10-04 22:01:11 +02:00
Ozkan Sezer e92a639b23 replaced many uses of libc calls with SDL_ counterparts in os2 sources.
TODO: core/os2 and geniconv sources _must_ be updated, as well..
2021-10-04 23:00:28 +03:00
Sylvain dd9b2daf8d
PSP: fixed build 2021-10-04 21:56:42 +02:00
Ozkan Sezer 3ea35fe5bb fix SDL_atoi()
fixes https://github.com/libsdl-org/SDL/issues/4811
2021-10-04 21:32:00 +03:00
Sam Lantinga c501d159a9 Fixed range for Steam Controller sensor values 2021-10-03 14:10:21 -07:00
Sam Lantinga ea1a2b94f2 Use the correct update rate for Steam Controller sensors 2021-10-02 09:13:29 -07:00
David Gow eadc8f9355 wayland: Cleanup some SDL_TryLockMutex() calls.
Check the result of these against 0 explicitly, so that it's obvious
we're bailing out on failure, not success.
2021-10-02 11:14:52 -04:00
David Gow 25f9e32b0e wayland: Don't let multiple threads dispatch wayland events at once
wl_display_dispatch() will block if there are no events available, and
while we try to avoid this by using SDL_IOReady() to verify there are
events before calling it, there is a race condition between
SDL_IOReady() and wl_display_dispatch() if multiple threads are
involved.

This is made more likely by the fact that SDL_GL_SwapWindow() calls
wl_display_dispatch() if vsync is enabled, in order to wait for frame
events. Therefore any program which pumps events on a different thread
from SDL_GL_SwapWindow() could end up blocking in one or other of them
until another event arrives.

This change fixes this by wrapping wl_display_dispatch() in a new mutex,
which ensures only one thread can compete for wayland events at a time,
and hence the SDL_IOReady() check should successfully prevent either
from blocking.
2021-10-02 11:03:20 -04:00
Sam Lantinga 8b74575267 Added support for the gyro and accelerometer on Steam Controllers
Fixes https://github.com/libsdl-org/SDL/issues/4577
2021-10-01 21:32:21 -07:00
Sam Lantinga db18764e41 Use correct relative include path 2021-10-01 16:27:59 -07:00
Sam Lantinga 632aca2945 Window input focus is based on WM_SETFOCUS and WM_KILLFOCUS as WM_ACTIVATE doesn't necessarily imply focus.
Hopefully resolves https://github.com/libsdl-org/SDL/issues/4450 and https://github.com/libsdl-org/SDL/pull/4293
2021-10-01 16:17:38 -07:00
Sam Lantinga 9706feacae Update length after shortening string (thanks mayraud705!)
Closes https://github.com/libsdl-org/SDL/pull/4698
2021-10-01 15:11:25 -07:00
Sylvain 77acd44f28
DirectFB: fixed creation of palette textures 2021-10-01 22:30:51 +02:00
Sylvain 83d600904b
DirectFB: add partial support for RenderGeometry
allow to fill triangles with color or texture
but only uniform vertex color is handled (not per vertex color)
2021-09-30 23:47:37 +02:00
Cameron Cawley c270949b5e Add a fast path for ARGB888->(A)BGR888 blending with pixel alpha 2021-09-28 11:27:56 -07:00
Ryan C. Gordon 114d1d46ac
direct3d: Remove unnecessary render target support check.
Direct3D 9 dictates that caps.NumSimultaneousRTs must always be at least 1,
which is to say that Direct3D 9 level hardware must always support render
targets.

(caps.NumSimultaneousRTs is meant to show if you can draw to multiple render
targets in a single draw call.)

We had already hardcoded SDL_RENDERER_TARGETTEXTURE as available earlier in
the function anyhow.

Fixes #4781.
2021-09-27 23:18:25 -04:00
Ethan Lee 0fc43504a0 wayland: Add support for XCURSOR_THEME/SIZE 2021-09-27 16:41:43 -04:00
Martin Mauersics 7c050aa60a egl: Don't fail to create a context if KHR_create_context_no_error is unsupported 2021-09-27 13:53:16 -04:00
David Gow 35d045584d video: wayland: Support displays with a 0 refresh rate
Some wayland compositors report the refresh rate as 0. Since we want to
force a minimum refresh rate of 10 frames worth, we were dividing by the
reported refresh rate, causing a divide-by-zero.

If the refresh rate is 0, instead force a frame every second if no frame
callbacks are received.

This fixes bug #4785
2021-09-27 09:26:40 -04:00
Sam Lantinga 9672d58119 Need to check structure version before setting xdg_toplevel to NULL 2021-09-26 14:22:11 -07:00
Northfear 14f225198d Use SDL_calloc for allocation of gxm_texture 2021-09-26 14:16:35 -07:00
Cacodemon345 b592e78f93 wayland: Expose xdg_toplevel to SysWM 2021-09-26 05:53:21 -04:00
Sam Lantinga 477fcf52e9 Fixed whitespace 2021-09-24 10:49:46 -07:00
Sam Lantinga db68af8032 Reduce the likelyhood that the mouse will hover over the taskbar or toast notification while in relative mode, which causes a mouse leave event.
This will still happen occasionally as the mouse is whipped around, if there is a window overlapping the game window, but it should happen less often now. This could even happen with the original code that warped the mouse every frame, so this should be a good compromise where we don't warp the mouse continously and we still keep the mouse in the safe area of the game window.

Note that notifications can be any size, so the safe area may need to be adjusted or even dynamically defined via a hint.
2021-09-24 10:49:44 -07:00
Ethan Lee 7ed415d2ed wayland: Reuse KeySymToUcs4 to replicate X11 keymap behavior 2021-09-23 11:50:47 -07:00
Ethan Lee 1a4e2e5ef7 wayland: For text, ignore key events when Ctrl is held
Fixes #4695
2021-09-23 14:34:39 -04:00
Ryan C. Gordon 0aff42a159
egl: Group data fields before function pointers in SDL_EGL_VideoData. 2021-09-23 00:03:26 -04:00
Ryan C. Gordon 0ad4956c06
egl: explicitly call eglBindAPI during SDL_GL_MakeCurrent.
The EGL API binding must be specified per-thread, per the docs.

Fixes #1820.
2021-09-23 00:03:25 -04:00
Ryan C. Gordon 3147716022
egl: make an int into an SDL_bool. 2021-09-23 00:03:25 -04:00
Sam Lantinga 4ec259a784 Fixed building on Visual Studio 2013 and older 2021-09-22 19:06:11 -07:00
Sam Lantinga 287571fb46 Limit effect of in_title_click and focus_click_pending to only blocking cursor warping; without this all relative mouse motion was getting ignored when a window was activated via a mouse button 2021-09-22 17:40:57 -07:00
Northfear 5292156398 End Scene on RunCommandQueue on Vita 2021-09-22 11:54:26 -07:00
Cameron Cawley 08ae790497 Replace calls to asprintf with SDL_asprintf 2021-09-22 11:53:46 -07:00
Cameron Cawley 25a614bc3e Add SDL_asprintf and SDL_vasprintf 2021-09-22 11:53:46 -07:00
Sam Lantinga 79b0aae86c The return value of SDL_snprintf is the number of characters that would have been written.
Fixes https://github.com/libsdl-org/SDL/issues/4762
2021-09-22 11:46:24 -07:00
Ethan Lee 9b74623be9 wayland: Woops, forgot to assign cursor theme size... 2021-09-22 13:52:36 -04:00
Ethan Lee 8e54698aa6 wayland: Add support for high-DPI cursors 2021-09-22 10:37:42 -07:00
Sam Lantinga 432ee7d8ad Fixed building SDL_dynapi.c without stdio support 2021-09-22 09:29:21 -07:00
Sam Lantinga 345c161feb Fixed some accidental uses of external C runtime functions 2021-09-22 09:06:45 -07:00
Sam Lantinga 5d455cabf9 Don't process raw input when the window is being dragged or clicked on. 2021-09-21 18:15:11 -07:00
Sam Lantinga 0fd54f91f4 Fixed using a tablet with raw input relative motion
Tested with a Wacom Cintiq Pro 16"
2021-09-21 18:15:11 -07:00
Sam Lantinga 8fee82d1fd Improve relative motion handling over RDP
CR and research: @danielj
2021-09-21 18:15:09 -07:00
Sam Lantinga eb3bf80f9c Fixed compiler warnings using Visual Studio 2019 2021-09-21 18:15:09 -07:00
Ryan C. Gordon ce11caa80f
alsa: Map 7.1 audio channels to match what Windows and macOS expect.
This matches what we did a long time ago for 5.1 audio.

Fixes #55.

(FIFTY FIVE. Bug reported 15 years, 3 months, and 11 days ago! lol)
2021-09-21 16:49:44 -04:00
pkubaj 9886d897e2 Fix AltiVec detection on FreeBSD
The previous code was not correct, because there's no PPC_FEATURE_HAS_ALTIVEC MIB.
Instead, elf vector check should be done.
2021-09-21 09:57:10 -07:00
Ryan C. Gordon c45facf2ca
alsa: clean up macro salsa a little. 2021-09-21 11:13:46 -04:00
Northfear 3b2fbb1cb7 End current scene before destroying the texture on Vita 2021-09-20 15:55:36 -07:00
Northfear fc4296c114 Use aligned stride in sceGxmColorSurfaceInit 2021-09-20 13:23:42 -07:00
Northfear 7080bc2a91 Fallback to SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE if CDRAM texture allocation fails 2021-09-20 13:23:42 -07:00
Ivan Epifanov 512355d7aa Vita: fix thread detach. Remove leftover KillThread 2021-09-20 11:03:02 -07:00
Ivan Epifanov ddcd847c8e Vita: fix thread priority Add support for thread name and stack size 2021-09-20 08:59:25 -07:00
Ryan C. Gordon 478f9eed28
x11: Don't include X11/extensions/extutil.h
We don't use it, it was a leftover from 1.2, I think, and it doesn't exist
on Solaris, so this should hopefully fix the build there.

This also means we don't need the configure/cmake checks for
SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY, so that was removed also.

Fixes #1666.
2021-09-20 10:22:50 -04:00
Ryan C. Gordon ca9a321715
render: GL/GLES now draw lines almost perfectly matching software renderer.
One place known to differ in a significant way is a single line segment that
starts and ends on the same point; the GL renderers will light up a single
pixel here, whereas the software renderer will not. My current belief is this
is a bug in the software renderer, based on the wording of the docs:

"SDL_RenderDrawLine() draws the line to include both end points."

You can see an example program that triggers that difference in Bug #2006.

As it stands, the GL renderers might _also_ render diagonal lines differently,
as the the Bresenham step might vary between implementations (one does three
pixels and then two, the other does two and then three, etc). But this patch
causes those lines to start and end on the correct pixel, and that's the best
we can do, and all anyone really needs here.

Not closing any bugs with this patch (yet!), but here are several that it
appears to fix. If no other corner cases pop up, we'll call this done.

Reference Bug #2006.
Reference Bug #1626.
Reference Bug #4001.
...and probably others...
2021-09-19 15:47:24 -04:00
Ryan C. Gordon 857cc7c0c9
render: constified some local variables in SDL_AllocateRenderVertices. 2021-09-19 00:38:06 -04:00
Ryan C. Gordon 5faea84c63
render: Mark viewport/cliprect dirty when window is resized.
Fixes #4751.
2021-09-18 11:54:25 -04:00
Cameron Gutman 5dccffd7e4 Allow usage of the new Condition Variable code with Critical Sections
Vista and later provide the SleepConditionVariableCS() function for this.

Since SDL_syscond_srw.c doesn't require SRW locks anymore, rename it to
SDL_syscond_cv.c which better reflects the implementation of condition
variables rather than the implementation of mutexes.

Fixes #4051.
2021-09-17 19:38:09 -04:00
Alex R ebdfd0e175 atomic: detect clang separately 2021-09-16 17:33:52 -07:00
Ivan Epifanov 8d1e0ca324 Vita: add support for disabling 'screensaver' (screen dimming and suspend) 2021-09-16 09:03:17 -07:00
Ivan Epifanov 79ec8986d3 Vita: refactor gxm texture render and add SDL_RenderGeometry support 2021-09-16 09:03:17 -07:00
Zach Reedy 2a8938f2bf
Fixed: Whitespace being striped from the end of IME strings incorrectly + Regression with SDL_SetTextInputRect (#4752)
* Fixed: Whitespace being striped from the end of IME strings incorrectly

* Fixed: Google IME Candidate Window not placing correctly

* Why are PostBuild events stored in the vcxproj and not a user file?

* Revert SDL.vcxproj properly...

* Remove whitespace as per code review

* Fix Werror=declaration-after-statement error in code
2021-09-15 09:40:22 -07:00
Ivan Epifanov ce177049f7 Vita: Allow completely skipping pvr init to override apphint from app 2021-09-14 16:20:50 -07:00
Misa 4a9947336c `SDL_RenderSetVSync()`: Restrict `vsync` to 0 or 1
In the future, we might want to support special swap intervals. To
prevent applications from expecting nonzero values of vsync to be the
same as "on", fail with SDL_Unsupported() if the value passed is neither
0 nor 1.
2021-09-14 16:18:02 -07:00
Misa 4549769d7d Add `SDL_RenderSetVSync()`
Currently, if an application wants to toggle VSync, they'd have to tear
down the renderer and recreate it. This patch fixes that by letting
applications call SDL_RenderSetVSync().

This is the same as the patch in #3673, except it applies to all
renderers (including PSP, even thought it seems that the VSync flag is
disabled for that renderer). Furthermore, the renderer flags also change
as well, which #3673 didn't do. It is also an API instead of using hint
callbacks (which could be potentially dangerous).

Closes #3673.
2021-09-14 09:56:29 -07:00
Ivan Epifanov b2504b5da6 Fix typos 2021-09-11 20:40:50 +03:00
Jaylon Gowie e455659467 Simplify Backspace and Enter 2021-09-10 19:49:47 -07:00
Jaylon Gowie f162d9ee23 Fix Indentation 2021-09-10 19:49:47 -07:00
Jaylon Gowie 058c4d36b2 Add envvar to disable touchpads independently 2021-09-10 19:49:47 -07:00
Jaylon Gowie 4435543db1 Add PVR On Screen Keyboard Support 2021-09-10 19:49:47 -07:00
Ivan Epifanov 10d3df44f1 Vita: fix copyright dates 2021-09-09 07:22:01 -07:00
Ivan Epifanov 2a83686071 Fix default path 2021-09-09 07:22:01 -07:00
Ivan Epifanov 134dd46819 Add pvr gles/gles2 context support 2021-09-09 07:22:01 -07:00
Sam Lantinga ff85d4fbe5 Fixed Xbox Series X controller being detected by both IOKit and GCController on macOS 2021-09-08 17:51:47 -07:00
Sam Lantinga 9f8552588d Added mapping for Xbox One S controller with newer firmware on macOS 2021-09-08 17:50:17 -07:00
Sam Lantinga bf97c5a22f Make sure SDL file descriptors don't leak into child processes 2021-09-08 14:47:40 -07:00
Ryan C. Gordon d49d955d73
render: SDL_RenderGeometry should still render when hidden, in most cases.
(otherwise render targets may fail, etc...the check is a legacy helper for
iOS apps that crash if you try to use OpenGL while in the background.)
2021-09-08 11:44:17 -04:00
Sam Lantinga 7d66fa209a Fixed double-copy of the report in BlueZ >= 5.56 2021-09-07 17:38:26 -07:00
Sam Lantinga 7ed7644a26 Fixed compiling HIDAPI Steam Controller support with C89 compiler 2021-09-07 17:37:47 -07:00
Sam Lantinga 27a48b142b Check the pathname first, as that's a faster check for XInput devices 2021-09-07 15:50:21 -07:00
Zach Reedy 6f97205229 Added: Support for showing the IME Candidate Window on Windows 2021-09-02 02:28:54 -10:00
Sylvain 183eb0673b
Fixed bug #4711: prevent opengl SDL_renderer from crashing if GL_ARB_multitexture isn't supported 2021-09-01 15:46:32 +02:00
Rokas Kupstys 515b7e93b5 Fix horizontal wheel scroll direction of X11. 2021-09-01 03:25:49 -10:00
David Gow a1ffeda0ed Add SDL_HINT_APP_NAME and DBUS inhibition hint
See SDL bug #4703. This implements two new hints:
- SDL_APP_NAME
- SDL_SCREENSAVER_INHIBIT_ACTIVITY_NAME

The former is the successor to SDL_HINT_AUDIO_DEVICE_APP_NAME, and acts
as a generic "application name" used both by audio drivers and DBUS
screensaver inhibition. If SDL_AUDIO_DEVICE_APP_NAME is set, it will
still take priority over SDL_APP_NAME.

The second allows the "activity name" used by
org.freedesktop.ScreenSavver's Inhibit method, which are often shown in
the UI as the reason the screensaver (and/or suspend/other
power-managment features) are disabled.
2021-08-30 09:15:11 -04:00
Lee Salzman 9fae8f7088 Treat empty SDL_VIDEODRIVER var to check all video drivers. 2021-08-30 05:00:51 +03:00
Lee Salzman 7d90df0ece Restore previous behavior of empty SDL_AUDIODRIVER trying all drivers.
The recent change to make SDL_AUDIODRIVER support comma-separated lists
broke the previous behavior where an SDL_AUDIODRIVER that was empty
behaved the same as if it was not set at all. This old behavior was
necessary to paper over differences in platforms where SDL_setenv may
or may not actually delete the env var if an empty string is specified.
This patch just adds a simple check to ensure SDL_AUDIODRIVER is not
empty before using it, restoring the old interpretation of the empty
var.
2021-08-30 05:00:51 +03:00
Sam Lantinga 8b1f8b6ec5 Use the high speed alternate setting on new Microsoft Xbox controllers 2021-08-27 11:14:09 -07:00
Sylvain 1fe9ad04be
SDL_ConvertSurface: add an intermediate variable to remove static analysis false positive (see bug #4600) 2021-08-27 14:09:47 +02:00
Sylvain be6bee0b5a
SW_RenderGeometry: add a redundant check to clear static analysis (see bug #4600) 2021-08-27 07:47:28 +02:00
Sylvain 54ca1d190e
SW_RenderGeometry: add a redundant check to clear static analysis (see bug #4600) 2021-08-27 07:44:03 +02:00
Sylvain b17aa5d080
SW_RenderGeometry: remove a few static analysis false positives (see bug #4600) 2021-08-27 07:16:40 +02:00
David Gow 3261f7f6ce audio: Support "pulse" as an alias for "pulseaudio"
Originally, SDL 1.2 used "pulse" as the name for its PulseAudio driver.
While it now supports "pulseaudio" as well for compatibility with SDL
2.0 [1], there are still scripts and distro packages which set
SDL_AUDIODRIVER=pulse [2]. While it's possible to remove this in most
circumstances or replace it with "pulseaudio" or a comma-separated list,
this may still conflict if the environment variable is set globally and
old binary builds of SDL 1.2 (e.g. packaged with older games) are being
used.

To fix this on SDL 2.0, add a hardcoded check for "pulse" as an audio
driver name, and replace it with "pulseaudio". This mimics what SDL 1.2
does (but in reverse). Note that setting driver_attempt{,_len} is safe
here as they're reset correctly based on driver_attempt_end on the next
loop.

[1] d951409784
[2] https://bugzilla.opensuse.org/show_bug.cgi?id=1189778
2021-08-25 22:43:32 -10:00
Sam Lantinga 503ea8e89f Don't modify the Nintendo Switch home LED state by default 2021-08-25 14:42:16 -07:00
Vanfanel b1e492d1fc Search for an appropiate plane instead of simply using the first one. 2021-08-25 10:51:26 -10:00
Eric Engestrom 23ffa3d914 Update SDL's copy of the EGL headers from Khronos 2021-08-25 10:50:21 -10:00
Ethan Lee 524964f966 Add SDL_HINT_VIDEO_EGL_ALLOW_TRANSPARENCY 2021-08-25 16:40:02 -04:00
Eric Engestrom 5113fedfa0 video/wayland: use EGL_EXT_present_opaque when available 2021-08-25 16:40:02 -04:00
Sam Lantinga 130b6bebae Manually scan for Linux joysticks before udev scan runs
This allows us to have joysticks sorted by insert time at startup, fixing https://github.com/libsdl-org/SDL/issues/4688
2021-08-24 17:03:19 -07:00
Sam Lantinga cbccf5bb50 Use SDL_GetHint() instead of SDL_getenv() for Linux joystick hints 2021-08-24 17:03:19 -07:00
Shawn Ellis 0ae2a9f8c3 Fixed the Atari gamecontroller mappings and added Atari Xbox 360
This change corrects the mappings for the Atari gamecontroller and
adds support for the Atari Xbox 360 compatible gamecontroller. The Atari
game controller can switch between Atari and Xbox 360 mappings.
2021-08-24 13:06:27 -10:00
Ryan C. Gordon d5fe9c308a x11: Log a warning if we decide to use XVidMode.
Reference issue #1782.
2021-08-24 14:29:39 -04:00
Ryan C. Gordon 9504bb121d
pulseaudio: Fix some function signatures that expect const pointers.
This might have changed at some point in the Pulse API, or this might have
always been wrong, but we didn't notice because the dynamic loading code
hides it by casting things to void *. The static path, where it
assigns the function pointer directly, puts out a clear compiler warning,
though.
2021-08-23 00:47:25 -04:00
Sylvain e426bb80cb
Fixed bug #4671 - D3D_QueueGeometry: use "count / 3" (Thanks alittlesail!) 2021-08-20 07:50:30 +02:00
Oschowa 70c23b25f0 audio: pipewire: Reset hotplug atomic variables on deinit. 2021-08-19 22:26:25 -04:00
Sylvain ae5336a3d2
Fixed bug #4669: D3D_QueueGeometry: -0.5f offset position of vertexs
This similar to D3D_QueueCopy positions
2021-08-19 14:03:10 +02:00
Ozkan Sezer 8270172e74 fix -Wshorten-64-to-32 warnings in android builds.
see: https://github.com/libsdl-org/SDL/pull/4195#issuecomment-901506386
2021-08-19 12:11:10 +03:00
Ozkan Sezer ccb06296b9 SDL_windowsevents.c: fix build against older SDKs. 2021-08-19 03:15:02 +03:00
Sylvain 154384a776 Add (uintptr_t) casts 2021-08-19 00:10:59 +02:00
Sylvain 08d6a4653e Fix dynapi prototypes 2021-08-19 00:10:59 +02:00
Sylvain 1670104ad8 Change 'size_indice' to 'size_indices' 2021-08-19 00:10:59 +02:00
Sylvain a8f89a01aa Change 'size_indice' to 'size_indices' 2021-08-19 00:10:59 +02:00
Sylvain 47db47c1cc Add SDL_HAVE_RENDER_GEOMETRY to compile or not with RenderGeometry support 2021-08-19 00:10:59 +02:00
Sylvain b9bd9da78f OpenGLES2: transfert color as 4 bytes, instead of 4 floats 2021-08-19 00:10:59 +02:00
Sylvain Becker c6ceaaeb4b METAL: use Uchar4Normalized format to transfert color as 4 bytes, instead of 4 floats 2021-08-19 00:10:59 +02:00
Sylvain eff840bb9b Add OpenGLES implementation 2021-08-19 00:10:59 +02:00
Sylvain 32e7910135 Fix warnings 2021-08-19 00:10:59 +02:00
Sylvain 6e47f53869 Fix warnings 2021-08-19 00:10:59 +02:00
Sylvain 4869a3d294 Add Direct3D9 implementation (not tested) 2021-08-19 00:10:59 +02:00
Sylvain 4ba3763897 Save and restore SDL renderer state after transforming triangles to rect 2021-08-19 00:10:59 +02:00
Sylvain cd0663e053 Fix declaration-after-statement and remove tabs 2021-08-19 00:10:59 +02:00
Sylvain Becker cd4663dfcb Update D3D11 for SDL_RenderGeometryRaw 2021-08-19 00:10:59 +02:00
Sylvain Becker 9f59170743 Update METAL backend for SDL_RenderGeometryRaw 2021-08-19 00:10:59 +02:00
Sylvain 61d9e9164f For the software renderer, try to reinterpret triangles as SDL_Rect
With Dear ImGui + software renderer, it draws:
- by default at 250 fps
- drops to 70 fps if you show the color picker
- drops to 10 fps if put the color picker fullscreen
2021-08-19 00:10:59 +02:00
Sylvain cc37c38e30 Add SDL_RenderGeometry based on SDL_RenderGeometryRaw 2021-08-19 00:10:59 +02:00
Sylvain e481261173 Move to SDL_RenderGeometryRaw prototype with separate xy/uv/color pointer parameters 2021-08-19 00:10:59 +02:00
Sylvain 111c70e141 Use 64 bits precision to prevent overflow when interpolating color / texture with wide triangles 2021-08-19 00:10:59 +02:00
Sylvain f73c1eff10 Use normalized texture coordinates 2021-08-19 00:10:59 +02:00
Sylvain 5828cc415a Update METAL backend: fix a typo in drawline 2021-08-19 00:10:59 +02:00
Sylvain 9eab5195fe Update dynapi files 2021-08-19 00:10:59 +02:00
Sylvain Becker 9a8a8e65b8 Update SDL_render_d3d11.c
Fix D3D11 compilation
2021-08-19 00:10:59 +02:00
Sylvain Becker 121114d061 Update METAL compiled shaders 2021-08-19 00:10:59 +02:00
Sylvain Becker 2d01573bb9 Add METAL shaders 2021-08-19 00:10:59 +02:00
Sylvain Becker 1e77dae7b7 Add METAL implementation 2021-08-19 00:10:59 +02:00
Sylvain 1ebef0732a Add D3D11 implementation (not yet tested) 2021-08-19 00:10:59 +02:00
Sylvain 3ee511d71c Add software renderer implementation 2021-08-19 00:10:59 +02:00
Sylvain 37f78fc1cc Add OpenGL implementation 2021-08-19 00:10:59 +02:00
Sylvain faded41ab1 Add OpenGLES2 implementation 2021-08-19 00:10:59 +02:00
Sylvain 6e26d320c6 Add sysrender interface 2021-08-19 00:10:59 +02:00
Sylvain 53a2608bd2 Renderer opengles2: turn color Uniform into Attribute.
all attributes are copied interleaved (based on rmg-nik initial patch+
+ minor clean up of data structure
+ add check for colorswap
2021-08-19 00:10:59 +02:00
Oschowa bfa159313b audio: pipewire: Set PW_KEY_NODE_RATE to suggest a rate.
This can be used by recent pipewire to avoid resampling.
2021-08-18 12:40:13 -04:00
Aleksey Rybalkin 402b86f2a8 waylandevents: prevent segfault if xkb compose table is not found
this can happen e.g. on pure wayland system where there is no X11
locales for xkbcommon to find.
2021-08-15 10:11:19 -04:00
Jānis Rūcis 454943cf3e emscripten: Don't flag window fullscreen on external requests
Also, the condition was always true.
2021-08-14 17:04:46 +01:00
Joseph Kogut 55af8dcad9 emscripten: use emscripten_set_window_title api 2021-08-14 17:04:46 +01:00
Joseph Kogut d8baad7e48 emscripten: use emscripten_get_screen_size api 2021-08-14 17:04:46 +01:00
Charlie Birks abc04270b7 emscripten: Fix framebuffer array creation optimisation 2021-08-14 17:04:46 +01:00
Charlie Birks b4f11a3669 emscripten: Drop commented out code from the dummy driver 2021-08-14 17:04:46 +01:00
David Gow fbc364908a Use the new SDL_clamp() macro where sensible
There were a few places throughout the SDL code where values were
clamped using SDL_min() and SDL_max(). Now that we have an SDL_clamp()
macro, use this instead.
2021-08-14 09:01:14 -07:00
Charlie Birks 07a2d71e90 emscripten: Feed silence to device when paused 2021-08-14 12:24:35 +01:00
Sam Lantinga dcc5eef0e2 Clarify that one of the PIDs of the Xbox Elite Series 2 controller is used in Bluetooth mode 2021-08-14 00:31:46 -07:00
Sam Lantinga 91a55a02de Relative mouse motion is delivered to the window with keyboard focus
This was the original intent (note SDL_UpdateWindowGrab() in SDL_OnWindowFocusGained() and SDL_OnWindowFocusLost()) and fixes a bug where relative motion unexpectedly stops if the task bar is covering the bottom of the game window and the mouse happens to move over it while relative mode is enabled.

Another alternative would be to confine the mouse when relative mode is enabled, but that generates mouse motion which would need to be ignored, and it's possible for the user moving the mouse to combine with the mouse moving into the confined area so you can't easily tell whether to ignore the mouse motion. See https://github.com/libsdl-org/SDL/issues/4165 for a case where this is problematic.
2021-08-14 00:00:57 -07:00
Sam Lantinga 694771513c Get the window size for the window receiving the mouse motion
This is the mouse focus except in the case where relative motion is enabled and the mouse is over a window floating on top of the application window (e.g. the taskbar)
2021-08-14 00:00:57 -07:00
Sam Lantinga 6a1e1ed9ae Relative mouse mode grab is based on the window with the input focus
This fixes restoring the cursor clip rectangle after the mouse has moved off of the window.

Also try to better synchronize cursor visibility with mouse position changes when changing relative mode. This doesn't work perfectly, but it seems to improve things on Windows.
2021-08-14 00:00:57 -07:00
Sam Lantinga e42e9a12de Fixed build 2021-08-13 20:48:56 -07:00
Sam Lantinga 441fbcaa3d Added HIDAPI support for the Xbox Adaptive Controller 2021-08-13 20:48:54 -07:00
Sam Lantinga b5e5c1ef48 Added Ctrl-T to toggle topmost mode in test programs 2021-08-13 17:53:39 -07:00
Sam Lantinga 4d9efcb55c Fixed flag test for boolean correctness 2021-08-13 11:52:25 -07:00
Sam Lantinga b28ed02803 Don't warp the mouse for relative mode when the window doesn't have focus 2021-08-13 11:39:41 -07:00
Sam Lantinga 629e9f820a Fixed return value of SDL_GetGrabbedWindow() when we have an internal grab because of mouse relative mode 2021-08-13 11:06:43 -07:00
Sam Lantinga 6aa1498b98 This assert wasn't correct, we set the internal grab for mouse relative mode as well. 2021-08-13 11:03:19 -07:00
Sam Lantinga 907943a236 Added support for the Xbox One S Controller with 5.x series firmware 2021-08-12 17:51:08 -07:00
Joshua Root 1e92135297 Improve portability of SDL_Convert51ToStereo_AVX
Don't rely on checking __clang_major__ since it is not comparable
between different vendors. Don't use "#pragma clang attribute" since it
is only available in relatively recent versions, there's no obvious way
to check if it's supported, and just using __attribute__ directly (for
gcc as well) results in simpler code anyway.
2021-08-12 16:04:35 -07:00
Ozkan Sezer 7aec0b90ee SDL_hidapi_xboxone.c: fix bogus 'uninitialized' warning from clang.
The last 'size == 50' check is always true anyway.
2021-08-13 01:56:56 +03:00
Sam Lantinga cec5a129f5 Fixed libudev hotplug notifications in the HIDAPI driver 2021-08-12 15:49:33 -07:00
Sam Lantinga 6eb4ebb502 Simplified the HIDAPI Xbox One controller initialization 2021-08-12 15:49:33 -07:00
Simon McVittie 25cd749adb x11: Don't change mode if we are already in the correct mode
If we are already in the desired mode, changing it is a no-op at best,
and harmful at worst: on Xwayland, it sometimes happens that we disable
the crtc and cannot re-enable it.

Resolves: https://github.com/libsdl-org/SDL/issues/4630
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-08-12 12:23:40 -07:00
Sam Lantinga 584b89abe6 Added support for the color LED on the Xbox Elite Series 2 controller 2021-08-12 08:17:10 -07:00
Sam Lantinga 64882b2466 Added support for the Xbox One Elite 2 Controller with 5.x series firmware 2021-08-12 08:17:08 -07:00
Ozkan Sezer ed6eb07e79 SDL_wasapi.c: fixed build against older SDKs. 2021-08-12 01:40:50 +03:00
Andrei Alexeyev 68ca35c318 wayland: fix memleak in output listener 2021-08-11 14:11:52 -07:00
Andrei Alexeyev e9179314c4 joystick/linux: fix memleaks; streamline joylist item removal 2021-08-11 14:11:52 -07:00
Ozkan Sezer 44a76710d1 Don't disable clang avx instrinsics on win32 if __AVX__ is defined.
C.f.: https://github.com/libsdl-org/SDL/issues/4533
2021-08-11 08:47:52 -07:00
Ethan Lee ae7ee2a59c wayland: Ignore stateless/sizeless configs when starting in fullscreen mode 2021-08-11 11:02:33 -04:00
Sam Lantinga ac32c522ad Try using the built-in WASAPI audio rate conversion
Fixes https://github.com/libsdl-org/SDL/issues/4608
2021-08-10 18:11:09 -07:00
Sam Lantinga cb1e20b058 Added KMOD_SCROLL to track the scroll lock state
Fixes https://github.com/libsdl-org/SDL/issues/4566
2021-08-10 17:50:17 -07:00
Sam Lantinga f5794f9eeb Added SDL_SetTextureUserData() and SDL_GetTextureUserData() to associate a user-specified pointer with an SDL texture 2021-08-10 15:17:59 -07:00
Sam Lantinga a0af7ce731 OSS is no longer the preferred audio backend on modern UNIX systems
Fixes https://github.com/libsdl-org/SDL/issues/4207
2021-08-10 15:05:49 -07:00
Sam Lantinga 3f6ebffff4 Updated to version 2.0.17 for development 2021-08-10 15:02:36 -07:00
Sam Lantinga 016b02f24c Fixed build, C89 doesn't allow non-constant static initializers 2021-08-10 12:17:37 -07:00
Ozkan Sezer 77c8d11137 configuration updates for dlopen:
- cmake, configure (CheckDLOPEN): --enable-sdl-dlopen is now history..
  detach the dl api discovery from SDL_LOADSO_DLOPEN functionality.
  define HAVE_DLOPEN. also define DYNAPI_NEEDS_DLOPEN (CheckDLOPEN is
  called only for relevant platforms.)
- update SDL_config.in and SDL_config.cmake accordingly.
- SDL_dynapi.h: set SDL_DYNAMIC_API to 0 if DYNAPI_NEEDS_DLOPEN is
  defined, but HAVE_DLOPEN is not.
- pthread/SDL_systhread.c: conditionalize dl api use to HAVE_DLOPEN
- SDL_x11opengl.c, SDL_DirectFB_opengl.c, SDL_naclopengles.c: rely
  on HAVE_DLOPEN, not SDL_LOADSO_DLOPEN.
- SDL_config_android.h, SDL_config_iphoneos.h, SDL_config_macosx.h,
  SDL_config_pandora.h, and SDL_config_wiz.h: define HAVE_DLOPEN.

Closes: https://github.com/libsdl-org/SDL/pull/4351
2021-08-10 12:07:32 -07:00
hgs3 cb0fd05eeb Adding a clarifying comment in case a programmer unfamiliar with UTF-16 and UTF-32's relationship chances upon the code. 2021-08-10 12:07:11 -07:00
Henry G. Stratmann III 3470112969 Optimizing the implementation. 2021-08-10 12:07:11 -07:00
Henry G. Stratmann III 712e0d1f06 Fixing WM_CHAR event handling for Unicode characters outside the Basic Multilingual Plane. 2021-08-10 12:07:11 -07:00
Sam Lantinga fcfd19db86 Added support for SDL_RENDERER_PRESENTVSYNC to the software renderer
This fixes https://github.com/libsdl-org/SDL/issues/4612
2021-08-10 12:02:59 -07:00
Sebastian Krzyszkowiak 25f9ed87ff audio: Fix false positives in driver name comparison
Without this change, driver names don't get matched correctly;
for example "a" can get matched with "alsa" since it only checks
whether the string matches up to the length of the requested
driver name.
2021-08-10 08:34:07 -07:00
Sebastian Krzyszkowiak b3a989d0df video: Fix false positives in driver name comparison
Without this change, driver names don't get matched correctly;
for example "x" can get matched with "x11" since it only checks
whether the string matches up to the length of the requested
driver name.
2021-08-10 08:34:07 -07:00
Sam Lantinga de6ba40d9e Added support for the Flydigi Vader 2 controller in 2.4G Android mode 2021-08-09 11:38:22 -07:00
Sam Lantinga 3f440daad9 Added support for the Flydigi Vader 2 controller in Bluetooth mode 2021-08-09 10:40:36 -07:00
Cameron Gutman 6ae227d011 x11/wayland: fix screensaver suspension via D-Bus
b08b1bde introduced a subtle bug. Despite not using D-Bus types directly,
the code used the SDL_USE_LIBDBUS definition set by SDL_dbus.h to conditionally
compile calls SDL_DBus_ScreensaverTickle() and SDL_DBus_ScreensaverInhibit().
As a result, it still compiled without SDL_dbus.h included, but screensaver
suspension silently failed to work.

The D-Bus stuff could probably use some tweaks to be harder to accidentally
break, but for now just restore the header includes.
2021-08-08 23:47:42 -05:00
Sebastian Krzyszkowiak 2e6dac870f wayland: Add a hint to allow disabling libdecor use
Useful for testing xdg-shell path with compositors like Weston.
2021-08-08 18:05:47 -07:00
Cameron Gutman 092a20d945 wayland: Avoid busy waiting for vsync 2021-08-08 18:04:08 -07:00
Cameron Gutman 791d9d3ff6 Fixed DInput mapping for NVIDIA Virtual Gamepad 2021-08-07 14:20:43 -07:00
Ethan Lee 7be970db31 wayland: Avoid setting floating width/height when re-entering fullscreen 2021-08-06 19:51:27 -04:00
Sam Lantinga bec783571b Better fix for compiling using clang on Windows
This fixes https://github.com/libsdl-org/SDL/issues/4533
2021-08-06 14:20:55 -07:00
Sam Lantinga a91ab883e9 Fixed building on Windows with cmake, ninja, and clang 2021-08-06 12:28:24 -07:00
Ryan C. Gordon dd683073bb
hidapi: Patched to compile on QNX.
Fixes #4591.
2021-08-06 15:13:40 -04:00
Sam Lantinga cae7bd9b65 Don't use AVX with clang if the compiler isn't building with AVX instructions
Fixes https://github.com/libsdl-org/SDL/issues/4533
2021-08-06 12:01:24 -07:00
Ethan Lee 10979d37fb wayland: Always assume configure is wrong for non-resizable windows.
Configure events from compositors have an extremely annoying habit of giving us
completely bogus sizes, from all sorts of places. Thankfully, the protocol
gives us the ability to completely ignore the width/height and just stick with
what we know, so for all windows that are not meant to be resized, pretend we
never even got the width/height at all, the compositor is required to respect
our dimensions whether they match configure's suggestion or not.
2021-08-05 17:19:11 -04:00
Sam Lantinga 88674b4a0e Fixed build 2021-08-04 13:17:35 -07:00
Sam Lantinga c14813a879 Fixed spacing 2021-08-04 13:00:14 -07:00
Sam Lantinga 3cad447ee7 Only update the window size if setting the display mode succeeded 2021-08-04 12:57:51 -07:00
Daniel Gibson 0eb6f79190 SDL_SetWindowDisplayMode(): If already fullscreen, adjust window size
Otherwise only the display resolution is changed, but the SDL window size
(and for example the window-surface size) aren't adjusted accordingly
and thus don't fill the whole screen.
See #3313
2021-08-04 12:48:48 -07:00
Daniel Gibson 72d8128520 Improve SDL_CreateWindow() fullscreen support on Windows
.. and maybe other platforms as well (though X11 was not affected)?

The issue was that passing a higher resolution than the current desktop
resolution to SDL_CreateWindow() with SDL_WINDOW_FULLSCREEN didn't switch
to that resolution (even though it did switch to lower resolutions).

When creating a fullscreen window, window->fullscreen wasn't even set
at all (only zeroed out), setting it only happened if the user explicitly
called SDL_SetWindowDisplayMode(). So without that, SDL_CreateWindow()
-> SDL_UpdateFullscreenMode() -> SDL_GetWindowDisplayMode() used the
resolution from window->windowed.w/h which were limited to the desktop size
due to some weird combination of WIN_AdjustWindowRectWithStyle() and
WIN_WindowProc() being called after a call to SetWindowPos().

fixes #3313
2021-08-04 12:48:48 -07:00
Sam Lantinga 9fdb06450d Added support for the Joy-Con Charging Grip when SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS is enabled 2021-08-04 11:34:06 -07:00
Ryan C. Gordon d483970262
dbus: Wrap init in a spinlock.
This prevents a race if two threads that need d-bus try to init it at the
same time. Note that SDL_Init will likely handle this from a single thread
at startup, but there are places outside of init where one might trigger
D-Bus init, like setting thread priority (a common first thing for a new
thread to do) resulting in SDL trying to use RTKit.

Fixes #4587.
2021-08-04 13:30:12 -04:00
Cameron Gutman b08b1bde66 linux: remove d-bus lazy init dead code
Lazy init in X11/Wayland is dead code since dbdbae4
2021-08-04 13:14:57 -04:00
Ryan C. Gordon 5fc13fcb21 direct3d: Commit viewport state before clearing, attempt 2.
This reintroduces the fix from 0e16ee8330, but just marks
the viewport state as dirty after a clear that needs to expand the
viewport to fill the render target, as we'll need to also reset
the orthographic projection state elsewhere, and that won't
happen if we clear the dirty flag here.

Fixes #4210.
(again.)
(...sorry...!)
2021-08-04 07:00:17 -04:00
Ryan C. Gordon ed6ce5ccb0
log: Fixed compiler warnings on 64-bit Visual Studio. 2021-08-04 02:34:09 -04:00
Ryan C. Gordon 7e88e772d7
winrt: Fixed incorrect code in a Windows Phone #ifdef. 2021-08-04 02:30:47 -04:00
Ethan Lee 32f909f7e3 wayland: Remove redundant waylanddyn.h includes.
All files including waylanddyn.h already include waylandvideo.h first.
2021-08-03 14:57:22 -04:00
Ethan Lee 124405a0bc wayland: Fix building without Vulkan support 2021-08-03 14:57:22 -04:00
David Gow 4077f7a2d9 Update the Renderer dpi_scale on SIZE_CHANGED event (fix #4580)
The Renderer logical scaling code scales mouse coordinates, and needs to
take the window DPI into account on HIGHDPI windows. However, the
variable which tracks this, renderer->dpi_scale, is set once when the
renderer is created, and then not updated. In the event that the window
is moved to another screen, or the screen DPI otherwise changes, this
will be outdates, and potentially the coordinates will be all wrong.

So let's update the dpi_scale on the SIZE_CHANGED event: it's at least a
possibility that this will be issued on some OSes when DPI changes, and
it's otherwise already handled by SDL_Renderer's event filter.
2021-08-03 09:30:43 -07:00
Sam Lantinga 9b4884d58a Warn if you're building a partially functional RAWINPUT driver without device notifications 2021-08-03 09:25:14 -07:00
Sam Lantinga 886eb02eba Fixed detection of Steam Virtual Gamepad with the WGI driver 2021-08-03 09:25:14 -07:00
Sam Lantinga 7c63e1d37a Added WGI mappings for the Amazon Luna and Google Stadia controllers 2021-08-03 09:25:14 -07:00
Sam Lantinga 99c8972b25 Added WGI mappings for PS4 and PS5 controllers 2021-08-03 09:25:14 -07:00
Sam Lantinga 2dfc92ca1e Added default mapping for WGI game controllers 2021-08-03 09:25:13 -07:00
Sam Lantinga 9d64e6b442 Revert "direct3d: Commit dirty viewport state before clearing."
This reverts commit 0e16ee8330.
2021-08-03 00:29:33 -07:00
Sam Lantinga 993a56766d Only use the default Xbox mapping on Linux
On Windows, this is already covered by XInput and is the wrong mapping if we try to use it with DirectInput/RAWINPUT/WGI controllers
2021-08-03 00:15:24 -07:00
Ryan C. Gordon 0e16ee8330 direct3d: Commit dirty viewport state before clearing.
Otherwise you might have set the viewport to the full size of
the render target in SDL's API but this change hasn't been
transmitted to Direct3D yet by the time we attempt to clear.

Fixes #4210.
2021-08-03 02:32:56 -04:00
Sam Lantinga 7edc7d5392 Added a mapping for the Steam Virtual Gamepad when it's detected in DirectInput mode 2021-08-02 22:45:07 -07:00
Ryan C. Gordon 350ca0f908 winrt: Don't register orientation hint callback in startup code.
SDL_AddHintCallback() uses SDL_malloc(), which means this would
run before main(), so the app wouldn't be able to supply its own
replacement SDL_malloc() implementation in time.

This code was moved to under SDL_Init. Since the hint callback
already makes efforts to not override the app manifest's
orientation settings, this is safe to move until after pre-main()
startup.

Fixes #4449.
2021-08-03 05:07:39 -04:00
Ryan C. Gordon 834a84fabb winrt: Don't use LoadLibraryA on WinRT.
This removes the CM_Register_Notification code on WinRT. Note
that this API _is_ available to UWP apps as of Windows 10.0.17763
(version 1809, released October 2018), according to:

https://docs.microsoft.com/en-us/uwp/win32-and-com/win32-apis#apis-from-api-ms-win-devices-config-l1-1-1dll

So it might be worth readding with some sort of preprocessor check
for minimum targeted version, or whatever is appropriate for WinRT
development.
2021-08-03 05:07:39 -04:00
Ethan Lee 7082fb04af wayland: Only dispatch on fullscreen set when the window is visible.
Fixes hang-on-startup described in #4572.
2021-08-02 22:42:30 -04:00
Ethan Lee 0f5b8a99f0 wayland: For libdecor, dispatch immediately after setting fullscreen
Reference: #4578
2021-08-02 19:48:31 -04:00
Sam Lantinga 022235012c Fixed crash if WGI didn't give us the name for a controller 2021-08-02 16:40:58 -07:00
Ethan Lee 4562da622c wayland: Make libdecor configure match xdg_toplevel 2021-08-02 18:56:14 -04:00
Ethan Lee 1fb1aa1983 wayland: Keep the fullscreen check for maximize/restore events 2021-08-02 12:57:28 -04:00
Ethan Lee 584673a5a1 wayland: Don't ignore configs for non-fullscreen, non-resizable windows.
This was causing configure events to not inform SDL of window size
changes, even when they were based on resizes that we fully expected. The
result was fullscreen->windowed not working at all, because it would
retain the desktop resolution instead of reverting to the floating size
that it had before moving to fullscreen mode.

Fixes Super Hexagon fullscreen toggling.
2021-08-02 12:54:39 -04:00
Sebastian Krzyszkowiak 2506729893 wayland: Flush in SetWindowFullscreen
The flush has been removed in e5f9fae034.
Unfortunately, even though ideally the flush shouldn't be necessary,
our resize sequence isn't... well, perfect, and removing that flush causes
tons of troubles.

We're also still flushing in other paths where the window size can be
changed by the compositor and where we may potentially have to obey that
change, like in Wayland_MaximizeWindow.

This also removes the hack introduced in 7f261d3b76,
which introduces problems with protocol violations and seems to not be
necessary when flushing.
2021-08-02 12:18:23 -04:00
Sebastian Krzyszkowiak ea28187cd5 wayland: Hack surface resize into compliance with set_window_geometry
We have issues with correct resize sequence and happen to commit old-sized
buffers even after configure event for the new size has been already
acknowledged. While the reason for that stays unknown, let's at least
workaround the problem by faking window geometry into expected size.
This does not fix visual glitch on e.g. fullscreen toggling, but having
a split-second glitch is still a much better outcome than being
terminated by the compositor for protocol violation.
2021-08-02 12:18:23 -04:00
Sebastian Krzyszkowiak b5210cac44 wayland: Initialize floating size at window creation
This allows the windowed size to be restored for windows initially
created already in non-floating state.
2021-08-02 12:11:06 -04:00
Ethan Lee dab33844e3 wayland: Fix a warning in handle_configure_xdg_toplevel 2021-08-02 12:05:13 -04:00
Ethan Lee 754aa2d321 Mostly revert cfcdfb7be9.
This was causing window changes to completely break, resulting in broken
decorations and bizarre frame timing, I don't know what exactly it's doing
but it's not good. Kept the libdecor_frame_is_floating logic, at least.
2021-08-02 12:05:10 -04:00
Ethan Lee 8803589fc3 wayland: Avoid redundant SetWindowBordered for libdecor 2021-08-02 12:05:06 -04:00
Sebastian Krzyszkowiak b4c4060ad2 wayland: Clean up Wayland_HandlePendingResize
Commit 871c11191b removed delayed
resize handling, but it left the whole structure untouched that
now became unnecessary. To help with code clarity, get rid
of the structure where pending resize state used to be stored
and pass all the data directly to Wayland_HandlePendingResize
(now renamed to Wayland_HandleResize, since it's not "pending"
anymore but applied immediately)
2021-08-01 21:07:51 -07:00
Sebastian Krzyszkowiak 9bb24ad0cf wayland: Always call Wayland_SetWindowBordered when showing the window
Otherwise our windows have no window decoration on compositors that
support xdg-decoration-unstable-v1, but default to client-side mode.

Contrary to what the comment was stating, there is nothing in the protocol
that would make redundant calls to zxdg_toplevel_decoration_v1::set_mode
problematic.
2021-08-01 21:07:14 -07:00
Christian Rauch cfcdfb7be9 libdecor: use same fullscreen/maximised restore logic as for xdg-toplevel 2021-08-01 15:14:44 -07:00
Christian Rauch 42452f8ca5 wayland: store and restore floating states
Some Wayland compositors send (0,0) as "suggested" configure event sizes to
indicate that the client has to decide on its own which sizes to used. This
is commonly done when restoring from maximised, fullscreen or tiles states
to fullscreen.
We now store the last known floating states in a new set of variables and
restore them when we receive such a (0,0) configure event.
2021-08-01 15:14:44 -07:00
Sebastian Krzyszkowiak d4e1b4974a unix: OpenURL: Move unsetenv above vfork
From the vfork manpage:

> The  vfork()  function has the same effect as fork(2), except that
> the behavior is undefined if the process created by vfork() either
> modifies any data other than a variable of type pid_t used to store
> the return value from vfork(), or returns from the function in which
> vfork() was called, or calls any other function before successfully
> calling _exit(2) or one of the exec(3) family of functions.

unsetenv is still called inside a child process, so it does not
influence the rest of the application.
2021-08-01 03:58:49 -07:00
Sam Lantinga 9b7b928765 Clear LD_PRELOAD so Chrome opens correctly when this application is launched by Steam
This fixes https://github.com/libsdl-org/SDL/issues/4565
2021-07-31 23:28:59 -07:00
Sebastian Krzyszkowiak 54aea2446e wayland: Disable key repeat when repeat rate equals 0
This fixes a crash on pressing keyboard button when compositor sends
zero as repeat rate, indicating that key repeat should be disabled.

From Wayland protocol spec:

> Negative values for either rate or delay are illegal. A rate of zero
> will disable any repeating (regardless of the value of delay).
2021-07-31 21:40:27 -07:00
Sam Lantinga b033cd0d2e Fixed XSync sequence to match other cases where we set the X11 error handler 2021-07-31 16:01:48 -07:00
Ryan C. Gordon 4c7825f6bd
x11: XSync while trying to catch XRRSetScreenSize error.
Reference issue #4561
2021-07-31 18:27:14 -04:00
Sam Lantinga cb1fd30e9a Updated to version 2.0.16 for release 2021-07-31 13:28:54 -07:00
Ryan C. Gordon d0effadf68
x11: Don't let XRRSetScreenSize fire a BadMatch error.
This is a workaround and not a proper fix, but this is possibly complicated,
and possibly a corner case, so this will do for 2.0.16, if not the
foreseeable future.

Reference issue #4561
2021-07-31 15:58:31 -04:00
Sam Lantinga 3a4b217d6c Allow defining SDL_MAIN_HANDLED on iOS if you're using another runtime that provides an application delegate 2021-07-31 12:44:29 -07:00
Sam Lantinga deed21a83d Removed useless forward declaration 2021-07-31 12:44:11 -07:00
Ethan Lee e5594e6677 wayland: Prefer our SSD implementation if available 2021-07-30 22:19:48 -07:00
Sam Lantinga 2d0075eff8 Updated comments for third party Nintendo Switch controllers 2021-07-30 18:23:43 -07:00
Sam Lantinga 16010f7561 Added support for the PowerA Nintendo Switch Fusion Arcade Stick 2021-07-30 18:23:43 -07:00
Sam Lantinga b33f470901 Fixed detection of the PDP Afterglow Wireless Switch Controller over Bluetooth 2021-07-30 18:23:42 -07:00
Sam Lantinga 6af6950dbc Added support for the Victrix Gambit Tournament Controller 2021-07-30 18:23:42 -07:00
Sam Lantinga 243a8836af The PowerA Nintendo Switch Fusion Pro Controller has a working USB mode, enabled via the switch on the underside of the controller. 2021-07-30 18:23:41 -07:00
Ethan Lee 71897cc1c9 wayland: Always trigger a resize when handling a configure event.
When we removed the OpenGL resize workaround it introduced a problem for
fullscreen windows in particular: When leaving fullscreen we tried to send a
resize event, but UpdateFullscreenMode would send a SIZE_CHANGED immediately
after, deleting our resize event and causing the following configure event's
resize to be ignored. This timing issue resulted in fullscreen windows not
being resized at all when becoming a floating window.

By always forcing resize events from configure events, we ensure that RESIZED
always makes it through. SetWindowSize-type changes should be unaffected as
they do not fire configure events.
2021-07-30 16:05:06 -04:00
David Gow 8f06a629aa render: Fix -Wmaybe-uninitialized warning in RenderDrawLinesWithRects{,F}
The RenderDrawLinesWithRects and RenderDrawLinesWithRectsF functions can
sometimes call QueueCmdFillRects() with the data pointed to by frects
uninitialised. This can occur if none of the lines can be replaced with
rects, in which case the frects array is empty, and nrects is 0.

gcc 10.3.0 will detect this possibility, and print a warning like:
/home/david/Development/SDL/src/render/SDL_render.c: In function 'RenderDrawLinesWithRectsF':
/home/david/Development/SDL/src/render/SDL_render.c:2725:15: warning: '<unknown>' may be used uninitialized [-Wmaybe-uninitialized]
 2725 |     retval += QueueCmdFillRects(renderer, frects, nrects);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/david/Development/SDL/src/render/SDL_render.c:499:1: note: by argument 2 of type 'const SDL_FRect *' to 'QueueCmdFillRects' declared here
  499 | QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect * rects, const int count)
      | ^~~~~~~~~~~~~~~~~

This is harmless, because when this is uninitialised, nrects is always
0, so QueueCmdFillRects() does nothing anyway. We therefore can work
around this by only calling QueueCmdFillRects() when nrects is nonzero.
Somewhat impressively, gcc recognises that this is now safe.
2021-07-30 10:53:49 -04:00
Ethan Lee c20ab7dae9 wayland: Fix GetWindowWMInfo for <2.0.15 2021-07-30 00:16:52 -07:00
Ryan C. Gordon 585c11c5ae
direct3d: Fix possibly-incorrect scissor test when clearing.
Thanks to @JayFoxRox who did the detective work on this!

Fixes #3357.
2021-07-30 00:33:15 -04:00
Cameron Gutman 6f684f674e cocoa: Add keyboard grab support
CGSSetGlobalHotKeyOperatingMode() is not a public API, so we will only
compile this in if SDL_MAC_NO_SANDBOX=1 is defined during compilation.
2021-07-29 19:06:43 -07:00
Sam Lantinga 69518b9ecc Make sure we don't send a resize event while a window is being destroyed
This fixes https://github.com/libsdl-org/SDL/issues/3669
2021-07-29 17:09:24 -07:00
Ryan C. Gordon 659e1f0a3f
audiocvt: The to-5.1 converters now soften FL and FR channels more.
This is experimental and might be tweaked further.

Reference #4104.

Also reference:

https://github.com/Keriew/augustus/issues/194#issuecomment-847655049
2021-07-29 17:55:59 -04:00
Christian Rauch f20a85818c commit after setting/unsetting limits 2021-07-29 14:55:03 -07:00
Sam Lantinga 9984891ba8 Use the wl_touch object as a touch ID on Wayland (thanks @russelltg!)
This fixes https://github.com/libsdl-org/SDL/issues/4517
2021-07-29 14:46:24 -07:00
Ethan Lee 74162b7401 wayland: Add support for text-input-unstable-v3 2021-07-29 14:43:46 -07:00
Jessica Clarke 02daab8736 Fix pointer provenance in SDL_SIMDRealloc
This is needed to support CHERI, and thus Arm's experimental Morello
prototype, where pointers are implemented using unforgeable capabilities
that include bounds and permissions metadata to provide fine-grained
spatial and referential memory safety, as well as revocation by sweeping
memory to provide heap temporal memory safety.

The C standard does not guarantee that if two pointers compare equal
they are the same pointer, as C pointers have a notion of provenance,
and compilers have been known to exploit this during optimisation. For
CHERI, this becomes even more important, as in-place expansion can
result in realloc returning a capability to the same address but with
increased capability bounds, and so reusing the old capability will trap
trying to access outside the bounds of the original allocation.

In the case that ptr == mem, memdiff and ptrdiff should still be equal,
so the only overhead is a small amount of pointer arithmetic and a store
of the new pointer (which is required per the C standard in order to not
be undefined behaviour when next loaded).

This also fixes the calculation of oldmem to use uintptr_t rather than
size_t as casting the pointer to size_t on CHERI will strip the
capability metadata, including the validity tag, with the subsequent
cast back to void * resulting in a null-derived capability whose
validity tag is clear and thus cannot be dereferenced without trapping.
2021-07-29 14:42:15 -07:00
Jessica Clarke 8f38ba4d68 Fix casts that should be using uintptr_t
This is needed to support CHERI, and thus Arm's experimental Morello
prototype, where pointers are implemented using unforgeable capabilities
that include bounds and permissions metadata to provide fine-grained
spatial and referential memory safety, as well as revocation by sweeping
memory to provide heap temporal memory safety.

On most systems (anything with a flat memory hierarchy rather than using
segment-based addressing), size_t and uintptr_t are the same type.
However, on CHERI, size_t is just an integer offset, whereas uintptr_t
is still a capability as described above. Casting a pointer to size_t
will strip the metadata and validity tag, and casting from size_t to a
pointer will result in a null-derived capability whose validity tag is
not set, and thus cannot be dereferenced without faulting.

The audio and cursor casts were harmless as they intend to stuff an
integer into a pointer, but using uintptr_t is the idiomatic way to do
that and silences our compiler warnings (which our build tool makes
fatal by default as they often indicate real problems). The iconv and
egl casts were true positives as SDL_iconv_t and iconv_t are pointer
types, as is NativeDisplayType on most OSes, so this would have trapped
at run time when using the round-tripped pointers. The gles2 casts were
also harmless; the OpenGL API defines this argument to be a pointer type
(and uses the argument name "pointer"), but it in fact represents an
integer offset, so like audio and cursor the additional idiomatic cast
is needed to silence the warning.
2021-07-29 14:42:15 -07:00
Sam Lantinga 9d457aa446 Don't uninitialize COM because of what appears to be a bug in Microsoft WGI reference counting.
This fixes https://github.com/libsdl-org/SDL/issues/4488
2021-07-29 14:25:13 -07:00
Sam Lantinga b3a0174b26 Scale the values correctly based on the sensor type (thanks @meyraud705) 2021-07-29 14:25:13 -07:00
Sam Lantinga a186a503e7 Added SDL_GameControllerGetSensorDataRate() to get the sensor update rate for a controller. 2021-07-29 06:43:39 -07:00
Brick 53987e9b4f Optimized SDL_Convert51ToStereo_AVX 2021-07-28 16:11:04 -07:00
Sam Lantinga 8e35ff5cb3 By default minimize real fullscreen windows when they lose focus so the desktop video mode is restored.
This fixes https://github.com/libsdl-org/SDL/issues/4039
2021-07-28 14:20:29 -07:00
Aaron Plattner 1e07dba09b x11: Use glXChooseFBConfig when available in X11_GL_GetVisual
When choosing an X11 Visual for a window based on its GLX capabilities, first
try glXChooseFBConfig (if available) before falling back to glXChooseVisual.
This normally does not make a difference because most GLX drivers create a
Visual for every GLXFBConfig, exposing all of the same capabilities.

For GLX render offload configurations (also know as "PRIME") where one GPU is
providing GLX rendering support for windows on an X screen running on a
different GPU, the GPU doing the offloading needs to use the Visuals that were
created by the host GPU's driver rather than being able to add its own. This
means that there may be fewer Visuals available for all of the GLXFBConfigs the
guest driver wants to expose. In order to handle that situation, the NVIDIA GLX
driver creates many GLXFBConfigs that map to the same Visual when running in a
render offload configuration.

This can result in a glXChooseVisual request failing to find a supported Visual
when there is a GLXFBConfig for that configuration that would have worked. For
example, when the game "Unnamed SDVX Clone" [1] tries to create a configuration
with multisample, glXChooseVisual fails because the Visual assigned to the
multisample GLXFBConfigs is shared with the GLXFBConfigs without multisample.

Avoid this problem by using glXChooseFBConfig, when available, to find a
GLXFBConfig with the requested capabilities and then using
glXGetVisualFromFBConfig to find the corresponding X11 Visual. This allows the
game to run, although it doesn't make me any better at actually playing it...

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Fixes: https://forums.developer.nvidia.com/t/prime-run-cannot-create-window-x-glxcreatecontext/180214

[1] https://github.com/Drewol/unnamed-sdvx-clone
2021-07-28 13:48:16 -07:00
Ozkan Sezer cf85710cf8 SDL_audiocvt.c: disable AVX for clang < 5 and gcc < 4.9
See: https://github.com/libsdl-org/SDL/issues/4533
2021-07-28 22:55:10 +03:00
Ryan C. Gordon cc4ab10195
windows: convert "//" comment to "/**/", add a FIXME.
Reference #4129
Reference #4177
2021-07-28 14:37:33 -04:00
Adam a203194893
Added in a MIME-type to the X11 clipboard. (#4385) 2021-07-28 14:06:51 -04:00
Ethan Lee ad310d3900 wayland: libdecor support for SetWindowModalFor 2021-07-28 09:45:10 -07:00
Ethan Lee 93976ade3b wayland: libdecor support for GetWindowWMInfo 2021-07-28 09:45:10 -07:00
David Gow 1fb4429bc0 wayland: Avoid a pointer→TouchID cast warning
As of [1], SDL now compiles with a warning in SDL_waylandevents.c on
32-bit systems under gcc 10.3.0:

/tmp/SDL/src/video/wayland/SDL_waylandevents.c: In function 'seat_handle_capabilities':
/tmp/SDL/src/video/wayland/SDL_waylandevents.c:958:22: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  958 |         SDL_AddTouch((SDL_TouchID)seat, SDL_TOUCH_DEVICE_DIRECT, "wayland_touch");
      |                      ^
/tmp/SDL/src/video/wayland/SDL_waylandevents.c:964:22: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  964 |         SDL_DelTouch((SDL_TouchID)seat);
      |                      ^

This is due to SDL_TouchID always being 32-bit, but seat being a pointer
which is (obviously) only 32-bit on 32-bit systems. The conversion is
therefore harmless, so silence it with an extra cast via intptr_t.

This is what the cocoa backend does (and is similar to what the Win32
backend does, except with size_t).

Fixes: 03c19efbd1 ("Added support for multiple seats with touch input on Wayland")

[1]: 03c19efbd1
2021-07-28 09:05:23 -07:00
David Gow 18303c92bc Wayland: Fix building with --disable-wayland-shared with libdecor.
When wayland is not dynamically loaded (--enable-wayland-shared=no)
libdecor.h is not included unless SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC
is set, so it fails to build.  We can't simply move the libdecor.h
include above the #ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC block, as
libdecor.h itself #includes wayland headers we need to replace with
#defines. Instead, duplicate the #include.

Fixes https://github.com/libsdl-org/SDL/issues/4543

Note that this doesn't fix any of the underlying issues of libdecor
being treated as part of wayland, it just fixes the build. A better
solution would probably be to decouple the wayland dynamic loading
from the libdecor dynamic loading completely, though that is a lot
more work...
2021-07-28 17:01:02 +03:00
David Gow 21cba92423 wayland: Don't create zxdg toplevel decoration twice
Each window can have at most one zxdg toplevel decoration, but as of
[1], we accidentally create two. (If libdecor is not in use). This
causes wayland windows with server-side decorations (e.g. on KDE/KWin)
to crash with the message:

zxdg_decoration_manager_v1@7: error 1: decoration has been already constructed

This extra zxdg_decoration_manager_v1.get_toplevel_decoration() call was
introduced while deprecating wl-shell and xdg-shell-stable[1] support,
and possibly was a bad interaction with [2], which moved the decoration
creation around.

Fixes: 6aae5b44f8 ("Remove wl-shell and xdg-shell-unstable-v6 support (#4323)")

[1]: https://github.com/libsdl-org/SDL/pull/4323
[2]: https://github.com/libsdl-org/SDL/pull/4374
2021-07-28 04:12:39 -07:00
Ethan Lee 7b239edb83 wayland: Assign frame_callback on window creation.
Fixes a crash when creating and destroying a window without calling SwapWindow.
2021-07-28 00:48:05 -07:00
Sam Lantinga 41e1a2360f Correct the maximized size and position for borderless resizable windows
This fixes bug https://github.com/libsdl-org/SDL/issues/4043
2021-07-27 16:51:08 -07:00
Ethan Lee 03185e748b wayland: Tag/Check wl_output objects as well, fixes crashes when libdecor is in use 2021-07-27 16:05:53 -07:00
Ryan C. Gordon 871c11191b wayland: handle pending resizes immediately, not on SwapWindow.
This was originally a workaround for an old Mesa bug, since fixed, apparently,
and causes other problems.

Fixes #4326.
2021-07-27 18:24:09 -04:00
Sam Lantinga 51c61d7cdf Run the entire Cocoa messagebox function on the main thread.
This fixes bug https://github.com/libsdl-org/SDL/issues/4420
2021-07-27 14:57:18 -07:00
Sam Lantinga dfd3f30e88 Make Cocoa_HandleTitleButtonEvent() static since it's not used anywhere else 2021-07-27 14:27:37 -07:00
Ethan Lee a3eb297ec2 wayland: Rework enter/leave and update_scale_factor to avoid bogus wl_output data.
Also remove get_window_scale_factor() which was just pointless indirection.
2021-07-27 14:21:32 -07:00
Simon Zeni 6aae5b44f8
Remove wl-shell and xdg-shell-unstable-v6 support (#4323)
* wayland-protocol: update wayland.xml to 1.19.0

* wayland: remove shell_surface field from SDL_SysWMinfo

* wayland: remove wl_shell support

* waypand-protocols: update xdg-shell.xml to 1.20

* wayland: remove xdg-shell-unstable-v6 support

* wayland: deprecate wl shell surface syswm info, add xdg surface
2021-07-27 14:12:26 -07:00
Sam Lantinga 88e4755c26 Make sure we don't try to turn on relative mouse mode while clicking on the window title bar.
This fixes bug https://github.com/libsdl-org/SDL/issues/4469
2021-07-27 12:43:45 -07:00
Splamy c72aef2664 Fixed microphone randomly stop working
WASAPI_WaitDevice is used for audio playback and capture, but needs to
behave slighty different.
For playback `GetCurrentPadding` returns the padding which is already
queued, so WaitDevice should return when buffer length falls below the
buffer threshold (`maxpadding`).
For capture `GetCurrentPadding` returns the available data which can be
read, so WaitDevice can return as soon as any data is available.

In the old implementation WaitDevice could suddenly hang. This is
because on many capture devices the buffer (`padding`) wasn't filled
fast enough to surpass `maxpadding`. But if at one point (due to unlucky
timing) more than maxpadding frames were available, WaitDevice would not
return anymore.

Issue #3234 is probably related to this.
2021-07-27 14:19:11 -04:00
Ryan C. Gordon 4ef8674df1
Revert "wasapi: Open capture devices the way we used to."
This reverts commit 0d0fee7569.
2021-07-27 14:18:44 -04:00
Ryan C. Gordon 0d0fee7569
wasapi: Open capture devices the way we used to.
This should work around the regression in #3234, since it basically reverts
the problem change, but only for capture devices.

Fixes #3234.
2021-07-27 14:13:31 -04:00
Ryan C. Gordon f4eb7f329e
spinlock: Favor gcc-style atomics over MSVC interfaces.
This resolves a problem when using Clang on Windows.

Fixes #4346.
2021-07-27 13:45:33 -04:00
Ryan C. Gordon 736a424ff4
pulseaudio: Optionally add "monitor" sources to device list.
There's a new hint to enable this.

Fixes #2917.
2021-07-27 13:12:57 -04:00
Ryan C. Gordon 8d790b10f8
audiocvt: stereo-to-mono SSE3 now uses unaligned accesses.
On modern CPUs, there's no penalty for using the unaligned instruction on
aligned memory, but now it can vectorize unaligned data too, which even if
it's not optimal, is still going to be faster than the scalar fallback.

Fixes #4532.
2021-07-27 12:23:46 -04:00
Sam Lantinga 2a53f8315a Fixed controllers showing up under both MFI and HIDAPI drivers
The Game Controller Kit doesn't show the controllers at startup, so the HIDAPI driver sees them first and therefore gets preference when a controller is supported by both drivers.

This fixes bug https://github.com/libsdl-org/SDL/issues/4209
2021-07-26 23:29:20 -07:00
Sam Lantinga 46869db01c Fixed controller rumble on macOS
Needed to add a strong reference to the haptics engine
2021-07-26 23:27:13 -07:00
Sam Lantinga a850fec733 Added missing mapping for the Xbox Elite Controller on Linux
This fixes https://github.com/ValveSoftware/steam-for-linux/issues/7826
2021-07-26 15:05:02 -07:00
Ozkan Sezer d80ef3e5f5 SDL_VideoInit: silence 'may be used uninitialized' warning
src/video/SDL_video.c:475: warning: 'i' may be used uninitialized in this function
2021-07-26 22:51:24 +03:00
Luis Cáceres 45de0a1d13 Support comma-separated lists in SDL_AUDIODRIVER 2021-07-26 15:14:54 -04:00
Luis Cáceres 5ec69285fa Support comma-separated lists in SDL_VIDEODRIVER 2021-07-26 15:14:54 -04:00
Sam Lantinga ba8bc143c1 Sort joystick entries in /dev/input
This fixes https://github.com/libsdl-org/SDL/issues/4430
2021-07-26 12:09:33 -07:00
Sam Lantinga 8d527def81 Revert "hidapi_switch: Implement HD rumble effect (#4538)"
This reverts commit 19082b115b, which broke rumble on the Nintendo Switch Pro controller
2021-07-26 10:18:18 -07:00
Narr the Reg 19082b115b
hidapi_switch: Implement HD rumble effect (#4538) 2021-07-26 10:00:53 -07:00
Christian Rauch ac904b8e95 wayland: ignore resize in fullscreen or maximised mode 2021-07-25 14:54:12 -07:00
Christian Rauch ee062c644a wayland: implement toggling decorations 2021-07-25 14:54:12 -07:00
Christian Rauch 2b3cf36fd9 wayland: forward window events 2021-07-25 14:54:12 -07:00
Christian Rauch 48066984b7 wayland: enable/disable ACTION_RESIZE for fullscreen 2021-07-25 14:54:12 -07:00
Christian Rauch 9e6fcbe72c wayland: client-side decoration 2021-07-25 14:54:12 -07:00
Christian Rauch e5f9fae034 wayland: don't flush after setting fullscreen 2021-07-25 14:54:12 -07:00
Mathieu Eyraud 8e604a5f12 Fix error handling in X11_SetWindowTitle
X11_XChangeProperty return 1 on success.
2021-07-25 14:51:33 -07:00
Jaylon Gowie bc3b98f3ed Replace with SDL_SendKeyboardKeyAutoRelease 2021-07-25 07:41:30 -07:00
Jaylon Gowie 5cd37c0a7b Add Enter Key support to PSVita IME keyboard 2021-07-25 07:41:30 -07:00
Sam Lantinga 10ec4c8671 Added support for the PowerA Nintendo Switch Spectra Controller 2021-07-24 22:11:22 -07:00
Sam Lantinga 3c9559f765 Don't try to rumble third-party Nintendo Switch Pro controllers
Sending rumble to the PowerA Spectra Nintendo Switch controller hangs input reports for a couple of seconds.
2021-07-24 19:43:56 -07:00
Sam Lantinga cc19b13bc3 Fixed missing return statement 2021-07-24 19:21:29 -07:00
Sam Lantinga d4ac6b5ed9 Detect buffer overflow when getting DirectInput device state
This fixes bug https://github.com/libsdl-org/SDL/issues/4528
2021-07-24 15:58:33 -07:00
Sam Lantinga 3b85e3fdfc Fixed internal Windows key state when using Windows+Space or Windows+G shortcuts
This fixes bugs:
https://github.com/libsdl-org/SDL/issues/4369
https://github.com/libsdl-org/SDL/issues/4500
2021-07-24 15:47:11 -07:00
Sam Lantinga 03c19efbd1 Added support for multiple seats with touch input on Wayland
This fixes bug https://github.com/libsdl-org/SDL/issues/4517
2021-07-24 15:25:50 -07:00
Sam Lantinga ff1b5e1bf7 Implemented the window flash operations for X11 2021-07-24 15:11:36 -07:00
Ryan C. Gordon 5ae0dd4b52
joystick: Split out Linux opening code for reuse by querying code.
This prevents an assertion whem LINUX_JoystickGetGamepadMapping tried to
open the stick temporarily and messed with global state by doing so. Now
the global state is only set in LINUX_JoystickOpen, but the common code
is shared by both interfaces.

Fixes #4198.
2021-07-24 17:48:26 -04:00
Sam Lantinga f1633127d1 Added a window flash operation to be explicit about window flash behavior 2021-07-24 13:42:19 -07:00
Joel Linn b2c8d3e9e4 audiocvt: 5.1 to Stereo conversion utilizing AVX 2021-07-24 15:39:17 -04:00
Joel Linn 638befc1a9 audiocvt: 5.1 to Stereo conversion utilizing SSE 2021-07-24 15:39:17 -04:00
Joel Linn db56526f14 audiocvt: Replace divisions
Division is expensive and the compiler can not replace it themselves.
Though we now we will be ok in terms of floating point edge behaviour.
2021-07-24 15:39:17 -04:00
Sam Lantinga e1c3a25034 Changed SDL_FlashWindow() so it doesn't take a flash count, and added the hint SDL_HINT_WINDOW_FLASH_COUNT to control behavior on Windows 2021-07-24 12:11:27 -07:00
Sam Lantinga 09d1cea733 Use the new controller type for the Luna and Stadia controllers 2021-07-24 11:15:09 -07:00
Sam Lantinga 808c3ae612 Allow mapping Android controllers that just have a D-PAD and face buttons
This fixes bug https://github.com/libsdl-org/SDL/issues/4327
2021-07-24 10:37:42 -07:00
Sam Lantinga 94b7a87645 Added SDL_GameControllerType enumerations for the Amazon Luna and Google Stadia controllers
Fixes bug https://github.com/libsdl-org/SDL/issues/4019
2021-07-24 09:10:18 -07:00
german77 e6e8fe6d4e hidapi_switch: Implement analog rumble 2021-07-24 01:06:05 -07:00
Sam Lantinga 669714cafe Added the ThrustMaster T.16000M as a flightstick 2021-07-23 23:51:35 -07:00
Sam Lantinga 384d86b584 Fixed compile warnings with Visual Studio 2021-07-23 23:48:23 -07:00
Sam Lantinga adb75d642c Fixed hotplug detection not working on UWP or when SDL isn't pumping Windows events
This fixes bugs:
https://github.com/libsdl-org/SDL/issues/4321
https://github.com/libsdl-org/SDL/issues/4147

Thanks to DJm00n for the suggestion!
2021-07-23 23:45:18 -07:00
Sebastian Krzyszkowiak 7b0092db6a vita: touch: Mark the back panel as an indirect absolute touch device
It's not a touchscreen, but an additional touch panel on the back of
the device.
2021-07-23 16:40:34 -07:00
Sam Lantinga 422b053b96 Added support for the full line of current PowerA Xbox Series X controllers 2021-07-23 16:32:35 -07:00
Jaylon Gowie 48bbe31bc6 Add PreSwapCallback for updating SceCommonDialog 2021-07-21 09:41:10 -07:00
Jaylon Gowie 9c1306bc5e Add elgext.h header 2021-07-21 09:41:10 -07:00
meyraud705 4ada14a267 Replace libc functions to SDL equivalent in wayland video subsystem
Wayland video subsystem uses a mix of libc and SDL function.
This patch switches libc functions to SDL ones and fixes a mismatch in memory
allocation/dealoccation of SDL_Cursor in SDL_waylandmouse.c (calloc on line 201
and SDL_free on line 313) which caused memory corruption if custom memory
allocator where provided to SDL.
2021-07-21 09:28:38 -07:00
Ivan Epifanov f806064e7e Remove 'support' for rgb/bgr textures, that was causing issues with them 2021-07-19 10:14:13 -04:00
Niklas Haas d6641d7123 kmsdrm: Explicitly set the surface transform and alpha mode
This is required by the specification. Set these to sensible defaults.
Fixes a validation layer error that occurs otherwise.
2021-07-19 10:12:54 -04:00
Niklas Haas 760074270a kmsdrm: Properly zero-initialize CreateInfo structs
As written, these contain undefined stack contents, which in practice
causes crashes/hangs and/or triggers the validation layers (they
complain about `pNext` and `flags` not being NULL).
2021-07-19 10:12:54 -04:00
Ivan Epifanov 817976da69 VITA: Rewrite and fix RenderCopyEx rotation 2021-07-13 08:45:33 -07:00
Sam Lantinga dc6f044309 Added mapping for the Xbox Series X controller on tvOS 2021-07-12 17:57:21 -07:00
Sam Lantinga 947ad6e13a Added support for the Xbox Series X controller on iOS and tvOS 2021-07-12 17:57:21 -07:00
Brick 7fe6dbafa3 Reset rawInputEnableCount when RawInput is not supported 2021-07-11 14:51:31 -07:00
Sam Lantinga 24059a19c5 The RAWINPUT driver is no longer tied to HIDAPI in any way 2021-07-09 18:11:42 -07:00
Sam Lantinga f93e9047eb Implemented the timeout in hid_read_timeout() on Android
This fixes detecting PS5 controllers connected over USB
2021-07-08 18:44:50 -07:00
Hanseul Jun 557d0f827f Commenting a false alarm in WIN_GLES_SetupWindow.
When hint SDL_HINT_OPENGL_ES_DRIVER is set to "1" (e.g. for ANGLE support), assertion due to !_this->gl_config.driver_loaded can be causes while EGL is available.
2021-07-08 14:49:40 -07:00
Sam Lantinga d135c0762f Added SDL_GameControllerSendEffect() and SDL_JoystickSendEffect() to allow applications to send custom effects to the PS4 and PS5 controllers
See testgamecontroller.c for an example of a custom PS5 trigger effect
2021-07-08 13:22:41 -07:00
Ozkan Sezer 3da6d2cdde WIN_SetErrorFromHRESULT: kill CR/LF that FormatMessage sticks at the end
Fixes: https://github.com/libsdl-org/SDL_mixer/issues/320
2021-07-08 20:33:50 +03:00
Dean Herbert 8fb95034e8 Avoid warping the cursor to the center of the window when not in relative_warp_mode
When relative mode is enabled and not using warp mode, the cursor is
being clipped to the window. Therefore there is no reason to restore the
cursor position to the center.

Avoiding the warp to center simplifies mouse position event flow, as we
are no longer potentially receiving mouse events for the automated
movement of the cursor and can be (mostly) assured that an incoming
event from the windowing system is that of external means.
2021-07-08 09:27:09 -07:00
Dean Herbert 4359a47b3e Simplify ClipCursor behaviour when RelativeMouseMode is enabled
The implementation of clip logic for relative mode seemed to
unnecessarily limit the usable area to the middle of the window, in a
2x2 pixel region. This has the adverse side effect of moving the
operating system cursor to that location, even if it is in a valid
location in the window.

While in most scenarios this is handled correctly (by storing the
original position of the cursor in the window and restoring when leaving
relative mode), there are edge cases where this clip operation can cause
WM_MOUSEMOVE to fire at a point in time where it counts as a relative
delta from SDL's perspective.
2021-07-08 09:27:09 -07:00
Dean Herbert 3720e254c4 Trim some stray whitespace 2021-07-08 09:27:09 -07:00
Austin Shafer 16e3bfe807 SetDisplayMode: Call XRRSetScreenSize before setting CRTC config
X11_SetDisplayMode currently calls X11_XRRSetCrtcConfig alone. This results
in the monitor's viewport getting changed, but the underlying screen dimensions
stay the same.

The spec indicates that RRSetCrtcConfig only changes the crtc mode and has no effect
on the screen dimensions, only mentioning that the new crtc must fit entirely within the
screen size. For the size to change, RRSetScreenSize also needs to be called.

This affects Metro Exodus on Linux, when changing the resolution in the in-game settings
Metro gets stuck in a loop waiting for the size of its vulkan surface to change. Because
XRRSetScreenSize is not called the screen size is never changed, the vulkan surface dimensions
do not change, and Metro hangs forever watching for a surface size update that will
never come.

This change disables the CRTC, calls XRRSetScreenSize, and then updates the
CRTC configuration. This fixes changing the resolution from the Metro settings.

Tested with:
Metro Exodus, Portal 2
2021-07-08 08:41:29 -07:00
Sam Lantinga 4a20dd3e54 Removed unnecessary comment, the mic button is in byte 16 on all firmware versions 2021-07-08 07:38:18 -07:00
Sam Lantinga 46f19c311d Implemented mouse relative mode for iOS 14.1 and newer 2021-07-08 07:23:29 -07:00
Sam Lantinga 430bbcb87f Added HIDAPI support for the Amazon Luna Controller connected over USB in DirectInput mode 2021-07-07 09:49:33 -07:00
Sam Lantinga 863f566941 Fixed reading thumbstick axes and mic button on the Amazon Luna Controller firmware version 305164320 2021-07-07 08:55:16 -07:00
Dimitriy Ryazantcev 17ed8d8085 Added HIDAPI backend for Amazon Luna Controller Model T28B69 connected via Bluetooth LE (VID:0171, PID:0419).
To enter Bluetooth pairing mode hold B and Action (button with circle) buttons for 3 seconds.

It works via usual HIDAPI if special filter driver is not installed:
https://www.amazon.com/gp/help/customer/display.html?nodeId=GZCT4CTFHXLHEB9T

With that driver installed it mimics Xbox One controller and works via XInput under Windows.

Under DInput this controller is not usable at all.
2021-07-07 08:31:12 -07:00
Sam Lantinga 00d67620da Added the SteelSeries manufacturer to the Nimbus+ entry on macOS 2021-07-06 11:32:11 -07:00
Sam Lantinga 24e836b0db Added controller mapping for the Nimbus+ controller on macOS when MFi support is not available 2021-07-06 10:00:09 -07:00
Ivan Epifanov 0994a75879 Don't hardcode message length 2021-07-01 15:14:49 -07:00
Ivan Epifanov 3b6e999244 Vita: remove unused variable and allow Razor perf analysis 2021-07-01 15:14:49 -07:00
Ivan Epifanov 656eb7df35 Vite: return system installed memory 2021-07-01 15:14:49 -07:00
Ivan Epifanov b55ee12f69 Vita: fix clip rectangle 2021-07-01 15:14:49 -07:00
Ivan Epifanov e41d3e617e VIta: fix render clearing 2021-07-01 15:14:49 -07:00
Ivan Epifanov 6b12280510 Vita: proper syntax 2021-07-01 15:14:49 -07:00
Ivan Epifanov 32deb6f70c Vita: fix point size 2021-07-01 15:14:49 -07:00
Ivan Epifanov 9d4527193d Vita: append messagebox title 2021-07-01 15:14:49 -07:00
Dimitriy Ryazantcev 39302c9214 Add Steam Virtual Gamepad and Xbox 360 Wired Controller defines instead of magic values
See  https://partner.steamgames.com/doc/features/steam_controller/steam_input_gamepad_emulation_bestpractices for details on what is Steam Virtual Gamepad.
2021-06-30 08:48:13 -07:00
Sam Lantinga 0c4ac33a09 Added support for the Razer Wolverine Tournament Edition controller 2021-06-28 14:31:27 -07:00
Joshua Ashton ca383599b5 Fix Anne Pro II keyboard showing up as a joystick
Having used this for a couple years, I can definitely confirm that it is not a joystick.
2021-06-26 21:23:26 -07:00
Joshua Ashton c90bd3bf79 Add missing PS5 DualSense GUIDs
Fixes my DualSense controller not being recognised as a SDL GameController which breaks Steam Input filtering causing SDL to fight for input.
2021-06-26 21:21:46 -07:00
Sam Lantinga 205b951b46 SDL_DINPUT_JoystickPresent() needs to do the full device enumeration
It is called from WGI before the normal joystick detection has been run, so it needs to actually enumerate currently connected devices.

We can skip the logic checking for other drivers also supporting this device, because that logic is duplicated from the call site.
2021-06-25 14:20:08 -07:00
Sam Lantinga ae6d9e343b Correcting the name of the Amazon Luna Controller 2021-06-25 11:09:46 -07:00
Sam Lantinga 5042ab6f24 Added Linux and macOS mappings for the DirectInput mode of the Amazon Luna Controller 2021-06-24 18:09:06 -07:00
Sam Lantinga 5b051459ed Fixed warnings on Windows 2021-06-24 18:09:04 -07:00
Sam Lantinga 99700a5c52 SDL: add Windows mappings for Luna controllers for USB DirectInput mode and BT. Note: the triggers do not seem to work in BT mode. 2021-06-24 18:09:01 -07:00
Ozkan Sezer 33b84c8d15 s/memcmp/SDL_memcmp/ for conistency 2021-06-24 23:10:56 +03:00
Ethan Lee 56b77b12bc cocoa: Implement FlashWindow 2021-06-24 13:08:26 -07:00
scribam c2e8a791bb SDL_windowsevents: add support for multiple mice 2021-06-24 12:15:54 -07:00
Cameron Gutman 7948c16df2 Pump events each time through the loop in SDL_WaitEventTimeout_Device()
Not only is it more efficient to batch process pending events, it is
necessary for correctness with the Win32 backend. WIN_PumpEvents() runs
periodic updates of the cursor clip region and disambiguation of
left and right shift keys in addition to standard event processing.
2021-06-24 12:14:17 -07:00
Cameron Gutman 105de64c2d Only queue one wakeup event per wait
Queuing more than one can lead to a spurious wakeup on the next wait.
2021-06-24 12:14:17 -07:00
Anthony Pesch c262569cd8 kmsdrm: fix KMSDRM_SetDisplayMode being called for the default desktop mode doing nothing 2021-06-24 12:12:29 -07:00
Anthony Pesch 98bda39186 kmsdrm: sync the display's current mode with what's set in KMSDRM_CreateSurfaces 2021-06-24 12:12:29 -07:00
Anthony Pesch d031a24e00 kmsdrm: defer surface recreation inside of KMSDRM_SetWindowSize and
KMSDRM_SetWindowFullscreen as is done in KMSDRM_SetWindowDisplayMode
2021-06-24 12:12:29 -07:00
Anthony Pesch 5a296e2589 kmsdrm: avoid overriding the mode requested by SDL_SetWindowDisplayMode
when recreating surfaces
2021-06-24 12:12:29 -07:00
Sam Lantinga 814285d6e3 Workaround for crash on Apple Mac M1 hardware 2021-06-23 09:19:02 -07:00
Sam Lantinga 41fab8532d ControllerList: set the default deadzone for Ps5 controller back to same one as Xbox controllers. Too many users complained about drift. 2021-06-18 18:10:24 -07:00
Sam Lantinga a8b28939a6 ControllerList: add more Xbox controllers from minidumps 2021-06-18 18:10:23 -07:00
Sam Lantinga 08eff56a5b ControllerList: add Brooks Mars controller to PS4 controller list 2021-06-18 18:10:22 -07:00
Sam Lantinga afd100f02b Added support for the PowerA Fusion Pro 2 and the PDP Xbox Series X Afterglow and Blue controllers 2021-06-18 17:37:46 -07:00
Ryan C. Gordon 839387ed0a
video/dummy: Don't zero out the fake display mode before adding it.
The SDL_zero call was in the wrong place as a historical accident, I think.
2021-06-17 22:11:10 -04:00
Sam Lantinga 268fbcd460 Fixed compiler warning on Visual Studio 2021-06-17 11:23:47 -07:00
Sam Lantinga d8dba5bcf3 Added support for the Logitech G923 racing wheel 2021-06-17 11:22:08 -07:00
Ethan Lee 7f261d3b76 wayland: Fix returning to a window from fullscreen without calling SetWindowSize 2021-06-15 09:00:18 -07:00
Ivan Epifanov 8da0dd17a1 Oops. Renderer already queues viewport change 2021-06-15 08:58:53 -07:00
Ivan Epifanov 1fc519880d Reset/re-apply viewport on frame start/target change. Fixes SDL_RenderSetLogicalSize on PSVita 2021-06-15 08:58:53 -07:00
Phillip Trudeau bc7ac134db Windows: Fix SDL_GetBasePath() truncating paths
SDL_GetBasePath grows its path buffer for long paths, but GetModuleFileNameExW always truncates and succeeds,
so `len` was always equal to (buflen - 1) which is 127. This is easily fixed by checking for (buflen - 1) instead of buflen.
For paths longer than MAX_PATH, this problem sometimes got hidden by Windows path shortening ("C:\PROGRA~1\" etc.).

Tested on Windows 10 x64 19041 and 10586.
2021-06-12 23:07:46 -04:00
Paul Cercueil db5cd8c694 joystick: virtual: Fix event injection for axes/hats
SDL_JoystickSetVirtualAxisInner() and SDL_JoystickSetVirtualHatInner()
did not properly sanitize the 'axis' and 'hat' parameters.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
2021-06-12 17:55:03 +03:00
Paul Cercueil f3cf019ecb joystick: Add missing comma in joystick drivers list
Without this comma it is impossible to enable both the Vita and Dummy
drivers at the same time.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
2021-06-12 15:50:02 +03:00
Ozkan Sezer bc9888c9b5 OS2_GetDisplayModes: malloc a new copy of mode's driver data.
Based on a patch by Jochen Schäfer <josch1710@live.de> :

The problem is, that in the initialization code uses the same structure for
desktop_mode and current_mode.  See SDL_os2video.c:OS2_VideoInit():

  stSDLDisplay.desktop_mode = stSDLDisplayMode;
  stSDLDisplay.current_mode = stSDLDisplayMode;
  ...
  stSDLDisplayMode.driverdata = pDisplayData;

Then, if you call GetDisplayModes, current_mode will added to the modes
list, with the same driverdata pointer to desktop_mode.

  SDL_AddDisplayMode( display, &display->current_mode );

When VideoQuit gets called, first the modes list gets freed including the
driverdata, the desktop_mode gets freed.  See SDL_video.c:SDL_VideoQuit():

  for (j = display->num_display_modes; j--;) {
      SDL_free(display->display_modes[j].driverdata);
      display->display_modes[j].driverdata = NULL;
  }
  SDL_free(display->display_modes);
  display->display_modes = NULL;
  SDL_free(display->desktop_mode.driverdata);
  display->desktop_mode.driverdata = NULL;

So, the display_modes[j].driverdata gets freed, but desktop_mode->driverdata
points to the same memory, but is not NULL'ed. When desktop_mode->driverdata
gets freed the memory is already freed, and libcx crashes the application on
SDL_Quit.
2021-06-12 14:55:24 +03:00
Ozkan Sezer d28437de3c SDL_keyboard.c: Add bounds guards when assigning to the scancode array.
Based on a patch by Jochen Schäfer <josch1710@live.de> :
On a T420 pressing the ACPI button for volume control, big scancodes
were emitted. This was causing an overflow, because missing guards.
2021-06-12 08:00:50 +03:00
Ethan Lee eb15b4e962 wayland: Drop SwapWindow calls for hidden windows 2021-06-11 21:50:18 -07:00
Ryan C. Gordon 37d35a3e34
kmsdrm: hook up KMSDRM_GLES_DefaultProfileConfig for use.
Fixes #3678.
2021-06-11 21:03:35 -04:00
Ivan Epifanov bbdd08e0b2 Build without PIB support by default and add flag to enable it 2021-06-11 13:21:07 -04:00
Ivan Epifanov a4442476df Cleanup dead and duplicate code 2021-06-11 13:21:07 -04:00
Ivan Epifanov c2b8b55634 Older api, not needed 2021-06-11 13:21:07 -04:00
Ivan Epifanov dd2a285825 Remove leftovers 2021-06-11 13:21:07 -04:00
Ozkan Sezer 2f248a2a31 SDL_cocoaevents.m: fix build against SDK < 10.12 after commit 0dd7024d. 2021-06-11 04:00:32 +03:00
Dimitriy Ryazantcev f5122377c9 Move SDL_IsXInputDevice check above actual joystick allocation 2021-06-10 16:41:09 -07:00
Dimitriy Ryazantcev 766d81ec86 Rewrite SDL_DINPUT_JoystickPresent method to avoid costly IDirectInput8_CreateDevice calls 2021-06-10 16:41:09 -07:00
Dimitriy Ryazantcev a6da2fbf73 Rename haptic methods to avoid confusion with joystick:
`SDL_DINPUT_MaybeAddDevice`->`SDL_DINPUT_HapticMaybeAddDevice`
`SDL_DINPUT_MaybeRemoveDevice`->`SDL_DINPUT_HapticMaybeRemoveDevice`
`SDL_XINPUT_MaybeAddDevice`->`SDL_XINPUT_HapticMaybeAddDevice`
`SDL_XINPUT_MaybeRemoveDevice`->`SDL_XINPUT_HapticMaybeRemoveDevice`
2021-06-10 16:41:09 -07:00
Dimitriy Ryazantcev 73dc68a7ae Simplify and cleanup DirectInput joystick backend code:
- Do not call IDirectInputDevice8_QueryInterface(device, &IID_IDirectInputDevice8,...) on DIRECTINPUTDEVICE8 device
- Get joystick VendorID and ProductID via IDirectInputDevice8_GetProperty(.., DIPROP_VIDPID, ..) call instead of messing with DIDEVICEINSTANCE.guidProduct
- Normalize HID device interface path to upper case for stable operation of XInput check
- Remove useless RawInput calls in SDL_IsXInputDevice() - just check for "IG_" string in HID device interface path that we already have

There shouldn't be any observable behavior changes.
2021-06-10 16:41:09 -07:00
Dimitriy Ryazantcev f2f759dca3 Remove not used DirectInput ignored_devices list 2021-06-10 16:41:09 -07:00
Dimitriy Ryazantcev adc2d362ba Remove outdated and not used WIN_IsXInputDevice code 2021-06-10 16:41:09 -07:00
Sam Lantinga 0e62926ec5 Fixed crash if vendor or product strings are empty 2021-06-10 16:28:32 -07:00
Ryan C. Gordon e65a658320
x11: Add a hint to force override-redirect.
Fixes #3776.
2021-06-09 22:10:20 -04:00
Sam Lantinga cb5e86353b Fixed crash after reinitializing libusb HID support 2021-06-08 13:15:24 -07:00
Eric Wasylishen c33e3c15fb testwm2: draw various debug logging into the window itself
Renderer output size, window position/size, display bounds, etc.
Uses new SDLTest_CommonDrawWindowInfo function in test_common.
2021-06-08 05:29:29 +03:00
Cameron Gutman e13b43ac21 Don't skip sending wakeups for the current thread
We can be in a situation where we receive a win32 hook callback on the same
thread that is currently waiting. In that case, we do still need to trigger
a wakeup when an event is pushed because the hook itself won't necessarily
do that (depending on what we return from the hook).
2021-06-05 14:35:21 -07:00
Cameron Gutman b992b915e5 Optimize SDL_WaitEventTimeout() for the SDL_PollEvent() case
There's no sense in doing all the setup for waiting if we're just polling.
2021-06-05 14:35:21 -07:00
Cameron Gutman 85b51e6c92 Fall back to polling normally if not operating the win32 message loop
In this condition, we cannot safely wait/wake on events.
2021-06-05 14:35:21 -07:00
Cameron Gutman e13d5df00b Call SDL_SendWakeupEvent() directly from SDL_PeepEvent()
SDL_PeepEvent() is a documented public API, so we must properly support
waking a waiting thread in SDL_WaitEventTimeout() with SDL_PeepEvent().
2021-06-05 14:35:21 -07:00
Ethan Lee d956636c85 wayland: Implement FlashWindow 2021-06-04 16:26:03 -07:00
Jupeyy 64724db0a1 Implement bare minimum for SDL_FlashWindow 2021-06-04 15:07:55 -07:00
Francesco Abbate 0dd7024d55 Modifies WaitEvent and WaitEventTimeout to actually wait instead of polling
When possible use native os functions to make a blocking call waiting for
an incoming event. Previous behavior was to continuously poll the event
queue with a small delay between each poll.

The blocking call uses a new optional video driver event,
WaitEventTimeout, if available. It is called only if an window
already shown is available. If present the window is designated
using the variable wakeup_window to receive a wakeup event if
needed.

The WaitEventTimeout function accept a timeout parameter. If
positive the call will wait for an event or return if the timeout
expired without any event. If the timeout is zero it will
implement a polling behavior. If the timeout is negative the
function will block indefinetely waiting for an event.

To let the main thread sees events sent form a different thread
a "wake-up" signal is sent to the main thread if the main thread
is in a blocking state. The wake-up event is sent to the designated
wakeup_window if present.

The wake-up event is sent only if the PushEvent call is coming
from a different thread. Before sending the wake-up event
the ID of the thread making the blocking call is saved using the
variable blocking_thread_id and it is compared to the current
thread's id to decide if the wake-up event should be sent.

Two new optional video device methods are introduced:

WaitEventTimeout
SendWakeupEvent

in addition the mutex

wakeup_lock

which is defined and initialized but only for the drivers supporting the
methods above.

If the methods are not present the system behaves as previously
performing a periodic polling of the events queue.

The blocking call is disabled if a joystick or sensor is detected
and falls back to previous behavior.
2021-06-04 13:50:50 -07:00
Sam Lantinga 40e5ce7fe5 This delay is no longer needed on Steam Link hardware 2021-06-04 13:23:54 -07:00
Andrew Murray cd67f42d8f
add Linux mapping for brook fighting board (#4416)
* added controller mapping for Brook fighting board

* fixed formatting on Brook Universal Fighting Board controller mapping entry
2021-06-04 09:20:47 -07:00
Sjoerd Simons 89fd9821de Add controller mapping for Atari vcs controllers
This add controller mappings for the Atari vcs (modern) controller as
well as the classic controller, for both bluetooth and USB connectivity.

Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
2021-06-03 11:43:41 -07:00
Sjoerd Simons de4ba6ebc0 Ignore the device version for Atari vcs controllers
At least on bluetooth the guid user the version reported by the
bluetooth device. Which for Atari vcs controllers is the firmware
version. However the mapping will stay the same regardless of firmware
version, so ignore the version entirely to avoid needing a new mapping
entry for each firmware version.

Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
2021-06-03 11:43:41 -07:00
Sam Lantinga 6de33c0945 Clarify why we're skipping Game Controller framework supported devices in hid.c 2021-06-03 09:05:33 -07:00
Patrick Hogan 28da6c5ddb Have HIDAPI skip MFI supported HID devices on macOS to avoid duplicate devices. 2021-06-03 09:03:11 -07:00
Ethan Lee 2af3f64ecf wayland: Activate the window on first ShowWindow, if possible 2021-06-02 12:59:07 -07:00