Commit Graph

1665 Commits

Author SHA1 Message Date
Sam Lantinga 6209c71f54 Added SDL_BlitSurface9Grid() and SDL_RenderTexture9Grid() 2024-07-20 18:21:19 -07:00
Sam Lantinga 198caa54a1 Added SDL_RenderTextureTiled() 2024-07-20 18:21:19 -07:00
Sam Lantinga 9e55ee9391 Added SDL_BlitSurfaceTiledWithScale() 2024-07-20 18:21:19 -07:00
Sam Lantinga f47ddbf1ac Added SDL_BlitSurfaceTiled()
Fixes https://gamedev.stackexchange.com/questions/136792/is-there-a-way-to-set-texture-wrap-mode-as-repeat-in-sdl-2
2024-07-20 18:21:19 -07:00
Sam Lantinga 03bb2c17ed Enable texture wrapping for SDL_RenderGeometry()
Currently wrapping is based on whether texture coordinates are outside of [0,1], but the code is structured so it's easy to add an API to set it and add additional wrapping modes if we want.

Fixes https://github.com/libsdl-org/SDL/issues/9238
Closes https://github.com/libsdl-org/SDL/pull/5369
2024-07-20 09:51:05 -07:00
Sam Lantinga a340de6196 The candidates in SDL_EVENT_TEXT_EDITING_CANDIDATES should be a single allocation 2024-07-19 12:22:03 -07:00
Sam Lantinga fd9fe1bb7b Renamed event memory to temporary memory, since it's not just used for events 2024-07-19 12:22:03 -07:00
Sam Lantinga c4eac60000 SDL_GetClipboardData() follows the SDL_GetStringRule 2024-07-19 12:22:03 -07:00
Sam Lantinga 61a7a0e579 SDL_GUIDToString() follows the SDL_GetStringRule
Also removed the distinction between SDL_GUID and SDL_JoystickGUID
2024-07-19 12:22:03 -07:00
Sam Lantinga 856d598d6e SDL_GetSensors() follows the SDL_GetStringRule 2024-07-19 12:22:03 -07:00
Sam Lantinga 4f8c348402 SDL_GetPreferredLocales() follows the SDL_GetStringRule 2024-07-19 12:22:03 -07:00
Sam Lantinga 9be73ed7c5 SDL_GetMice() follows the SDL_GetStringRule 2024-07-19 12:22:03 -07:00
Sam Lantinga 6ca18ed0e5 SDL_GetKeyboards() follows the SDL_GetStringRule 2024-07-19 12:22:03 -07:00
Sam Lantinga 4961af4569 SDL_GetJoysticks() follows the SDL_GetStringRule 2024-07-19 12:22:03 -07:00
Sam Lantinga b32c9615a7 SDL_GetHaptics() follows the SDL_GetStringRule 2024-07-19 12:22:03 -07:00
Sam Lantinga 9de8cb888a SDL_GetFullscreenDisplayModes() follows the SDL_GetStringRule 2024-07-19 12:22:03 -07:00
Sam Lantinga 9758e102bc SDL_GetDisplays() follows the SDL_GetStringRule 2024-07-19 12:22:03 -07:00
Sam Lantinga 01199469de SDL_GetCameras() follows the SDL_GetStringRule 2024-07-19 12:22:03 -07:00
Sam Lantinga 0fe6603747 SDL_GetCameraSupportedFormats() follows the SDL_GetStringRule
Also changed the function to return an array of pointers and added example usage to testcamera
2024-07-19 12:22:03 -07:00
Sam Lantinga bdafc8e212 SDL_GetWindows() follows the SDL_GetStringRule 2024-07-19 12:22:03 -07:00
Sam Lantinga 8ca6caeda5 SDL_GetAudioPlaybackDevices() and SDL_GetAudioRecordingDevices() follow the SDL_GetStringRule 2024-07-19 12:22:03 -07:00
Sam Lantinga ef884c8aa6 Transfer event memory between the local pool and the event queue
This allows threads to free memory from their local pool without affecting events that are queued, and to transfer memory ownership cleanly between threads that are queuing and dequeuing events.
2024-07-19 12:22:03 -07:00
Sam Lantinga 38a301a3f9 Added automated tests to verify SDL_ClearSurface() and SDL_PremultiplySurfaceAlpha() 2024-07-17 18:04:16 -07:00
Amir 5db08b86ca Fix warning for Android NDK compiler: "function declaration without a prototype is deprecated in all versions of C [-Wstrict-prototypes]"
https://stackoverflow.com/questions/42125/warning-error-function-declaration-isnt-a-prototype
In C int foo() and int foo(void) are different functions. int foo() accepts an arbitrary number of arguments, while int foo(void) accepts 0 arguments. In C++ they mean the same thing.
2024-07-17 14:09:11 -07:00
Sam Lantinga 5f5e91eab6 Reverted 3d2e5a0b66
Applying these changes to external code doesn't actually improve anything, and within the context of the other Get* functions for renderers and surfaces, these stand out as outliers, so I'm going to back this change out.
2024-07-17 10:27:37 -07:00
Sam Lantinga 3d2e5a0b66 Fixed a few remaining functions to directly return their values instead of an error code. 2024-07-16 21:32:17 -07:00
Sam Lantinga 1e828eec57 Fixed warning C4244: '=': conversion from 'float' to 'int', possible loss of data 2024-07-16 21:32:17 -07:00
Sam Lantinga 7c0307060d Textures with alpha format default to SDL_BLENDMODE_BLEND
Fixes https://github.com/libsdl-org/SDL/issues/9941
2024-07-16 18:50:22 -07:00
Sam Lantinga b5292bdec9 Added blend mode testing for 8-bit surfaces 2024-07-16 17:57:12 -07:00
Ryan C. Gordon 4dda785c69 gamepad: Several gamepad mapping functions now follow the SDL_GetStringRule.
Reference Issue #10229.
2024-07-16 16:44:36 -04:00
Ryan C. Gordon ed1f93cd11 filesystem: `SDL_Glob*Directory()` functions now follow the SDL_GetStringRule.
Reference Issue #10229.
2024-07-16 16:44:36 -04:00
Ryan C. Gordon 52bf7ff42d filesystem: SDL_GetPrefPath() now follows the SDL_GetStringRule.
Reference Issue #10229.
2024-07-16 16:44:36 -04:00
Ryan C. Gordon 2321726ff1 filesystem: SDL_GetUserFolder() now follows the SDL_GetStringRule.
It also now caches at the higher level, so the platform-specific bits don't
change their interface much.

