src/core/windows


Log

Author Commit Date CI Message
Pierre Wendling d0bbfdbf 2022-12-01T16:07:03 Clang-Tidy fixes (#6725) (cherry picked from commit 3c501b963dd8f0605a6ce7978882df39ba76f9cd)
Sam Lantinga b8d85c69 2022-11-30T12:51:59 Update for SDL3 coding style (#6717) I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base. In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted. The script I ran for the src directory is added as build-scripts/clang-format-src.sh This fixes: #6592 #6593 #6594 (cherry picked from commit 5750bcb174300011b91d1de20edb288fcca70f8c)
Sam Lantinga 2d24baaa 2022-11-29T09:26:29 Fixed building on Windows with SDL_VIDEO=OFF Fixes https://github.com/libsdl-org/SDL/issues/6562
Sylvain Becker fb0ce375 2022-11-27T17:38:43 Cleanup add brace (#6545) * Add braces after if conditions * More add braces after if conditions * Add braces after while() conditions * Fix compilation because of macro being modified * Add braces to for loop * Add braces after if/goto * Move comments up * Remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements after merge * Fix inconsistent patterns are xxx == NULL vs !xxx * More "{}" for "if() break;" and "if() continue;" * More "{}" after if() short statement * More "{}" after "if () return;" statement * More fix inconsistent patterns are xxx == NULL vs !xxx * Revert some modificaion on SDL_RLEaccel.c * SDL_RLEaccel: no short statement * Cleanup 'if' where the bracket is in a new line * Cleanup 'while' where the bracket is in a new line * Cleanup 'for' where the bracket is in a new line * Cleanup 'else' where the bracket is in a new line (cherry picked from commit 6a2200823c66e53bd3cda4a25f0206b834392652 to reduce conflicts merging between SDL2 and SDL3)
Sam Lantinga 8b20b568 2022-11-21T07:41:35 Don't report battery level for disconnected batteries Fixes https://github.com/libsdl-org/SDL/issues/6536
ulatekh ec58a817 2022-10-05T19:26:09 Fixes made in response to running a static code analyzer under MS Windows. Most of these are probably harmless, but the changes to SDL_immdevice.c and SDL_pixels.c appear to have fixed genuine bugs. SDL_audiocvt.c: By separating the calculation of the divisor, I got rid of the suspicion that dividing a double by an integer led to loss of precision. SDL_immdevice.c: Added a missing test, one that could have otherwise led to dereferencing a null pointer. SDL_events.c, SDL_gamecontroller.c, SDL_joystick.c, SDL_malloc.c, SDL_video.c: Made it clear the return values weren't used. SDL_hidapi_shield.c: The size is zero, so nothing bad would have happened, but the SDL_memset() was still being given an address outside of the array's range. SDL_dinputjoystick.c: Initialize local data, just in case IDirectInputDevice8_GetProperty() isn't guaranteed to write to it. SDL_render_sw.c: drawstate.viewport could be null (as seen on line 691). SDL.c: SDL_MostSignificantBitIndex32() could return -1, though I don't know if you want to cope with that (what I did) or SDL_assert() that it can't happen. SDL_hints.c: Replaced boolean tests on pointer values with comparisons to NULL. SDL_pixels.c: Looks like the switch is genuinely missing a break! SDL_rect_impl.h: The MacOS static checker pointed out issues with the X comparisons that were handled by assertions; I added assertions for the Y comparisons. SDL_yuv.c, SDL_windowskeyboard.c, SDL_windowswindow.c: Checked error-result returns.
Ozkan Sezer 339f7a2f 2022-09-16T17:28:20 SDL_windows.h: guard WIN32_LEAN_AND_MEAN and STRICT macro defines. also define them as 1, instead of empty. Reference issue: https://github.com/libsdl-org/SDL/issues/6239
Cameron Cawley fd93f817 2022-09-04T17:50:29 Assume that stdint.h is available on Windows with compilers other than MSVC <= 2008
Mathieu Eyraud f1390780 2022-08-02T15:25:44 Fix use after free when removing Windows audio device
Ethan Lee fff34f63 2022-07-15T09:46:53 windows: SDL_IMMDevice needed more deinit code from the Win32 path. Fixes #5919
Ethan Lee 2f0816ad 2022-07-11T13:08:30 Add SDL_GetDefaultAudioInfo. This API is supported on pipewire, pulseaudio, wasapi, and directsound. Co-authored-by: Frank Praznik <frank.praznik@gmail.com>
Ethan Lee 15d06180 2022-07-11T01:06:57 SDL_IMMDevice: Fix a WASAPI-specific leak, clean up Add()
Ethan Lee ae105ae1 2022-07-10T12:59:33 windows: Move IMMDevice work to common file, implement DirectSound enumeration support
chalonverse f317d619 2022-07-01T13:59:14 Xbox GDKX support (#5869) * Xbox GDK support (14 squashed commits) * Added basic keyboard testing * Update readme * Code review fixes * Fixed issue where controller add/removal wasn't working (since the device notification events don't work on Xbox, have to use the joystick thread to poll XInput)
chalonverse 3b191580 2022-06-27T17:19:39 Windows GDK Support (#5830) * Added GDK * Simplfied checks in SDL_config_wingdk.h * Added testgdk sample * Added GDK readme * Fixed error in merge of SDL_windows.h * Additional GDK fixes * OpenWatcom should not export _SDL_GDKGetTaskQueue * Formatting fixes * Moved initialization code into SDL_GDKRunApp
unknown 51c6488f 2022-06-26T18:47:34 Add support for SDL_render_d3d12.c to compile in C++ mode
Ozkan Sezer 2316e568 2022-06-19T11:32:10 SDL_windows.h: match WINVER value to _WIN32_WINNT.
Ozkan Sezer 22a29321 2022-06-19T11:32:10 tweak _WIN32_WINNT value for shellscalingapi.h present but no d3d12
chalonverse 40828218 2022-06-06T17:42:30 DirectX 12 Renderer (#5761) * DirectX 12 Renderer (27 squashed commits) * Add missing SDL_hidapi.h of merge of SDL.vcxproj.filters * Fixed OpenWatcom build failure * Dynapi fix Co-authored-by: Ryan C. Gordon <icculus@icculus.org>
Cameron Cawley 9dfa000b 2022-05-18T20:20:03 Initial support for building for Windows with OpenWatcom
Cameron Cawley 622311c0 2022-05-18T22:51:58 Add extra XInput structures and defines for older SDKs
Dimitriy Ryazantcev c39df2fb 2021-12-22T18:27:10 joystick: get HID top-level collection preparsed data directly from RawInput API.
Cameron Gutman 8982d9f4 2022-04-18T21:19:25 windows: Fix RoInitialize() failure after a CoInitializeEx() call using apartment threading This mirrors the same codepath in WIN_CoInitialize() which handles STA and MTA.
Cameron Gutman 923cb446 2022-04-20T21:02:40 windows: Fix calling convention for RoInitialize/RoUninitialize Fixes #5563
Ozkan Sezer 312c899f 2022-04-02T03:32:10 attempt to fix uwp build
Ozkan Sezer 575dadb1 2022-04-02T02:20:02 fix build against older SDKs after commit 8ebef12.
Sam Lantinga 8ebef12d 2022-04-01T14:58:33 Use RoInitialize/RoUninitialize for Windows.Gaming.Input Thanks @walbourn! Fixes https://github.com/libsdl-org/SDL/issues/5270
Sam Lantinga b22ce2b5 2022-03-17T17:10:40 Workaround for bug in Microsoft WGI support Fixes https://github.com/libsdl-org/SDL/issues/5270
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Sam Lantinga 6872cb12 2021-11-28T21:10:46 null-terminate the message buffer if FormatMessage() fails
Ozkan Sezer e4aa608a 2021-11-14T02:30:34 change (char*) casts to (const char*) in WIN_UTF8 macros
Sam Lantinga db68af80 2021-09-24T10:49:44 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.
Ozkan Sezer 3da6d2cd 2021-07-08T20:33:50 WIN_SetErrorFromHRESULT: kill CR/LF that FormatMessage sticks at the end Fixes: https://github.com/libsdl-org/SDL_mixer/issues/320
Cameron Cawley 391bb80b 2021-03-05T16:53:06 Replace duplicate functions and lstrlen/lstrcat with SDL string functions
Sam Lantinga d95a9eae 2021-01-27T21:30:13 Added WIN_IsWindows8OrGreater() for internal use
Ozkan Sezer 5b14bbff 2021-01-04T10:00:10 make ANSI/UNICODE versions of WIN??UTF8 macros individually available.
Ozkan Sezer f2bd861c 2021-01-04T08:50:00 move SDL_tcsstr definition to core/windows/SDL_windows.h
Ozkan Sezer 01a2f276 2021-01-04T01:23:50 consistently use TEXT() macro with LoadLibrary() and GetModuleHandle() cf. bug #5435.
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Sam Lantinga cb361896 2020-12-09T07:16:22 Fixed bug 5235 - All internal sources should include SDL_assert.h Ryan C. Gordon We should really stick this in SDL_internal.h or something so it's always available.
Sam Lantinga 5b3616c3 2020-11-23T18:24:05 Generalized the raw input controller driver and moved XInput/WGI detection into it for XInput devices This fixes bad report parsing for various newer Xbox controllers, and this driver is now preferred over XInput, since it handles more than 4 controllers.
Sam Lantinga f176d7fd 2020-05-22T16:45:02 Added a note not to use XinputUap.dll for XInput support
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Sam Lantinga d401a77e 2018-03-10T21:22:42 Fixed bug 4102 - define _WIN32_WINNT_WIN7 if not already defined Ozkan Sezer The following patch defines _WIN32_WINNT_WIN7 if it is not already defined in core/windows/SDL_windows.c, similar to what is already there for _WIN32_WINNT_VISTA.
Ryan C. Gordon ed64d54d 2018-02-21T21:36:10 windows: added WIN_IsWindows7OrGreater().
sezero 40b27fd5 2018-02-12T17:00:00 revert the recent typecast assignment changes (see bug #4079) also change the void* typedefs for the two vulkan function pointers added in vulkan_internal.h into generic function pointer typedefs.
Sam Lantinga 90e72bf4 2018-01-30T18:08:34 Fixed ISO C99 compatibility SDL now builds with gcc 7.2 with the following command line options: -Wall -pedantic-errors -Wno-deprecated-declarations -Wno-overlength-strings --std=c99
Sam Lantinga e3cc5b2c 2018-01-03T10:03:25 Updated copyright for 2018
Ryan C. Gordon 988034fc 2017-12-12T22:25:39 windows: Fixed a comment.
Sam Lantinga 0d011ec6 2017-08-28T00:22:23 Renaming of guard header names to quiet -Wreserved-id-macro
Sam Lantinga 3c09265d 2017-07-10T18:31:28 Fixed bug 3609 - Windows build fails due to conflicting types for 'XINPUT_GAMEPAD_EX' Ozkan Sezer (In reply to Ryan C. Gordon from comment #9) > I've put this patch in as https://hg.libsdl.org/SDL/rev/7213ae46e870 ...can > you verify this works on the latest MinGW? > > Thanks, > --ryan. This patch is wrong: the structure in question has nothing to do with any gcc version in use. I suggest reverting this adding a conigury check for it, instead. Something like the following should do it: (configure needs regenerating.)
Ryan C. Gordon d8444877 2017-06-06T12:35:35 windows: Fix compiling of XInput code on newer MinGW installs. Fixes Bugzilla #3609.
Ryan C. Gordon 6046fd4c 2017-02-14T03:03:27 wasapi: Initial WASAPI support, for Windows Vista and later. This should remain binary compatible with Windows XP, as we dynamically load anything we need and fall back to DirectSound/WinMM/XAudio2 if not available.
Ryan C. Gordon 70c0400b 2017-02-13T17:00:46 windows: Try to unify all the GUID comparison code into a core helper function. There are likely several more I missed.
Sam Lantinga 45b774e3 2017-01-01T18:33:28 Updated copyright for 2017
Sam Lantinga b4e069e7 2016-12-26T02:12:21 Fixed bug 3517 - Compiler warnings with gcc -Wstrict-prototypes felix Compiling even a simple SDL2 'hello world' program with gcc -Wstrict-prototypes (GCC 6.2.1) results in warnings like: /usr/include/SDL2/SDL_gamecontroller.h:143:1: attention : function declaration isn't a prototype [-Wstrict-prototypes] extern DECLSPEC int SDLCALL SDL_GameControllerNumMappings(); ^~~~~~ It seems there is a missing 'void' between the parentheses.
Sam Lantinga cfb24c76 2016-10-12T00:01:17 Fixed pointer signedness warning
David Ludwig b65763c0 2016-08-29T10:48:56 WinRT: patched to compile
Ryan C. Gordon 21c7fe00 2016-08-10T15:34:24 windows: directsound should also map audio device GUIDs to proper names. Moved this code from winmm into core so both can use it. DirectSound (at least on Win10) also returns truncated device names, even though it's handed in as a string pointer and not a static-sized buffer. :/
Sam Lantinga 42065e78 2016-01-02T10:10:34 Updated copyright to 2016
Sam Lantinga 11f2a9f8 2015-11-16T21:20:38 Fixed bug 3168 - xinput build failure with dxsdk Ozkan Sezer Yes, the annotations can actually be removed. They are used only by MSVC and aren't vital.
David Ludwig dc804c0e 2015-11-14T21:29:14 WinRT: fixed build error in latest XInput code This change has also been tested as buildable + runnable on Win32 + MSVC 2015, 2013, 2012, and 2010. It may fix similar build errors (in XInput code) that are appearing in MingW builds (on buildbot).
Sam Lantinga a0c4b56f 2015-09-30T15:39:30 SDL - added new SDL_JoystickCurrentPowerLevel() API that returns the battery level of the selected joystick. Currently only implemented for XInput devices, other platforms are a TODO. CR: Sam
Alex Szpakowski a506f1cb 2015-09-14T22:50:55 Windows: Try to use xinput9_1_0.dll if XInput 1.4 and 1.3 are not available. XInput "9.1.0" ships with Windows Vista and 7 systems, but it lacks some features, including support for detecting Guide button presses.
Philipp Wiesemann 0e45984f 2015-06-21T17:33:46 Fixed crash if initialization of EGL failed but was tried again later. The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly uninitialized data structure if loading the library first failed. A later try to use EGL then skipped initialization and assumed it was previously successful because the data structure now already existed. This led to at least one crash in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was dereferenced to make a call to eglBindAPI().
Philipp Wiesemann fd8b7c1c 2015-06-05T19:41:18 Fixed comments at conditional compilation macros.
Sam Lantinga 2c4a6ea0 2015-05-26T06:27:46 Updated the copyright year to 2015
Ryan C. Gordon b72938c8 2015-04-20T12:22:44 Windows: Always set the system timer resolution to 1ms by default. An existing hint lets apps that don't need the timer resolution changed avoid this, to save battery, etc, but this fixes several problems in timing, audio callbacks not firing fast enough, etc. Fixes Bugzilla #2944.
Alex Szpakowski fe6c797c 2015-04-10T23:30:31 Fixed an iOS view orientation issue when SDL_GL_CreateContext or SDL_CreateRenderer is called.
Edward Rudd b88ca1b4 2015-02-10T16:28:56 the last parameter of XChangeProperty is the number of elements.. and when the element format is 32.. the element is "long" so we have 5 long elements here. Yes this seems confusing as on mac+linux Long is either 32 or 64bits depending on the architecture, but this is how the X11 protocol is defined. Thus 5 is the correct value for the nelts here. Not 5 or 10 depending on the architecture. More info on the confusion https://bugs.freedesktop.org/show_bug.cgi?id=16802
Philipp Wiesemann b48e54aa 2015-01-26T22:00:29 Fixed bug 2802 - [patch] Fix android build compiling in wrong filesystem implementation Jonas Kulla The configure script didn't differentiate between Linux and Android, unconditionally compiling in the unix implementation of SDL_sysfilesystem.c. I'm probably one of the very few people building SDL for android using classic configure + standalone toolchain, so this has gone undetected all along.
David Ludwig 70438be2 2014-12-03T10:55:23 WinRT: fixed bug whereby SDL would override an app's default orientation WinRT apps can set a default, preferred orientation via a .appxmanifest file. SDL was overriding this on app startup, and making the app use all possible orientations (landscape and portrait). Thanks to Eric Wing for the heads up on this!
Philipp Wiesemann 9c398852 2014-11-22T22:20:40 Corrected header file documentation comment.
Pierre-Loup A. Griffais 24c86b55 2014-09-11T19:24:42 [X11] Reconcile logical keyboard state with physical state on FocusIn since the window system doesn't do it for us like other platforms. This prevents sticky keys and missed keys when going in and out of focus, for example Alt would appear to stick if switching away from an SDL app with Alt-Tab and had to be pressed again. CR: Sam
David Ludwig cf4ff728 2014-07-04T18:20:23 Made the latest XInput + Haptic changes compile and run on WinRT Notes: - Support for the 'Guide' button does not seem to be possible, as XInputGetStateEx is not available on WinRT. - Haptic support appears to be working on WinRT now! - SDL/WinRT does not allow calls to LoadLibrary or LoadLibraryEx. The calls to those were removed by this change, but only when compiling for WinRT. Non-WinRT Windows will continue to detect and load XInput via LoadLibrary and GetProcAddress calls.
Sam Lantinga b79e7f32 2014-07-03T15:39:55 Split the XInput and DirectInput code so Windows RT can use the existing XInput support.
David Ludwig c10afa48 2014-04-29T19:22:48 Fixed a linker error when building SDL/WinRT The Win32 APIs, VerifyVersionInfoW and VerSetConditionMask, are not currently available for use in WinRT apps. This change primarily #if[n]defs-out some calls to them.
Sam Lantinga dfea14d9 2014-04-23T13:54:47 Fixed cygwin build
Sam Lantinga acbc321c 2014-04-23T13:47:42 Don't try to load d3dcompiler_46.dll on Windows XP
David Ludwig 3dcb451f 2014-04-09T21:29:19 Added a README file regarding WinRT support To note, this file is currently formatted with CRLF line endings, rather than LF, to allow the file to be viewed with Notepad.
Sam Lantinga 1367bf87 2014-03-09T11:36:47 Integrated David Ludwig's support for Windows RT
Sam Lantinga 58edac3e 2014-02-02T00:53:27 Fixed bug 2374 - Update copyright for 2014... Is it that time already??
Sam Lantinga 69153196 2013-12-27T10:18:19 Switch back to apartment threaded COM initialization, which was the previous default. We do succeed now if the application previously initialized COM in multi-threaded mode.
Sam Lantinga 3666c1f7 2013-12-23T10:54:27 Explicitly initialize COM with multi-threaded support. This is the safest option for applications that use COM, multi-threaded or not.
Gabriel Jacobo f848adff 2013-11-29T10:06:08 Improve Android pause/resume behavior.
Ryan C. Gordon 7e1289af 2013-11-24T23:56:17 Make internal SDL sources include SDL_internal.h instead of SDL_config.h The new header will include SDL_config.h, but allows for other global stuff.
David Ludwig 69c5d21d 2013-10-27T21:26:46 WinRT: merged with SDL 2.0.1 codebase
Sam Lantinga a329c7f1 2013-10-18T00:13:51 Fixed bug 2139 - SDL_CreateWindow/WIN_GL_LoadLibrary fails due to external iconv not being able to convert path J?nis R?cis Brief history: We recently ported a game from SDL 1.2 to SDL 2. While doing Windows testing, I soon discovered that the game exits without opening a window with my cross-compiled SDL2.dll, but works great with the SDL2.dll from the MinGW SDK on libsdl.org. It was as simple as swapping out the DLLs to make it work. Running the game in Wine showed that the game actually does run, up until the call to SDL_CreateWindow, which fails and leads the game to print out an error: Failure to create window (LoadLibrary("OPENGL32.DLL"): (null)) Which basically says that there was no error, but maybe that's a Wine quirk. The error string originates in SDL_windowsopengl.c, in WIN_GL_LoadLibrary, which contains this piece of code: wpath = WIN_UTF8ToString(path); _this->gl_config.dll_handle = LoadLibrary(wpath); SDL_free(wpath); if (!_this->gl_config.dll_handle) { char message[1024]; SDL_snprintf(message, SDL_arraysize(message), "LoadLibrary(\"%s\")", path); return WIN_SetError(message); } After some digging, I discovered the culprit: WIN_UTF8ToString returns NULL. Why? Because it calls iconv_open from an iconv.dll that does not support the UCS-2-INTERNAL encoding. Why does the official SDL2.dll work? Because it calls no external iconv functions at all. It turns out that the Fedora MinGW infrastructure (from which I obtained the conventiently prebuilt iconv.dll) does not provide a DLL from libiconv, but instead provides a DLL from a minimal Windows library called win-iconv. Which knows a good bit, but doesn't know anything about UCS-2-INTERNAL: http://code.google.com/p/win-iconv/source/browse/trunk/win_iconv.c#155 So there are two problems here: 1) The error message is clearly useless, because LoadLibrary is an innocent bystander. Instead wpath should probably checked for NULL, and a more appropriate error should be set. Ideally something that makes it clear than an external iconv is causing trouble. 2) SDL doomed itself at the ./configure step, by finding an existing iconv and happily using it without confirming support for the mandatory encodings required by SDL. There are certainly a few easy ways out of the situation (although I didn't yet manage to figure out how to prevent ./configure from looking for external iconv), but this had me completely stomped for a good while, so I figured it's worth writing down if anything. (Search also found this, which talks a little about using UTF-16LE instead of UCS-2-INTERNAL: https://bugzilla.libsdl.org/show_bug.cgi?id=2075)
Sam Lantinga 12ca3ce3 2013-10-17T23:02:29 Fixed building using MinGW Our SDL_windows.h needed to be included before anything else so UNICODE is defined.
Ryan C. Gordon e43ff8fb 2013-08-20T12:43:06 Added some FIXMEs for later.
David Ludwig f7049b93 2013-08-12T22:29:55 WinRT: merged with SDL 2.0.0 codebase (aka. SDL hg rev d4ce48ff30d1)
Gabriel Jacobo dad42067 2013-08-12T11:13:50 Fixes #2022, do not resume on Android when surfaceChanged If the app is in landscape mode and the user presses the power button, a pause is followed immediately by a surfaceChanged event because the lock screen is shown in portrait mode. This triggers a "false" resume. So, we just pause and resume following the onWindowFocusChanged events. Also, wait for SDL_APP_WILLENTERBACKGROUND and SDL_APP_DIDENTERBACKGROUND before blocking the event pump.
Sam Lantinga 1ad936eb 2013-08-11T19:56:43 Fixed bug 2027 - Full-screen appears to be broken - hang in SDL_DestroyWindow() Rainer Deyke I'm running Linux Mint 15 with the Cinnamon window manager. SDL_DestroyWindow consistently locks up for me when the window if fullscreen.