Commit Graph

1992 Commits (0907f345cb36c77bfdcc9e9f9f2942ecb42824a2)

Author SHA1 Message Date
Sam Lantinga 0907f345cb Added property types: pointer, string, number, float 2023-11-12 10:48:38 -08:00
Christoph Reichenbach 7c80ac6df7 API for pressure-sensitive pens + XInput2/Wayland
This patch adds an API for querying pressure-
sensitive pens, cf. SDL_pen.h:
- Enumerate all pens
- Get pen capabilities, names, GUIDs
- Distinguishes pens and erasers
- Distinguish attached and detached pens
- Pressure and tilt support
- Rotation, distance, throttle wheel support
  (throttle wheel untested)
- Pen type and meta-information reporting
  (partially tested)

Pen event reporting:
- Three new event structures: PenTip, PenMotion, and
  PenButton
- Report location with sub-pixel precision
- Include axis and button status, is-eraser flag

Internal pen tracker, intended to be independent
of platform APIs, cf. SDL_pen_c.h:
- Track known pens
- Handle pen hotplugging

Automatic test:
- testautomation_pen.c

Other features:
- XInput2 implementation, incl. hotplugging
- Wayland implementation, incl. hotplugging
- Backward compatibility: pen events default to
  emulating pens with mouse ID SDL_PEN_MOUSEID
- Can be toggled via SDL_HINT_PEN_NOT_MOUSE
- Test/demo program (testpen)
- Wacom pen feature identification by pen ID

Acknowledgements:
- Ping Cheng (Wacom) provided extensive feedback
  on Wacom pen features and detection so that
  hopefully untested Wacom devices have a
  realistic chance of working out of the box.
2023-11-12 09:52:02 -08:00
Sam Lantinga d3e43668d0 Revert "Sync SDL3 wiki -> header"
This reverts commit 43571769f1.
2023-11-12 09:02:22 -08:00
SDL Wiki Bot 43571769f1 Sync SDL3 wiki -> header 2023-11-12 15:55:10 +00:00
Sam Lantinga b374105975 Replaced SDL_GetTextureDXGIResource() with texture properties
Fixes https://github.com/libsdl-org/SDL/issues/8529
2023-11-10 20:38:13 -08:00
Sam Lantinga 312faf9305 Updated documentation for the controller face buttons 2023-11-10 16:39:32 -08:00
Sam Lantinga 2991b9f6ac SDL now represents gamepad buttons as positional elements with a separate label
This gives applications and binding systems a clearer view of what the hardware is so they can make intelligent decisions about how to present things to the user.

Gamepad mappings continue to use abxy for the face buttons for simplicity and compatibility with earlier versions of SDL, however the "SDL_GAMECONTROLLER_USE_BUTTON_LABELS" hint no longer has any effect.

Fixes https://github.com/libsdl-org/SDL/issues/6117
2023-11-10 12:21:43 -08:00
Ryan C. Gordon aa7baf63aa
Sync wiki -> headers. 2023-11-09 20:11:23 -05:00
Sylvain 59f93e20a7 Add SDL Video Capture, with back-end for linux/macos/ios/android 2023-11-09 08:36:23 -08:00
Sam Lantinga 979214363f Added SDL_GetGlobalProperties()
We'll undoubtedly want to have global properties available
2023-11-08 12:01:48 -08:00
Sam Lantinga 151cdfa99f Added the "SDL.window.wayland.registry" property
Fixes https://github.com/libsdl-org/SDL/issues/8393
2023-11-08 12:01:48 -08:00
Sam Lantinga 6c91b28e71 Added the "SDL.renderer.d3d12.command_queue" property
Fixes https://github.com/libsdl-org/SDL/issues/8491
2023-11-08 12:01:48 -08:00
Sam Lantinga fd4a2cce9e SDL_syswm.h has been removed and replaced with window properties 2023-11-08 12:01:48 -08:00
Sam Lantinga aea6e6de6f Simplified SDL_SetProperty() and added SDL_SetPropertyWithCleanup()
Most of the time people won't need to set a cleanup callback, so we can simplify the more commonly used API.
2023-11-08 12:01:48 -08:00
Sam Lantinga a1941fad6c Replaced SDL_RenderGetD3D11Device(), SDL_RenderGetD3D12Device(), and SDL_RenderGetD3D9Device() with renderer properties. 2023-11-08 12:01:48 -08:00
Sam Lantinga 0cd4b7d3e3 Added display properties 2023-11-08 12:01:48 -08:00
Sam Lantinga 8668943746 Standardized property names for internal SDL properties 2023-11-08 12:01:48 -08:00
Sam Lantinga b5057edf29 Remove unused SDL_TextureModulate enum
Fixes https://github.com/libsdl-org/SDL/issues/6387
2023-11-07 09:23:26 -08:00
Sam Lantinga 9458cbf75e Removed unused SDL_OSEvent 2023-11-07 09:14:35 -08:00
Frank Praznik 1a57f6bb29 wayland: Remove QtWayland extensions
These were added a very long time ago and seem to serve no purpose now, as the functionality they provided is now in core Wayland protocols, current information on their usage and status is nonexistent, no modern compositor seems to support them, and the code paths are untested and subject to bit-rot at this point. It also causes duplicate symbol issues when statically linking an application to both Qt and SDL.
2023-11-07 11:00:32 -05:00
SDL Wiki Bot fccec65afe Sync SDL3 wiki -> header 2023-11-06 18:32:15 +00:00
Ryan C. Gordon 2f92807087
vulkan: SDL_Vulkan_CreateSurface now accepts an app-provided allocator.
Fixes #3638.
2023-11-06 13:31:20 -05:00
Ryan C. Gordon c53843a961
docs: Remove Doxygen `\brief` tags.
Doxygen and the wiki bridge don't need them; they'll both just use the first
line/sentence instead.