Reference Issue #10229.
2024-07-16 16:44:36 -04:00
Ryan C. Gordon d40b89dff6 clipboard: SDL_GetPrimarySelectionText() now follows the SDL_GetStringRule.
Reference Issue #10229.
2024-07-16 16:44:36 -04:00
Ryan C. Gordon 158fc459f1 clipboard: SDL_GetClipboardText() now follows the SDL_GetStringRule.
Reference Issue #10229.
2024-07-16 16:44:36 -04:00
Ryan C. Gordon 3bc81a81f5 filesystem: SDL_GetBasePath() now follows the SDL_GetStringRule.
It also now caches at the higher level, so the platform-specific bits don't
change their interface much.

A little code hygiene work was applied to some of the platform bits on top of
this.

Reference Issue #10229.
2024-07-16 16:44:36 -04:00
Sam Lantinga ec3bb4c029 Removed the need for SDL_CreateTLS()
This eliminates the tap dancing needed for allocating TLS slots, we'll automatically allocate them as needed, in a thread-safe way.
2024-07-16 12:01:51 -07:00
Sam Lantinga 033df70d4c SDL_DelayNS() will attempt to sleep exactly the requested amount of time
This provides a highly accurate sleep function for your application, although you are still subject to being switched out occasionally.

Fixes https://github.com/libsdl-org/SDL/issues/10210
2024-07-15 18:38:09 -07:00
Sam Lantinga a419e2c890 Updated and re-enabled surface and render blend mode tests 2024-07-15 14:12:33 -07:00
Sam Lantinga df573391b1 Added SDL_BLENDMODE_BLEND_PREMULTIPLIED and SDL_BLENDMODE_ADD_PREMULTIPLIED
Fixes https://github.com/libsdl-org/SDL/issues/2485
2024-07-15 14:12:33 -07:00
Sam Lantinga 5c875e1183 Renamed *FromID() to *ForID()
While it makes sense to get an object pointer from an object ID, you want to get object attributes for an ID, otherwise e.g. GetNameFromID() sounds like it's a name ID, not an object ID. This is also consistent with the function naming convention in SDL2.
2024-07-14 15:56:50 -07:00
Sam Lantinga 9797c5d0c0 Renamed CameraDevice to Camera
This is consistent with the rest of the SDL API
2024-07-14 13:01:53 -07:00
Sam Lantinga 9358333286 Renamed SDL_GetKeyboardInstanceName() and SDL_GetMouseInstanceName()
For consistency with other device APIs
2024-07-14 13:01:53 -07:00
Sam Lantinga d154b37b41 Renamed *FromInstanceID() to *FromID() 2024-07-14 13:01:53 -07:00
Sam Lantinga 1fecef5e4b Assign numeric values to pixel format enums
This makes it easier to generate language bindings for these.
2024-07-14 11:02:56 -07:00
Sam Lantinga e290e99d89 Fixed error: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'unsigned int' 2024-07-14 09:04:09 -07:00
Sam Lantinga e90060d07f Renamed functions to get information from device IDs
Fixes https://github.com/libsdl-org/SDL/issues/10237
2024-07-14 09:03:59 -07:00
Sam Lantinga bfee544685 Changed SDL_GetWindowPixelFormat() to return SDL_PixelFormat
Fixes https://github.com/libsdl-org/SDL/issues/10257
Closes https://github.com/libsdl-org/SDL/pull/10258
2024-07-14 07:19:20 -07:00
Sam Lantinga 650271af46 Added SDL_CreateSurfacePalette() 2024-07-13 14:31:28 -07:00
Anonymous Maarten f13be04980 testaudio: use SDL_APP_FAILURE macro to signal failure 2024-07-13 17:06:54 +02:00
Sam Lantinga 5bf6bc4d7d Renamed SDL_Get/SetProperty() to SDL_Get/SetPointerProperty()
This is consistent with the naming for the functions that affect other data types

Fixes https://github.com/libsdl-org/SDL/issues/10241
2024-07-12 10:41:02 -07:00
Anonymous Maarten ca36f6c43b sdlprocdump: remove dead code 2024-07-12 18:38:03 +02:00
Anonymous Maarten 40f9fd854f test: use SDL_HINT_(AUDIO,VIDEO)_DRIVER macro 2024-07-11 23:37:11 +02:00
Ethan Lee 5d506a53a6 testvulkan: Add call to SDL_Vulkan_GetPresentationSupport 2024-07-11 15:00:59 -04:00
Sam Lantinga 875c4f0a4c Support indexed surfaces without palettes (thanks @sulix!)
Currently, all SDL_Surfaces with an indexed pixel format have an
associated SDL_Palette. This palette either consists of entirely the
colour black, or -- in the special case of 1-bit surfaces, black and
white.

When an indexed surface is blitted to another indexed surface, a 'map'
is generated from the source surface's palette to the destination
surfaces palette, in order to preserve the look of the image if the
palettes differ.

However, in most cases, applications will want to blit the raw index
values, rather than translate to make the colours as similar as
possible. For instance, the destination surface's palette may have been
modified to fade the screen out.

This change allows an indexed surface to have no associated palette. If
either the source or destination surface of a blit do not have a
palette, then the raw indices are copied (assuming both have an indexed
format).

This mimics better what happens with most other APIs (such as
DirectDraw), where most users do not set a palette on any surface but
the screen, whose palette is implicitly used for the whole application.
2024-07-11 08:31:32 -07:00
Anonymous Maarten 131108ee48 Remove references to SDL_CreatePixelFormat and SDL_DestroyPixelFormat 2024-07-11 08:12:42 -07:00
David Gow 540a356199 test: Add testspritesurface
This is a cut-down version of testsprite which uses SDL_Surface (and
SDL_GetWindowSurface), instead of the Render API. It's useful for
quickly validating that blitting works, including some basic format
conversion (with a palette).

Signed-off-by: David Gow <david@ingeniumdigital.com>
2024-07-11 08:11:29 -07:00
Sam Lantinga 0b2c80557c Update the blit mapping when the palette is set on a surface
Make sure you do this even if the palette pointer hasn't changed, as the contents may have.

Fixes https://github.com/libsdl-org/SDL/issues/10225
2024-07-10 23:22:06 -07:00
Ryan C. Gordon af2dbf3ff3 video: Rename SDL_GL_DeleteContext to SDL_GL_DestroyContext.
Turns out that there isn't a strong OpenGL naming convention for "Delete" ...
WGL offers "wglDeleteContext" but the GLX equivalent is "glxDestroyContext"
and then EGL sealed the deal by going with Destroy as well! Since it matches
SDL3 naming conventions (Create/Destroy), we're renaming it.

Fixes #10197.
2024-07-10 15:54:08 -04:00
Ryan C. Gordon 4755055bc3 audio: Separate channel maps out of SDL_AudioSpec. 2024-07-10 15:43:57 -04:00
Sam Lantinga 2ba76dbe80 Simplified SDL_Surface
SDL_Surface has been simplified and internal details are no longer in the public structure.

The `format` member of SDL_Surface is now an enumerated pixel format value. You can get the full details of the pixel format by calling `SDL_GetPixelFormatDetails(surface->format)`. You can get the palette associated with the surface by calling SDL_GetSurfacePalette(). You can get the clip rectangle by calling SDL_GetSurfaceClipRect().

SDL_PixelFormat has been renamed SDL_PixelFormatDetails and just describes the pixel format, it does not include a palette for indexed pixel types.

SDL_PixelFormatEnum has been renamed SDL_PixelFormat and is used instead of Uint32 for API functions that refer to pixel format by enumerated value.

SDL_MapRGB(), SDL_MapRGBA(), SDL_GetRGB(), and SDL_GetRGBA() take an optional palette parameter for indexed color lookups.
2024-07-10 00:48:18 -07:00
Brick 43a5da358d Set ALLOWABLE_ERROR_BLENDED to 0 2024-07-08 20:59:42 +01:00
Anonymous Maarten 1cddc7b66e sdlprocdump: exceptions are not handled 2024-07-08 21:30:49 +02:00
Anonymous Maarten c4cbbca185 sdlprocdump: ignore C++ exceptions 2024-07-08 20:48:33 +02:00
Sam Lantinga d6c8485f28 Make sure we're actually running on Windows before using D3D renderers 2024-07-08 11:36:11 -07:00
Sam Lantinga 4d5f139f0f Add the blit automation tests 2024-07-08 10:58:48 -07:00
Isaac Aronson 3ecb927587 Remove last non-SDL types from test 2024-07-08 10:53:46 -07:00
Isaac Aronson adca9d408e Fixup tests to use correct types 2024-07-08 10:53:46 -07:00
Isaac Aronson f5ee88c2cf Implement mathematically correct scalar blitters 2024-07-08 10:53:46 -07:00
Isaac Aronson f0238ef615 Fix build issues 2024-07-08 10:53:46 -07:00
Isaac Aronson 594ca1a897 Add testautomation suite for alpha blending 2024-07-08 10:53:46 -07:00
Sam Lantinga 4fa5196820 Revert "Switch pixel format loss fields to number of bits"
This reverts commit 3c90b1c1f6.

It turns out this is problematic for sdl2-compat. We're investigating a more complete separation between SDL2 and SDL3 surfaces, but in the meantime, I'll fix the breakage.
2024-07-07 19:41:05 -07:00
Anonymous Maarten 18c9bd21b5 sdlprocdump: become C90 compatible 2024-07-07 21:18:16 +02:00
Sam Lantinga 3c90b1c1f6 Switch pixel format loss fields to number of bits
This makes more sense and handles pixel formats with > 8 bits per channel