Fixes #8446.
2023-11-06 10:26:06 -05:00
Ozkan Sezer c132295ad7 SDL_FlushEventMemory is not a public procedure. 2023-11-06 17:40:56 +03:00
Ryan C. Gordon 7ac281f800
Sync wiki -> headers. 2023-11-06 09:33:05 -05:00
Sam Lantinga f7d40b7594 Added 10-bit pixel formats in addition to SDL_PIXELFORMAT_ARGB2101010
Added SDL_PIXELFORMAT_XRGB2101010, SDL_PIXELFORMAT_XBGR2101010, SDL_PIXELFORMAT_ABGR2101010

Fixes https://github.com/libsdl-org/SDL/issues/3553
2023-11-06 00:41:09 -08:00
Sam Lantinga 04dfca958a Added a note to events indicating that memory is owned by SDL 2023-11-05 21:25:43 -08:00
Sam Lantinga 70c149c88f Automatically clean up memory associated with events 2023-11-05 09:14:11 -08:00
Sam Lantinga d3f2eb2aba Use XINPUT_STATE instead of XINPUT_STATE_EX (thanks Andrew!)
XINPUT_STATE_EX isn't actually a thing, we can just use the normal XINPUT_STATE

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

(cherry picked from commit e8f4045d0bccacbf8f4b716d0dde17140e9f2cc4)
2023-11-04 22:28:09 -07:00
Sam Lantinga 75ea3a8d32 Dynamically allocate long text for SDL_EVENT_TEXT_INPUT events
This prevents input text from being split across Unicode combining or modifier characters, and in practice allocations will rarely happen.
2023-11-04 20:55:10 -07:00
Sam Lantinga 2a1660ab51 Additional cleanup for SDL_RWprintf() (thanks @sezero!) 2023-11-04 20:47:08 -07:00
Ryan C. Gordon e5f2cea234
Sync wiki -> headers 2023-11-04 22:18:38 -04:00
Sam Lantinga ad842dd5ad Fixed a typo in SDL_log.h 2023-11-04 16:46:08 -07:00
Sam Lantinga f9d11807c0 Added SDL_RWprintf() and SDL_RWvprintf() to do formatted printing to an SDL_rwops stream
Fixes https://github.com/libsdl-org/SDL/issues/2390
2023-11-04 16:46:08 -07:00
Sam Lantinga 91f0456391 Add the source application for drag and drop events (thanks Nathan!)
This is only implemented on iOS, but is useful for third party application integrations.

Fixes https://github.com/libsdl-org/SDL/issues/2024
2023-11-04 13:00:41 -07:00
Ryan C. Gordon 1a8bf31a69 include: Fixing whitespace on SDL_MixAudioFormat. 2023-11-04 15:06:41 -04:00
Sam Lantinga d07a264a9b Use the default UCS2/UCS4 conversion rather than non-portable INTERNAL encoding
Fxies https://github.com/libsdl-org/SDL/issues/1497
2023-11-04 12:01:30 -07:00
Sam Lantinga ad9dcdbbce Clarify that you should use the other field when reading the event 2023-11-04 09:58:35 -07:00
Ryan C. Gordon a19029e3c1
docs: Updated README-main-functions.md based on feedback. 2023-11-04 10:03:10 -04:00
Sam Lantinga 7e445da569 Added SDL_CleanupEvent()
This is used to free any dynamically allocated memory in events.
2023-11-04 06:47:24 -07:00
SDL Wiki Bot 3ab6670cb1 Sync SDL3 wiki -> header 2023-11-04 05:36:15 +00:00
Sam Lantinga f439ccfc1a Updated return values for SDL event functions
SDL_PollEvent(), SDL_WaitEvent(), and SDL_WaitEventTimeout() all return SDL_bool.
SDL_AddEventWatch() returns an int result code.