Fixes https://github.com/libsdl-org/SDL/issues/10168
2024-07-06 11:37:16 -07:00
Anonymous Maarten be43dec798 sdlprocdump: store context and exception record in minidump 2024-07-06 17:36:16 +02:00
Ryan C. Gordon 2a8f1e11ca audio: Add gain support to audio streams and logical audio devices.
Fixes #10028.
2024-07-03 16:05:55 -04:00
Ryan C. Gordon 16e7fdc4f2 audio: Add channel remapping to SDL_AudioSpec and SDL_AudioStream.
Fixes #8367.
2024-07-03 14:38:33 -04:00
Ryan C. Gordon 0367f1af19 loopwave: Use SDL_ResumeAudioStreamDevice.
...instead of the more-wordy:

`SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(stream));`
2024-07-03 14:38:33 -04:00
Sam Lantinga e8dbbf8380 Renamed SDLK_a-z to SDLK_A-Z
Made the symbols uppercase for consistency with the other SDLK_* constants, but the values are still lowercase.
2024-07-01 13:56:49 -07:00
Sam Lantinga d9dc4b320a The keycode in key events is the base, unmodified, keycode for the current keyboard layout 2024-07-01 13:56:49 -07:00
Anonymous Maarten 8290c4e82e sdlprocdump: also print a stacktrace on a fatal exception 2024-07-01 20:49:52 +02:00
Sam Lantinga 473257cce6 Added SDL_GetRenderLogicalPresentationRect()
Fixes https://github.com/libsdl-org/SDL/issues/8815
2024-06-29 14:25:59 -07:00
Sam Lantinga a522bfe3f1 Clean up any renderer in SDL_DestroyWindowSurface()
Also added an automated test to verify window surface functionality.

Fixes https://github.com/libsdl-org/SDL/issues/10133
2024-06-29 10:47:28 -07:00
Sam Lantinga 6f199eabb8 Removed SDL_RenderGeometryRawFloat()
After discussion with @ocornut, SDL_RenderGeometryRaw() will take floating point colors and conversion from 8-bit color can happen on the application side.  We can always add an 8-bit color fast path in the future if we need it on handheld platforms.

If you need code to do this in your application, you can use the following:

int SDL_RenderGeometryRaw8BitColor(SDL_Renderer *renderer, SDL_Texture *texture, const float *xy, int xy_stride, const SDL_Color *color, int color_stride, const float *uv, int uv_stride, int num_vertices, const void *indices, int num_indices, int size_indices)
{
    int i, retval, isstack;
    const Uint8 *color2 = (const Uint8 *)color;
    SDL_FColor *color3;

    if (num_vertices <= 0) {
        return SDL_InvalidParamError("num_vertices");
    }
    if (!color) {
        return SDL_InvalidParamError("color");
    }

    color3 = (SDL_FColor *)SDL_small_alloc(SDL_FColor, num_vertices, &isstack);
    if (!color3) {
        return -1;
    }

    for (i = 0; i < num_vertices; ++i) {
        color3[i].r = color->r / 255.0f;
        color3[i].g = color->g / 255.0f;
        color3[i].b = color->b / 255.0f;
        color3[i].a = color->a / 255.0f;
        color2 += color_stride;
        color = (const SDL_Color *)color2;
    }

    retval = SDL_RenderGeometryRaw(renderer, texture, xy, xy_stride, color3, sizeof(*color3), uv, uv_stride, num_vertices, indices, num_indices, size_indices);

    SDL_small_free(color3, isstack);

    return retval;
}

Fixes https://github.com/libsdl-org/SDL/issues/9009
2024-06-29 00:10:08 -07:00
Sam Lantinga 212a491f7c Renamed SDL_HINT_IME_NATIVE_UI to SDL_HINT_IME_IMPLEMENTED_UI
This inverts the logic to make more sense from an application perspective.
2024-06-28 19:41:37 -07:00
Sam Lantinga 4c7db129df SDL_HINT_IME_INTERNAL_EDITING and SDL_HINT_IME_SHOW_UI are replaced with SDL_HINT_IME_NATIVE_UI 2024-06-28 17:09:22 -07:00
Sam Lantinga bdd531986b SDL_SetTextInputRect() has been renamed to SDL_SetTextInputArea()
The new function includes the cursor position so IME UI elements can be placed relative to the cursor, as well as having the whole text area available so on-screen keyboards can avoid it.
2024-06-28 17:09:22 -07:00
Sam Lantinga ed2022a175 Added SDL_EVENT_TEXT_EDITING_CANDIDATES
This allows applications that have set SDL_HINT_IME_SHOW_UI to "0" to get candidates lists they can draw themselves.

Fixes https://github.com/libsdl-org/SDL/issues/4855
2024-06-28 17:09:22 -07:00
Sam Lantinga 8165e96514 Fixed whitespace 2024-06-27 18:35:12 -07:00
Sam Lantinga dcd7b4e497 testime: highlight selected clauses in Japanese composition mode 2024-06-27 17:43:03 -07:00
Sam Lantinga 50250adba7 testime: draw a blinking cursor at the text insertion point 2024-06-27 17:43:03 -07:00
Sam Lantinga 3d525331aa testime: add a 1 pixel border around glyphs to avoid texture sampling into other glyphs 2024-06-27 17:43:03 -07:00
Sam Lantinga 938c974cca testime: use a replacement character for characters not in the font 2024-06-27 17:43:03 -07:00
Sam Lantinga a67e6b80de Updated unifont to version 15.1.05 2024-06-27 17:43:03 -07:00
Sam Lantinga 50f50612bd Removed checkkeysthreads
It's out of date relative to the IME changes and doesn't add any value
2024-06-27 17:43:03 -07:00
Ryan C. Gordon 1e0ac5771a testiconv: Remove half-baked SDL_StepUTF8 testing code. 2024-06-27 17:36:09 -04:00
Ryan C. Gordon a9cfcf6bde stdinc: Drastically improve SDL_StepUTF8() and make it a public API.
Fixes #10105.
2024-06-27 17:36:09 -04:00
Ryan C. Gordon 9b8c5f642f
testaudio: Better fix for NULL dereference.
This code already handled NULL fine, it just got wrapped in a SDL_strdup call
in e23257307e, so make that SDL_strdup check for
NULL first.
2024-06-27 17:24:49 -04:00
Ryan C. Gordon 5631c6dbaa
testaudio: Don't crash if SDL_GetAudioDeviceName() returns NULL.
It definitely will for default devices, so this crash is real, but it's also
good defensive coding if something blows up unexpectedly.

Fixes #10130.
2024-06-27 17:20:11 -04:00
Ryan C. Gordon 982feb7a65 vulkan: SDL_Vulkan_CreateSurface now returns the usual int (0=ok, -1=error).
Fixes #10091.
2024-06-27 15:25:10 -04:00
Sam Lantinga def7a43a2e SDL_HINT_IME_SHOW_UI defaults to SDL_TRUE
This hint is currently only used on Windows, and this matches the behavior of other platforms.
2024-06-24 20:32:03 -07:00
Sam Lantinga 382494eeda checkkeys: draw the IME composition text 2024-06-24 20:32:03 -07:00
Sam Lantinga 92b3ce20b1 checkkeys: don't toggle text input with the left mouse button
This often gets triggered when clicking back and forth between the language bar and the application
2024-06-24 20:32:03 -07:00
Sam Lantinga 01ae067504 checkkeys: print the start/length values of the SDL_EVENT_TEXT_EDITING event 2024-06-24 20:32:03 -07:00
Sam Lantinga 94ae4e1513 Fixed build warnings 2024-06-24 13:36:56 -07:00
Sam Lantinga 0ff5c05486 Added SDL_GetWindows() 2024-06-24 12:22:12 -07:00
Sam Lantinga 2f5b20fcb5 Updated based on feedback from @JKaniarz 2024-06-24 11:49:15 -07:00
Sam Lantinga a938e2b979 Replaced test framework random code with SDL random functions 2024-06-24 11:49:15 -07:00
Sam Lantinga 96f2f23240 Simplified SDL random function names and added thread-safe versions 2024-06-24 11:49:15 -07:00
Sam Lantinga 138eb8649d checkkeys: draw a blinking cursor 2024-06-24 11:20:08 -07:00
Sam Lantinga 505badb7af checkkeys: added support for multiple windows 2024-06-24 11:20:08 -07:00
Sam Lantinga 76631a0978 The text input state has been changed to be window-specific.
SDL_StartTextInput(), SDL_StopTextInput(), SDL_TextInputActive(), SDL_ClearComposition(), and SDL_SetTextInputRect() all now take a window parameter.

This change also fixes IME candidate positioning when SDL_SetTextInputRect() is called before SDL_StartTextInput(), as is recommended in the documentation.
2024-06-24 11:20:08 -07:00
Sam Lantinga 258ee05655 checkkeys: enable showing IME candidates 2024-06-24 11:20:08 -07:00
Simon McVittie 2cfeff1505 testevdev: Associate HID reports for pedals with their other test data
This is how these globals were intended to have been used, similar to
what we already did for the Fanatec device.

Fixes: 3772d6cc "testevdev: Add raw HID report descriptors where available"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-06-24 04:39:34 -07:00
Simon McVittie 3150fdc75e Revert "testevdev.c: comment out two unused data to fix build."
This reverts commit e4f53e6b21.
We'll use these in the next commit.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-06-24 04:39:34 -07:00
Anonymous Maarten 2018882bf2 testmanymouse: enable raw keyboard events on Windows 2024-06-22 11:35:00 -07:00
Anonymous Maarten 99d28ca485 testmanymouse: fix argument parsing 2024-06-22 14:43:06 +02:00
Sam Lantinga 90034b16dc The keycode in key events is affected by modifiers by default.
This behavior can be customized with SDL_HINT_KEYCODE_OPTIONS.
2024-06-22 00:19:06 -07:00
Sam Lantinga 0dd579d40d Removed SDL_Keysym 2024-06-21 22:06:08 -07:00
Sam Lantinga 679e4471ed Added the ability to query the keymap for keycodes based on modifier state 2024-06-21 22:06:08 -07:00
Sam Lantinga ef9bd8b609 Add the raw platform specific key code to SDL_Keysym
This allows applications to handle keys that SDL doesn't recognize, in a platform dependent way.

Fixes https://github.com/libsdl-org/SDL/issues/6390
2024-06-21 22:06:08 -07:00
Sam Lantinga 9d816c72ef Updated SDL3 scancode list
This adds more app editing and audio control keys and removes keys that launch applications