Also improved timeout accuracy in SDL_WaitEventTimeout()
2023-11-03 22:31:42 -07:00
Sam Lantinga a76d8e39aa Changed SDL_bool from an enum to unsigned int
Fixes https://github.com/libsdl-org/SDL/issues/7957
2023-11-03 09:54:04 -07:00
Ryan C. Gordon 70d75b4a23
Sync wiki -> headers 2023-11-03 10:13:46 -04:00
Ryan C. Gordon 07a776f255
include: Fixed documentation for SDL_Vulkan_GetInstanceExtensions. 2023-11-02 15:12:24 -04:00
ilyas-taouaou 9224a0a2d8 Fix emscripten, android, uikit and windows 2023-11-02 14:27:36 -04:00
ilyas-taouaou d0d8b28df1 Change SDL_Vulkan_GetInstanceExtensions 2023-11-02 14:27:36 -04:00
Ryan C. Gordon 9c664b0062
main: Added _optional_ callback entry points.
This lets apps optionally have a handful of callbacks for their entry points instead of a single main function. If used, the actual main/SDL_main/whatever entry point will be implemented in the single-header library SDL_main.h and the app will implement four separate functions:

First:

    int SDL_AppInit(int argc, char **argv);

This will be called once before anything else. argc/argv work like they always do. If this returns 0, the app runs. If it returns < 0, the app calls SDL_AppQuit and terminates with an exit code that reports an error to the platform. If it returns > 0, the app calls SDL_AppQuit and terminates with an exit code that reports success to the platform. This function should not go into an infinite mainloop; it should do any one-time startup it requires and then return.

Then:

     int SDL_AppIterate(void);

This is called over and over, possibly at the refresh rate of the display or some other metric that the platform dictates. This is where the heart of your app runs. It should return as quickly as reasonably possible, but it's not a "run one memcpy and that's all the time you have" sort of thing. The app should do any game updates, and render a frame of video. If it returns < 0, SDL will call SDL_AppQuit and terminate the process with an exit code that reports an error to the platform. If it returns > 0, the app calls SDL_AppQuit and terminates with an exit code that reports success to the platform. If it returns 0, then SDL_AppIterate will be called again at some regular frequency. The platform may choose to run this more or less (perhaps less in the background, etc), or it might just call this function in a loop as fast as possible. You do not check the event queue in this function (SDL_AppEvent exists for that).

Next:

    int SDL_AppEvent(const SDL_Event *event);

This will be called once for each event pushed into the SDL queue. This may be called from any thread, and possibly in parallel to SDL_AppIterate. The fields in event do not need to be free'd (as you would normally need to do for SDL_EVENT_DROP_FILE, etc), and your app should not call SDL_PollEvent, SDL_PumpEvent, etc, as SDL will manage this for you. Return values are the same as from SDL_AppIterate(), so you can terminate in response to SDL_EVENT_QUIT, etc.

Finally:

    void SDL_AppQuit(void);

This is called once before terminating the app--assuming the app isn't being forcibly killed or crashed--as a last chance to clean up. After this returns, SDL will call SDL_Quit so the app doesn't have to (but it's safe for the app to call it, too). Process termination proceeds as if the app returned normally from main(), so atexit handles will run, if your platform supports that.

The app does not implement SDL_main if using this. To turn this on, define SDL_MAIN_USE_CALLBACKS before including SDL_main.h. Defines like SDL_MAIN_HANDLED and SDL_MAIN_NOIMPL are also respected for callbacks, if the app wants to do some sort of magic main implementation thing.

In theory, on most platforms these can be implemented in the app itself, but this saves some #ifdefs in the app and lets everyone struggle less against some platforms, and might be more efficient in the long run, too.

On some platforms, it's possible this is the only reasonable way to go, but we haven't actually hit one that 100% requires it yet (but we will, if we want to write a RetroArch backend, for example).

Using the callback entry points works on every platform, because on platforms that don't require them, we can fake them with a simple loop in an internal implementation of the usual SDL_main.

The primary way we expect people to write SDL apps is with SDL_main, and this is not intended to replace it. If the app chooses to use this, it just removes some platform-specific details they might have to otherwise manage, and maybe removes a barrier to entry on some future platform.

Fixes #6785.
Reference PR #8247.
2023-11-01 18:40:41 -04:00
Anonymous Maarten 6127ac0871 Use SDL_DISABLE_ALLOCA instead of HAVE_ALLOCA in SDL_stdinc.h 2023-10-28 18:54:12 +02:00
SDL Wiki Bot 2e9eb1073d Sync SDL3 wiki -> header 2023-10-26 18:23:13 +00:00