Work in progress on https://github.com/libsdl-org/SDL/issues/6390
2024-06-21 22:06:08 -07:00
Simon McVittie 53eff7f903 testevdev: Add X-Box One S controller via xpadneo 0.9.x
This is an out-of-tree driver providing an alternative interface to
X-Box gamepads. Compared with the in-kernel driver, it adds four
pseudo-buttons used to indicate which profile is active, and an
optional "misc" axis that combines the two triggers into a rudder.

Partially addresses libsdl-org/SDL#7823

Thanks: @kakra
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-06-21 07:05:26 -07:00
Simon McVittie 2804f92eff testevdev: Add missing device ID for Wiimote Classic Controller
Thanks: Jeremy Whiting
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-06-21 07:04:56 -07:00
Simon McVittie c244eb937b testevdev: Add the virtual X360 controller created by Steam Input
Thanks: Robert Beckett
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-06-21 07:02:23 -07:00
Simon McVittie f471392e73 testevdev: Add test data from Steam Deck built-in devices
Thanks: Robert Beckett
Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-06-21 07:02:23 -07:00
Simon McVittie 740850d3ce testevdev: Add a field for the USB device version
For some devices, such as the Steam Deck's built-in Steam Controller,
the version number reported via evdev and the version number reported
via USB are different. We don't currently use this information anyway,
but in case we want to use it in the future, let's include it in our
test data.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2024-06-21 07:02:23 -07:00
Anonymous Maarten 0f27686a51 tests: run tests under a minimal debugger that can create minidumps
Tests on ci are run using this dumper, and will upload the minidumps.
2024-06-21 12:39:11 +02:00
Frank Praznik 2f276a2eea video: Expose HDR metadata per-window
Moves the HDR properties from the display to be per-window, and adds the frog_color protocol to enable HDR under Wayland.
2024-06-20 15:55:07 -04:00
Anonymous Maarten 72d5f39e5c Make testnative (on win32) UNICODE compatible 2024-06-20 15:40:32 +02:00
Anonymous Maarten 992f80eb51 testnative: include SDL_build_config.h instead of SDL_internal.h 2024-06-20 15:40:32 +02:00
John Kaniarz 38cac043af Added algorithm comments to SDL_rand_*() 2024-06-19 17:00:58 -07:00
John Kaniarz 8f29f8cae5 Renamed SDL_rand() to SDL_rand_bits() and updated tests 2024-06-19 17:00:58 -07:00
Hubert Maier 3acdb8a90b
JANITORIAL: Fix typos in comments in various files (#10058) 2024-06-19 07:13:46 -07:00
Sam Lantinga d7391394d3 Switched the camera format to use framerate ratio instead of interval ratio
This is more intuitive for game developers and users.

Fixes https://github.com/libsdl-org/SDL/issues/9896
2024-06-18 07:39:52 -07:00
Sam Lantinga 3a68febedf Enable HIDAPI controller support on mobile platforms 2024-06-17 15:05:12 -07:00
Sam Lantinga aeea819494 Added colorspace to SDL_CameraSpec 2024-06-16 17:47:16 -07:00
Sam Lantinga d1d484ddbe Added SDL_srand(), SDL_rand(), and SDL_rand_r() (thanks @JKaniarz!)
These are simple random functions that should not be used for serious random number generation.

Fixes https://github.com/libsdl-org/SDL/issues/4968
2024-06-16 07:41:00 -07:00
Sam Lantinga e388e377aa audio: Refer to audio devices to "playback" and "recording" 2024-06-15 08:00:33 -07:00
Ryan C. Gordon 38f0214e8a audio: Refer to audio devices to "playback" and "recording".
Fixes #9619.
2024-06-15 01:08:12 -04:00
Ryan C. Gordon 5bc654aad3
camera: SDL_GetCameraDeviceName() now follows the SDL_GetStringRule. 2024-06-13 18:13:51 -04:00
Ryan C. Gordon 9d3d893322
testcamera: Report device name and SDL camera driver in the window title. 2024-06-13 17:05:47 -04:00
Sam Lantinga 9f984e6fb4 testcontroller: fixed showing analog axis values 2024-06-12 22:27:54 -07:00
Sam Lantinga 80a907e0e6 Backed out the viewport and cliprect changes in 9fb5a9ccac
This ended up being lots of application code churn without any real benefit in practice.
2024-06-12 19:25:15 -07:00
Sam Lantinga 3e70376bce Enabled HIDAPI debug logging for diagnostic purposes 2024-06-12 15:03:41 -07:00
Sam Lantinga 9fb5a9ccac Use floating point values for viewport, clip rectangle, and texture sizes
These are integer values internally, but the API has been changed to make it easier to mix other render code with querying those values.

Fixes https://github.com/libsdl-org/SDL/issues/7519
2024-06-12 10:18:39 -07:00
Anonymous Maarten 32907a9606 Rename SDL_Swap(16|32|64)(LE|BE) to SDL_Swap(LE|BE)(16|32|64) 2024-06-12 02:29:39 +02:00
Sam Lantinga 391a63f29f Check raw keyboard input in checkkeys 2024-06-11 09:09:30 -07:00
Sam Lantinga ed5993d1cb Removed unused variable 2024-06-10 15:01:41 -07:00
Sam Lantinga 0cc61b27a2 SDL takes care of handling mouse relative mode on focus change 2024-06-10 14:57:32 -07:00
Sam Lantinga 3e018517c3 Fixed build errors after SDL_IOWhence change 2024-06-09 11:52:04 -04:00
Sam Lantinga 1938d25b7e Use "%S" format specifier for wide-character strings 2024-06-06 10:59:15 -07:00
Hunter Kvalevog 14f7eebac6 testcamera: Add [--camera name] parameter 2024-06-04 16:24:27 -07:00
Sam Lantinga 4d392bfc67 Fixed camera capture on iOS
My phone captured 1920x1080 images even though the highest reported format was higher resolution, so I adjusted testcamera to be able to handle different sized images than expected.

Fixes https://github.com/libsdl-org/SDL/issues/9930
2024-06-04 11:34:39 -07:00
Sam Lantinga 60396971ce Move the main header with SDL_MAIN_USE_CALLBACKS 2024-06-04 10:42:44 -07:00
Sam Lantinga a0d1445ccb Replaced SDL_GetRendererInfo() with SDL_GetRendererName()
The texture formats are available via the SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER property

Fixes https://github.com/libsdl-org/SDL/issues/9851
2024-06-03 21:10:58 -07:00
Semphris 8c8ee2174d Dialog: Add filter number, remove NULL termination 2024-06-03 18:22:26 -07:00
Sam Lantinga 1d83b782b8 Set the headphones to 50% volume to avoid blasting people's ears
Also fixed audio routing comments
2024-06-03 17:28:32 -07:00
Sam Lantinga 8aa7910184 Added an example of setting PS5 controller audio routing
Closes https://github.com/libsdl-org/SDL/pull/9661
2024-06-03 17:24:36 -07:00
Anonymous Maarten a919774fe4
Build with -Wfloat-conversion + fix all warnings 2024-06-03 21:33:29 +00:00
Ryan C. Gordon e23257307e Introduce formal policy for APIs that return strings.
This declares that any `const char *` returned from SDL is owned by SDL, and
promises to be valid _at least_ until the next time the event queue runs, or
SDL_Quit() is called, even if the thing that owns the string gets destroyed
or changed before then.

This is noted in the headers as "the SDL_GetStringRule", so this will both be
greppable to find a detailed explaination in docs/README-strings.md and
wikiheaders will automatically turn it into a link we can point at the
appropriate documentation.

Fixes #9902.

(and several FIXMEs, both known and yet-undocumented.)
2024-06-03 14:20:49 -04:00
Ryan C. Gordon 9a9a3d1a33 SDL_SystemCursor: rename enum items to match CSS.
Fixes #9079.
2024-06-01 22:32:43 -04:00
Anonymous Maarten 6896c4c3bf tests: testcases accept a void pointer argument 2024-05-31 19:18:24 +02:00
Anonymous Maarten d5060423a2 testplatform: fix leak at exit time
A leak was present at exit time on the Emscripten platform
2024-05-31 18:53:36 +02:00
Ryan C. Gordon 3364aff757
main: Make the main callback return value symbols smaller (thanks, @Lzard!).
Reference #9901.
2024-05-27 16:03:45 -04:00
L zard 06aa02453a Tests: Use the main callback code macros 2024-05-27 09:22:07 -07:00
Sam Lantinga 99599d9236 Added SDL_AddTimerNS() 2024-05-27 07:57:33 -07:00
Sam Lantinga b6360516e4 Added the timerID to the SDL timer callback
Fixes https://github.com/libsdl-org/SDL/issues/2593
2024-05-27 07:57:33 -07:00
Sam Lantinga df25e4022d Removed short aliases for 16-bit pixel formats
These were potentially misleading in the same way the RGB888/BGR888 aliases were

Fixes https://github.com/libsdl-org/SDL/issues/4994
2024-05-27 07:24:46 -07:00
Ryan C. Gordon cf2874080f mouse: Move mouse button state from a Uint32 to a formal typedef.
Reference Issue #9812.
2024-05-26 13:23:21 -04:00
Ryan C. Gordon 0f0570b060 pen: Change a Uint32 bitfield into a typedef.
Reference Issue #9812.
2024-05-26 13:23:21 -04:00
Anonymous Maarten fefa47e409 dropfile: main callbacks need extra CMake care on UWP 2024-05-25 16:35:11 +02:00
Anonymous Maarten 78e25d4994 testdropfile: convert to use callbacks 2024-05-25 04:44:07 +02:00
Sam Lantinga 2461bd8648 Removed unnecessary float casts 2024-05-23 15:12:19 -07:00
Frank Praznik 888a45977d
tests: Check the usable bounds for centered window positioning
SDL now centers windows according to the usable display bounds, so the window centering test requires an update for the new behavior.
2024-05-21 12:26:40 -04:00
Anonymous Maarten d3d7c04bf8 testcamera: libSDL3_test destroys the window and renderer
This fixes a "DEBUG: Parameter 'renderer' is invalid" message when exiting testcamera.
2024-05-17 14:39:29 +02:00
Anonymous Maarten 690875d555 testiconv: free all memory to fix --trackmem 2024-05-17 14:39:29 +02:00
Anonymous Maarten 831c79d32f testatomic: destroy threads + free all memory at quit to fix --trackmem 2024-05-17 14:39:29 +02:00
Sam Lantinga 4609af618a Updated logging functions for SDL3 naming convention 2024-05-16 10:22:15 -07:00
Anonymous Maarten 88980aeb21 android+test: testcamera needs CAMERA permissions 2024-05-16 16:43:53 +02:00
Sam Lantinga 661f2fc1fc Removed the SDL_Version structure, moved SDL version to SDL.h
Inspired by https://github.com/libsdl-org/SDL/issues/9788
2024-05-15 10:43:31 -07:00
Frank Praznik df3fea87d6 wayland: Rework scale-to-display
This extends the display scaling mode to be global and work in terms of pixels everywhere, with the content scale value set on displays. The per-window property had some issues, and has been removed in favor of retaining only the global hint that changes all coordinates to pixel values, sets the content scale on the displays, and generally makes the Wayland backend behave similarly to Win32 or X11.

Some additional work was needed to fix cases where displays can appear to overlap, since Wayland desktops are always described in logical coordinates, and attempting to adjust the display positions so that they don't overlap can get very ugly in all but the simplest cases, as large gaps between displays can result.
2024-05-13 19:10:19 -04:00
Sam Lantinga 17520c2e6e Removed SDL_RendererFlags
The flags parameter has been removed from SDL_CreateRenderer() and SDL_RENDERER_PRESENTVSYNC has been replaced with SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER during window creation and SDL_PROP_RENDERER_VSYNC_NUMBER after renderer creation.

SDL_SetRenderVSync() now takes additional values besides 0 and 1.

The maximum texture size has been removed from SDL_RendererInfo, replaced with SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER.
2024-05-13 15:06:11 -07:00
Frank Praznik f4aca6866c test: Free clipboard data after calling SDL_GetClipboardText()
Clipboard allocations were being leaked in two instances.
2024-05-13 10:27:24 -04:00
Sam Lantinga c95c415a0b Fixed warning C4244: '=': conversion from 'SDL_Keymod' to 'Uint16', possible loss of data 2024-05-10 16:43:09 -07:00
Sam Lantinga c1ba31118b Added ball, touchpad, and sensor support for virtual joysticks
Fixes https://github.com/libsdl-org/SDL/issues/9542
2024-05-09 18:25:22 -07:00
Sam Lantinga bcbf09acde Renamed SDL_AttachVirtualJoystickEx() to SDL_AttachVirtualJoystick()
The shorthand version of this function didn't allow specifying a controller name, which seems pretty important. It seems like anyone actually implementing a virtual joystick is going to want to use some of the extended functionality.
2024-05-09 14:05:58 -07:00
Sam Lantinga 54fb629da5 SDL_WindowFlags is now 64-bit
Fixes https://github.com/libsdl-org/SDL/issues/7321
2024-05-09 10:39:54 -07:00
Frank Praznik 1f43c88220 time: Use a function instead of properties to retrieve the system date and time locale info
This allows applications to re-query the values if the system locale is changed during runtime, and better matches the other locale functions. A note is included in the documentation mentioning that this can be slow, as it has to call into OS functions.

Also allows for the removal of the init/quit time functions, as they are no longer needed.
2024-05-08 15:35:04 -04:00
Sam Lantinga aecb62e30d Improved API consistency for flag data types
Flag data types are always unsigned and have the valid values following the typedef.
2024-05-07 12:24:37 -07:00
Anonymous Maarten 9aff68746f cmake: add khronos include directories with PRIVATE visibility 2024-05-07 17:37:21 +02:00
Susko3 56feecc17d
Fix property cleanup callback not being called on error (#9663)
The documentation for `SDL_SetPropertyWithCleanup` mentions that the cleanup function
is called upon failure. But this wasn't working in the code.
2024-05-06 14:50:28 -07:00
Petar Popovic 45ac1a09d9 System dependent 64 bit integer suffixes
Added macros SDL_SINT64_C() and SDL_UINT64_C().
Integer suffixes of SDL_MAX_SINT64, SDL_MIN_SINT64, SDL_MAX_UINT64
and SDL_MIN_UINT64 are now system dependent.
2024-05-06 09:08:49 -07:00
Frank Praznik 3979ea8ed0 tests: Add a pointer warp test to testmouse
Press 'c' to center the pointer in the window using relative coordinates via SDL_WarpMouseInWindow().

Press alt+'c' to center the pointer in the window using global coordinates via SDL_WarpMouseGlobal().
2024-05-03 12:33:19 -04:00
Sam Lantinga 22016228ca Fixed build 2024-05-03 09:25:54 -07:00
Sam Lantinga db43a6b418 testcamera: open the camera using the highest framerate available 2024-05-02 12:27:20 -07:00
Sam Lantinga e6e1412e20 testcamera: create the texture as a streaming texture, since we'll update it every frame.
Also set the window size to the camera texture size
2024-05-02 11:40:28 -07:00
Semphris b9d3d746a0 Add trailing path separator to SDL_GetUserFolder() 2024-04-30 18:01:16 -07:00
Semphris c6a70d6898 Add support for modal windows to more platforms
- Adds support for modal windows to Win32, Mac, and Haiku, and enhances functionality on Wayland and X11, which previous set only the parent window, but not the modal state.
- Windows can be declared modal at creation time, and the modal state can be toggled at any time via SDL_SetWindowModalFor() (tested with UE5 through sdl2-compat).
- Allows dynamic unparenting/reparenting of windows.
- Includes a modal window test.
2024-04-30 13:47:57 -04:00
Sam Lantinga 0df12d223c Fixed crash cleaning up text
Text needs to be cleaned up before the renderer is freed.
2024-04-26 19:32:20 -07:00