Compare commits

24 Commits

Author SHA1 Message Date
653bb7dc76 treballant en ServiceMenu 2025-05-30 13:59:25 +02:00
f661da5215 tots els singletons tornats a fer a la vieja y gorda usanza 2025-05-30 10:17:41 +02:00
64b6f66044 ja va amb lo de friend pero no se perque 2025-05-29 14:04:17 +02:00
2c2685f73c passant Asset a singleton de tota la vida 2025-05-29 13:39:53 +02:00
5fd987c6a1 commit de merda pa llevar la branch 2025-05-29 12:25:19 +02:00
0fc8224ef8 revisió de capçaleres 2025-05-29 09:58:23 +02:00
677e4d465d reestructurat background, balloon_formations i balloon_manager 2025-05-27 13:58:51 +02:00
ada141cb09 convertit Asset i Audio 2025-05-27 11:06:17 +02:00
9bc07b2bcb Limitat el nom a tres caracters 2025-05-27 07:44:50 +02:00
a3cd1b9887 eliminat OnScreenHelp 2025-05-22 09:07:07 +02:00
d2417f48d9 treballant en la classe Audio 2025-03-28 23:27:33 +01:00
31a0ad6fd5 per alguna rao, la tecla F12 en VSC en windows en una sesió de debug em penja el programa, per tant Screen::renderInfoDebug funciona correctament 2025-03-28 17:43:24 +01:00
1db80485a6 resolt bug en jail_audio
treballant en Screen::renderInfo() deixa el programa congelat
2025-03-28 17:23:08 +01:00
25cd6b00eb afegida tecla per activar o desactivar el vsync 2025-03-28 08:38:28 +01:00
11d015daf8 afegit SDL_ScaleMode scale_mode a VideoOptions 2025-03-27 21:20:45 +01:00
36b3048070 acabat amb SDL_Log 2025-03-27 20:56:21 +01:00
8afca398e9 Passant std::cout a SDL_Log 2025-03-27 19:57:30 +01:00
c6288918b2 ja funciona el audio 2025-03-27 18:34:04 +01:00
e2339bd54a actualitzada la versio de jail_audio
modificat SDL_Init a SDL_Init(SDL_INIT_VIDEO || SDL_INIT_AUDIO || SDL_INIT_GAMEPAD)
2025-03-27 13:15:04 +01:00
2edb978a28 migrant a SDL3 2025-03-27 09:43:19 +01:00
d2286905dc migrant a SDL3 2025-03-27 08:14:37 +01:00
a9c869baf6 migrant a SDL3 2025-03-25 20:26:45 +01:00
f1b0303474 migrant a SDL3 2025-03-25 14:13:58 +01:00
9cc41aaf53 arreglat makefile, info.plist i sdl.frameworks per a compilar en macos intel 2025-03-25 11:42:23 +01:00
177 changed files with 8849 additions and 9105 deletions

View File

@@ -1,88 +1,64 @@
# CMakeLists.txt # CMakeLists.txt
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.10)
project(coffee_crisis_arcade_edition VERSION 0.01) project(coffee_crisis_arcade_edition VERSION 2.00)
# Establece las políticas # Establece las políticas
cmake_policy(SET CMP0072 NEW) cmake_policy(SET CMP0072 NEW)
# Configuración de compilador para MinGW en Windows, si es necesario
if(WIN32 AND NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(CMAKE_CXX_COMPILER "g++")
set(CMAKE_C_COMPILER "gcc")
endif()
# Establecer estándar de C++ # Establecer estándar de C++
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_CXX_STANDARD_REQUIRED True)
# Configuración global de flags de compilación # Cargar todos los archivos fuente directamente desde el directorio
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") file(GLOB SOURCES "${CMAKE_SOURCE_DIR}/source/*.cpp")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os -ffunction-sections -fdata-sections")
# Define el directorio de los archivos fuente
set(DIR_SOURCES "${CMAKE_SOURCE_DIR}/source")
# Cargar todos los archivos fuente en DIR_SOURCES
file(GLOB SOURCES "${DIR_SOURCES}/*.cpp")
# Verificar si se encontraron archivos fuente # Verificar si se encontraron archivos fuente
if(NOT SOURCES) if(NOT SOURCES)
message(FATAL_ERROR "No se encontraron archivos fuente en ${DIR_SOURCES}. Verifica que el directorio existe y contiene archivos .cpp.") message(FATAL_ERROR "No se encontraron archivos fuente en ${CMAKE_SOURCE_DIR}/source. Verifica que el directorio existe y contiene archivos .cpp.")
endif() endif()
# Configuración de SDL2 # Configuración de SDL3 (usando el método recomendado)
find_package(SDL2 REQUIRED) find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3)
if(SDL2_FOUND) message(STATUS "SDL3 encontrado: ${SDL3_INCLUDE_DIRS}")
message(STATUS "SDL2 encontrado: ${SDL2_INCLUDE_DIRS}")
include_directories(${SDL2_INCLUDE_DIRS})
link_directories(${SDL2_LIBDIR})
else()
message(FATAL_ERROR "SDL2 no encontrado")
endif()
# Incluye rutas de SDL2 obtenidas con pkg-config
include_directories(/usr/local/include /usr/local/include/SDL2)
link_directories(/usr/local/lib)
# Definir las bibliotecas comunes
set(LIBS SDL2)
# Configuración común de salida de ejecutables en el directorio raíz
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
# Añadir ejecutable principal # Añadir ejecutable principal
add_executable(${PROJECT_NAME} ${SOURCES}) add_executable(${PROJECT_NAME} ${SOURCES})
# Añadir definiciones de compilación dependiendo del tipo de build # Configuración de flags de compilación
target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<CONFIG:DEBUG>:DEBUG VERBOSE>) target_compile_options(${PROJECT_NAME} PRIVATE -Wall)
target_compile_options(${PROJECT_NAME} PRIVATE $<$<CONFIG:RELEASE>:-Os -ffunction-sections -fdata-sections>)
# Enlazar bibliotecas # Definir _DEBUG en modo Debug
target_link_libraries(${PROJECT_NAME} ${LIBS}) target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<CONFIG:DEBUG>:DEBUG>)
# Enlazar la librería SDL3
target_link_libraries(${PROJECT_NAME} PRIVATE SDL3::SDL3)
# Configuración específica para cada plataforma # Configuración específica para cada plataforma
if(WIN32) if(WIN32)
target_compile_definitions(${PROJECT_NAME} PRIVATE WINDOWS_BUILD) target_compile_definitions(${PROJECT_NAME} PRIVATE WINDOWS_BUILD)
target_link_libraries(${PROJECT_NAME} mingw32 opengl32 gdi32 winmm imm32 ole32 version) target_link_libraries(${PROJECT_NAME} PRIVATE ws2_32 mingw32 opengl32)
elseif(APPLE) elseif(APPLE)
set(LIBS ${LIBS} "-framework OpenGL")
target_compile_definitions(${PROJECT_NAME} PRIVATE MACOS_BUILD) target_compile_definitions(${PROJECT_NAME} PRIVATE MACOS_BUILD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") target_compile_options(${PROJECT_NAME} PRIVATE -Wno-deprecated)
# Configurar compilación para Apple Silicon
set(CMAKE_OSX_ARCHITECTURES "arm64") set(CMAKE_OSX_ARCHITECTURES "arm64")
elseif(UNIX AND NOT APPLE) elseif(UNIX AND NOT APPLE)
set(LIBS ${LIBS} GL)
target_compile_definitions(${PROJECT_NAME} PRIVATE LINUX_BUILD) target_compile_definitions(${PROJECT_NAME} PRIVATE LINUX_BUILD)
target_link_libraries(${PROJECT_NAME} ${LIBS})
endif() endif()
# Añadir OpenGL a las bibliotecas enlazadas # Configuración común para OpenGL (excepto en Windows, ya configurado)
if(NOT WIN32) if(NOT WIN32)
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
if(OPENGL_FOUND) if(OPENGL_FOUND)
message(STATUS "OpenGL encontrado: ${OPENGL_LIBRARIES}") message(STATUS "OpenGL encontrado: ${OPENGL_LIBRARIES}")
target_link_libraries(${PROJECT_NAME} ${OPENGL_LIBRARIES}) target_link_libraries(${PROJECT_NAME} PRIVATE ${OPENGL_LIBRARIES})
else() else()
message(FATAL_ERROR "OpenGL no encontrado") message(FATAL_ERROR "OpenGL no encontrado")
endif() endif()
endif() endif()
# Configuración común de salida de ejecutables en el directorio raíz
#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
# Especificar la ubicación del ejecutable (en la raíz del proyecto)
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})

View File

@@ -29,16 +29,15 @@ ifeq ($(OS),Windows_NT)
SOURCES := source/*.cpp SOURCES := source/*.cpp
CXXFLAGS := -std=c++20 -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows CXXFLAGS := -std=c++20 -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows
CXXFLAGS_DEBUG := -std=c++20 -Wall -g CXXFLAGS_DEBUG := -std=c++20 -Wall -g
LDFLAGS := -lmingw32 -lws2_32 -lSDL2main -lSDL2 -lopengl32 LDFLAGS := -lmingw32 -lws2_32 -lSDL3 -lopengl32
RM := del /Q RM := del /Q
MKDIR := mkdir MKDIR := mkdir
else else
FixPath = $1 FixPath = $1
SOURCES := $(shell find $(DIR_SOURCES) -name '*.cpp')
SOURCES := source/*.cpp SOURCES := source/*.cpp
CXXFLAGS := -std=c++20 -Wall -Os -ffunction-sections -fdata-sections CXXFLAGS := -std=c++20 -Wall -Os -ffunction-sections -fdata-sections
CXXFLAGS_DEBUG := -std=c++20 -Wall -g CXXFLAGS_DEBUG := -std=c++20 -Wall -g
LDFLAGS := -lSDL2 LDFLAGS := -lSDL3
RMFILE := rm -f RMFILE := rm -f
RMDIR := rm -rdf RMDIR := rm -rdf
MKDIR := mkdir -p MKDIR := mkdir -p
@@ -128,16 +127,24 @@ macos_release:
ln -s /Applications "$(RELEASE_FOLDER)"/Applications ln -s /Applications "$(RELEASE_FOLDER)"/Applications
# Compila la versión para procesadores Intel # Compila la versión para procesadores Intel
$(CXX) $(SOURCES) -D MACOS_BUNDLE $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)" -rpath @executable_path/../Frameworks/ -target x86_64-apple-macos10.12 ifdef ENABLE_MACOS_X86_64
$(CXX) $(SOURCES) -D MACOS_BUNDLE $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)" -rpath @executable_path/../Frameworks/ -target x86_64-apple-macos10.15
# Firma la aplicación
codesign --deep --force --sign - --timestamp=none "$(RELEASE_FOLDER)/$(APP_NAME).app"
# Empaqueta el .dmg de la versión Intel # Empaqueta el .dmg de la versión Intel
hdiutil create tmp.dmg -ov -volname "$(APP_NAME)" -fs HFS+ -srcfolder "$(RELEASE_FOLDER)" hdiutil create tmp.dmg -ov -volname "$(APP_NAME)" -fs HFS+ -srcfolder "$(RELEASE_FOLDER)"
hdiutil convert tmp.dmg -format UDZO -o "$(MACOS_INTEL_RELEASE)" hdiutil convert tmp.dmg -format UDZO -o "$(MACOS_INTEL_RELEASE)"
$(RMFILE) tmp.dmg $(RMFILE) tmp.dmg
endif
# Compila la versión para procesadores Apple Silicon # Compila la versión para procesadores Apple Silicon
$(CXX) $(SOURCES) -D MACOS_BUNDLE -D SDL_DISABLE_IMMINTRIN_H $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)" -rpath @executable_path/../Frameworks/ -target arm64-apple-macos11 $(CXX) $(SOURCES) -D MACOS_BUNDLE -D SDL_DISABLE_IMMINTRIN_H $(CXXFLAGS) $(LDFLAGS) -o "$(RELEASE_FOLDER)/$(APP_NAME).app/Contents/MacOS/$(TARGET_NAME)" -rpath @executable_path/../Frameworks/ -target arm64-apple-macos11
# Firma la aplicación
codesign --deep --force --sign - --timestamp=none "$(RELEASE_FOLDER)/$(APP_NAME).app"
# Empaqueta el .dmg de la versión Apple Silicon # Empaqueta el .dmg de la versión Apple Silicon
hdiutil create tmp.dmg -ov -volname "$(APP_NAME)" -fs HFS+ -srcfolder "$(RELEASE_FOLDER)" hdiutil create tmp.dmg -ov -volname "$(APP_NAME)" -fs HFS+ -srcfolder "$(RELEASE_FOLDER)"
hdiutil convert tmp.dmg -format UDZO -o "$(MACOS_APPLE_SILICON_RELEASE)" hdiutil convert tmp.dmg -format UDZO -o "$(MACOS_APPLE_SILICON_RELEASE)"

View File

@@ -40,9 +40,10 @@ El joc està optimitzat per a ser jugat amb un mando de jocs, encara que un dels
| **F3** | Alterna entre mode de pantalla completa i finestra | | **F3** | Alterna entre mode de pantalla completa i finestra |
| **F4** | Activa o desactiva el filtre de pantalla | | **F4** | Activa o desactiva el filtre de pantalla |
| **F5** | Activa o desactiva el mode d'escalat sencer | | **F5** | Activa o desactiva el mode d'escalat sencer |
| **F6** | Activa o desactiva l'àudio | | **F6** | Activa o desactiva el sincronisme vertical |
| **F7** | Activa o desactiva el dispar automàtic | | **F7** | Activa o desactiva l'àudio |
| **F8** | Canvia l'idioma del joc (Provoca el reinici) | | **F8** | Activa o desactiva el dispar automàtic |
| **F9** | Canvia l'idioma del joc (Provoca el reinici) |
| **F10** | Reinicia el joc | | **F10** | Reinicia el joc |
<p align="center"> <p align="center">

View File

@@ -404,4 +404,7 @@ Mode pantalla completa
Mode d'escalat sencer Mode d'escalat sencer
## 135 - VARIOS ## 135 - VARIOS
Filtre Filtre
## 136 - VARIOS
Sincronisme vertical

View File

@@ -404,4 +404,7 @@ Fullscreen mode
Integer scale Integer scale
## 135 - VARIOS ## 135 - VARIOS
Filter Filter
## 136 - VARIOS
Vertical Sync

View File

@@ -404,4 +404,7 @@ Modo pantalla completa
Modo de escalado entero Modo de escalado entero
## 135 - VARIOS ## 135 - VARIOS
Filtro Filtro
## 136 - VARIOS
Sincronismo vertical

View File

@@ -5,9 +5,9 @@
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>es</string> <string>es</string>
<key>CFBundleDisplayName</key> <key>CFBundleDisplayName</key>
<string>coffee_crisis arcade edition</string> <string>coffee_crisis_arcade_edition</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>coffee_crisis</string> <string>coffee_crisis_arcade_edition</string>
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>icon</string> <string>icon</string>
<key>CFBundleIconName</key> <key>CFBundleIconName</key>
@@ -29,7 +29,7 @@
<key>CSResourcesFileMapped</key> <key>CSResourcesFileMapped</key>
<true/> <true/>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>10.12</string> <string>10.15</string>
<key>NSHighResolutionCapable</key> <key>NSHighResolutionCapable</key>
<true/> <true/>
<key>NSHumanReadableCopyright</key> <key>NSHumanReadableCopyright</key>

View File

@@ -1 +0,0 @@
Versions/Current/Headers

View File

@@ -0,0 +1 @@
Versions/Current/Headers

View File

@@ -1 +0,0 @@
Versions/Current/Resources

View File

@@ -0,0 +1 @@
Versions/Current/Resources

View File

@@ -1 +0,0 @@
Versions/Current/SDL2

1
release/SDL2.framework/SDL2 Symbolic link
View File

@@ -0,0 +1 @@
Versions/Current/SDL2

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -25,7 +25,6 @@
* Main include header for the SDL library * Main include header for the SDL library
*/ */
#ifndef SDL_h_ #ifndef SDL_h_
#define SDL_h_ #define SDL_h_
@@ -70,6 +69,8 @@
extern "C" { extern "C" {
#endif #endif
/* WIKI CATEGORY: Init */
/* As of version 0.5, SDL is loaded dynamically into the application */ /* As of version 0.5, SDL is loaded dynamically into the application */
/** /**
@@ -130,7 +131,7 @@ extern "C" {
* call SDL_Quit() to force shutdown). If a subsystem is already loaded then * call SDL_Quit() to force shutdown). If a subsystem is already loaded then
* this call will increase the ref-count and return. * this call will increase the ref-count and return.
* *
* \param flags subsystem initialization flags * \param flags subsystem initialization flags.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -61,6 +61,8 @@ assert can have unique static variables associated with it.
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #22\n\t" ) #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #22\n\t" )
#elif defined(__APPLE__) && defined(__arm__) #elif defined(__APPLE__) && defined(__arm__)
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "bkpt #22\n\t" ) #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "bkpt #22\n\t" )
#elif defined(_WIN32) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__arm64__) || defined(__aarch64__)) )
#define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #0xF000\n\t" )
#elif defined(__386__) && defined(__WATCOMC__) #elif defined(__386__) && defined(__WATCOMC__)
#define SDL_TriggerBreakpoint() { _asm { int 0x03 } } #define SDL_TriggerBreakpoint() { _asm { int 0x03 } }
#elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__) #elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__)
@@ -191,8 +193,8 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
* A callback that fires when an SDL assertion fails. * A callback that fires when an SDL assertion fails.
* *
* \param data a pointer to the SDL_AssertData structure corresponding to the * \param data a pointer to the SDL_AssertData structure corresponding to the
* current assertion * current assertion.
* \param userdata what was passed as `userdata` to SDL_SetAssertionHandler() * \param userdata what was passed as `userdata` to SDL_SetAssertionHandler().
* \returns an SDL_AssertState value indicating how to handle the failure. * \returns an SDL_AssertState value indicating how to handle the failure.
*/ */
typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)( typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)(
@@ -212,8 +214,8 @@ typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)(
* This callback is NOT reset to SDL's internal handler upon SDL_Quit()! * This callback is NOT reset to SDL's internal handler upon SDL_Quit()!
* *
* \param handler the SDL_AssertionHandler function to call when an assertion * \param handler the SDL_AssertionHandler function to call when an assertion
* fails or NULL for the default handler * fails or NULL for the default handler.
* \param userdata a pointer that is passed to `handler` * \param userdata a pointer that is passed to `handler`.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -254,7 +256,7 @@ extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void
* data, it is safe to pass a NULL pointer to this function to ignore it. * data, it is safe to pass a NULL pointer to this function to ignore it.
* *
* \param puserdata pointer which is filled with the "userdata" pointer that * \param puserdata pointer which is filled with the "userdata" pointer that
* was passed to SDL_SetAssertionHandler() * was passed to SDL_SetAssertionHandler().
* \returns the SDL_AssertionHandler that is called when an assert triggers. * \returns the SDL_AssertionHandler that is called when an assert triggers.
* *
* \since This function is available since SDL 2.0.2. * \since This function is available since SDL 2.0.2.

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,38 +20,29 @@
*/ */
/** /**
* \file SDL_atomic.h * # CategoryAtomic
* *
* Atomic operations. * Atomic operations.
* *
* IMPORTANT: * IMPORTANT: If you are not an expert in concurrent lockless programming, you
* If you are not an expert in concurrent lockless programming, you should * should not be using any functions in this file. You should be protecting
* only be using the atomic lock and reference counting functions in this * your data structures with full mutexes instead.
* file. In all other cases you should be protecting your data structures
* with full mutexes.
* *
* The list of "safe" functions to use are: * ***Seriously, here be dragons!***
* SDL_AtomicLock()
* SDL_AtomicUnlock()
* SDL_AtomicIncRef()
* SDL_AtomicDecRef()
* *
* Seriously, here be dragons! * You can find out a little more about lockless programming and the subtle
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^ * issues that can arise here:
* * https://learn.microsoft.com/en-us/windows/win32/dxtecharts/lockless-programming
* You can find out a little more about lockless programming and the
* subtle issues that can arise here:
* http://msdn.microsoft.com/en-us/library/ee418650%28v=vs.85%29.aspx
* *
* There's also lots of good information here: * There's also lots of good information here:
* http://www.1024cores.net/home/lock-free-algorithms
* http://preshing.com/
* *
* These operations may or may not actually be implemented using * - https://www.1024cores.net/home/lock-free-algorithms
* processor specific atomic operations. When possible they are * - https://preshing.com/
* implemented as true processor specific atomic operations. When that *
* is not possible the are implemented using locks that *do* use the * These operations may or may not actually be implemented using processor
* available atomic operations. * specific atomic operations. When possible they are implemented as true
* processor specific atomic operations. When that is not possible the are
* implemented using locks that *do* use the available atomic operations.
* *
* All of the atomic operations that modify memory are full memory barriers. * All of the atomic operations that modify memory are full memory barriers.
*/ */
@@ -94,7 +85,7 @@ typedef int SDL_SpinLock;
* ***Please note that spinlocks are dangerous if you don't know what you're * ***Please note that spinlocks are dangerous if you don't know what you're
* doing. Please be careful using any sort of spinlock!*** * doing. Please be careful using any sort of spinlock!***
* *
* \param lock a pointer to a lock variable * \param lock a pointer to a lock variable.
* \returns SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already * \returns SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already
* held. * held.
* *
@@ -111,7 +102,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTryLock(SDL_SpinLock *lock);
* ***Please note that spinlocks are dangerous if you don't know what you're * ***Please note that spinlocks are dangerous if you don't know what you're
* doing. Please be careful using any sort of spinlock!*** * doing. Please be careful using any sort of spinlock!***
* *
* \param lock a pointer to a lock variable * \param lock a pointer to a lock variable.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -128,7 +119,7 @@ extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock);
* ***Please note that spinlocks are dangerous if you don't know what you're * ***Please note that spinlocks are dangerous if you don't know what you're
* doing. Please be careful using any sort of spinlock!*** * doing. Please be careful using any sort of spinlock!***
* *
* \param lock a pointer to a lock variable * \param lock a pointer to a lock variable.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -209,7 +200,7 @@ typedef void (*SDL_KernelMemoryBarrierFunc)();
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(__ARM_ARCH_8A__) #if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(__ARM_ARCH_8A__)
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory")
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory")
#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_5TE__) #elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__)
#ifdef __thumb__ #ifdef __thumb__
/* The mcr instruction isn't available in thumb mode, use real functions */ /* The mcr instruction isn't available in thumb mode, use real functions */
#define SDL_MEMORY_BARRIER_USES_FUNCTION #define SDL_MEMORY_BARRIER_USES_FUNCTION
@@ -257,10 +248,13 @@ typedef void (*SDL_KernelMemoryBarrierFunc)();
/** /**
* \brief A type representing an atomic integer value. It is a struct * A type representing an atomic integer value.
* so people don't accidentally use numeric operations on it. *
* It is a struct so people don't accidentally use numeric operations on it.
*/ */
typedef struct { int value; } SDL_atomic_t; typedef struct SDL_atomic_t {
int value;
} SDL_atomic_t;
/** /**
* Set an atomic variable to a new value if it is currently an old value. * Set an atomic variable to a new value if it is currently an old value.
@@ -268,9 +262,9 @@ typedef struct { int value; } SDL_atomic_t;
* ***Note: If you don't know what this function is for, you shouldn't use * ***Note: If you don't know what this function is for, you shouldn't use
* it!*** * it!***
* *
* \param a a pointer to an SDL_atomic_t variable to be modified * \param a a pointer to an SDL_atomic_t variable to be modified.
* \param oldval the old value * \param oldval the old value.
* \param newval the new value * \param newval the new value.
* \returns SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise. * \returns SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -289,8 +283,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int
* ***Note: If you don't know what this function is for, you shouldn't use * ***Note: If you don't know what this function is for, you shouldn't use
* it!*** * it!***
* *
* \param a a pointer to an SDL_atomic_t variable to be modified * \param a a pointer to an SDL_atomic_t variable to be modified.
* \param v the desired value * \param v the desired value.
* \returns the previous value of the atomic variable. * \returns the previous value of the atomic variable.
* *
* \since This function is available since SDL 2.0.2. * \since This function is available since SDL 2.0.2.
@@ -305,7 +299,7 @@ extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_atomic_t *a, int v);
* ***Note: If you don't know what this function is for, you shouldn't use * ***Note: If you don't know what this function is for, you shouldn't use
* it!*** * it!***
* *
* \param a a pointer to an SDL_atomic_t variable * \param a a pointer to an SDL_atomic_t variable.
* \returns the current value of an atomic variable. * \returns the current value of an atomic variable.
* *
* \since This function is available since SDL 2.0.2. * \since This function is available since SDL 2.0.2.
@@ -322,8 +316,8 @@ extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a);
* ***Note: If you don't know what this function is for, you shouldn't use * ***Note: If you don't know what this function is for, you shouldn't use
* it!*** * it!***
* *
* \param a a pointer to an SDL_atomic_t variable to be modified * \param a a pointer to an SDL_atomic_t variable to be modified.
* \param v the desired value to add * \param v the desired value to add.
* \returns the previous value of the atomic variable. * \returns the previous value of the atomic variable.
* *
* \since This function is available since SDL 2.0.2. * \since This function is available since SDL 2.0.2.
@@ -356,9 +350,9 @@ extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_atomic_t *a, int v);
* ***Note: If you don't know what this function is for, you shouldn't use * ***Note: If you don't know what this function is for, you shouldn't use
* it!*** * it!***
* *
* \param a a pointer to a pointer * \param a a pointer to a pointer.
* \param oldval the old pointer value * \param oldval the old pointer value.
* \param newval the new pointer value * \param newval the new pointer value.
* \returns SDL_TRUE if the pointer was set, SDL_FALSE otherwise. * \returns SDL_TRUE if the pointer was set, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -375,8 +369,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr(void **a, void *oldval, void *
* ***Note: If you don't know what this function is for, you shouldn't use * ***Note: If you don't know what this function is for, you shouldn't use
* it!*** * it!***
* *
* \param a a pointer to a pointer * \param a a pointer to a pointer.
* \param v the desired pointer value * \param v the desired pointer value.
* \returns the previous value of the pointer. * \returns the previous value of the pointer.
* *
* \since This function is available since SDL 2.0.2. * \since This function is available since SDL 2.0.2.
@@ -392,7 +386,7 @@ extern DECLSPEC void* SDLCALL SDL_AtomicSetPtr(void **a, void* v);
* ***Note: If you don't know what this function is for, you shouldn't use * ***Note: If you don't know what this function is for, you shouldn't use
* it!*** * it!***
* *
* \param a a pointer to a pointer * \param a a pointer to a pointer.
* \returns the current value of a pointer. * \returns the current value of a pointer.
* *
* \since This function is available since SDL 2.0.2. * \since This function is available since SDL 2.0.2.

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -22,9 +22,9 @@
/* !!! FIXME: several functions in here need Doxygen comments. */ /* !!! FIXME: several functions in here need Doxygen comments. */
/** /**
* \file SDL_audio.h * # CategoryAudio
* *
* Access to the raw audio mixing buffer for the SDL library. * Access to the raw audio mixing buffer for the SDL library.
*/ */
#ifndef SDL_audio_h_ #ifndef SDL_audio_h_
@@ -44,24 +44,24 @@ extern "C" {
#endif #endif
/** /**
* \brief Audio format flags. * Audio format flags.
* *
* These are what the 16 bits in SDL_AudioFormat currently mean... * These are what the 16 bits in SDL_AudioFormat currently mean...
* (Unspecified bits are always zero). * (Unspecified bits are always zero).
* *
* \verbatim * ```
++-----------------------sample is signed if set * ++-----------------------sample is signed if set
|| * ||
|| ++-----------sample is bigendian if set * || ++-----------sample is bigendian if set
|| || * || ||
|| || ++---sample is float if set * || || ++---sample is float if set
|| || || * || || ||
|| || || +---sample bit size---+ * || || || +---sample bit size---+
|| || || | | * || || || | |
15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 * 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
\endverbatim * ```
* *
* There are macros in SDL 2.0 and later to query these bits. * There are macros in SDL 2.0 and later to query these bits.
*/ */
typedef Uint16 SDL_AudioFormat; typedef Uint16 SDL_AudioFormat;
@@ -149,33 +149,30 @@ typedef Uint16 SDL_AudioFormat;
/* @} *//* Audio flags */ /* @} *//* Audio flags */
/** /**
* This function is called when the audio device needs more data. * This function is called when the audio device needs more data.
* *
* \param userdata An application-specific parameter saved in * \param userdata An application-specific parameter saved in the
* the SDL_AudioSpec structure * SDL_AudioSpec structure.
* \param stream A pointer to the audio data buffer. * \param stream A pointer to the audio data buffer.
* \param len The length of that buffer in bytes. * \param len Length of **stream** in bytes.
*
* Once the callback returns, the buffer will no longer be valid.
* Stereo samples are stored in a LRLRLR ordering.
*
* You can choose to avoid callbacks and use SDL_QueueAudio() instead, if
* you like. Just open your audio device with a NULL callback.
*/ */
typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream, typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream,
int len); int len);
/** /**
* The calculated values in this structure are calculated by SDL_OpenAudio(). * The calculated values in this structure are calculated by SDL_OpenAudio().
* *
* For multi-channel audio, the default SDL channel mapping is: * For multi-channel audio, the default SDL channel mapping is:
* 2: FL FR (stereo) *
* 3: FL FR LFE (2.1 surround) * ```
* 4: FL FR BL BR (quad) * 2: FL FR (stereo)
* 5: FL FR LFE BL BR (4.1 surround) * 3: FL FR LFE (2.1 surround)
* 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR) * 4: FL FR BL BR (quad)
* 7: FL FR FC LFE BC SL SR (6.1 surround) * 5: FL FR LFE BL BR (4.1 surround)
* 8: FL FR FC LFE BL BR SL SR (7.1 surround) * 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR)
* 7: FL FR FC LFE BC SL SR (6.1 surround)
* 8: FL FR FC LFE BL BR SL SR (7.1 surround)
* ```
*/ */
typedef struct SDL_AudioSpec typedef struct SDL_AudioSpec
{ {
@@ -196,11 +193,11 @@ typedef void (SDLCALL * SDL_AudioFilter) (struct SDL_AudioCVT * cvt,
SDL_AudioFormat format); SDL_AudioFormat format);
/** /**
* \brief Upper limit of filters in SDL_AudioCVT * Upper limit of filters in SDL_AudioCVT
* *
* The maximum number of SDL_AudioFilter functions in SDL_AudioCVT is * The maximum number of SDL_AudioFilter functions in SDL_AudioCVT is
* currently limited to 9. The SDL_AudioCVT.filters array has 10 pointers, * currently limited to 9. The SDL_AudioCVT.filters array has 10 pointers, one
* one of which is the terminating NULL pointer. * of which is the terminating NULL pointer.
*/ */
#define SDL_AUDIOCVT_MAX_FILTERS 9 #define SDL_AUDIOCVT_MAX_FILTERS 9
@@ -287,7 +284,7 @@ extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void);
* meant to be proper names. * meant to be proper names.
* *
* \param index the index of the audio driver; the value ranges from 0 to * \param index the index of the audio driver; the value ranges from 0 to
* SDL_GetNumAudioDrivers() - 1 * SDL_GetNumAudioDrivers() - 1.
* \returns the name of the audio driver at the requested index, or NULL if an * \returns the name of the audio driver at the requested index, or NULL if an
* invalid index was specified. * invalid index was specified.
* *
@@ -314,7 +311,7 @@ extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver(int index);
* specific need to designate the audio driver you want to use. You should * specific need to designate the audio driver you want to use. You should
* normally use SDL_Init() or SDL_InitSubSystem(). * normally use SDL_Init() or SDL_InitSubSystem().
* *
* \param driver_name the name of the desired audio driver * \param driver_name the name of the desired audio driver.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -408,13 +405,13 @@ extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired,
SDL_AudioSpec * obtained); SDL_AudioSpec * obtained);
/** /**
* SDL Audio Device IDs. * SDL Audio Device IDs.
* *
* A successful call to SDL_OpenAudio() is always device id 1, and legacy * A successful call to SDL_OpenAudio() is always device id 1, and legacy SDL
* SDL audio APIs assume you want this device ID. SDL_OpenAudioDevice() calls * audio APIs assume you want this device ID. SDL_OpenAudioDevice() calls
* always returns devices >= 2 on success. The legacy calls are good both * always returns devices >= 2 on success. The legacy calls are good both for
* for backwards compatibility and when you don't care about multiple, * backwards compatibility and when you don't care about multiple, specific,
* specific, or capture devices. * or capture devices.
*/ */
typedef Uint32 SDL_AudioDeviceID; typedef Uint32 SDL_AudioDeviceID;
@@ -452,7 +449,7 @@ typedef Uint32 SDL_AudioDeviceID;
* ``` * ```
* *
* \param iscapture zero to request playback devices, non-zero to request * \param iscapture zero to request playback devices, non-zero to request
* recording devices * recording devices.
* \returns the number of available devices exposed by the current driver or * \returns the number of available devices exposed by the current driver or
* -1 if an explicit list of devices can't be determined. A return * -1 if an explicit list of devices can't be determined. A return
* value of -1 does not necessarily mean an error condition. * value of -1 does not necessarily mean an error condition.
@@ -478,7 +475,7 @@ extern DECLSPEC int SDLCALL SDL_GetNumAudioDevices(int iscapture);
* invalid next time any of several other SDL functions are called. * invalid next time any of several other SDL functions are called.
* *
* \param index the index of the audio device; valid values range from 0 to * \param index the index of the audio device; valid values range from 0 to
* SDL_GetNumAudioDevices() - 1 * SDL_GetNumAudioDevices() - 1.
* \param iscapture non-zero to query the list of recording devices, zero to * \param iscapture non-zero to query the list of recording devices, zero to
* query the list of output devices. * query the list of output devices.
* \returns the name of the audio device at the requested index, or NULL on * \returns the name of the audio device at the requested index, or NULL on
@@ -504,11 +501,11 @@ extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index,
* count. * count.
* *
* \param index the index of the audio device; valid values range from 0 to * \param index the index of the audio device; valid values range from 0 to
* SDL_GetNumAudioDevices() - 1 * SDL_GetNumAudioDevices() - 1.
* \param iscapture non-zero to query the list of recording devices, zero to * \param iscapture non-zero to query the list of recording devices, zero to
* query the list of output devices. * query the list of output devices.
* \param spec The SDL_AudioSpec to be initialized by this function. * \param spec The SDL_AudioSpec to be initialized by this function.
* \returns 0 on success, nonzero on error * \returns 0 on success, nonzero on error.
* *
* \since This function is available since SDL 2.0.16. * \since This function is available since SDL 2.0.16.
* *
@@ -542,7 +539,7 @@ extern DECLSPEC int SDLCALL SDL_GetAudioDeviceSpec(int index,
* \param spec The SDL_AudioSpec to be initialized by this function. * \param spec The SDL_AudioSpec to be initialized by this function.
* \param iscapture non-zero to query the default recording device, zero to * \param iscapture non-zero to query the default recording device, zero to
* query the default output device. * query the default output device.
* \returns 0 on success, nonzero on error * \returns 0 on success, nonzero on error.
* *
* \since This function is available since SDL 2.24.0. * \since This function is available since SDL 2.24.0.
* *
@@ -594,7 +591,7 @@ extern DECLSPEC int SDLCALL SDL_GetDefaultAudioInfo(char **name,
* frames_ (with stereo output, two samples--left and right--would make a * frames_ (with stereo output, two samples--left and right--would make a
* single sample frame). This number should be a power of two, and may be * single sample frame). This number should be a power of two, and may be
* adjusted by the audio driver to a value more suitable for the hardware. * adjusted by the audio driver to a value more suitable for the hardware.
* Good values seem to range between 512 and 8096 inclusive, depending on * Good values seem to range between 512 and 4096 inclusive, depending on
* the application and CPU speed. Smaller values reduce latency, but can * the application and CPU speed. Smaller values reduce latency, but can
* lead to underflow if the application is doing heavy processing and cannot * lead to underflow if the application is doing heavy processing and cannot
* fill the audio buffer in time. Note that the number of sample frames is * fill the audio buffer in time. Note that the number of sample frames is
@@ -645,12 +642,12 @@ extern DECLSPEC int SDLCALL SDL_GetDefaultAudioInfo(char **name,
* driver-specific name as appropriate. NULL requests the most * driver-specific name as appropriate. NULL requests the most
* reasonable default device. * reasonable default device.
* \param iscapture non-zero to specify a device should be opened for * \param iscapture non-zero to specify a device should be opened for
* recording, not playback * recording, not playback.
* \param desired an SDL_AudioSpec structure representing the desired output * \param desired an SDL_AudioSpec structure representing the desired output
* format; see SDL_OpenAudio() for more information * format; see SDL_OpenAudio() for more information.
* \param obtained an SDL_AudioSpec structure filled in with the actual output * \param obtained an SDL_AudioSpec structure filled in with the actual output
* format; see SDL_OpenAudio() for more information * format; see SDL_OpenAudio() for more information.
* \param allowed_changes 0, or one or more flags OR'd together * \param allowed_changes 0, or one or more flags OR'd together.
* \returns a valid device ID that is > 0 on success or 0 on failure; call * \returns a valid device ID that is > 0 on success or 0 on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -712,7 +709,7 @@ extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void);
* Use this function to get the current audio state of an audio device. * Use this function to get the current audio state of an audio device.
* *
* \param dev the ID of an audio device previously opened with * \param dev the ID of an audio device previously opened with
* SDL_OpenAudioDevice() * SDL_OpenAudioDevice().
* \returns the SDL_AudioStatus of the specified audio device. * \returns the SDL_AudioStatus of the specified audio device.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -745,7 +742,7 @@ extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioDeviceStatus(SDL_AudioDevice
* *
* ...and is only useful if you used the legacy SDL_OpenAudio() function. * ...and is only useful if you used the legacy SDL_OpenAudio() function.
* *
* \param pause_on non-zero to pause, 0 to unpause * \param pause_on non-zero to pause, 0 to unpause.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -775,8 +772,8 @@ extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on);
* callback, you shouldn't pause the audio device, as it will lead to dropouts * callback, you shouldn't pause the audio device, as it will lead to dropouts
* in the audio playback. Instead, you should use SDL_LockAudioDevice(). * in the audio playback. Instead, you should use SDL_LockAudioDevice().
* *
* \param dev a device opened by SDL_OpenAudioDevice() * \param dev a device opened by SDL_OpenAudioDevice().
* \param pause_on non-zero to pause, 0 to unpause * \param pause_on non-zero to pause, 0 to unpause.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -841,14 +838,14 @@ extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev,
* SDL_LoadWAV("sample.wav", &spec, &buf, &len); * SDL_LoadWAV("sample.wav", &spec, &buf, &len);
* ``` * ```
* *
* \param src The data source for the WAVE data * \param src The data source for the WAVE data.
* \param freesrc If non-zero, SDL will _always_ free the data source * \param freesrc If non-zero, SDL will _always_ free the data source.
* \param spec An SDL_AudioSpec that will be filled in with the wave file's * \param spec An SDL_AudioSpec that will be filled in with the wave file's
* format details * format details.
* \param audio_buf A pointer filled with the audio data, allocated by the * \param audio_buf A pointer filled with the audio data, allocated by the
* function. * function.
* \param audio_len A pointer filled with the length of the audio data buffer * \param audio_len A pointer filled with the length of the audio data buffer
* in bytes * in bytes.
* \returns This function, if successfully called, returns `spec`, which will * \returns This function, if successfully called, returns `spec`, which will
* be filled with the audio data format of the wave source data. * be filled with the audio data format of the wave source data.
* `audio_buf` will be filled with a pointer to an allocated buffer * `audio_buf` will be filled with a pointer to an allocated buffer
@@ -874,8 +871,9 @@ extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src,
Uint32 * audio_len); Uint32 * audio_len);
/** /**
* Loads a WAV from a file. * Loads a WAV from a file.
* Compatibility convenience function. *
* Compatibility convenience function.
*/ */
#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \ #define SDL_LoadWAV(file, spec, audio_buf, audio_len) \
SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len) SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len)
@@ -888,7 +886,7 @@ extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src,
* this function with a NULL pointer. * this function with a NULL pointer.
* *
* \param audio_buf a pointer to the buffer created by SDL_LoadWAV() or * \param audio_buf a pointer to the buffer created by SDL_LoadWAV() or
* SDL_LoadWAV_RW() * SDL_LoadWAV_RW().
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -912,15 +910,16 @@ extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 * audio_buf);
* and then can call SDL_ConvertAudio() to complete the conversion. * and then can call SDL_ConvertAudio() to complete the conversion.
* *
* \param cvt an SDL_AudioCVT structure filled in with audio conversion * \param cvt an SDL_AudioCVT structure filled in with audio conversion
* information * information.
* \param src_format the source format of the audio data; for more info see * \param src_format the source format of the audio data; for more info see
* SDL_AudioFormat * SDL_AudioFormat.
* \param src_channels the number of channels in the source * \param src_channels the number of channels in the source.
* \param src_rate the frequency (sample-frames-per-second) of the source * \param src_rate the frequency (sample-frames-per-second) of the source.
* \param dst_format the destination format of the audio data; for more info * \param dst_format the destination format of the audio data; for more info
* see SDL_AudioFormat * see SDL_AudioFormat.
* \param dst_channels the number of channels in the destination * \param dst_channels the number of channels in the destination.
* \param dst_rate the frequency (sample-frames-per-second) of the destination * \param dst_rate the frequency (sample-frames-per-second) of the
* destination.
* \returns 1 if the audio filter is prepared, 0 if no conversion is needed, * \returns 1 if the audio filter is prepared, 0 if no conversion is needed,
* or a negative error code on failure; call SDL_GetError() for more * or a negative error code on failure; call SDL_GetError() for more
* information. * information.
@@ -991,12 +990,12 @@ typedef struct _SDL_AudioStream SDL_AudioStream;
/** /**
* Create a new audio stream. * Create a new audio stream.
* *
* \param src_format The format of the source audio * \param src_format The format of the source audio.
* \param src_channels The number of channels of the source audio * \param src_channels The number of channels of the source audio.
* \param src_rate The sampling rate of the source audio * \param src_rate The sampling rate of the source audio.
* \param dst_format The format of the desired audio output * \param dst_format The format of the desired audio output.
* \param dst_channels The number of channels of the desired audio output * \param dst_channels The number of channels of the desired audio output.
* \param dst_rate The sampling rate of the desired audio output * \param dst_rate The sampling rate of the desired audio output.
* \returns 0 on success, or -1 on error. * \returns 0 on success, or -1 on error.
* *
* \since This function is available since SDL 2.0.7. * \since This function is available since SDL 2.0.7.
@@ -1018,9 +1017,9 @@ extern DECLSPEC SDL_AudioStream * SDLCALL SDL_NewAudioStream(const SDL_AudioForm
/** /**
* Add data to be converted/resampled to the stream. * Add data to be converted/resampled to the stream.
* *
* \param stream The stream the audio data is being added to * \param stream The stream the audio data is being added to.
* \param buf A pointer to the audio data to add * \param buf A pointer to the audio data to add.
* \param len The number of bytes to write to the stream * \param len The number of bytes to write to the stream.
* \returns 0 on success, or -1 on error. * \returns 0 on success, or -1 on error.
* *
* \since This function is available since SDL 2.0.7. * \since This function is available since SDL 2.0.7.
@@ -1037,10 +1036,10 @@ extern DECLSPEC int SDLCALL SDL_AudioStreamPut(SDL_AudioStream *stream, const vo
/** /**
* Get converted/resampled data from the stream * Get converted/resampled data from the stream
* *
* \param stream The stream the audio is being requested from * \param stream The stream the audio is being requested from.
* \param buf A buffer to fill with audio data * \param buf A buffer to fill with audio data.
* \param len The maximum number of bytes to fill * \param len The maximum number of bytes to fill.
* \returns the number of bytes read from the stream, or -1 on error * \returns the number of bytes read from the stream, or -1 on error.
* *
* \since This function is available since SDL 2.0.7. * \since This function is available since SDL 2.0.7.
* *
@@ -1118,6 +1117,9 @@ extern DECLSPEC void SDLCALL SDL_AudioStreamClear(SDL_AudioStream *stream);
*/ */
extern DECLSPEC void SDLCALL SDL_FreeAudioStream(SDL_AudioStream *stream); extern DECLSPEC void SDLCALL SDL_FreeAudioStream(SDL_AudioStream *stream);
/**
* Maximum volume allowed in calls to SDL_MixAudio and SDL_MixAudioFormat.
*/
#define SDL_MIX_MAXVOLUME 128 #define SDL_MIX_MAXVOLUME 128
/** /**
@@ -1132,11 +1134,11 @@ extern DECLSPEC void SDLCALL SDL_FreeAudioStream(SDL_AudioStream *stream);
* ...where `format` is the obtained format of the audio device from the * ...where `format` is the obtained format of the audio device from the
* legacy SDL_OpenAudio() function. * legacy SDL_OpenAudio() function.
* *
* \param dst the destination for the mixed audio * \param dst the destination for the mixed audio.
* \param src the source audio buffer to be mixed * \param src the source audio buffer to be mixed.
* \param len the length of the audio buffer in bytes * \param len the length of the audio buffer in bytes.
* \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME * \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
* for full audio volume * for full audio volume.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -1165,13 +1167,13 @@ extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 * dst, const Uint8 * src,
* SDL_MixAudioFormat() is really only needed when you're mixing a single * SDL_MixAudioFormat() is really only needed when you're mixing a single
* audio stream with a volume adjustment. * audio stream with a volume adjustment.
* *
* \param dst the destination for the mixed audio * \param dst the destination for the mixed audio.
* \param src the source audio buffer to be mixed * \param src the source audio buffer to be mixed.
* \param format the SDL_AudioFormat structure representing the desired audio * \param format the SDL_AudioFormat structure representing the desired audio
* format * format.
* \param len the length of the audio buffer in bytes * \param len the length of the audio buffer in bytes.
* \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME * \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
* for full audio volume * for full audio volume.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
*/ */
@@ -1215,9 +1217,9 @@ extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst,
* from planar audio formats into a non-planar one (see SDL_AudioFormat) * from planar audio formats into a non-planar one (see SDL_AudioFormat)
* before queuing audio. * before queuing audio.
* *
* \param dev the device ID to which we will queue audio * \param dev the device ID to which we will queue audio.
* \param data the data to queue to the device for later playback * \param data the data to queue to the device for later playback.
* \param len the number of bytes (not samples!) to which `data` points * \param len the number of bytes (not samples!) to which `data` points.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -1263,9 +1265,9 @@ extern DECLSPEC int SDLCALL SDL_QueueAudio(SDL_AudioDeviceID dev, const void *da
* You should not call SDL_LockAudio() on the device before dequeueing; SDL * You should not call SDL_LockAudio() on the device before dequeueing; SDL
* handles locking internally for this function. * handles locking internally for this function.
* *
* \param dev the device ID from which we will dequeue audio * \param dev the device ID from which we will dequeue audio.
* \param data a pointer into where audio data should be copied * \param data a pointer into where audio data should be copied.
* \param len the number of bytes (not samples!) to which (data) points * \param len the number of bytes (not samples!) to which (data) points.
* \returns the number of bytes dequeued, which could be less than requested; * \returns the number of bytes dequeued, which could be less than requested;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
@@ -1299,7 +1301,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_DequeueAudio(SDL_AudioDeviceID dev, void *dat
* You should not call SDL_LockAudio() on the device before querying; SDL * You should not call SDL_LockAudio() on the device before querying; SDL
* handles locking internally for this function. * handles locking internally for this function.
* *
* \param dev the device ID of which we will query queued audio size * \param dev the device ID of which we will query queued audio size.
* \returns the number of bytes (not samples!) of queued audio. * \returns the number of bytes (not samples!) of queued audio.
* *
* \since This function is available since SDL 2.0.4. * \since This function is available since SDL 2.0.4.
@@ -1334,7 +1336,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetQueuedAudioSize(SDL_AudioDeviceID dev);
* *
* This function always succeeds and thus returns void. * This function always succeeds and thus returns void.
* *
* \param dev the device ID of which to clear the audio queue * \param dev the device ID of which to clear the audio queue.
* *
* \since This function is available since SDL 2.0.4. * \since This function is available since SDL 2.0.4.
* *
@@ -1406,7 +1408,7 @@ extern DECLSPEC void SDLCALL SDL_LockAudio(void);
* at once, not only will you block the audio callback, you'll block the other * at once, not only will you block the audio callback, you'll block the other
* thread. * thread.
* *
* \param dev the ID of the device to be locked * \param dev the ID of the device to be locked.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -1439,7 +1441,7 @@ extern DECLSPEC void SDLCALL SDL_UnlockAudio(void);
* *
* This function should be paired with a previous SDL_LockAudioDevice() call. * This function should be paired with a previous SDL_LockAudioDevice() call.
* *
* \param dev the ID of the device to be unlocked * \param dev the ID of the device to be unlocked.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -1481,7 +1483,7 @@ extern DECLSPEC void SDLCALL SDL_CloseAudio(void);
* The device ID is invalid as soon as the device is closed, and is eligible * The device ID is invalid as soon as the device is closed, and is eligible
* for reuse in a new SDL_OpenAudioDevice() call immediately. * for reuse in a new SDL_OpenAudioDevice() call immediately.
* *
* \param dev an audio device previously opened with SDL_OpenAudioDevice() * \param dev an audio device previously opened with SDL_OpenAudioDevice().
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_bits.h * # CategoryBits
* *
* Functions for fiddling with bits and bitmasks. * Functions for fiddling with bits and bitmasks.
*/ */
#ifndef SDL_bits_h_ #ifndef SDL_bits_h_
@@ -56,6 +56,12 @@ extern __inline int _SDL_bsr_watcom(Uint32);
modify exact [eax] nomemory; modify exact [eax] nomemory;
#endif #endif
/**
* Use this function to get the index of the most significant (set) bit in a
*
* \param x the number to find the MSB of.
* \returns the index of the most significant bit of x, or -1 if x is 0.
*/
SDL_FORCE_INLINE int SDL_FORCE_INLINE int
SDL_MostSignificantBitIndex32(Uint32 x) SDL_MostSignificantBitIndex32(Uint32 x)
{ {

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_blendmode.h * # CategoryBlendmode
* *
* Header file declaring the SDL_BlendMode enumeration * Header file declaring the SDL_BlendMode enumeration
*/ */
#ifndef SDL_blendmode_h_ #ifndef SDL_blendmode_h_
@@ -35,9 +35,9 @@ extern "C" {
#endif #endif
/** /**
* \brief The blend mode used in SDL_RenderCopy() and drawing operations. * The blend mode used in SDL_RenderCopy() and drawing operations.
*/ */
typedef enum typedef enum SDL_BlendMode
{ {
SDL_BLENDMODE_NONE = 0x00000000, /**< no blending SDL_BLENDMODE_NONE = 0x00000000, /**< no blending
dstRGBA = srcRGBA */ dstRGBA = srcRGBA */
@@ -60,21 +60,22 @@ typedef enum
} SDL_BlendMode; } SDL_BlendMode;
/** /**
* \brief The blend operation used when combining source and destination pixel components * The blend operation used when combining source and destination pixel
* components
*/ */
typedef enum typedef enum SDL_BlendOperation
{ {
SDL_BLENDOPERATION_ADD = 0x1, /**< dst + src: supported by all renderers */ SDL_BLENDOPERATION_ADD = 0x1, /**< dst + src: supported by all renderers */
SDL_BLENDOPERATION_SUBTRACT = 0x2, /**< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES */ SDL_BLENDOPERATION_SUBTRACT = 0x2, /**< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES */
SDL_BLENDOPERATION_REV_SUBTRACT = 0x3, /**< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES */ SDL_BLENDOPERATION_REV_SUBTRACT = 0x3, /**< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES */
SDL_BLENDOPERATION_MINIMUM = 0x4, /**< min(dst, src) : supported by D3D9, D3D11 */ SDL_BLENDOPERATION_MINIMUM = 0x4, /**< min(dst, src) : supported by D3D9, D3D11 */
SDL_BLENDOPERATION_MAXIMUM = 0x5 /**< max(dst, src) : supported by D3D9, D3D11 */ SDL_BLENDOPERATION_MAXIMUM = 0x5 /**< max(dst, src) : supported by D3D9, D3D11 */
} SDL_BlendOperation; } SDL_BlendOperation;
/** /**
* \brief The normalized factor used to multiply pixel components * The normalized factor used to multiply pixel components
*/ */
typedef enum typedef enum SDL_BlendFactor
{ {
SDL_BLENDFACTOR_ZERO = 0x1, /**< 0, 0, 0, 0 */ SDL_BLENDFACTOR_ZERO = 0x1, /**< 0, 0, 0, 0 */
SDL_BLENDFACTOR_ONE = 0x2, /**< 1, 1, 1, 1 */ SDL_BLENDFACTOR_ONE = 0x2, /**< 1, 1, 1, 1 */
@@ -158,18 +159,18 @@ typedef enum
* case. * case.
* *
* \param srcColorFactor the SDL_BlendFactor applied to the red, green, and * \param srcColorFactor the SDL_BlendFactor applied to the red, green, and
* blue components of the source pixels * blue components of the source pixels.
* \param dstColorFactor the SDL_BlendFactor applied to the red, green, and * \param dstColorFactor the SDL_BlendFactor applied to the red, green, and
* blue components of the destination pixels * blue components of the destination pixels.
* \param colorOperation the SDL_BlendOperation used to combine the red, * \param colorOperation the SDL_BlendOperation used to combine the red,
* green, and blue components of the source and * green, and blue components of the source and
* destination pixels * destination pixels.
* \param srcAlphaFactor the SDL_BlendFactor applied to the alpha component of * \param srcAlphaFactor the SDL_BlendFactor applied to the alpha component of
* the source pixels * the source pixels.
* \param dstAlphaFactor the SDL_BlendFactor applied to the alpha component of * \param dstAlphaFactor the SDL_BlendFactor applied to the alpha component of
* the destination pixels * the destination pixels.
* \param alphaOperation the SDL_BlendOperation used to combine the alpha * \param alphaOperation the SDL_BlendOperation used to combine the alpha
* component of the source and destination pixels * component of the source and destination pixels.
* \returns an SDL_BlendMode that represents the chosen factors and * \returns an SDL_BlendMode that represents the chosen factors and
* operations. * operations.
* *

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,7 +20,7 @@
*/ */
/** /**
* \file SDL_clipboard.h * # CategoryClipboard
* *
* Include file for SDL clipboard handling * Include file for SDL clipboard handling
*/ */
@@ -41,7 +41,7 @@ extern "C" {
/** /**
* Put UTF-8 text into the clipboard. * Put UTF-8 text into the clipboard.
* *
* \param text the text to store in the clipboard * \param text the text to store in the clipboard.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -85,7 +85,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void);
/** /**
* Put UTF-8 text into the primary selection. * Put UTF-8 text into the primary selection.
* *
* \param text the text to store in the primary selection * \param text the text to store in the primary selection.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -24,9 +24,7 @@
#include <SDL2/SDL_platform.h> #include <SDL2/SDL_platform.h>
/** /* WIKI CATEGORY: - */
* \file SDL_config.h
*/
/* Add any platform that doesn't build using the configure system. */ /* Add any platform that doesn't build using the configure system. */
#if defined(__WIN32__) #if defined(__WIN32__)

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -19,10 +19,16 @@
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/* WIKI CATEGORY: CPUInfo */
/** /**
* \file SDL_cpuinfo.h * # CategoryCPUInfo
* *
* CPU feature detection for SDL. * CPU feature detection for SDL.
*
* These functions are largely concerned with reporting if the system has
* access to various SIMD instruction sets, but also has other important info
* to share, such as number of logical CPU cores.
*/ */
#ifndef SDL_cpuinfo_h_ #ifndef SDL_cpuinfo_h_
@@ -53,9 +59,11 @@ _m_prefetch(void *__P)
#ifndef __MMX__ #ifndef __MMX__
#define __MMX__ #define __MMX__
#endif #endif
/*
#ifndef __3dNOW__ #ifndef __3dNOW__
#define __3dNOW__ #define __3dNOW__
#endif #endif
*/
#endif #endif
#ifndef __SSE__ #ifndef __SSE__
#define __SSE__ #define __SSE__

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_endian.h * # CategoryEndian
* *
* Functions for reading and writing endian-specific values * Functions for reading and writing endian-specific values
*/ */
#ifndef SDL_endian_h_ #ifndef SDL_endian_h_
@@ -59,6 +59,15 @@ _m_prefetch(void *__P)
#ifdef __linux__ #ifdef __linux__
#include <endian.h> #include <endian.h>
#define SDL_BYTEORDER __BYTE_ORDER #define SDL_BYTEORDER __BYTE_ORDER
#elif defined(__sun) && defined(__SVR4) /* Solaris */
#include <sys/byteorder.h>
#if defined(_LITTLE_ENDIAN)
#define SDL_BYTEORDER SDL_LIL_ENDIAN
#elif defined(_BIG_ENDIAN)
#define SDL_BYTEORDER SDL_BIG_ENDIAN
#else
#error Unsupported endianness
#endif
#elif defined(__OpenBSD__) || defined(__DragonFly__) #elif defined(__OpenBSD__) || defined(__DragonFly__)
#include <endian.h> #include <endian.h>
#define SDL_BYTEORDER BYTE_ORDER #define SDL_BYTEORDER BYTE_ORDER
@@ -79,7 +88,7 @@ _m_prefetch(void *__P)
defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \
(defined(__MIPS__) && defined(__MIPSEB__)) || \ (defined(__MIPS__) && defined(__MIPSEB__)) || \
defined(__ppc__) || defined(__POWERPC__) || defined(__powerpc__) || defined(__PPC__) || \ defined(__ppc__) || defined(__POWERPC__) || defined(__powerpc__) || defined(__PPC__) || \
defined(__sparc__) defined(__sparc__) || defined(__sparc)
#define SDL_BYTEORDER SDL_BIG_ENDIAN #define SDL_BYTEORDER SDL_BIG_ENDIAN
#else #else
#define SDL_BYTEORDER SDL_LIL_ENDIAN #define SDL_BYTEORDER SDL_LIL_ENDIAN
@@ -180,6 +189,16 @@ extern __inline Uint16 SDL_Swap16(Uint16);
parm [ax] \ parm [ax] \
modify [ax]; modify [ax];
#else #else
/**
* Use this function to swap the byte order of a 16-bit value.
*
* \param x the value to be swapped.
* \returns the swapped value.
*
* \sa SDL_SwapBE16
* \sa SDL_SwapLE16
*/
SDL_FORCE_INLINE Uint16 SDL_FORCE_INLINE Uint16
SDL_Swap16(Uint16 x) SDL_Swap16(Uint16 x)
{ {
@@ -231,6 +250,16 @@ extern __inline Uint32 SDL_Swap32(Uint32);
parm [eax] \ parm [eax] \
modify [eax]; modify [eax];
#else #else
/**
* Use this function to swap the byte order of a 32-bit value.
*
* \param x the value to be swapped.
* \returns the swapped value.
*
* \sa SDL_SwapBE32
* \sa SDL_SwapLE32
*/
SDL_FORCE_INLINE Uint32 SDL_FORCE_INLINE Uint32
SDL_Swap32(Uint32 x) SDL_Swap32(Uint32 x)
{ {
@@ -276,6 +305,16 @@ extern __inline Uint64 SDL_Swap64(Uint64);
parm [eax edx] \ parm [eax edx] \
modify [eax edx]; modify [eax edx];
#else #else
/**
* Use this function to swap the byte order of a 64-bit value.
*
* \param x the value to be swapped.
* \returns the swapped value.
*
* \sa SDL_SwapBE64
* \sa SDL_SwapLE64
*/
SDL_FORCE_INLINE Uint64 SDL_FORCE_INLINE Uint64
SDL_Swap64(Uint64 x) SDL_Swap64(Uint64 x)
{ {
@@ -293,6 +332,15 @@ SDL_Swap64(Uint64 x)
#endif #endif
/**
* Use this function to swap the byte order of a floating point value.
*
* \param x the value to be swapped.
* \returns the swapped value.
*
* \sa SDL_SwapFloatBE
* \sa SDL_SwapFloatLE
*/
SDL_FORCE_INLINE float SDL_FORCE_INLINE float
SDL_SwapFloat(float x) SDL_SwapFloat(float x)
{ {

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_error.h * # CategoryError
* *
* Simple error message routines for SDL. * Simple error message routines for SDL.
*/ */
#ifndef SDL_error_h_ #ifndef SDL_error_h_
@@ -53,9 +53,9 @@ extern "C" {
* } * }
* ``` * ```
* *
* \param fmt a printf()-style message format string * \param fmt a printf()-style message format string.
* \param ... additional parameters matching % tokens in the `fmt` string, if * \param ... additional parameters matching % tokens in the `fmt` string, if
* any * any.
* \returns always -1. * \returns always -1.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -109,8 +109,8 @@ extern DECLSPEC const char *SDLCALL SDL_GetError(void);
* otherwise operates exactly the same as SDL_GetError(). * otherwise operates exactly the same as SDL_GetError().
* *
* \param errstr A buffer to fill with the last error message that was set for * \param errstr A buffer to fill with the last error message that was set for
* the current thread * the current thread.
* \param maxlen The size of the buffer pointed to by the errstr parameter * \param maxlen The size of the buffer pointed to by the errstr parameter.
* \returns the pointer passed in as the `errstr` parameter. * \returns the pointer passed in as the `errstr` parameter.
* *
* \since This function is available since SDL 2.0.14. * \since This function is available since SDL 2.0.14.

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_events.h * # CategoryEvents
* *
* Include file for SDL event handling. * Include file for SDL event handling.
*/ */
#ifndef SDL_events_h_ #ifndef SDL_events_h_
@@ -52,7 +52,7 @@ extern "C" {
/** /**
* The types of events that can be delivered. * The types of events that can be delivered.
*/ */
typedef enum typedef enum SDL_EventType
{ {
SDL_FIRSTEVENT = 0, /**< Unused (do not remove) */ SDL_FIRSTEVENT = 0, /**< Unused (do not remove) */
@@ -131,6 +131,8 @@ typedef enum
SDL_CONTROLLERTOUCHPADMOTION, /**< Game controller touchpad finger was moved */ SDL_CONTROLLERTOUCHPADMOTION, /**< Game controller touchpad finger was moved */
SDL_CONTROLLERTOUCHPADUP, /**< Game controller touchpad finger was lifted */ SDL_CONTROLLERTOUCHPADUP, /**< Game controller touchpad finger was lifted */
SDL_CONTROLLERSENSORUPDATE, /**< Game controller sensor was updated */ SDL_CONTROLLERSENSORUPDATE, /**< Game controller sensor was updated */
SDL_CONTROLLERUPDATECOMPLETE_RESERVED_FOR_SDL3,
SDL_CONTROLLERSTEAMHANDLEUPDATED, /**< Game controller Steam handle has changed */
/* Touch events */ /* Touch events */
SDL_FINGERDOWN = 0x700, SDL_FINGERDOWN = 0x700,
@@ -165,7 +167,7 @@ typedef enum
/* Internal events */ /* Internal events */
SDL_POLLSENTINEL = 0x7F00, /**< Signals the end of an event poll cycle */ SDL_POLLSENTINEL = 0x7F00, /**< Signals the end of an event poll cycle */
/** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use, /** Events SDL_USEREVENT through SDL_LASTEVENT are for your use,
* and should be allocated with SDL_RegisterEvents() * and should be allocated with SDL_RegisterEvents()
*/ */
SDL_USEREVENT = 0x8000, SDL_USEREVENT = 0x8000,
@@ -177,7 +179,7 @@ typedef enum
} SDL_EventType; } SDL_EventType;
/** /**
* \brief Fields shared by every event * Fields shared by every event
*/ */
typedef struct SDL_CommonEvent typedef struct SDL_CommonEvent
{ {
@@ -186,14 +188,14 @@ typedef struct SDL_CommonEvent
} SDL_CommonEvent; } SDL_CommonEvent;
/** /**
* \brief Display state change event data (event.display.*) * Display state change event data (event.display.*)
*/ */
typedef struct SDL_DisplayEvent typedef struct SDL_DisplayEvent
{ {
Uint32 type; /**< ::SDL_DISPLAYEVENT */ Uint32 type; /**< SDL_DISPLAYEVENT */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
Uint32 display; /**< The associated display index */ Uint32 display; /**< The associated display index */
Uint8 event; /**< ::SDL_DisplayEventID */ Uint8 event; /**< SDL_DisplayEventID */
Uint8 padding1; Uint8 padding1;
Uint8 padding2; Uint8 padding2;
Uint8 padding3; Uint8 padding3;
@@ -201,14 +203,14 @@ typedef struct SDL_DisplayEvent
} SDL_DisplayEvent; } SDL_DisplayEvent;
/** /**
* \brief Window state change event data (event.window.*) * Window state change event data (event.window.*)
*/ */
typedef struct SDL_WindowEvent typedef struct SDL_WindowEvent
{ {
Uint32 type; /**< ::SDL_WINDOWEVENT */ Uint32 type; /**< SDL_WINDOWEVENT */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
Uint32 windowID; /**< The associated window */ Uint32 windowID; /**< The associated window */
Uint8 event; /**< ::SDL_WindowEventID */ Uint8 event; /**< SDL_WindowEventID */
Uint8 padding1; Uint8 padding1;
Uint8 padding2; Uint8 padding2;
Uint8 padding3; Uint8 padding3;
@@ -217,14 +219,14 @@ typedef struct SDL_WindowEvent
} SDL_WindowEvent; } SDL_WindowEvent;
/** /**
* \brief Keyboard button event structure (event.key.*) * Keyboard button event structure (event.key.*)
*/ */
typedef struct SDL_KeyboardEvent typedef struct SDL_KeyboardEvent
{ {
Uint32 type; /**< ::SDL_KEYDOWN or ::SDL_KEYUP */ Uint32 type; /**< SDL_KEYDOWN or SDL_KEYUP */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
Uint32 windowID; /**< The window with keyboard focus, if any */ Uint32 windowID; /**< The window with keyboard focus, if any */
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
Uint8 repeat; /**< Non-zero if this is a key repeat */ Uint8 repeat; /**< Non-zero if this is a key repeat */
Uint8 padding2; Uint8 padding2;
Uint8 padding3; Uint8 padding3;
@@ -232,12 +234,13 @@ typedef struct SDL_KeyboardEvent
} SDL_KeyboardEvent; } SDL_KeyboardEvent;
#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32) #define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
/** /**
* \brief Keyboard text editing event structure (event.edit.*) * Keyboard text editing event structure (event.edit.*)
*/ */
typedef struct SDL_TextEditingEvent typedef struct SDL_TextEditingEvent
{ {
Uint32 type; /**< ::SDL_TEXTEDITING */ Uint32 type; /**< SDL_TEXTEDITING */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
Uint32 windowID; /**< The window with keyboard focus, if any */ Uint32 windowID; /**< The window with keyboard focus, if any */
char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */ char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */
@@ -246,12 +249,12 @@ typedef struct SDL_TextEditingEvent
} SDL_TextEditingEvent; } SDL_TextEditingEvent;
/** /**
* \brief Extended keyboard text editing event structure (event.editExt.*) when text would be * Extended keyboard text editing event structure (event.editExt.*) when text
* truncated if stored in the text buffer SDL_TextEditingEvent * would be truncated if stored in the text buffer SDL_TextEditingEvent
*/ */
typedef struct SDL_TextEditingExtEvent typedef struct SDL_TextEditingExtEvent
{ {
Uint32 type; /**< ::SDL_TEXTEDITING_EXT */ Uint32 type; /**< SDL_TEXTEDITING_EXT */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
Uint32 windowID; /**< The window with keyboard focus, if any */ Uint32 windowID; /**< The window with keyboard focus, if any */
char* text; /**< The editing text, which should be freed with SDL_free(), and will not be NULL */ char* text; /**< The editing text, which should be freed with SDL_free(), and will not be NULL */
@@ -259,24 +262,43 @@ typedef struct SDL_TextEditingExtEvent
Sint32 length; /**< The length of selected editing text */ Sint32 length; /**< The length of selected editing text */
} SDL_TextEditingExtEvent; } SDL_TextEditingExtEvent;
#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
/** /**
* \brief Keyboard text input event structure (event.text.*) * The maximum bytes of text that can be supplied in an SDL_TextInputEvent.
*/
#define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
/**
* Keyboard text input event structure (event.text.*)
*
* `text` is limited to SDL_TEXTINPUTEVENT_TEXT_SIZE bytes. If the incoming
* string is larger than this, SDL will split it and send it in pieces, across
* multiple events. The string is in UTF-8 format, and if split, SDL
* guarantees that it will not split in the middle of a UTF-8 sequence, so any
* event will only contain complete codepoints. However, if there are several
* codepoints that go together into a single glyph (like an emoji "thumbs up"
* followed by a skin color), they may be split between events.
*
* This event will never be delivered unless text input is enabled by calling
* SDL_StartTextInput(). Text input is enabled by default on desktop
* platforms, and disabled by default on mobile platforms!
*
* \sa SDL_StartTextInput
* \sa SDL_StopTextInput
*/ */
typedef struct SDL_TextInputEvent typedef struct SDL_TextInputEvent
{ {
Uint32 type; /**< ::SDL_TEXTINPUT */ Uint32 type; /**< SDL_TEXTINPUT */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
Uint32 windowID; /**< The window with keyboard focus, if any */ Uint32 windowID; /**< The window with keyboard focus, if any */
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */ char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text; UTF-8 encoded. */
} SDL_TextInputEvent; } SDL_TextInputEvent;
/** /**
* \brief Mouse motion event structure (event.motion.*) * Mouse motion event structure (event.motion.*)
*/ */
typedef struct SDL_MouseMotionEvent typedef struct SDL_MouseMotionEvent
{ {
Uint32 type; /**< ::SDL_MOUSEMOTION */ Uint32 type; /**< SDL_MOUSEMOTION */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
Uint32 windowID; /**< The window with mouse focus, if any */ Uint32 windowID; /**< The window with mouse focus, if any */
Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
@@ -288,16 +310,16 @@ typedef struct SDL_MouseMotionEvent
} SDL_MouseMotionEvent; } SDL_MouseMotionEvent;
/** /**
* \brief Mouse button event structure (event.button.*) * Mouse button event structure (event.button.*)
*/ */
typedef struct SDL_MouseButtonEvent typedef struct SDL_MouseButtonEvent
{ {
Uint32 type; /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */ Uint32 type; /**< SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
Uint32 windowID; /**< The window with mouse focus, if any */ Uint32 windowID; /**< The window with mouse focus, if any */
Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
Uint8 button; /**< The mouse button index */ Uint8 button; /**< The mouse button index */
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
Uint8 clicks; /**< 1 for single-click, 2 for double-click, etc. */ Uint8 clicks; /**< 1 for single-click, 2 for double-click, etc. */
Uint8 padding1; Uint8 padding1;
Sint32 x; /**< X coordinate, relative to window */ Sint32 x; /**< X coordinate, relative to window */
@@ -305,11 +327,11 @@ typedef struct SDL_MouseButtonEvent
} SDL_MouseButtonEvent; } SDL_MouseButtonEvent;
/** /**
* \brief Mouse wheel event structure (event.wheel.*) * Mouse wheel event structure (event.wheel.*)
*/ */
typedef struct SDL_MouseWheelEvent typedef struct SDL_MouseWheelEvent
{ {
Uint32 type; /**< ::SDL_MOUSEWHEEL */ Uint32 type; /**< SDL_MOUSEWHEEL */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
Uint32 windowID; /**< The window with mouse focus, if any */ Uint32 windowID; /**< The window with mouse focus, if any */
Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */ Uint32 which; /**< The mouse instance id, or SDL_TOUCH_MOUSEID */
@@ -323,11 +345,11 @@ typedef struct SDL_MouseWheelEvent
} SDL_MouseWheelEvent; } SDL_MouseWheelEvent;
/** /**
* \brief Joystick axis motion event structure (event.jaxis.*) * Joystick axis motion event structure (event.jaxis.*)
*/ */
typedef struct SDL_JoyAxisEvent typedef struct SDL_JoyAxisEvent
{ {
Uint32 type; /**< ::SDL_JOYAXISMOTION */ Uint32 type; /**< SDL_JOYAXISMOTION */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
SDL_JoystickID which; /**< The joystick instance id */ SDL_JoystickID which; /**< The joystick instance id */
Uint8 axis; /**< The joystick axis index */ Uint8 axis; /**< The joystick axis index */
@@ -339,11 +361,11 @@ typedef struct SDL_JoyAxisEvent
} SDL_JoyAxisEvent; } SDL_JoyAxisEvent;
/** /**
* \brief Joystick trackball motion event structure (event.jball.*) * Joystick trackball motion event structure (event.jball.*)
*/ */
typedef struct SDL_JoyBallEvent typedef struct SDL_JoyBallEvent
{ {
Uint32 type; /**< ::SDL_JOYBALLMOTION */ Uint32 type; /**< SDL_JOYBALLMOTION */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
SDL_JoystickID which; /**< The joystick instance id */ SDL_JoystickID which; /**< The joystick instance id */
Uint8 ball; /**< The joystick trackball index */ Uint8 ball; /**< The joystick trackball index */
@@ -355,18 +377,18 @@ typedef struct SDL_JoyBallEvent
} SDL_JoyBallEvent; } SDL_JoyBallEvent;
/** /**
* \brief Joystick hat position change event structure (event.jhat.*) * Joystick hat position change event structure (event.jhat.*)
*/ */
typedef struct SDL_JoyHatEvent typedef struct SDL_JoyHatEvent
{ {
Uint32 type; /**< ::SDL_JOYHATMOTION */ Uint32 type; /**< SDL_JOYHATMOTION */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
SDL_JoystickID which; /**< The joystick instance id */ SDL_JoystickID which; /**< The joystick instance id */
Uint8 hat; /**< The joystick hat index */ Uint8 hat; /**< The joystick hat index */
Uint8 value; /**< The hat position value. Uint8 value; /**< The hat position value.
* \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP * \sa SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP
* \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT * \sa SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT
* \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN * \sa SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN
* *
* Note that zero means the POV is centered. * Note that zero means the POV is centered.
*/ */
@@ -375,46 +397,51 @@ typedef struct SDL_JoyHatEvent
} SDL_JoyHatEvent; } SDL_JoyHatEvent;
/** /**
* \brief Joystick button event structure (event.jbutton.*) * Joystick button event structure (event.jbutton.*)
*/ */
typedef struct SDL_JoyButtonEvent typedef struct SDL_JoyButtonEvent
{ {
Uint32 type; /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */ Uint32 type; /**< SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
SDL_JoystickID which; /**< The joystick instance id */ SDL_JoystickID which; /**< The joystick instance id */
Uint8 button; /**< The joystick button index */ Uint8 button; /**< The joystick button index */
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
Uint8 padding1; Uint8 padding1;
Uint8 padding2; Uint8 padding2;
} SDL_JoyButtonEvent; } SDL_JoyButtonEvent;
/** /**
* \brief Joystick device event structure (event.jdevice.*) * Joystick device event structure (event.jdevice.*)
*
* SDL will send JOYSTICK_ADDED events for devices that are already plugged in
* during SDL_Init.
*
* \sa SDL_ControllerDeviceEvent
*/ */
typedef struct SDL_JoyDeviceEvent typedef struct SDL_JoyDeviceEvent
{ {
Uint32 type; /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */ Uint32 type; /**< SDL_JOYDEVICEADDED or SDL_JOYDEVICEREMOVED */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */ Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */
} SDL_JoyDeviceEvent; } SDL_JoyDeviceEvent;
/** /**
* \brief Joysick battery level change event structure (event.jbattery.*) * Joysick battery level change event structure (event.jbattery.*)
*/ */
typedef struct SDL_JoyBatteryEvent typedef struct SDL_JoyBatteryEvent
{ {
Uint32 type; /**< ::SDL_JOYBATTERYUPDATED */ Uint32 type; /**< SDL_JOYBATTERYUPDATED */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
SDL_JoystickID which; /**< The joystick instance id */ SDL_JoystickID which; /**< The joystick instance id */
SDL_JoystickPowerLevel level; /**< The joystick battery level */ SDL_JoystickPowerLevel level; /**< The joystick battery level */
} SDL_JoyBatteryEvent; } SDL_JoyBatteryEvent;
/** /**
* \brief Game controller axis motion event structure (event.caxis.*) * Game controller axis motion event structure (event.caxis.*)
*/ */
typedef struct SDL_ControllerAxisEvent typedef struct SDL_ControllerAxisEvent
{ {
Uint32 type; /**< ::SDL_CONTROLLERAXISMOTION */ Uint32 type; /**< SDL_CONTROLLERAXISMOTION */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
SDL_JoystickID which; /**< The joystick instance id */ SDL_JoystickID which; /**< The joystick instance id */
Uint8 axis; /**< The controller axis (SDL_GameControllerAxis) */ Uint8 axis; /**< The controller axis (SDL_GameControllerAxis) */
@@ -427,36 +454,42 @@ typedef struct SDL_ControllerAxisEvent
/** /**
* \brief Game controller button event structure (event.cbutton.*) * Game controller button event structure (event.cbutton.*)
*/ */
typedef struct SDL_ControllerButtonEvent typedef struct SDL_ControllerButtonEvent
{ {
Uint32 type; /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */ Uint32 type; /**< SDL_CONTROLLERBUTTONDOWN or SDL_CONTROLLERBUTTONUP */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
SDL_JoystickID which; /**< The joystick instance id */ SDL_JoystickID which; /**< The joystick instance id */
Uint8 button; /**< The controller button (SDL_GameControllerButton) */ Uint8 button; /**< The controller button (SDL_GameControllerButton) */
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */ Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
Uint8 padding1; Uint8 padding1;
Uint8 padding2; Uint8 padding2;
} SDL_ControllerButtonEvent; } SDL_ControllerButtonEvent;
/** /**
* \brief Controller device event structure (event.cdevice.*) * Controller device event structure (event.cdevice.*)
*
* Joysticks that are supported game controllers receive both an
* SDL_JoyDeviceEvent and an SDL_ControllerDeviceEvent.
*
* SDL will send CONTROLLERDEVICEADDED events for joysticks that are already
* plugged in during SDL_Init() and are recognized as game controllers.
*/ */
typedef struct SDL_ControllerDeviceEvent typedef struct SDL_ControllerDeviceEvent
{ {
Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, or ::SDL_CONTROLLERDEVICEREMAPPED */ Uint32 type; /**< SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEREMOVED, SDL_CONTROLLERDEVICEREMAPPED, or SDL_CONTROLLERSTEAMHANDLEUPDATED */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */ Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */
} SDL_ControllerDeviceEvent; } SDL_ControllerDeviceEvent;
/** /**
* \brief Game controller touchpad event structure (event.ctouchpad.*) * Game controller touchpad event structure (event.ctouchpad.*)
*/ */
typedef struct SDL_ControllerTouchpadEvent typedef struct SDL_ControllerTouchpadEvent
{ {
Uint32 type; /**< ::SDL_CONTROLLERTOUCHPADDOWN or ::SDL_CONTROLLERTOUCHPADMOTION or ::SDL_CONTROLLERTOUCHPADUP */ Uint32 type; /**< SDL_CONTROLLERTOUCHPADDOWN or SDL_CONTROLLERTOUCHPADMOTION or SDL_CONTROLLERTOUCHPADUP */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
SDL_JoystickID which; /**< The joystick instance id */ SDL_JoystickID which; /**< The joystick instance id */
Sint32 touchpad; /**< The index of the touchpad */ Sint32 touchpad; /**< The index of the touchpad */
@@ -467,24 +500,24 @@ typedef struct SDL_ControllerTouchpadEvent
} SDL_ControllerTouchpadEvent; } SDL_ControllerTouchpadEvent;
/** /**
* \brief Game controller sensor event structure (event.csensor.*) * Game controller sensor event structure (event.csensor.*)
*/ */
typedef struct SDL_ControllerSensorEvent typedef struct SDL_ControllerSensorEvent
{ {
Uint32 type; /**< ::SDL_CONTROLLERSENSORUPDATE */ Uint32 type; /**< SDL_CONTROLLERSENSORUPDATE */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
SDL_JoystickID which; /**< The joystick instance id */ SDL_JoystickID which; /**< The joystick instance id */
Sint32 sensor; /**< The type of the sensor, one of the values of ::SDL_SensorType */ Sint32 sensor; /**< The type of the sensor, one of the values of SDL_SensorType */
float data[3]; /**< Up to 3 values from the sensor, as defined in SDL_sensor.h */ float data[3]; /**< Up to 3 values from the sensor, as defined in SDL_sensor.h */
Uint64 timestamp_us; /**< The timestamp of the sensor reading in microseconds, if the hardware provides this information. */ Uint64 timestamp_us; /**< The timestamp of the sensor reading in microseconds, if the hardware provides this information. */
} SDL_ControllerSensorEvent; } SDL_ControllerSensorEvent;
/** /**
* \brief Audio device event structure (event.adevice.*) * Audio device event structure (event.adevice.*)
*/ */
typedef struct SDL_AudioDeviceEvent typedef struct SDL_AudioDeviceEvent
{ {
Uint32 type; /**< ::SDL_AUDIODEVICEADDED, or ::SDL_AUDIODEVICEREMOVED */ Uint32 type; /**< SDL_AUDIODEVICEADDED, or SDL_AUDIODEVICEREMOVED */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
Uint32 which; /**< The audio device index for the ADDED event (valid until next SDL_GetNumAudioDevices() call), SDL_AudioDeviceID for the REMOVED event */ Uint32 which; /**< The audio device index for the ADDED event (valid until next SDL_GetNumAudioDevices() call), SDL_AudioDeviceID for the REMOVED event */
Uint8 iscapture; /**< zero if an output device, non-zero if a capture device. */ Uint8 iscapture; /**< zero if an output device, non-zero if a capture device. */
@@ -495,11 +528,11 @@ typedef struct SDL_AudioDeviceEvent
/** /**
* \brief Touch finger event structure (event.tfinger.*) * Touch finger event structure (event.tfinger.*)
*/ */
typedef struct SDL_TouchFingerEvent typedef struct SDL_TouchFingerEvent
{ {
Uint32 type; /**< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP */ Uint32 type; /**< SDL_FINGERMOTION or SDL_FINGERDOWN or SDL_FINGERUP */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
SDL_TouchID touchId; /**< The touch device id */ SDL_TouchID touchId; /**< The touch device id */
SDL_FingerID fingerId; SDL_FingerID fingerId;
@@ -513,11 +546,11 @@ typedef struct SDL_TouchFingerEvent
/** /**
* \brief Multiple Finger Gesture Event (event.mgesture.*) * Multiple Finger Gesture Event (event.mgesture.*)
*/ */
typedef struct SDL_MultiGestureEvent typedef struct SDL_MultiGestureEvent
{ {
Uint32 type; /**< ::SDL_MULTIGESTURE */ Uint32 type; /**< SDL_MULTIGESTURE */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
SDL_TouchID touchId; /**< The touch device id */ SDL_TouchID touchId; /**< The touch device id */
float dTheta; float dTheta;
@@ -530,11 +563,11 @@ typedef struct SDL_MultiGestureEvent
/** /**
* \brief Dollar Gesture Event (event.dgesture.*) * Dollar Gesture Event (event.dgesture.*)
*/ */
typedef struct SDL_DollarGestureEvent typedef struct SDL_DollarGestureEvent
{ {
Uint32 type; /**< ::SDL_DOLLARGESTURE or ::SDL_DOLLARRECORD */ Uint32 type; /**< SDL_DOLLARGESTURE or SDL_DOLLARRECORD */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
SDL_TouchID touchId; /**< The touch device id */ SDL_TouchID touchId; /**< The touch device id */
SDL_GestureID gestureId; SDL_GestureID gestureId;
@@ -546,13 +579,15 @@ typedef struct SDL_DollarGestureEvent
/** /**
* \brief An event used to request a file open by the system (event.drop.*) * An event used to request a file open by the system (event.drop.*)
* This event is enabled by default, you can disable it with SDL_EventState(). *
* \note If this event is enabled, you must free the filename in the event. * This event is enabled by default, you can disable it with SDL_EventState().
*
* If this event is enabled, you must free the filename in the event.
*/ */
typedef struct SDL_DropEvent typedef struct SDL_DropEvent
{ {
Uint32 type; /**< ::SDL_DROPBEGIN or ::SDL_DROPFILE or ::SDL_DROPTEXT or ::SDL_DROPCOMPLETE */ Uint32 type; /**< SDL_DROPBEGIN or SDL_DROPFILE or SDL_DROPTEXT or SDL_DROPCOMPLETE */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
char *file; /**< The file name, which should be freed with SDL_free(), is NULL on begin/complete */ char *file; /**< The file name, which should be freed with SDL_free(), is NULL on begin/complete */
Uint32 windowID; /**< The window that was dropped on, if any */ Uint32 windowID; /**< The window that was dropped on, if any */
@@ -560,11 +595,11 @@ typedef struct SDL_DropEvent
/** /**
* \brief Sensor event structure (event.sensor.*) * Sensor event structure (event.sensor.*)
*/ */
typedef struct SDL_SensorEvent typedef struct SDL_SensorEvent
{ {
Uint32 type; /**< ::SDL_SENSORUPDATE */ Uint32 type; /**< SDL_SENSORUPDATE */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
Sint32 which; /**< The instance ID of the sensor */ Sint32 which; /**< The instance ID of the sensor */
float data[6]; /**< Up to 6 values from the sensor - additional values can be queried using SDL_SensorGetData() */ float data[6]; /**< Up to 6 values from the sensor - additional values can be queried using SDL_SensorGetData() */
@@ -572,29 +607,20 @@ typedef struct SDL_SensorEvent
} SDL_SensorEvent; } SDL_SensorEvent;
/** /**
* \brief The "quit requested" event * The "quit requested" event
*/ */
typedef struct SDL_QuitEvent typedef struct SDL_QuitEvent
{ {
Uint32 type; /**< ::SDL_QUIT */ Uint32 type; /**< SDL_QUIT */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
} SDL_QuitEvent; } SDL_QuitEvent;
/** /**
* \brief OS Specific event * A user-defined event type (event.user.*)
*/
typedef struct SDL_OSEvent
{
Uint32 type; /**< ::SDL_QUIT */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
} SDL_OSEvent;
/**
* \brief A user-defined event type (event.user.*)
*/ */
typedef struct SDL_UserEvent typedef struct SDL_UserEvent
{ {
Uint32 type; /**< ::SDL_USEREVENT through ::SDL_LASTEVENT-1 */ Uint32 type; /**< SDL_USEREVENT through SDL_LASTEVENT-1 */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
Uint32 windowID; /**< The associated window if any */ Uint32 windowID; /**< The associated window if any */
Sint32 code; /**< User defined event code */ Sint32 code; /**< User defined event code */
@@ -607,20 +633,24 @@ struct SDL_SysWMmsg;
typedef struct SDL_SysWMmsg SDL_SysWMmsg; typedef struct SDL_SysWMmsg SDL_SysWMmsg;
/** /**
* \brief A video driver dependent system event (event.syswm.*) * A video driver dependent system event (event.syswm.*)
* This event is disabled by default, you can enable it with SDL_EventState()
* *
* \note If you want to use this event, you should include SDL_syswm.h. * This event is disabled by default, you can enable it with SDL_EventState()
*
* If you want to use this event, you should include SDL_syswm.h.
*/ */
typedef struct SDL_SysWMEvent typedef struct SDL_SysWMEvent
{ {
Uint32 type; /**< ::SDL_SYSWMEVENT */ Uint32 type; /**< SDL_SYSWMEVENT */
Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */
SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */ SDL_SysWMmsg *msg; /**< driver dependent data, defined in SDL_syswm.h */
} SDL_SysWMEvent; } SDL_SysWMEvent;
/** /**
* \brief General event structure * General event structure
*
* The SDL_Event structure is the core of all event handling in SDL. SDL_Event
* is a union of all event structures used in SDL.
*/ */
typedef union SDL_Event typedef union SDL_Event
{ {
@@ -703,7 +733,7 @@ SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == sizeof(((SDL_Event *)NUL
extern DECLSPEC void SDLCALL SDL_PumpEvents(void); extern DECLSPEC void SDLCALL SDL_PumpEvents(void);
/* @{ */ /* @{ */
typedef enum typedef enum SDL_eventaction
{ {
SDL_ADDEVENT, SDL_ADDEVENT,
SDL_PEEKEVENT, SDL_PEEKEVENT,
@@ -730,15 +760,15 @@ typedef enum
* *
* This function is thread-safe. * This function is thread-safe.
* *
* \param events destination buffer for the retrieved events * \param events destination buffer for the retrieved events.
* \param numevents if action is SDL_ADDEVENT, the number of events to add * \param numevents if action is SDL_ADDEVENT, the number of events to add
* back to the event queue; if action is SDL_PEEKEVENT or * back to the event queue; if action is SDL_PEEKEVENT or
* SDL_GETEVENT, the maximum number of events to retrieve * SDL_GETEVENT, the maximum number of events to retrieve.
* \param action action to take; see [[#action|Remarks]] for details * \param action action to take; see [[#action|Remarks]] for details.
* \param minType minimum value of the event type to be considered; * \param minType minimum value of the event type to be considered;
* SDL_FIRSTEVENT is a safe choice * SDL_FIRSTEVENT is a safe choice.
* \param maxType maximum value of the event type to be considered; * \param maxType maximum value of the event type to be considered;
* SDL_LASTEVENT is a safe choice * SDL_LASTEVENT is a safe choice.
* \returns the number of events actually stored or a negative error code on * \returns the number of events actually stored or a negative error code on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
@@ -759,7 +789,7 @@ extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
* If you need to check for a range of event types, use SDL_HasEvents() * If you need to check for a range of event types, use SDL_HasEvents()
* instead. * instead.
* *
* \param type the type of event to be queried; see SDL_EventType for details * \param type the type of event to be queried; see SDL_EventType for details.
* \returns SDL_TRUE if events matching `type` are present, or SDL_FALSE if * \returns SDL_TRUE if events matching `type` are present, or SDL_FALSE if
* events matching `type` are not present. * events matching `type` are not present.
* *
@@ -776,9 +806,9 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
* If you need to check for a single event type, use SDL_HasEvent() instead. * If you need to check for a single event type, use SDL_HasEvent() instead.
* *
* \param minType the low end of event type to be queried, inclusive; see * \param minType the low end of event type to be queried, inclusive; see
* SDL_EventType for details * SDL_EventType for details.
* \param maxType the high end of event type to be queried, inclusive; see * \param maxType the high end of event type to be queried, inclusive; see
* SDL_EventType for details * SDL_EventType for details.
* \returns SDL_TRUE if events with type >= `minType` and <= `maxType` are * \returns SDL_TRUE if events with type >= `minType` and <= `maxType` are
* present, or SDL_FALSE if not. * present, or SDL_FALSE if not.
* *
@@ -802,7 +832,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
* sure that all pending OS events are flushed, you can call SDL_PumpEvents() * sure that all pending OS events are flushed, you can call SDL_PumpEvents()
* on the main thread immediately before the flush call. * on the main thread immediately before the flush call.
* *
* \param type the type of event to be cleared; see SDL_EventType for details * \param type the type of event to be cleared; see SDL_EventType for details.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -825,9 +855,9 @@ extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
* on the main thread immediately before the flush call. * on the main thread immediately before the flush call.
* *
* \param minType the low end of event type to be cleared, inclusive; see * \param minType the low end of event type to be cleared, inclusive; see
* SDL_EventType for details * SDL_EventType for details.
* \param maxType the high end of event type to be cleared, inclusive; see * \param maxType the high end of event type to be cleared, inclusive; see
* SDL_EventType for details * SDL_EventType for details.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -868,7 +898,7 @@ extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
* ``` * ```
* *
* \param event the SDL_Event structure to be filled with the next event from * \param event the SDL_Event structure to be filled with the next event from
* the queue, or NULL * the queue, or NULL.
* \returns 1 if there is a pending event or 0 if there are none available. * \returns 1 if there is a pending event or 0 if there are none available.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -892,7 +922,7 @@ extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event);
* this function in the thread that initialized the video subsystem. * this function in the thread that initialized the video subsystem.
* *
* \param event the SDL_Event structure to be filled in with the next event * \param event the SDL_Event structure to be filled in with the next event
* from the queue, or NULL * from the queue, or NULL.
* \returns 1 on success or 0 if there was an error while waiting for events; * \returns 1 on success or 0 if there was an error while waiting for events;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
@@ -915,9 +945,9 @@ extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event);
* this function in the thread that initialized the video subsystem. * this function in the thread that initialized the video subsystem.
* *
* \param event the SDL_Event structure to be filled in with the next event * \param event the SDL_Event structure to be filled in with the next event
* from the queue, or NULL * from the queue, or NULL.
* \param timeout the maximum number of milliseconds to wait for the next * \param timeout the maximum number of milliseconds to wait for the next
* available event * available event.
* \returns 1 on success or 0 if there was an error while waiting for events; * \returns 1 on success or 0 if there was an error while waiting for events;
* call SDL_GetError() for more information. This also returns 0 if * call SDL_GetError() for more information. This also returns 0 if
* the timeout elapsed without an event arriving. * the timeout elapsed without an event arriving.
@@ -952,7 +982,7 @@ extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event,
* get an event type that does not conflict with other code that also wants * get an event type that does not conflict with other code that also wants
* its own custom event types. * its own custom event types.
* *
* \param event the SDL_Event to be added to the queue * \param event the SDL_Event to be added to the queue.
* \returns 1 on success, 0 if the event was filtered, or a negative error * \returns 1 on success, 0 if the event was filtered, or a negative error
* code on failure; call SDL_GetError() for more information. A * code on failure; call SDL_GetError() for more information. A
* common reason for error is the event queue being full. * common reason for error is the event queue being full.
@@ -968,11 +998,11 @@ extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
/** /**
* A function pointer used for callbacks that watch the event queue. * A function pointer used for callbacks that watch the event queue.
* *
* \param userdata what was passed as `userdata` to SDL_SetEventFilter() * \param userdata what was passed as `userdata` to SDL_SetEventFilter() or
* or SDL_AddEventWatch, etc * SDL_AddEventWatch, etc.
* \param event the event that triggered the callback * \param event the event that triggered the callback.
* \returns 1 to permit event to be added to the queue, and 0 to disallow * \returns 1 to permit event to be added to the queue, and 0 to disallow it.
* it. When used with SDL_AddEventWatch, the return value is ignored. * When used with SDL_AddEventWatch, the return value is ignored.
* *
* \sa SDL_SetEventFilter * \sa SDL_SetEventFilter
* \sa SDL_AddEventWatch * \sa SDL_AddEventWatch
@@ -995,7 +1025,7 @@ typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
* interrupt signal (e.g. pressing Ctrl-C), it will be delivered to the * interrupt signal (e.g. pressing Ctrl-C), it will be delivered to the
* application at the next event poll. * application at the next event poll.
* *
* There is one caveat when dealing with the ::SDL_QuitEvent event type. The * There is one caveat when dealing with the SDL_QuitEvent event type. The
* event filter is only called when the window manager desires to close the * event filter is only called when the window manager desires to close the
* application window. If the event filter returns 1, then the window will be * application window. If the event filter returns 1, then the window will be
* closed, otherwise the window will remain open if possible. * closed, otherwise the window will remain open if possible.
@@ -1010,8 +1040,8 @@ typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event);
* the event filter, but events pushed onto the queue with SDL_PeepEvents() do * the event filter, but events pushed onto the queue with SDL_PeepEvents() do
* not. * not.
* *
* \param filter An SDL_EventFilter function to call when an event happens * \param filter An SDL_EventFilter function to call when an event happens.
* \param userdata a pointer that is passed to `filter` * \param userdata a pointer that is passed to `filter`.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -1030,9 +1060,9 @@ extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter,
* This function can be used to "chain" filters, by saving the existing filter * This function can be used to "chain" filters, by saving the existing filter
* before replacing it with a function that will call that saved filter. * before replacing it with a function that will call that saved filter.
* *
* \param filter the current callback function will be stored here * \param filter the current callback function will be stored here.
* \param userdata the pointer that is passed to the current event filter will * \param userdata the pointer that is passed to the current event filter will
* be stored here * be stored here.
* \returns SDL_TRUE on success or SDL_FALSE if there is no event filter set. * \returns SDL_TRUE on success or SDL_FALSE if there is no event filter set.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -1061,7 +1091,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter,
* through SDL_PeepEvents(). * through SDL_PeepEvents().
* *
* \param filter an SDL_EventFilter function to call when an event happens. * \param filter an SDL_EventFilter function to call when an event happens.
* \param userdata a pointer that is passed to `filter` * \param userdata a pointer that is passed to `filter`.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -1077,8 +1107,8 @@ extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter,
* This function takes the same input as SDL_AddEventWatch() to identify and * This function takes the same input as SDL_AddEventWatch() to identify and
* delete the corresponding callback. * delete the corresponding callback.
* *
* \param filter the function originally passed to SDL_AddEventWatch() * \param filter the function originally passed to SDL_AddEventWatch().
* \param userdata the pointer originally passed to SDL_AddEventWatch() * \param userdata the pointer originally passed to SDL_AddEventWatch().
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -1095,8 +1125,8 @@ extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter,
* this function does not change the filter permanently, it only uses the * this function does not change the filter permanently, it only uses the
* supplied filter until this function returns. * supplied filter until this function returns.
* *
* \param filter the SDL_EventFilter function to call when an event happens * \param filter the SDL_EventFilter function to call when an event happens.
* \param userdata a pointer that is passed to `filter` * \param userdata a pointer that is passed to `filter`.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -1122,8 +1152,8 @@ extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter,
* from the event queue and will not be filtered * from the event queue and will not be filtered
* - `SDL_ENABLE`: the event will be processed normally * - `SDL_ENABLE`: the event will be processed normally
* *
* \param type the type of event; see SDL_EventType for details * \param type the type of event; see SDL_EventType for details.
* \param state how to process the event * \param state how to process the event.
* \returns `SDL_DISABLE` or `SDL_ENABLE`, representing the processing state * \returns `SDL_DISABLE` or `SDL_ENABLE`, representing the processing state
* of the event before this function makes any changes to it. * of the event before this function makes any changes to it.
* *
@@ -1145,7 +1175,7 @@ extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state);
* Note, (Uint32)-1 means the maximum unsigned 32-bit integer value (or * Note, (Uint32)-1 means the maximum unsigned 32-bit integer value (or
* 0xFFFFFFFF), but is clearer to write. * 0xFFFFFFFF), but is clearer to write.
* *
* \param numevents the number of events to be allocated * \param numevents the number of events to be allocated.
* \returns the beginning event number, or (Uint32)-1 if there are not enough * \returns the beginning event number, or (Uint32)-1 if there are not enough
* user-defined events left. * user-defined events left.
* *

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_filesystem.h * # CategoryFilesystem
* *
* \brief Include file for filesystem SDL API functions * Include file for filesystem SDL API functions
*/ */
#ifndef SDL_filesystem_h_ #ifndef SDL_filesystem_h_
@@ -64,7 +64,7 @@ extern "C" {
* directory of the application as it is uncommon to store resources outside * directory of the application as it is uncommon to store resources outside
* the executable. As such it is not a writable directory. * the executable. As such it is not a writable directory.
* *
* The returned path is guaranteed to end with a path separator ('\' on * The returned path is guaranteed to end with a path separator ('\\' on
* Windows, '/' on most other platforms). * Windows, '/' on most other platforms).
* *
* The pointer returned is owned by the caller. Please call SDL_free() on the * The pointer returned is owned by the caller. Please call SDL_free() on the
@@ -120,14 +120,14 @@ extern DECLSPEC char *SDLCALL SDL_GetBasePath(void);
* - ...only use letters, numbers, and spaces. Avoid punctuation like "Game * - ...only use letters, numbers, and spaces. Avoid punctuation like "Game
* Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient. * Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient.
* *
* The returned path is guaranteed to end with a path separator ('\' on * The returned path is guaranteed to end with a path separator ('\\' on
* Windows, '/' on most other platforms). * Windows, '/' on most other platforms).
* *
* The pointer returned is owned by the caller. Please call SDL_free() on the * The pointer returned is owned by the caller. Please call SDL_free() on the
* pointer when done with it. * pointer when done with it.
* *
* \param org the name of your organization * \param org the name of your organization.
* \param app the name of your application * \param app the name of your application.
* \returns a UTF-8 string of the user directory in platform-dependent * \returns a UTF-8 string of the user directory in platform-dependent
* notation. NULL if there's a problem (creating directory failed, * notation. NULL if there's a problem (creating directory failed,
* etc.). * etc.).

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -19,10 +19,12 @@
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/* WIKI CATEGORY: GameController */
/** /**
* \file SDL_gamecontroller.h * # CategoryGameController
* *
* Include file for SDL game controller event handling * Include file for SDL game controller event handling
*/ */
#ifndef SDL_gamecontroller_h_ #ifndef SDL_gamecontroller_h_
@@ -44,7 +46,7 @@ extern "C" {
* \file SDL_gamecontroller.h * \file SDL_gamecontroller.h
* *
* In order to use these functions, SDL_Init() must have been called * In order to use these functions, SDL_Init() must have been called
* with the ::SDL_INIT_GAMECONTROLLER flag. This causes SDL to scan the system * with the SDL_INIT_GAMECONTROLLER flag. This causes SDL to scan the system
* for game controllers, and load appropriate drivers. * for game controllers, and load appropriate drivers.
* *
* If you would like to receive controller updates while the application * If you would like to receive controller updates while the application
@@ -58,7 +60,7 @@ extern "C" {
struct _SDL_GameController; struct _SDL_GameController;
typedef struct _SDL_GameController SDL_GameController; typedef struct _SDL_GameController SDL_GameController;
typedef enum typedef enum SDL_GameControllerType
{ {
SDL_CONTROLLER_TYPE_UNKNOWN = 0, SDL_CONTROLLER_TYPE_UNKNOWN = 0,
SDL_CONTROLLER_TYPE_XBOX360, SDL_CONTROLLER_TYPE_XBOX360,
@@ -73,10 +75,11 @@ typedef enum
SDL_CONTROLLER_TYPE_NVIDIA_SHIELD, SDL_CONTROLLER_TYPE_NVIDIA_SHIELD,
SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT, SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT,
SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT, SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT,
SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR,
SDL_CONTROLLER_TYPE_MAX
} SDL_GameControllerType; } SDL_GameControllerType;
typedef enum typedef enum SDL_GameControllerBindType
{ {
SDL_CONTROLLER_BINDTYPE_NONE = 0, SDL_CONTROLLER_BINDTYPE_NONE = 0,
SDL_CONTROLLER_BINDTYPE_BUTTON, SDL_CONTROLLER_BINDTYPE_BUTTON,
@@ -85,7 +88,7 @@ typedef enum
} SDL_GameControllerBindType; } SDL_GameControllerBindType;
/** /**
* Get the SDL joystick layer binding for this controller button/axis mapping * Get the SDL joystick layer binding for this controller button/axis mapping
*/ */
typedef struct SDL_GameControllerButtonBind typedef struct SDL_GameControllerButtonBind
{ {
@@ -143,6 +146,10 @@ typedef struct SDL_GameControllerButtonBind
* If a new mapping is loaded for an already known controller GUID, the later * If a new mapping is loaded for an already known controller GUID, the later
* version will overwrite the one currently loaded. * version will overwrite the one currently loaded.
* *
* If this function is called before SDL_Init, SDL will generate an
* SDL_CONTROLLERDEVICEADDED event for matching controllers that are plugged
* in at the time that SDL_Init is called.
*
* Mappings not belonging to the current platform or with no platform field * Mappings not belonging to the current platform or with no platform field
* specified will be ignored (i.e. mappings for Linux will be ignored in * specified will be ignored (i.e. mappings for Linux will be ignored in
* Windows, etc). * Windows, etc).
@@ -151,8 +158,8 @@ typedef struct SDL_GameControllerButtonBind
* processing it, so take this into consideration if you are in a memory * processing it, so take this into consideration if you are in a memory
* constrained environment. * constrained environment.
* *
* \param rw the data stream for the mappings to be added * \param rw the data stream for the mappings to be added.
* \param freerw non-zero to close the stream after being read * \param freerw non-zero to close the stream after being read.
* \returns the number of mappings added or -1 on error; call SDL_GetError() * \returns the number of mappings added or -1 on error; call SDL_GetError()
* for more information. * for more information.
* *
@@ -161,13 +168,15 @@ typedef struct SDL_GameControllerButtonBind
* \sa SDL_GameControllerAddMapping * \sa SDL_GameControllerAddMapping
* \sa SDL_GameControllerAddMappingsFromFile * \sa SDL_GameControllerAddMappingsFromFile
* \sa SDL_GameControllerMappingForGUID * \sa SDL_GameControllerMappingForGUID
* \sa SDL_CONTROLLERDEVICEADDED
*/ */
extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw); extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw);
/** /**
* Load a set of mappings from a file, filtered by the current SDL_GetPlatform() * Load a set of mappings from a file, filtered by the current
* SDL_GetPlatform()
* *
* Convenience macro. * Convenience macro.
*/ */
#define SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1) #define SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1)
@@ -189,7 +198,11 @@ extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw,
* "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7" * "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7"
* ``` * ```
* *
* \param mappingString the mapping string * If this function is called before SDL_Init, SDL will generate an
* SDL_CONTROLLERDEVICEADDED event for matching controllers that are plugged
* in at the time that SDL_Init is called.
*
* \param mappingString the mapping string.
* \returns 1 if a new mapping is added, 0 if an existing mapping is updated, * \returns 1 if a new mapping is added, 0 if an existing mapping is updated,
* -1 on error; call SDL_GetError() for more information. * -1 on error; call SDL_GetError() for more information.
* *
@@ -197,6 +210,7 @@ extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw,
* *
* \sa SDL_GameControllerMapping * \sa SDL_GameControllerMapping
* \sa SDL_GameControllerMappingForGUID * \sa SDL_GameControllerMappingForGUID
* \sa SDL_CONTROLLERDEVICEADDED
*/ */
extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char* mappingString); extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char* mappingString);
@@ -224,7 +238,7 @@ extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForIndex(int mapping_ind
* *
* The returned string must be freed with SDL_free(). * The returned string must be freed with SDL_free().
* *
* \param guid a structure containing the GUID for which a mapping is desired * \param guid a structure containing the GUID for which a mapping is desired.
* \returns a mapping string or NULL on error; call SDL_GetError() for more * \returns a mapping string or NULL on error; call SDL_GetError() for more
* information. * information.
* *
@@ -243,7 +257,7 @@ extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID(SDL_JoystickGUID
* Details about mappings are discussed with SDL_GameControllerAddMapping(). * Details about mappings are discussed with SDL_GameControllerAddMapping().
* *
* \param gamecontroller the game controller you want to get the current * \param gamecontroller the game controller you want to get the current
* mapping for * mapping for.
* \returns a string that has the controller's mapping or NULL if no mapping * \returns a string that has the controller's mapping or NULL if no mapping
* is available; call SDL_GetError() for more information. * is available; call SDL_GetError() for more information.
* *
@@ -261,7 +275,7 @@ extern DECLSPEC char * SDLCALL SDL_GameControllerMapping(SDL_GameController *gam
* SDL_JoystickOpen(). * SDL_JoystickOpen().
* *
* \param joystick_index the device_index of a device, up to * \param joystick_index the device_index of a device, up to
* SDL_NumJoysticks() * SDL_NumJoysticks().
* \returns SDL_TRUE if the given joystick is supported by the game controller * \returns SDL_TRUE if the given joystick is supported by the game controller
* interface, SDL_FALSE if it isn't or it's an invalid index. * interface, SDL_FALSE if it isn't or it's an invalid index.
* *
@@ -281,7 +295,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index);
* SDL_JoystickOpen(). * SDL_JoystickOpen().
* *
* \param joystick_index the device_index of a device, from zero to * \param joystick_index the device_index of a device, from zero to
* SDL_NumJoysticks()-1 * SDL_NumJoysticks()-1.
* \returns the implementation-dependent name for the game controller, or NULL * \returns the implementation-dependent name for the game controller, or NULL
* if there is no name or the index is invalid. * if there is no name or the index is invalid.
* *
@@ -302,7 +316,7 @@ extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_
* SDL_JoystickOpen(). * SDL_JoystickOpen().
* *
* \param joystick_index the device_index of a device, from zero to * \param joystick_index the device_index of a device, from zero to
* SDL_NumJoysticks()-1 * SDL_NumJoysticks()-1.
* \returns the implementation-dependent path for the game controller, or NULL * \returns the implementation-dependent path for the game controller, or NULL
* if there is no path or the index is invalid. * if there is no path or the index is invalid.
* *
@@ -318,7 +332,7 @@ extern DECLSPEC const char *SDLCALL SDL_GameControllerPathForIndex(int joystick_
* This can be called before any controllers are opened. * This can be called before any controllers are opened.
* *
* \param joystick_index the device_index of a device, from zero to * \param joystick_index the device_index of a device, from zero to
* SDL_NumJoysticks()-1 * SDL_NumJoysticks()-1.
* \returns the controller type. * \returns the controller type.
* *
* \since This function is available since SDL 2.0.12. * \since This function is available since SDL 2.0.12.
@@ -331,7 +345,7 @@ extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerTypeForIndex(in
* This can be called before any controllers are opened. * This can be called before any controllers are opened.
* *
* \param joystick_index the device_index of a device, from zero to * \param joystick_index the device_index of a device, from zero to
* SDL_NumJoysticks()-1 * SDL_NumJoysticks()-1.
* \returns the mapping string. Must be freed with SDL_free(). Returns NULL if * \returns the mapping string. Must be freed with SDL_free(). Returns NULL if
* no mapping is available. * no mapping is available.
* *
@@ -351,7 +365,7 @@ extern DECLSPEC char *SDLCALL SDL_GameControllerMappingForDeviceIndex(int joysti
* be used there instead. * be used there instead.
* *
* \param joystick_index the device_index of a device, up to * \param joystick_index the device_index of a device, up to
* SDL_NumJoysticks() * SDL_NumJoysticks().
* \returns a gamecontroller identifier or NULL if an error occurred; call * \returns a gamecontroller identifier or NULL if an error occurred; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -366,7 +380,7 @@ extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_
/** /**
* Get the SDL_GameController associated with an instance id. * Get the SDL_GameController associated with an instance id.
* *
* \param joyid the instance id to get the SDL_GameController for * \param joyid the instance id to get the SDL_GameController for.
* \returns an SDL_GameController on success or NULL on failure; call * \returns an SDL_GameController on success or NULL on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -398,7 +412,7 @@ extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromPlayerIndex(in
* it takes a controller identifier instead of the (unstable) device index. * it takes a controller identifier instead of the (unstable) device index.
* *
* \param gamecontroller a game controller identifier previously returned by * \param gamecontroller a game controller identifier previously returned by
* SDL_GameControllerOpen() * SDL_GameControllerOpen().
* \returns the implementation dependent name for the game controller, or NULL * \returns the implementation dependent name for the game controller, or NULL
* if there is no name or the identifier passed is invalid. * if there is no name or the identifier passed is invalid.
* *
@@ -416,7 +430,7 @@ extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *g
* it takes a controller identifier instead of the (unstable) device index. * it takes a controller identifier instead of the (unstable) device index.
* *
* \param gamecontroller a game controller identifier previously returned by * \param gamecontroller a game controller identifier previously returned by
* SDL_GameControllerOpen() * SDL_GameControllerOpen().
* \returns the implementation dependent path for the game controller, or NULL * \returns the implementation dependent path for the game controller, or NULL
* if there is no path or the identifier passed is invalid. * if there is no path or the identifier passed is invalid.
* *
@@ -523,11 +537,25 @@ extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetFirmwareVersion(SDL_GameCont
*/ */
extern DECLSPEC const char * SDLCALL SDL_GameControllerGetSerial(SDL_GameController *gamecontroller); extern DECLSPEC const char * SDLCALL SDL_GameControllerGetSerial(SDL_GameController *gamecontroller);
/**
* Get the Steam Input handle of an opened controller, if available.
*
* Returns an InputHandle_t for the controller that can be used with Steam
* Input API: https://partner.steamgames.com/doc/api/ISteamInput
*
* \param gamecontroller the game controller object to query.
* \returns the gamepad handle, or 0 if unavailable.
*
* \since This function is available since SDL 2.30.0.
*/
extern DECLSPEC Uint64 SDLCALL SDL_GameControllerGetSteamHandle(SDL_GameController *gamecontroller);
/** /**
* Check if a controller has been opened and is currently connected. * Check if a controller has been opened and is currently connected.
* *
* \param gamecontroller a game controller identifier previously returned by * \param gamecontroller a game controller identifier previously returned by
* SDL_GameControllerOpen() * SDL_GameControllerOpen().
* \returns SDL_TRUE if the controller has been opened and is currently * \returns SDL_TRUE if the controller has been opened and is currently
* connected, or SDL_FALSE if not. * connected, or SDL_FALSE if not.
* *
@@ -552,7 +580,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameControlle
* cause SDL to crash. * cause SDL to crash.
* *
* \param gamecontroller the game controller object that you want to get a * \param gamecontroller the game controller object that you want to get a
* joystick from * joystick from.
* \returns a SDL_Joystick object; call SDL_GetError() for more information. * \returns a SDL_Joystick object; call SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -569,7 +597,7 @@ extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameCont
* Any number can be passed to SDL_GameControllerEventState(), but only -1, 0, * Any number can be passed to SDL_GameControllerEventState(), but only -1, 0,
* and 1 will have any effect. Other numbers will just be returned. * and 1 will have any effect. Other numbers will just be returned.
* *
* \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE` * \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE`.
* \returns the same value passed to the function, with exception to -1 * \returns the same value passed to the function, with exception to -1
* (SDL_QUERY), which will return the current state. * (SDL_QUERY), which will return the current state.
* *
@@ -592,15 +620,19 @@ extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void);
/** /**
* The list of axes available from a controller * The list of axes available from a controller
* *
* Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to SDL_JOYSTICK_AXIS_MAX, * Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to
* and are centered within ~8000 of zero, though advanced UI will allow users to set * SDL_JOYSTICK_AXIS_MAX, and are centered within ~8000 of zero, though
* or autodetect the dead zone, which varies between controllers. * advanced UI will allow users to set or autodetect the dead zone, which
* varies between controllers.
* *
* Trigger axis values range from 0 to SDL_JOYSTICK_AXIS_MAX. * Trigger axis values range from 0 (released) to SDL_JOYSTICK_AXIS_MAX (fully
* pressed) when reported by SDL_GameControllerGetAxis(). Note that this is
* not the same range that will be reported by the lower-level
* SDL_GetJoystickAxis().
*/ */
typedef enum typedef enum SDL_GameControllerAxis
{ {
SDL_CONTROLLER_AXIS_INVALID = -1, SDL_CONTROLLER_AXIS_INVALID = -1,
SDL_CONTROLLER_AXIS_LEFTX, SDL_CONTROLLER_AXIS_LEFTX,
@@ -624,7 +656,7 @@ typedef enum
* `SDL_CONTROLLER_AXIS_TRIGGERRIGHT` and `SDL_CONTROLLER_AXIS_TRIGGERLEFT`, * `SDL_CONTROLLER_AXIS_TRIGGERRIGHT` and `SDL_CONTROLLER_AXIS_TRIGGERLEFT`,
* respectively. * respectively.
* *
* \param str string representing a SDL_GameController axis * \param str string representing a SDL_GameController axis.
* \returns the SDL_GameControllerAxis enum corresponding to the input string, * \returns the SDL_GameControllerAxis enum corresponding to the input string,
* or `SDL_CONTROLLER_AXIS_INVALID` if no match was found. * or `SDL_CONTROLLER_AXIS_INVALID` if no match was found.
* *
@@ -639,7 +671,7 @@ extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromStri
* *
* The caller should not SDL_free() the returned string. * The caller should not SDL_free() the returned string.
* *
* \param axis an enum value for a given SDL_GameControllerAxis * \param axis an enum value for a given SDL_GameControllerAxis.
* \returns a string for the given axis, or NULL if an invalid axis is * \returns a string for the given axis, or NULL if an invalid axis is
* specified. The string returned is of the format used by * specified. The string returned is of the format used by
* SDL_GameController mapping strings. * SDL_GameController mapping strings.
@@ -653,8 +685,8 @@ extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameC
/** /**
* Get the SDL joystick layer binding for a controller axis mapping. * Get the SDL joystick layer binding for a controller axis mapping.
* *
* \param gamecontroller a game controller * \param gamecontroller a game controller.
* \param axis an axis enum value (one of the SDL_GameControllerAxis values) * \param axis an axis enum value (one of the SDL_GameControllerAxis values).
* \returns a SDL_GameControllerButtonBind describing the bind. On failure * \returns a SDL_GameControllerButtonBind describing the bind. On failure
* (like the given Controller axis doesn't exist on the device), its * (like the given Controller axis doesn't exist on the device), its
* `.bindType` will be `SDL_CONTROLLER_BINDTYPE_NONE`. * `.bindType` will be `SDL_CONTROLLER_BINDTYPE_NONE`.
@@ -673,8 +705,8 @@ SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
* This merely reports whether the controller's mapping defined this axis, as * This merely reports whether the controller's mapping defined this axis, as
* that is all the information SDL has about the physical device. * that is all the information SDL has about the physical device.
* *
* \param gamecontroller a game controller * \param gamecontroller a game controller.
* \param axis an axis enum value (an SDL_GameControllerAxis value) * \param axis an axis enum value (an SDL_GameControllerAxis value).
* \returns SDL_TRUE if the controller has this axis, SDL_FALSE otherwise. * \returns SDL_TRUE if the controller has this axis, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.14. * \since This function is available since SDL 2.0.14.
@@ -687,11 +719,15 @@ SDL_GameControllerHasAxis(SDL_GameController *gamecontroller, SDL_GameController
* *
* The axis indices start at index 0. * The axis indices start at index 0.
* *
* The state is a value ranging from -32768 to 32767. Triggers, however, range * For thumbsticks, the state is a value ranging from -32768 (up/left) to
* from 0 to 32767 (they never return a negative value). * 32767 (down/right).
* *
* \param gamecontroller a game controller * Triggers range from 0 when released to 32767 when fully pressed, and never
* \param axis an axis index (one of the SDL_GameControllerAxis values) * return a negative value. Note that this differs from the value reported by
* the lower-level SDL_JoystickGetAxis(), which normally uses the full range.
*
* \param gamecontroller a game controller.
* \param axis an axis index (one of the SDL_GameControllerAxis values).
* \returns axis state (including 0) on success or 0 (also) on failure; call * \returns axis state (including 0) on success or 0 (also) on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -703,9 +739,9 @@ extern DECLSPEC Sint16 SDLCALL
SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis); SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
/** /**
* The list of buttons available from a controller * The list of buttons available from a controller
*/ */
typedef enum typedef enum SDL_GameControllerButton
{ {
SDL_CONTROLLER_BUTTON_INVALID = -1, SDL_CONTROLLER_BUTTON_INVALID = -1,
SDL_CONTROLLER_BUTTON_A, SDL_CONTROLLER_BUTTON_A,
@@ -740,7 +776,7 @@ typedef enum
* SDL_GameController mapping. You do not normally need to call this function * SDL_GameController mapping. You do not normally need to call this function
* unless you are parsing SDL_GameController mappings in your own code. * unless you are parsing SDL_GameController mappings in your own code.
* *
* \param str string representing a SDL_GameController axis * \param str string representing a SDL_GameController axis.
* \returns the SDL_GameControllerButton enum corresponding to the input * \returns the SDL_GameControllerButton enum corresponding to the input
* string, or `SDL_CONTROLLER_AXIS_INVALID` if no match was found. * string, or `SDL_CONTROLLER_AXIS_INVALID` if no match was found.
* *
@@ -753,7 +789,7 @@ extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFrom
* *
* The caller should not SDL_free() the returned string. * The caller should not SDL_free() the returned string.
* *
* \param button an enum value for a given SDL_GameControllerButton * \param button an enum value for a given SDL_GameControllerButton.
* \returns a string for the given button, or NULL if an invalid button is * \returns a string for the given button, or NULL if an invalid button is
* specified. The string returned is of the format used by * specified. The string returned is of the format used by
* SDL_GameController mapping strings. * SDL_GameController mapping strings.
@@ -767,8 +803,8 @@ extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_Gam
/** /**
* Get the SDL joystick layer binding for a controller button mapping. * Get the SDL joystick layer binding for a controller button mapping.
* *
* \param gamecontroller a game controller * \param gamecontroller a game controller.
* \param button an button enum value (an SDL_GameControllerButton value) * \param button an button enum value (an SDL_GameControllerButton value).
* \returns a SDL_GameControllerButtonBind describing the bind. On failure * \returns a SDL_GameControllerButtonBind describing the bind. On failure
* (like the given Controller button doesn't exist on the device), * (like the given Controller button doesn't exist on the device),
* its `.bindType` will be `SDL_CONTROLLER_BINDTYPE_NONE`. * its `.bindType` will be `SDL_CONTROLLER_BINDTYPE_NONE`.
@@ -787,8 +823,8 @@ SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller,
* This merely reports whether the controller's mapping defined this button, * This merely reports whether the controller's mapping defined this button,
* as that is all the information SDL has about the physical device. * as that is all the information SDL has about the physical device.
* *
* \param gamecontroller a game controller * \param gamecontroller a game controller.
* \param button a button enum value (an SDL_GameControllerButton value) * \param button a button enum value (an SDL_GameControllerButton value).
* \returns SDL_TRUE if the controller has this button, SDL_FALSE otherwise. * \returns SDL_TRUE if the controller has this button, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.14. * \since This function is available since SDL 2.0.14.
@@ -799,8 +835,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasButton(SDL_GameController
/** /**
* Get the current state of a button on a game controller. * Get the current state of a button on a game controller.
* *
* \param gamecontroller a game controller * \param gamecontroller a game controller.
* \param button a button index (one of the SDL_GameControllerButton values) * \param button a button index (one of the SDL_GameControllerButton values).
* \returns 1 for pressed state or 0 for not pressed state or error; call * \returns 1 for pressed state or 0 for not pressed state or error; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -836,8 +872,8 @@ extern DECLSPEC int SDLCALL SDL_GameControllerGetTouchpadFinger(SDL_GameControll
/** /**
* Return whether a game controller has a particular sensor. * Return whether a game controller has a particular sensor.
* *
* \param gamecontroller The controller to query * \param gamecontroller The controller to query.
* \param type The type of sensor to query * \param type The type of sensor to query.
* \returns SDL_TRUE if the sensor exists, SDL_FALSE otherwise. * \returns SDL_TRUE if the sensor exists, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.14. * \since This function is available since SDL 2.0.14.
@@ -847,9 +883,9 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasSensor(SDL_GameController
/** /**
* Set whether data reporting for a game controller sensor is enabled. * Set whether data reporting for a game controller sensor is enabled.
* *
* \param gamecontroller The controller to update * \param gamecontroller The controller to update.
* \param type The type of sensor to enable/disable * \param type The type of sensor to enable/disable.
* \param enabled Whether data reporting should be enabled * \param enabled Whether data reporting should be enabled.
* \returns 0 or -1 if an error occurred. * \returns 0 or -1 if an error occurred.
* *
* \since This function is available since SDL 2.0.14. * \since This function is available since SDL 2.0.14.
@@ -859,8 +895,8 @@ extern DECLSPEC int SDLCALL SDL_GameControllerSetSensorEnabled(SDL_GameControlle
/** /**
* Query whether sensor data reporting is enabled for a game controller. * Query whether sensor data reporting is enabled for a game controller.
* *
* \param gamecontroller The controller to query * \param gamecontroller The controller to query.
* \param type The type of sensor to query * \param type The type of sensor to query.
* \returns SDL_TRUE if the sensor is enabled, SDL_FALSE otherwise. * \returns SDL_TRUE if the sensor is enabled, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.14. * \since This function is available since SDL 2.0.14.
@@ -871,8 +907,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerIsSensorEnabled(SDL_GameContr
* Get the data rate (number of events per second) of a game controller * Get the data rate (number of events per second) of a game controller
* sensor. * sensor.
* *
* \param gamecontroller The controller to query * \param gamecontroller The controller to query.
* \param type The type of sensor to query * \param type The type of sensor to query.
* \return the data rate, or 0.0f if the data rate is not available. * \return the data rate, or 0.0f if the data rate is not available.
* *
* \since This function is available since SDL 2.0.16. * \since This function is available since SDL 2.0.16.
@@ -885,10 +921,10 @@ extern DECLSPEC float SDLCALL SDL_GameControllerGetSensorDataRate(SDL_GameContro
* The number of values and interpretation of the data is sensor dependent. * The number of values and interpretation of the data is sensor dependent.
* See SDL_sensor.h for the details for each type of sensor. * See SDL_sensor.h for the details for each type of sensor.
* *
* \param gamecontroller The controller to query * \param gamecontroller The controller to query.
* \param type The type of sensor to query * \param type The type of sensor to query.
* \param data A pointer filled with the current sensor state * \param data A pointer filled with the current sensor state.
* \param num_values The number of values to write to data * \param num_values The number of values to write to data.
* \return 0 or -1 if an error occurred. * \return 0 or -1 if an error occurred.
* *
* \since This function is available since SDL 2.0.14. * \since This function is available since SDL 2.0.14.
@@ -902,12 +938,12 @@ extern DECLSPEC int SDLCALL SDL_GameControllerGetSensorData(SDL_GameController *
* The number of values and interpretation of the data is sensor dependent. * The number of values and interpretation of the data is sensor dependent.
* See SDL_sensor.h for the details for each type of sensor. * See SDL_sensor.h for the details for each type of sensor.
* *
* \param gamecontroller The controller to query * \param gamecontroller The controller to query.
* \param type The type of sensor to query * \param type The type of sensor to query.
* \param timestamp A pointer filled with the timestamp in microseconds of the * \param timestamp A pointer filled with the timestamp in microseconds of the
* current sensor reading if available, or 0 if not * current sensor reading if available, or 0 if not.
* \param data A pointer filled with the current sensor state * \param data A pointer filled with the current sensor state.
* \param num_values The number of values to write to data * \param num_values The number of values to write to data.
* \return 0 or -1 if an error occurred. * \return 0 or -1 if an error occurred.
* *
* \since This function is available since SDL 2.26.0. * \since This function is available since SDL 2.26.0.
@@ -920,13 +956,13 @@ extern DECLSPEC int SDLCALL SDL_GameControllerGetSensorDataWithTimestamp(SDL_Gam
* Each call to this function cancels any previous rumble effect, and calling * Each call to this function cancels any previous rumble effect, and calling
* it with 0 intensity stops any rumbling. * it with 0 intensity stops any rumbling.
* *
* \param gamecontroller The controller to vibrate * \param gamecontroller The controller to vibrate.
* \param low_frequency_rumble The intensity of the low frequency (left) * \param low_frequency_rumble The intensity of the low frequency (left)
* rumble motor, from 0 to 0xFFFF * rumble motor, from 0 to 0xFFFF.
* \param high_frequency_rumble The intensity of the high frequency (right) * \param high_frequency_rumble The intensity of the high frequency (right)
* rumble motor, from 0 to 0xFFFF * rumble motor, from 0 to 0xFFFF.
* \param duration_ms The duration of the rumble effect, in milliseconds * \param duration_ms The duration of the rumble effect, in milliseconds.
* \returns 0, or -1 if rumble isn't supported on this controller * \returns 0, or -1 if rumble isn't supported on this controller.
* *
* \since This function is available since SDL 2.0.9. * \since This function is available since SDL 2.0.9.
* *
@@ -945,13 +981,13 @@ extern DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecon
* want the (more common) whole-controller rumble, use * want the (more common) whole-controller rumble, use
* SDL_GameControllerRumble() instead. * SDL_GameControllerRumble() instead.
* *
* \param gamecontroller The controller to vibrate * \param gamecontroller The controller to vibrate.
* \param left_rumble The intensity of the left trigger rumble motor, from 0 * \param left_rumble The intensity of the left trigger rumble motor, from 0
* to 0xFFFF * to 0xFFFF.
* \param right_rumble The intensity of the right trigger rumble motor, from 0 * \param right_rumble The intensity of the right trigger rumble motor, from 0
* to 0xFFFF * to 0xFFFF.
* \param duration_ms The duration of the rumble effect, in milliseconds * \param duration_ms The duration of the rumble effect, in milliseconds.
* \returns 0, or -1 if trigger rumble isn't supported on this controller * \returns 0, or -1 if trigger rumble isn't supported on this controller.
* *
* \since This function is available since SDL 2.0.14. * \since This function is available since SDL 2.0.14.
* *
@@ -962,9 +998,9 @@ extern DECLSPEC int SDLCALL SDL_GameControllerRumbleTriggers(SDL_GameController
/** /**
* Query whether a game controller has an LED. * Query whether a game controller has an LED.
* *
* \param gamecontroller The controller to query * \param gamecontroller The controller to query.
* \returns SDL_TRUE, or SDL_FALSE if this controller does not have a * \returns SDL_TRUE, or SDL_FALSE if this controller does not have a
* modifiable LED * modifiable LED.
* *
* \since This function is available since SDL 2.0.14. * \since This function is available since SDL 2.0.14.
*/ */
@@ -973,9 +1009,9 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasLED(SDL_GameController *ga
/** /**
* Query whether a game controller has rumble support. * Query whether a game controller has rumble support.
* *
* \param gamecontroller The controller to query * \param gamecontroller The controller to query.
* \returns SDL_TRUE, or SDL_FALSE if this controller does not have rumble * \returns SDL_TRUE, or SDL_FALSE if this controller does not have rumble
* support * support.
* *
* \since This function is available since SDL 2.0.18. * \since This function is available since SDL 2.0.18.
* *
@@ -986,9 +1022,9 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasRumble(SDL_GameController
/** /**
* Query whether a game controller has rumble support on triggers. * Query whether a game controller has rumble support on triggers.
* *
* \param gamecontroller The controller to query * \param gamecontroller The controller to query.
* \returns SDL_TRUE, or SDL_FALSE if this controller does not have trigger * \returns SDL_TRUE, or SDL_FALSE if this controller does not have trigger
* rumble support * rumble support.
* *
* \since This function is available since SDL 2.0.18. * \since This function is available since SDL 2.0.18.
* *
@@ -999,11 +1035,11 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasRumbleTriggers(SDL_GameCon
/** /**
* Update a game controller's LED color. * Update a game controller's LED color.
* *
* \param gamecontroller The controller to update * \param gamecontroller The controller to update.
* \param red The intensity of the red LED * \param red The intensity of the red LED.
* \param green The intensity of the green LED * \param green The intensity of the green LED.
* \param blue The intensity of the blue LED * \param blue The intensity of the blue LED.
* \returns 0, or -1 if this controller does not have a modifiable LED * \returns 0, or -1 if this controller does not have a modifiable LED.
* *
* \since This function is available since SDL 2.0.14. * \since This function is available since SDL 2.0.14.
*/ */
@@ -1012,11 +1048,11 @@ extern DECLSPEC int SDLCALL SDL_GameControllerSetLED(SDL_GameController *gamecon
/** /**
* Send a controller specific effect packet * Send a controller specific effect packet
* *
* \param gamecontroller The controller to affect * \param gamecontroller The controller to affect.
* \param data The data to send to the controller * \param data The data to send to the controller.
* \param size The size of the data to send to the controller * \param size The size of the data to send to the controller.
* \returns 0, or -1 if this controller or driver doesn't support effect * \returns 0, or -1 if this controller or driver doesn't support effect
* packets * packets.
* *
* \since This function is available since SDL 2.0.16. * \since This function is available since SDL 2.0.16.
*/ */
@@ -1026,7 +1062,7 @@ extern DECLSPEC int SDLCALL SDL_GameControllerSendEffect(SDL_GameController *gam
* Close a game controller previously opened with SDL_GameControllerOpen(). * Close a game controller previously opened with SDL_GameControllerOpen().
* *
* \param gamecontroller a game controller identifier previously returned by * \param gamecontroller a game controller identifier previously returned by
* SDL_GameControllerOpen() * SDL_GameControllerOpen().
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -1038,9 +1074,9 @@ extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecon
* Return the sfSymbolsName for a given button on a game controller on Apple * Return the sfSymbolsName for a given button on a game controller on Apple
* platforms. * platforms.
* *
* \param gamecontroller the controller to query * \param gamecontroller the controller to query.
* \param button a button on the game controller * \param button a button on the game controller.
* \returns the sfSymbolsName or NULL if the name can't be found * \returns the sfSymbolsName or NULL if the name can't be found.
* *
* \since This function is available since SDL 2.0.18. * \since This function is available since SDL 2.0.18.
* *
@@ -1052,9 +1088,9 @@ extern DECLSPEC const char* SDLCALL SDL_GameControllerGetAppleSFSymbolsNameForBu
* Return the sfSymbolsName for a given axis on a game controller on Apple * Return the sfSymbolsName for a given axis on a game controller on Apple
* platforms. * platforms.
* *
* \param gamecontroller the controller to query * \param gamecontroller the controller to query.
* \param axis an axis on the game controller * \param axis an axis on the game controller.
* \returns the sfSymbolsName or NULL if the name can't be found * \returns the sfSymbolsName or NULL if the name can't be found.
* *
* \since This function is available since SDL 2.0.18. * \since This function is available since SDL 2.0.18.
* *

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_gesture.h * # CategoryGesture
* *
* Include file for SDL gesture event handling. * Include file for SDL gesture event handling.
*/ */
#ifndef SDL_gesture_h_ #ifndef SDL_gesture_h_
@@ -51,7 +51,7 @@ typedef Sint64 SDL_GestureID;
* If the parameter `touchId` is -1 (i.e., all devices), this function will * If the parameter `touchId` is -1 (i.e., all devices), this function will
* always return 1, regardless of whether there actually are any devices. * always return 1, regardless of whether there actually are any devices.
* *
* \param touchId the touch device id, or -1 for all touch devices * \param touchId the touch device id, or -1 for all touch devices.
* \returns 1 on success or 0 if the specified device could not be found. * \returns 1 on success or 0 if the specified device could not be found.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -64,7 +64,7 @@ extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId);
/** /**
* Save all currently loaded Dollar Gesture templates. * Save all currently loaded Dollar Gesture templates.
* *
* \param dst a SDL_RWops to save to * \param dst a SDL_RWops to save to.
* \returns the number of saved templates on success or 0 on failure; call * \returns the number of saved templates on success or 0 on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -78,8 +78,8 @@ extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst);
/** /**
* Save a currently loaded Dollar Gesture template. * Save a currently loaded Dollar Gesture template.
* *
* \param gestureId a gesture id * \param gestureId a gesture id.
* \param dst a SDL_RWops to save to * \param dst a SDL_RWops to save to.
* \returns 1 on success or 0 on failure; call SDL_GetError() for more * \returns 1 on success or 0 on failure; call SDL_GetError() for more
* information. * information.
* *
@@ -94,8 +94,8 @@ extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_R
/** /**
* Load Dollar Gesture templates from a file. * Load Dollar Gesture templates from a file.
* *
* \param touchId a touch id * \param touchId a touch id.
* \param src a SDL_RWops to load from * \param src a SDL_RWops to load from.
* \returns the number of loaded templates on success or a negative error code * \returns the number of loaded templates on success or a negative error code
* (or 0) on failure; call SDL_GetError() for more information. * (or 0) on failure; call SDL_GetError() for more information.
* *

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -19,10 +19,13 @@
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/* WIKI CATEGORY: GUID */
/** /**
* \file SDL_guid.h * # CategoryGUID
* *
* Include file for handling ::SDL_GUID values. * A GUID is a 128-bit value that represents something that is uniquely
* identifiable by this value: "globally unique."
*/ */
#ifndef SDL_guid_h_ #ifndef SDL_guid_h_
@@ -38,34 +41,38 @@ extern "C" {
#endif #endif
/** /**
* An SDL_GUID is a 128-bit identifier for an input device that * An SDL_GUID is a 128-bit identifier.
* identifies that device across runs of SDL programs on the same
* platform. If the device is detached and then re-attached to a
* different port, or if the base system is rebooted, the device
* should still report the same GUID.
* *
* GUIDs are as precise as possible but are not guaranteed to * This is an acronym for "Globally Unique ID."
* distinguish physically distinct but equivalent devices. For
* example, two game controllers from the same vendor with the same
* product ID and revision may have the same GUID.
* *
* GUIDs may be platform-dependent (i.e., the same device may report * While a GUID can be used to assign a unique value to almost anything, in
* different GUIDs on different operating systems). * SDL these are largely used to identify input devices across runs of SDL
* programs on the same platform.If the device is detached and then
* re-attached to a different port, or if the base system is rebooted, the
* device should still report the same GUID.
*
* GUIDs are as precise as possible but are not guaranteed to distinguish
* physically distinct but equivalent devices. For example, two game
* controllers from the same vendor with the same product ID and revision may
* have the same GUID.
*
* GUIDs may be platform-dependent (i.e., the same device may report different
* GUIDs on different operating systems).
*/ */
typedef struct { typedef struct SDL_GUID {
Uint8 data[16]; Uint8 data[16];
} SDL_GUID; } SDL_GUID;
/* Function prototypes */ /* Function prototypes */
/** /**
* Get an ASCII string representation for a given ::SDL_GUID. * Get an ASCII string representation for a given SDL_GUID.
* *
* You should supply at least 33 bytes for pszGUID. * You should supply at least 33 bytes for pszGUID.
* *
* \param guid the ::SDL_GUID you wish to convert to string * \param guid the SDL_GUID you wish to convert to string.
* \param pszGUID buffer in which to write the ASCII string * \param pszGUID buffer in which to write the ASCII string.
* \param cbGUID the size of pszGUID * \param cbGUID the size of pszGUID.
* *
* \since This function is available since SDL 2.24.0. * \since This function is available since SDL 2.24.0.
* *
@@ -74,14 +81,14 @@ typedef struct {
extern DECLSPEC void SDLCALL SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID); extern DECLSPEC void SDLCALL SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID);
/** /**
* Convert a GUID string into a ::SDL_GUID structure. * Convert a GUID string into a SDL_GUID structure.
* *
* Performs no error checking. If this function is given a string containing * Performs no error checking. If this function is given a string containing
* an invalid GUID, the function will silently succeed, but the GUID generated * an invalid GUID, the function will silently succeed, but the GUID generated
* will not be useful. * will not be useful.
* *
* \param pchGUID string containing an ASCII representation of a GUID * \param pchGUID string containing an ASCII representation of a GUID.
* \returns a ::SDL_GUID structure. * \returns a SDL_GUID structure.
* *
* \since This function is available since SDL 2.24.0. * \since This function is available since SDL 2.24.0.
* *

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -19,44 +19,35 @@
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/* WIKI CATEGORY: HIDAPI */
/** /**
* \file SDL_hidapi.h * # CategoryHIDAPI
* *
* Header file for SDL HIDAPI functions. * Header file for SDL HIDAPI functions.
* *
* This is an adaptation of the original HIDAPI interface by Alan Ott, * This is an adaptation of the original HIDAPI interface by Alan Ott, and
* and includes source code licensed under the following BSD license: * includes source code licensed under the following license:
* *
Copyright (c) 2010, Alan Ott, Signal 11 Software * ```
All rights reserved. * HIDAPI - Multi-Platform library for
* communication with HID devices.
Redistribution and use in source and binary forms, with or without *
modification, are permitted provided that the following conditions are met: * Copyright 2009, Alan Ott, Signal 11 Software.
* All Rights Reserved.
* Redistributions of source code must retain the above copyright notice, *
this list of conditions and the following disclaimer. * This software may be used by anyone for any reason so
* Redistributions in binary form must reproduce the above copyright * long as the copyright notice in the source files
notice, this list of conditions and the following disclaimer in the * remains intact.
documentation and/or other materials provided with the distribution. * ```
* Neither the name of Signal 11 Software nor the names of its *
contributors may be used to endorse or promote products derived from * (Note that this license is the same as item three of SDL's zlib license, so
this software without specific prior written permission. * it adds no new requirements on the user.)
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
* *
* If you would like a version of SDL without this code, you can build SDL * If you would like a version of SDL without this code, you can build SDL
* with SDL_HIDAPI_DISABLED defined to 1. You might want to do this for example * with SDL_HIDAPI_DISABLED defined to 1. You might want to do this for
* on iOS or tvOS to avoid a dependency on the CoreBluetooth framework. * example on iOS or tvOS to avoid a dependency on the CoreBluetooth
* framework.
*/ */
#ifndef SDL_hidapi_h_ #ifndef SDL_hidapi_h_
@@ -71,14 +62,15 @@ extern "C" {
#endif #endif
/** /**
* \brief A handle representing an open HID device * A handle representing an open HID device
*/ */
struct SDL_hid_device_; struct SDL_hid_device_;
typedef struct SDL_hid_device_ SDL_hid_device; /**< opaque hidapi structure */ typedef struct SDL_hid_device_ SDL_hid_device; /**< opaque hidapi structure */
/** hidapi info structure */ /** hidapi info structure */
/** /**
* \brief Information about a connected HID device * Information about a connected HID device
*/ */
typedef struct SDL_hid_device_info typedef struct SDL_hid_device_info
{ {
@@ -234,13 +226,13 @@ extern DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open(unsigned short vendor_id,
* The path name be determined by calling SDL_hid_enumerate(), or a * The path name be determined by calling SDL_hid_enumerate(), or a
* platform-specific path name can be used (eg: /dev/hidraw0 on Linux). * platform-specific path name can be used (eg: /dev/hidraw0 on Linux).
* *
* \param path The path name of the device to open * \param path The path name of the device to open.
* \returns a pointer to a SDL_hid_device object on success or NULL on * \returns a pointer to a SDL_hid_device object on success or NULL on
* failure. * failure.
* *
* \since This function is available since SDL 2.0.18. * \since This function is available since SDL 2.0.18.
*/ */
extern DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open_path(const char *path, int bExclusive /* = false */); extern DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open_path(const char *path, int bExclusive);
/** /**
* Write an Output report to a HID device. * Write an Output report to a HID device.
@@ -434,7 +426,7 @@ extern DECLSPEC int SDLCALL SDL_hid_get_indexed_string(SDL_hid_device *dev, int
/** /**
* Start or stop a BLE scan on iOS and tvOS to pair Steam Controllers * Start or stop a BLE scan on iOS and tvOS to pair Steam Controllers
* *
* \param active SDL_TRUE to start the scan, SDL_FALSE to stop the scan * \param active SDL_TRUE to start the scan, SDL_FALSE to stop the scan.
* *
* \since This function is available since SDL 2.0.18. * \since This function is available since SDL 2.0.18.
*/ */

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,22 +20,26 @@
*/ */
/** /**
* \file SDL_joystick.h * # CategoryJoystick
* *
* Include file for SDL joystick event handling * Include file for SDL joystick event handling
* *
* The term "device_index" identifies currently plugged in joystick devices between 0 and SDL_NumJoysticks(), with the exact joystick * The term "device_index" identifies currently plugged in joystick devices
* behind a device_index changing as joysticks are plugged and unplugged. * between 0 and SDL_NumJoysticks(), with the exact joystick behind a
* device_index changing as joysticks are plugged and unplugged.
* *
* The term "instance_id" is the current instantiation of a joystick device in the system, if the joystick is removed and then re-inserted * The term "instance_id" is the current instantiation of a joystick device in
* then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in. * the system, if the joystick is removed and then re-inserted then it will
* get a new instance_id, instance_id's are monotonically increasing
* identifiers of a joystick plugged in.
* *
* The term "player_index" is the number assigned to a player on a specific * The term "player_index" is the number assigned to a player on a specific
* controller. For XInput controllers this returns the XInput user index. * controller. For XInput controllers this returns the XInput user index. Many
* Many joysticks will not be able to supply this information. * joysticks will not be able to supply this information.
* *
* The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of * The term JoystickGUID is a stable 128-bit identifier for a joystick device
* the device (a X360 wired controller for example). This identifier is platform dependent. * that does not change over time, it identifies class of the device (a X360
* wired controller for example). This identifier is platform dependent.
*/ */
#ifndef SDL_joystick_h_ #ifndef SDL_joystick_h_
@@ -56,7 +60,7 @@ extern "C" {
* \file SDL_joystick.h * \file SDL_joystick.h
* *
* In order to use these functions, SDL_Init() must have been called * In order to use these functions, SDL_Init() must have been called
* with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system * with the SDL_INIT_JOYSTICK flag. This causes SDL to scan the system
* for joysticks, and load appropriate drivers. * for joysticks, and load appropriate drivers.
* *
* If you would like to receive joystick updates while the application * If you would like to receive joystick updates while the application
@@ -73,15 +77,21 @@ extern SDL_mutex *SDL_joystick_lock;
struct _SDL_Joystick; struct _SDL_Joystick;
typedef struct _SDL_Joystick SDL_Joystick; typedef struct _SDL_Joystick SDL_Joystick;
/* A structure that encodes the stable unique id for a joystick device */ /**
* A structure that encodes the stable unique id for a joystick device.
*
* This is just a standard SDL_GUID by a different name.
*/
typedef SDL_GUID SDL_JoystickGUID; typedef SDL_GUID SDL_JoystickGUID;
/** /**
* This is a unique ID for a joystick for the time it is connected to the system, * This is a unique ID for a joystick for the time it is connected to the
* and is never reused for the lifetime of the application. If the joystick is * system, and is never reused for the lifetime of the application.
* disconnected and reconnected, it will get a new ID.
* *
* The ID value starts at 0 and increments from there. The value -1 is an invalid ID. * If the joystick is disconnected and reconnected, it will get a new ID.
*
* The ID value starts at 0 and increments from there. The value -1 is an
* invalid ID.
*/ */
typedef Sint32 SDL_JoystickID; typedef Sint32 SDL_JoystickID;
@@ -172,7 +182,7 @@ extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
* This can be called before any joysticks are opened. * This can be called before any joysticks are opened.
* *
* \param device_index the index of the joystick to query (the N'th joystick * \param device_index the index of the joystick to query (the N'th joystick
* on the system) * on the system).
* \returns the name of the selected joystick. If no name can be found, this * \returns the name of the selected joystick. If no name can be found, this
* function returns NULL; call SDL_GetError() for more information. * function returns NULL; call SDL_GetError() for more information.
* *
@@ -189,7 +199,7 @@ extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index);
* This can be called before any joysticks are opened. * This can be called before any joysticks are opened.
* *
* \param device_index the index of the joystick to query (the N'th joystick * \param device_index the index of the joystick to query (the N'th joystick
* on the system) * on the system).
* \returns the path of the selected joystick. If no path can be found, this * \returns the path of the selected joystick. If no path can be found, this
* function returns NULL; call SDL_GetError() for more information. * function returns NULL; call SDL_GetError() for more information.
* *
@@ -215,9 +225,9 @@ extern DECLSPEC int SDLCALL SDL_JoystickGetDevicePlayerIndex(int device_index);
* This function can be called before any joysticks are opened. * This function can be called before any joysticks are opened.
* *
* \param device_index the index of the joystick to query (the N'th joystick * \param device_index the index of the joystick to query (the N'th joystick
* on the system * on the system.
* \returns the GUID of the selected joystick. If called on an invalid index, * \returns the GUID of the selected joystick. If called on an invalid index,
* this function returns a zero GUID * this function returns a zero GUID.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -233,9 +243,9 @@ extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_in
* available this function returns 0. * available this function returns 0.
* *
* \param device_index the index of the joystick to query (the N'th joystick * \param device_index the index of the joystick to query (the N'th joystick
* on the system * on the system.
* \returns the USB vendor ID of the selected joystick. If called on an * \returns the USB vendor ID of the selected joystick. If called on an
* invalid index, this function returns zero * invalid index, this function returns zero.
* *
* \since This function is available since SDL 2.0.6. * \since This function is available since SDL 2.0.6.
*/ */
@@ -248,9 +258,9 @@ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceVendor(int device_index);
* available this function returns 0. * available this function returns 0.
* *
* \param device_index the index of the joystick to query (the N'th joystick * \param device_index the index of the joystick to query (the N'th joystick
* on the system * on the system.
* \returns the USB product ID of the selected joystick. If called on an * \returns the USB product ID of the selected joystick. If called on an
* invalid index, this function returns zero * invalid index, this function returns zero.
* *
* \since This function is available since SDL 2.0.6. * \since This function is available since SDL 2.0.6.
*/ */
@@ -263,9 +273,9 @@ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProduct(int device_index);
* isn't available this function returns 0. * isn't available this function returns 0.
* *
* \param device_index the index of the joystick to query (the N'th joystick * \param device_index the index of the joystick to query (the N'th joystick
* on the system * on the system.
* \returns the product version of the selected joystick. If called on an * \returns the product version of the selected joystick. If called on an
* invalid index, this function returns zero * invalid index, this function returns zero.
* *
* \since This function is available since SDL 2.0.6. * \since This function is available since SDL 2.0.6.
*/ */
@@ -277,9 +287,9 @@ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProductVersion(int device_in
* This can be called before any joysticks are opened. * This can be called before any joysticks are opened.
* *
* \param device_index the index of the joystick to query (the N'th joystick * \param device_index the index of the joystick to query (the N'th joystick
* on the system * on the system.
* \returns the SDL_JoystickType of the selected joystick. If called on an * \returns the SDL_JoystickType of the selected joystick. If called on an
* invalid index, this function returns `SDL_JOYSTICK_TYPE_UNKNOWN` * invalid index, this function returns `SDL_JOYSTICK_TYPE_UNKNOWN`.
* *
* \since This function is available since SDL 2.0.6. * \since This function is available since SDL 2.0.6.
*/ */
@@ -291,7 +301,7 @@ extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetDeviceType(int device_in
* This can be called before any joysticks are opened. * This can be called before any joysticks are opened.
* *
* \param device_index the index of the joystick to query (the N'th joystick * \param device_index the index of the joystick to query (the N'th joystick
* on the system * on the system.
* \returns the instance id of the selected joystick. If called on an invalid * \returns the instance id of the selected joystick. If called on an invalid
* index, this function returns -1. * index, this function returns -1.
* *
@@ -310,7 +320,7 @@ extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickGetDeviceInstanceID(int devic
* The joystick subsystem must be initialized before a joystick can be opened * The joystick subsystem must be initialized before a joystick can be opened
* for use. * for use.
* *
* \param device_index the index of the joystick to query * \param device_index the index of the joystick to query.
* \returns a joystick identifier or NULL if an error occurred; call * \returns a joystick identifier or NULL if an error occurred; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -324,7 +334,7 @@ extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index);
/** /**
* Get the SDL_Joystick associated with an instance id. * Get the SDL_Joystick associated with an instance id.
* *
* \param instance_id the instance id to get the SDL_Joystick for * \param instance_id the instance id to get the SDL_Joystick for.
* \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError() * \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError()
* for more information. * for more information.
* *
@@ -335,7 +345,7 @@ extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromInstanceID(SDL_JoystickID
/** /**
* Get the SDL_Joystick associated with a player index. * Get the SDL_Joystick associated with a player index.
* *
* \param player_index the player index to get the SDL_Joystick for * \param player_index the player index to get the SDL_Joystick for.
* \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError() * \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError()
* for more information. * for more information.
* *
@@ -358,8 +368,10 @@ extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtual(SDL_JoystickType type,
/** /**
* The structure that defines an extended virtual joystick description * The structure that defines an extended virtual joystick description
* *
* The caller must zero the structure and then initialize the version with `SDL_VIRTUAL_JOYSTICK_DESC_VERSION` before passing it to SDL_JoystickAttachVirtualEx() * The caller must zero the structure and then initialize the version with
* All other elements of this structure are optional and can be left 0. * `SDL_VIRTUAL_JOYSTICK_DESC_VERSION` before passing it to
* SDL_JoystickAttachVirtualEx() All other elements of this structure are
* optional and can be left 0.
* *
* \sa SDL_JoystickAttachVirtualEx * \sa SDL_JoystickAttachVirtualEx
*/ */
@@ -390,7 +402,7 @@ typedef struct SDL_VirtualJoystickDesc
} SDL_VirtualJoystickDesc; } SDL_VirtualJoystickDesc;
/** /**
* \brief The current version of the SDL_VirtualJoystickDesc structure * The current version of the SDL_VirtualJoystickDesc structure
*/ */
#define SDL_VIRTUAL_JOYSTICK_DESC_VERSION 1 #define SDL_VIRTUAL_JOYSTICK_DESC_VERSION 1
@@ -407,7 +419,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtualEx(const SDL_VirtualJoystic
* Detach a virtual joystick. * Detach a virtual joystick.
* *
* \param device_index a value previously returned from * \param device_index a value previously returned from
* SDL_JoystickAttachVirtual() * SDL_JoystickAttachVirtual().
* \returns 0 on success, or -1 if an error occurred. * \returns 0 on success, or -1 if an error occurred.
* *
* \since This function is available since SDL 2.0.14. * \since This function is available since SDL 2.0.14.
@@ -485,7 +497,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualHat(SDL_Joystick *joystick, in
/** /**
* Get the implementation dependent name of a joystick. * Get the implementation dependent name of a joystick.
* *
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
* \returns the name of the selected joystick. If no name can be found, this * \returns the name of the selected joystick. If no name can be found, this
* function returns NULL; call SDL_GetError() for more information. * function returns NULL; call SDL_GetError() for more information.
* *
@@ -499,7 +511,7 @@ extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick *joystick);
/** /**
* Get the implementation dependent path of a joystick. * Get the implementation dependent path of a joystick.
* *
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
* \returns the path of the selected joystick. If no path can be found, this * \returns the path of the selected joystick. If no path can be found, this
* function returns NULL; call SDL_GetError() for more information. * function returns NULL; call SDL_GetError() for more information.
* *
@@ -515,7 +527,7 @@ extern DECLSPEC const char *SDLCALL SDL_JoystickPath(SDL_Joystick *joystick);
* For XInput controllers this returns the XInput user index. Many joysticks * For XInput controllers this returns the XInput user index. Many joysticks
* will not be able to supply this information. * will not be able to supply this information.
* *
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
* \returns the player index, or -1 if it's not available. * \returns the player index, or -1 if it's not available.
* *
* \since This function is available since SDL 2.0.9. * \since This function is available since SDL 2.0.9.
@@ -525,7 +537,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickGetPlayerIndex(SDL_Joystick *joystick);
/** /**
* Set the player index of an opened joystick. * Set the player index of an opened joystick.
* *
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
* \param player_index Player index to assign to this joystick, or -1 to clear * \param player_index Player index to assign to this joystick, or -1 to clear
* the player index and turn off player LEDs. * the player index and turn off player LEDs.
* *
@@ -538,7 +550,7 @@ extern DECLSPEC void SDLCALL SDL_JoystickSetPlayerIndex(SDL_Joystick *joystick,
* *
* This function requires an open joystick. * This function requires an open joystick.
* *
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
* \returns the GUID of the given joystick. If called on an invalid index, * \returns the GUID of the given joystick. If called on an invalid index,
* this function returns a zero GUID; call SDL_GetError() for more * this function returns a zero GUID; call SDL_GetError() for more
* information. * information.
@@ -555,7 +567,7 @@ extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick *joyst
* *
* If the vendor ID isn't available this function returns 0. * If the vendor ID isn't available this function returns 0.
* *
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
* \returns the USB vendor ID of the selected joystick, or 0 if unavailable. * \returns the USB vendor ID of the selected joystick, or 0 if unavailable.
* *
* \since This function is available since SDL 2.0.6. * \since This function is available since SDL 2.0.6.
@@ -567,7 +579,7 @@ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetVendor(SDL_Joystick *joystick);
* *
* If the product ID isn't available this function returns 0. * If the product ID isn't available this function returns 0.
* *
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
* \returns the USB product ID of the selected joystick, or 0 if unavailable. * \returns the USB product ID of the selected joystick, or 0 if unavailable.
* *
* \since This function is available since SDL 2.0.6. * \since This function is available since SDL 2.0.6.
@@ -579,7 +591,7 @@ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProduct(SDL_Joystick *joystick);
* *
* If the product version isn't available this function returns 0. * If the product version isn't available this function returns 0.
* *
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
* \returns the product version of the selected joystick, or 0 if unavailable. * \returns the product version of the selected joystick, or 0 if unavailable.
* *
* \since This function is available since SDL 2.0.6. * \since This function is available since SDL 2.0.6.
@@ -591,7 +603,7 @@ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProductVersion(SDL_Joystick *joyst
* *
* If the firmware version isn't available this function returns 0. * If the firmware version isn't available this function returns 0.
* *
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
* \returns the firmware version of the selected joystick, or 0 if * \returns the firmware version of the selected joystick, or 0 if
* unavailable. * unavailable.
* *
@@ -604,7 +616,7 @@ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetFirmwareVersion(SDL_Joystick *joys
* *
* Returns the serial number of the joystick, or NULL if it is not available. * Returns the serial number of the joystick, or NULL if it is not available.
* *
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
* \returns the serial number of the selected joystick, or NULL if * \returns the serial number of the selected joystick, or NULL if
* unavailable. * unavailable.
* *
@@ -615,7 +627,7 @@ extern DECLSPEC const char * SDLCALL SDL_JoystickGetSerial(SDL_Joystick *joystic
/** /**
* Get the type of an opened joystick. * Get the type of an opened joystick.
* *
* \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen().
* \returns the SDL_JoystickType of the selected joystick. * \returns the SDL_JoystickType of the selected joystick.
* *
* \since This function is available since SDL 2.0.6. * \since This function is available since SDL 2.0.6.
@@ -627,9 +639,9 @@ extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetType(SDL_Joystick *joyst
* *
* You should supply at least 33 bytes for pszGUID. * You should supply at least 33 bytes for pszGUID.
* *
* \param guid the SDL_JoystickGUID you wish to convert to string * \param guid the SDL_JoystickGUID you wish to convert to string.
* \param pszGUID buffer in which to write the ASCII string * \param pszGUID buffer in which to write the ASCII string.
* \param cbGUID the size of pszGUID * \param cbGUID the size of pszGUID.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -646,7 +658,7 @@ extern DECLSPEC void SDLCALL SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, ch
* an invalid GUID, the function will silently succeed, but the GUID generated * an invalid GUID, the function will silently succeed, but the GUID generated
* will not be useful. * will not be useful.
* *
* \param pchGUID string containing an ASCII representation of a GUID * \param pchGUID string containing an ASCII representation of a GUID.
* \returns a SDL_JoystickGUID structure. * \returns a SDL_JoystickGUID structure.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -658,15 +670,15 @@ extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const cha
/** /**
* Get the device information encoded in a SDL_JoystickGUID structure * Get the device information encoded in a SDL_JoystickGUID structure
* *
* \param guid the SDL_JoystickGUID you wish to get info about * \param guid the SDL_JoystickGUID you wish to get info about.
* \param vendor A pointer filled in with the device VID, or 0 if not * \param vendor A pointer filled in with the device VID, or 0 if not
* available * available.
* \param product A pointer filled in with the device PID, or 0 if not * \param product A pointer filled in with the device PID, or 0 if not
* available * available.
* \param version A pointer filled in with the device version, or 0 if not * \param version A pointer filled in with the device version, or 0 if not
* available * available.
* \param crc16 A pointer filled in with a CRC used to distinguish different * \param crc16 A pointer filled in with a CRC used to distinguish different
* products with the same VID/PID, or 0 if not available * products with the same VID/PID, or 0 if not available.
* *
* \since This function is available since SDL 2.26.0. * \since This function is available since SDL 2.26.0.
* *
@@ -677,7 +689,7 @@ extern DECLSPEC void SDLCALL SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint
/** /**
* Get the status of a specified joystick. * Get the status of a specified joystick.
* *
* \param joystick the joystick to query * \param joystick the joystick to query.
* \returns SDL_TRUE if the joystick has been opened, SDL_FALSE if it has not; * \returns SDL_TRUE if the joystick has been opened, SDL_FALSE if it has not;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
@@ -691,7 +703,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick *joystick)
/** /**
* Get the instance ID of an opened joystick. * Get the instance ID of an opened joystick.
* *
* \param joystick an SDL_Joystick structure containing joystick information * \param joystick an SDL_Joystick structure containing joystick information.
* \returns the instance ID of the specified joystick on success or a negative * \returns the instance ID of the specified joystick on success or a negative
* error code on failure; call SDL_GetError() for more information. * error code on failure; call SDL_GetError() for more information.
* *
@@ -708,7 +720,7 @@ extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick *joys
* separate buttons or a POV hat, and not axes, but all of this is up to the * separate buttons or a POV hat, and not axes, but all of this is up to the
* device and platform. * device and platform.
* *
* \param joystick an SDL_Joystick structure containing joystick information * \param joystick an SDL_Joystick structure containing joystick information.
* \returns the number of axis controls/number of axes on success or a * \returns the number of axis controls/number of axes on success or a
* negative error code on failure; call SDL_GetError() for more * negative error code on failure; call SDL_GetError() for more
* information. * information.
@@ -728,7 +740,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick);
* *
* Most joysticks do not have trackballs. * Most joysticks do not have trackballs.
* *
* \param joystick an SDL_Joystick structure containing joystick information * \param joystick an SDL_Joystick structure containing joystick information.
* \returns the number of trackballs on success or a negative error code on * \returns the number of trackballs on success or a negative error code on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
@@ -741,7 +753,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick);
/** /**
* Get the number of POV hats on a joystick. * Get the number of POV hats on a joystick.
* *
* \param joystick an SDL_Joystick structure containing joystick information * \param joystick an SDL_Joystick structure containing joystick information.
* \returns the number of POV hats on success or a negative error code on * \returns the number of POV hats on success or a negative error code on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
@@ -755,7 +767,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick);
/** /**
* Get the number of buttons on a joystick. * Get the number of buttons on a joystick.
* *
* \param joystick an SDL_Joystick structure containing joystick information * \param joystick an SDL_Joystick structure containing joystick information.
* \returns the number of buttons on success or a negative error code on * \returns the number of buttons on success or a negative error code on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
@@ -790,12 +802,17 @@ extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
* **WARNING**: Calling this function may delete all events currently in SDL's * **WARNING**: Calling this function may delete all events currently in SDL's
* event queue. * event queue.
* *
* \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE` * While `param` is meant to be one of `SDL_QUERY`, `SDL_IGNORE`, or
* \returns 1 if enabled, 0 if disabled, or a negative error code on failure; * `SDL_ENABLE`, this function accepts any value, with any non-zero value that
* call SDL_GetError() for more information. * isn't `SDL_QUERY` being treated as `SDL_ENABLE`.
* *
* If `state` is `SDL_QUERY` then the current state is returned, * If SDL was built with events disabled (extremely uncommon!), this will do
* otherwise the new processing state is returned. * nothing and always return `SDL_IGNORE`.
*
* \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE`.
* \returns If `state` is `SDL_QUERY` then the current state is returned,
* otherwise `state` is returned (even if it was not one of the
* allowed values).
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -803,6 +820,7 @@ extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
*/ */
extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state); extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
/* Limits for joystick axes... */
#define SDL_JOYSTICK_AXIS_MAX 32767 #define SDL_JOYSTICK_AXIS_MAX 32767
#define SDL_JOYSTICK_AXIS_MIN -32768 #define SDL_JOYSTICK_AXIS_MIN -32768
@@ -819,8 +837,8 @@ extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
* 32767) representing the current position of the axis. It may be necessary * 32767) representing the current position of the axis. It may be necessary
* to impose certain tolerances on these values to account for jitter. * to impose certain tolerances on these values to account for jitter.
* *
* \param joystick an SDL_Joystick structure containing joystick information * \param joystick an SDL_Joystick structure containing joystick information.
* \param axis the axis to query; the axis indices start at index 0 * \param axis the axis to query; the axis indices start at index 0.
* \returns a 16-bit signed integer representing the current position of the * \returns a 16-bit signed integer representing the current position of the
* axis or 0 on failure; call SDL_GetError() for more information. * axis or 0 on failure; call SDL_GetError() for more information.
* *
@@ -838,8 +856,8 @@ extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick,
* *
* The axis indices start at index 0. * The axis indices start at index 0.
* *
* \param joystick an SDL_Joystick structure containing joystick information * \param joystick an SDL_Joystick structure containing joystick information.
* \param axis the axis to query; the axis indices start at index 0 * \param axis the axis to query; the axis indices start at index 0.
* \param state Upon return, the initial value is supplied here. * \param state Upon return, the initial value is supplied here.
* \return SDL_TRUE if this axis has any initial value, or SDL_FALSE if not. * \return SDL_TRUE if this axis has any initial value, or SDL_FALSE if not.
* *
@@ -878,8 +896,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAxisInitialState(SDL_Joystick *j
* - `SDL_HAT_LEFTUP` * - `SDL_HAT_LEFTUP`
* - `SDL_HAT_LEFTDOWN` * - `SDL_HAT_LEFTDOWN`
* *
* \param joystick an SDL_Joystick structure containing joystick information * \param joystick an SDL_Joystick structure containing joystick information.
* \param hat the hat index to get the state from; indices start at index 0 * \param hat the hat index to get the state from; indices start at index 0.
* \returns the current hat position. * \returns the current hat position.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -897,10 +915,10 @@ extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick,
* *
* Most joysticks do not have trackballs. * Most joysticks do not have trackballs.
* *
* \param joystick the SDL_Joystick to query * \param joystick the SDL_Joystick to query.
* \param ball the ball index to query; ball indices start at index 0 * \param ball the ball index to query; ball indices start at index 0.
* \param dx stores the difference in the x axis position since the last poll * \param dx stores the difference in the x axis position since the last poll.
* \param dy stores the difference in the y axis position since the last poll * \param dy stores the difference in the y axis position since the last poll.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -914,9 +932,9 @@ extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick,
/** /**
* Get the current state of a button on a joystick. * Get the current state of a button on a joystick.
* *
* \param joystick an SDL_Joystick structure containing joystick information * \param joystick an SDL_Joystick structure containing joystick information.
* \param button the button index to get the state from; indices start at * \param button the button index to get the state from; indices start at
* index 0 * index 0.
* \returns 1 if the specified button is pressed, 0 otherwise. * \returns 1 if the specified button is pressed, 0 otherwise.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -932,13 +950,13 @@ extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick,
* Each call to this function cancels any previous rumble effect, and calling * Each call to this function cancels any previous rumble effect, and calling
* it with 0 intensity stops any rumbling. * it with 0 intensity stops any rumbling.
* *
* \param joystick The joystick to vibrate * \param joystick The joystick to vibrate.
* \param low_frequency_rumble The intensity of the low frequency (left) * \param low_frequency_rumble The intensity of the low frequency (left)
* rumble motor, from 0 to 0xFFFF * rumble motor, from 0 to 0xFFFF.
* \param high_frequency_rumble The intensity of the high frequency (right) * \param high_frequency_rumble The intensity of the high frequency (right)
* rumble motor, from 0 to 0xFFFF * rumble motor, from 0 to 0xFFFF.
* \param duration_ms The duration of the rumble effect, in milliseconds * \param duration_ms The duration of the rumble effect, in milliseconds.
* \returns 0, or -1 if rumble isn't supported on this joystick * \returns 0, or -1 if rumble isn't supported on this joystick.
* *
* \since This function is available since SDL 2.0.9. * \since This function is available since SDL 2.0.9.
* *
@@ -957,13 +975,13 @@ extern DECLSPEC int SDLCALL SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 lo
* want the (more common) whole-controller rumble, use SDL_JoystickRumble() * want the (more common) whole-controller rumble, use SDL_JoystickRumble()
* instead. * instead.
* *
* \param joystick The joystick to vibrate * \param joystick The joystick to vibrate.
* \param left_rumble The intensity of the left trigger rumble motor, from 0 * \param left_rumble The intensity of the left trigger rumble motor, from 0
* to 0xFFFF * to 0xFFFF.
* \param right_rumble The intensity of the right trigger rumble motor, from 0 * \param right_rumble The intensity of the right trigger rumble motor, from 0
* to 0xFFFF * to 0xFFFF.
* \param duration_ms The duration of the rumble effect, in milliseconds * \param duration_ms The duration of the rumble effect, in milliseconds.
* \returns 0, or -1 if trigger rumble isn't supported on this joystick * \returns 0, or -1 if trigger rumble isn't supported on this joystick.
* *
* \since This function is available since SDL 2.0.14. * \since This function is available since SDL 2.0.14.
* *
@@ -977,7 +995,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickRumbleTriggers(SDL_Joystick *joystick, U
* An example of a joystick LED is the light on the back of a PlayStation 4's * An example of a joystick LED is the light on the back of a PlayStation 4's
* DualShock 4 controller. * DualShock 4 controller.
* *
* \param joystick The joystick to query * \param joystick The joystick to query.
* \return SDL_TRUE if the joystick has a modifiable LED, SDL_FALSE otherwise. * \return SDL_TRUE if the joystick has a modifiable LED, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.14. * \since This function is available since SDL 2.0.14.
@@ -987,7 +1005,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasLED(SDL_Joystick *joystick);
/** /**
* Query whether a joystick has rumble support. * Query whether a joystick has rumble support.
* *
* \param joystick The joystick to query * \param joystick The joystick to query.
* \return SDL_TRUE if the joystick has rumble, SDL_FALSE otherwise. * \return SDL_TRUE if the joystick has rumble, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.18. * \since This function is available since SDL 2.0.18.
@@ -999,7 +1017,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasRumble(SDL_Joystick *joystick);
/** /**
* Query whether a joystick has rumble support on triggers. * Query whether a joystick has rumble support on triggers.
* *
* \param joystick The joystick to query * \param joystick The joystick to query.
* \return SDL_TRUE if the joystick has trigger rumble, SDL_FALSE otherwise. * \return SDL_TRUE if the joystick has trigger rumble, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.18. * \since This function is available since SDL 2.0.18.
@@ -1014,11 +1032,11 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasRumbleTriggers(SDL_Joystick *joy
* An example of a joystick LED is the light on the back of a PlayStation 4's * An example of a joystick LED is the light on the back of a PlayStation 4's
* DualShock 4 controller. * DualShock 4 controller.
* *
* \param joystick The joystick to update * \param joystick The joystick to update.
* \param red The intensity of the red LED * \param red The intensity of the red LED.
* \param green The intensity of the green LED * \param green The intensity of the green LED.
* \param blue The intensity of the blue LED * \param blue The intensity of the blue LED.
* \returns 0 on success, -1 if this joystick does not have a modifiable LED * \returns 0 on success, -1 if this joystick does not have a modifiable LED.
* *
* \since This function is available since SDL 2.0.14. * \since This function is available since SDL 2.0.14.
*/ */
@@ -1027,10 +1045,11 @@ extern DECLSPEC int SDLCALL SDL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red
/** /**
* Send a joystick specific effect packet * Send a joystick specific effect packet
* *
* \param joystick The joystick to affect * \param joystick The joystick to affect.
* \param data The data to send to the joystick * \param data The data to send to the joystick.
* \param size The size of the data to send to the joystick * \param size The size of the data to send to the joystick.
* \returns 0, or -1 if this joystick or driver doesn't support effect packets * \returns 0, or -1 if this joystick or driver doesn't support effect
* packets.
* *
* \since This function is available since SDL 2.0.16. * \since This function is available since SDL 2.0.16.
*/ */
@@ -1039,7 +1058,7 @@ extern DECLSPEC int SDLCALL SDL_JoystickSendEffect(SDL_Joystick *joystick, const
/** /**
* Close a joystick previously opened with SDL_JoystickOpen(). * Close a joystick previously opened with SDL_JoystickOpen().
* *
* \param joystick The joystick device to close * \param joystick The joystick device to close.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -1050,9 +1069,9 @@ extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick);
/** /**
* Get the battery level of a joystick as SDL_JoystickPowerLevel. * Get the battery level of a joystick as SDL_JoystickPowerLevel.
* *
* \param joystick the SDL_Joystick to query * \param joystick the SDL_Joystick to query.
* \returns the current battery level as SDL_JoystickPowerLevel on success or * \returns the current battery level as SDL_JoystickPowerLevel on success or
* `SDL_JOYSTICK_POWER_UNKNOWN` if it is unknown * `SDL_JOYSTICK_POWER_UNKNOWN` if it is unknown.
* *
* \since This function is available since SDL 2.0.4. * \since This function is available since SDL 2.0.4.
*/ */

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_keyboard.h * # CategoryKeyboard
* *
* Include file for SDL keyboard event handling * Include file for SDL keyboard event handling
*/ */
#ifndef SDL_keyboard_h_ #ifndef SDL_keyboard_h_
@@ -40,14 +40,15 @@ extern "C" {
#endif #endif
/** /**
* \brief The SDL keysym structure, used in key events. * The SDL keysym structure, used in key events.
* *
* \note If you are looking for translated character input, see the ::SDL_TEXTINPUT event. * If you are looking for translated character input, see the SDL_TEXTINPUT
* event.
*/ */
typedef struct SDL_Keysym typedef struct SDL_Keysym
{ {
SDL_Scancode scancode; /**< SDL physical key code - see ::SDL_Scancode for details */ SDL_Scancode scancode; /**< SDL physical key code - see SDL_Scancode for details */
SDL_Keycode sym; /**< SDL virtual key code - see ::SDL_Keycode for details */ SDL_Keycode sym; /**< SDL virtual key code - see SDL_Keycode for details */
Uint16 mod; /**< current key modifiers */ Uint16 mod; /**< current key modifiers */
Uint32 unused; Uint32 unused;
} SDL_Keysym; } SDL_Keysym;
@@ -84,7 +85,7 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);
* Note: This function doesn't take into account whether shift has been * Note: This function doesn't take into account whether shift has been
* pressed or not. * pressed or not.
* *
* \param numkeys if non-NULL, receives the length of the returned array * \param numkeys if non-NULL, receives the length of the returned array.
* \returns a pointer to an array of key states. * \returns a pointer to an array of key states.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -129,7 +130,7 @@ extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void);
* This does not change the keyboard state, only the key modifier flags that * This does not change the keyboard state, only the key modifier flags that
* SDL reports. * SDL reports.
* *
* \param modstate the desired SDL_Keymod for the keyboard * \param modstate the desired SDL_Keymod for the keyboard.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -143,7 +144,7 @@ extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate);
* *
* See SDL_Keycode for details. * See SDL_Keycode for details.
* *
* \param scancode the desired SDL_Scancode to query * \param scancode the desired SDL_Scancode to query.
* \returns the SDL_Keycode that corresponds to the given SDL_Scancode. * \returns the SDL_Keycode that corresponds to the given SDL_Scancode.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -159,7 +160,7 @@ extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode
* *
* See SDL_Scancode for details. * See SDL_Scancode for details.
* *
* \param key the desired SDL_Keycode to query * \param key the desired SDL_Keycode to query.
* \returns the SDL_Scancode that corresponds to the given SDL_Keycode. * \returns the SDL_Scancode that corresponds to the given SDL_Keycode.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -183,7 +184,7 @@ extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key);
* unsuitable for creating a stable cross-platform two-way mapping between * unsuitable for creating a stable cross-platform two-way mapping between
* strings and scancodes. * strings and scancodes.
* *
* \param scancode the desired SDL_Scancode to query * \param scancode the desired SDL_Scancode to query.
* \returns a pointer to the name for the scancode. If the scancode doesn't * \returns a pointer to the name for the scancode. If the scancode doesn't
* have a name this function returns an empty string (""). * have a name this function returns an empty string ("").
* *
@@ -197,7 +198,7 @@ extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode);
/** /**
* Get a scancode from a human-readable name. * Get a scancode from a human-readable name.
* *
* \param name the human-readable scancode name * \param name the human-readable scancode name.
* \returns the SDL_Scancode, or `SDL_SCANCODE_UNKNOWN` if the name wasn't * \returns the SDL_Scancode, or `SDL_SCANCODE_UNKNOWN` if the name wasn't
* recognized; call SDL_GetError() for more information. * recognized; call SDL_GetError() for more information.
* *
@@ -214,7 +215,7 @@ extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name);
* *
* See SDL_Scancode and SDL_Keycode for details. * See SDL_Scancode and SDL_Keycode for details.
* *
* \param key the desired SDL_Keycode to query * \param key the desired SDL_Keycode to query.
* \returns a pointer to a UTF-8 string that stays valid at least until the * \returns a pointer to a UTF-8 string that stays valid at least until the
* next call to this function. If you need it around any longer, you * next call to this function. If you need it around any longer, you
* must copy it. If the key doesn't have a name, this function * must copy it. If the key doesn't have a name, this function
@@ -231,7 +232,7 @@ extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key);
/** /**
* Get a key code from a human-readable name. * Get a key code from a human-readable name.
* *
* \param name the human-readable key name * \param name the human-readable key name.
* \returns key code, or `SDLK_UNKNOWN` if the name wasn't recognized; call * \returns key code, or `SDLK_UNKNOWN` if the name wasn't recognized; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -253,6 +254,10 @@ extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name);
* *
* On some platforms using this function activates the screen keyboard. * On some platforms using this function activates the screen keyboard.
* *
* On desktop platforms, SDL_StartTextInput() is implicitly called on SDL
* video subsystem initialization which will cause SDL_TextInputEvent and
* SDL_TextEditingEvent to begin emitting.
*
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
* \sa SDL_SetTextInputRect * \sa SDL_SetTextInputRect
@@ -300,6 +305,9 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputShown(void);
/** /**
* Set the rectangle used to type Unicode text inputs. * Set the rectangle used to type Unicode text inputs.
* *
* Native input methods will place a window with word suggestions near it,
* without covering the text being inputted.
*
* To start text input in a given location, this function is intended to be * To start text input in a given location, this function is intended to be
* called before SDL_StartTextInput, although some platforms support moving * called before SDL_StartTextInput, although some platforms support moving
* the rectangle even while text input (and a composition) is active. * the rectangle even while text input (and a composition) is active.
@@ -309,7 +317,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputShown(void);
* any feedback. * any feedback.
* *
* \param rect the SDL_Rect structure representing the rectangle to receive * \param rect the SDL_Rect structure representing the rectangle to receive
* text (ignored if NULL) * text (ignored if NULL).
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -333,7 +341,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasScreenKeyboardSupport(void);
/** /**
* Check whether the screen keyboard is shown for given window. * Check whether the screen keyboard is shown for given window.
* *
* \param window the window for which screen keyboard should be queried * \param window the window for which screen keyboard should be queried.
* \returns SDL_TRUE if screen keyboard is shown or SDL_FALSE if not. * \returns SDL_TRUE if screen keyboard is shown or SDL_FALSE if not.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_keycode.h * # CategoryKeycode
* *
* Defines constants which identify keyboard keys and modifiers. * Defines constants which identify keyboard keys and modifiers.
*/ */
#ifndef SDL_keycode_h_ #ifndef SDL_keycode_h_
@@ -32,22 +32,22 @@
#include <SDL2/SDL_scancode.h> #include <SDL2/SDL_scancode.h>
/** /**
* \brief The SDL virtual key representation. * The SDL virtual key representation.
* *
* Values of this type are used to represent keyboard keys using the current * Values of this type are used to represent keyboard keys using the current
* layout of the keyboard. These values include Unicode values representing * layout of the keyboard. These values include Unicode values representing
* the unmodified character that would be generated by pressing the key, or * the unmodified character that would be generated by pressing the key, or an
* an SDLK_* constant for those keys that do not generate characters. * SDLK_* constant for those keys that do not generate characters.
* *
* A special exception is the number keys at the top of the keyboard which * A special exception is the number keys at the top of the keyboard which map
* map to SDLK_0...SDLK_9 on AZERTY layouts. * to SDLK_0...SDLK_9 on AZERTY layouts.
*/ */
typedef Sint32 SDL_Keycode; typedef Sint32 SDL_Keycode;
#define SDLK_SCANCODE_MASK (1<<30) #define SDLK_SCANCODE_MASK (1<<30)
#define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK) #define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK)
typedef enum typedef enum SDL_KeyCode
{ {
SDLK_UNKNOWN = 0, SDLK_UNKNOWN = 0,
@@ -327,9 +327,9 @@ typedef enum
} SDL_KeyCode; } SDL_KeyCode;
/** /**
* \brief Enumeration of valid key mods (possibly OR'd together). * Enumeration of valid key mods (possibly OR'd together).
*/ */
typedef enum typedef enum SDL_Keymod
{ {
KMOD_NONE = 0x0000, KMOD_NONE = 0x0000,
KMOD_LSHIFT = 0x0001, KMOD_LSHIFT = 0x0001,

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -19,23 +19,25 @@
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/* WIKI CATEGORY: LoadSO */
/** /**
* \file SDL_loadso.h * # CategoryLoadSO
* *
* System dependent library loading routines * System-dependent library loading routines.
* *
* Some things to keep in mind: * Some things to keep in mind:
* \li These functions only work on C function names. Other languages may *
* have name mangling and intrinsic language support that varies from * - These functions only work on C function names. Other languages may have
* compiler to compiler. * name mangling and intrinsic language support that varies from compiler to
* \li Make sure you declare your function pointers with the same calling * compiler.
* convention as the actual library function. Your code will crash * - Make sure you declare your function pointers with the same calling
* mysteriously if you do not do this. * convention as the actual library function. Your code will crash
* \li Avoid namespace collisions. If you load a symbol from the library, * mysteriously if you do not do this.
* it is not defined whether or not it goes into the global symbol * - Avoid namespace collisions. If you load a symbol from the library, it is
* namespace for the application. If it does and it conflicts with * not defined whether or not it goes into the global symbol namespace for
* symbols in your code or other shared libraries, you will not get * the application. If it does and it conflicts with symbols in your code or
* the results you expect. :) * other shared libraries, you will not get the results you expect. :)
*/ */
#ifndef SDL_loadso_h_ #ifndef SDL_loadso_h_
@@ -53,7 +55,7 @@ extern "C" {
/** /**
* Dynamically load a shared object. * Dynamically load a shared object.
* *
* \param sofile a system-dependent name of the object file * \param sofile a system-dependent name of the object file.
* \returns an opaque pointer to the object handle or NULL if there was an * \returns an opaque pointer to the object handle or NULL if there was an
* error; call SDL_GetError() for more information. * error; call SDL_GetError() for more information.
* *
@@ -79,8 +81,8 @@ extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile);
* *
* If the requested function doesn't exist, NULL is returned. * If the requested function doesn't exist, NULL is returned.
* *
* \param handle a valid shared object handle returned by SDL_LoadObject() * \param handle a valid shared object handle returned by SDL_LoadObject().
* \param name the name of the function to look up * \param name the name of the function to look up.
* \returns a pointer to the function or NULL if there was an error; call * \returns a pointer to the function or NULL if there was an error; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -95,7 +97,7 @@ extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle,
/** /**
* Unload a shared object from memory. * Unload a shared object from memory.
* *
* \param handle a valid shared object handle returned by SDL_LoadObject() * \param handle a valid shared object handle returned by SDL_LoadObject().
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_locale.h * # CategoryLocale
* *
* Include file for SDL locale services * Include file for SDL locale services
*/ */
#ifndef _SDL_locale_h #ifndef _SDL_locale_h

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,18 +20,19 @@
*/ */
/** /**
* \file SDL_log.h * # CategoryLog
* *
* Simple log messages with categories and priorities. * Simple log messages with categories and priorities.
* *
* By default logs are quiet, but if you're debugging SDL you might want: * By default logs are quiet, but if you're debugging SDL you might want:
* *
* SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN); * SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN);
* *
* Here's where the messages go on different platforms: * Here's where the messages go on different platforms:
* Windows: debug output stream *
* Android: log output * - Windows: debug output stream
* Others: standard error output (stderr) * - Android: log output
* - Others: standard error output (stderr)
*/ */
#ifndef SDL_log_h_ #ifndef SDL_log_h_
@@ -47,21 +48,20 @@ extern "C" {
/** /**
* \brief The maximum size of a log message prior to SDL 2.0.24 * The maximum size of a log message prior to SDL 2.0.24
* *
* As of 2.0.24 there is no limit to the length of SDL log messages. * As of 2.0.24 there is no limit to the length of SDL log messages.
*/ */
#define SDL_MAX_LOG_MESSAGE 4096 #define SDL_MAX_LOG_MESSAGE 4096
/** /**
* \brief The predefined log categories * The predefined log categories
* *
* By default the application category is enabled at the INFO level, * By default the application category is enabled at the INFO level, the
* the assert category is enabled at the WARN level, test is enabled * assert category is enabled at the WARN level, test is enabled at the
* at the VERBOSE level and all other categories are enabled at the * VERBOSE level and all other categories are enabled at the ERROR level.
* CRITICAL level.
*/ */
typedef enum typedef enum SDL_LogCategory
{ {
SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_CATEGORY_APPLICATION,
SDL_LOG_CATEGORY_ERROR, SDL_LOG_CATEGORY_ERROR,
@@ -97,9 +97,9 @@ typedef enum
} SDL_LogCategory; } SDL_LogCategory;
/** /**
* \brief The predefined log priorities * The predefined log priorities
*/ */
typedef enum typedef enum SDL_LogPriority
{ {
SDL_LOG_PRIORITY_VERBOSE = 1, SDL_LOG_PRIORITY_VERBOSE = 1,
SDL_LOG_PRIORITY_DEBUG, SDL_LOG_PRIORITY_DEBUG,
@@ -114,7 +114,7 @@ typedef enum
/** /**
* Set the priority of all log categories. * Set the priority of all log categories.
* *
* \param priority the SDL_LogPriority to assign * \param priority the SDL_LogPriority to assign.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -125,8 +125,8 @@ extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority);
/** /**
* Set the priority of a particular log category. * Set the priority of a particular log category.
* *
* \param category the category to assign a priority to * \param category the category to assign a priority to.
* \param priority the SDL_LogPriority to assign * \param priority the SDL_LogPriority to assign.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -139,8 +139,8 @@ extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category,
/** /**
* Get the priority of a particular log category. * Get the priority of a particular log category.
* *
* \param category the category to query * \param category the category to query.
* \returns the SDL_LogPriority for the requested category * \returns the SDL_LogPriority for the requested category.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -166,7 +166,7 @@ extern DECLSPEC void SDLCALL SDL_LogResetPriorities(void);
* = * \param fmt a printf() style message format string * = * \param fmt a printf() style message format string
* *
* \param ... additional parameters matching % tokens in the `fmt` string, if * \param ... additional parameters matching % tokens in the `fmt` string, if
* any * any.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -184,10 +184,10 @@ extern DECLSPEC void SDLCALL SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, .
/** /**
* Log a message with SDL_LOG_PRIORITY_VERBOSE. * Log a message with SDL_LOG_PRIORITY_VERBOSE.
* *
* \param category the category of the message * \param category the category of the message.
* \param fmt a printf() style message format string * \param fmt a printf() style message format string.
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any * if any.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -205,10 +205,10 @@ extern DECLSPEC void SDLCALL SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRI
/** /**
* Log a message with SDL_LOG_PRIORITY_DEBUG. * Log a message with SDL_LOG_PRIORITY_DEBUG.
* *
* \param category the category of the message * \param category the category of the message.
* \param fmt a printf() style message format string * \param fmt a printf() style message format string.
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any * if any.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -226,10 +226,10 @@ extern DECLSPEC void SDLCALL SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING
/** /**
* Log a message with SDL_LOG_PRIORITY_INFO. * Log a message with SDL_LOG_PRIORITY_INFO.
* *
* \param category the category of the message * \param category the category of the message.
* \param fmt a printf() style message format string * \param fmt a printf() style message format string.
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any * if any.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -247,10 +247,10 @@ extern DECLSPEC void SDLCALL SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING
/** /**
* Log a message with SDL_LOG_PRIORITY_WARN. * Log a message with SDL_LOG_PRIORITY_WARN.
* *
* \param category the category of the message * \param category the category of the message.
* \param fmt a printf() style message format string * \param fmt a printf() style message format string.
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any * if any.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -268,10 +268,10 @@ extern DECLSPEC void SDLCALL SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING
/** /**
* Log a message with SDL_LOG_PRIORITY_ERROR. * Log a message with SDL_LOG_PRIORITY_ERROR.
* *
* \param category the category of the message * \param category the category of the message.
* \param fmt a printf() style message format string * \param fmt a printf() style message format string.
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any * if any.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -289,10 +289,10 @@ extern DECLSPEC void SDLCALL SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING
/** /**
* Log a message with SDL_LOG_PRIORITY_CRITICAL. * Log a message with SDL_LOG_PRIORITY_CRITICAL.
* *
* \param category the category of the message * \param category the category of the message.
* \param fmt a printf() style message format string * \param fmt a printf() style message format string.
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any * if any.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -310,11 +310,11 @@ extern DECLSPEC void SDLCALL SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STR
/** /**
* Log a message with the specified category and priority. * Log a message with the specified category and priority.
* *
* \param category the category of the message * \param category the category of the message.
* \param priority the priority of the message * \param priority the priority of the message.
* \param fmt a printf() style message format string * \param fmt a printf() style message format string.
* \param ... additional parameters matching % tokens in the **fmt** string, * \param ... additional parameters matching % tokens in the **fmt** string,
* if any * if any.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -334,10 +334,10 @@ extern DECLSPEC void SDLCALL SDL_LogMessage(int category,
/** /**
* Log a message with the specified category and priority. * Log a message with the specified category and priority.
* *
* \param category the category of the message * \param category the category of the message.
* \param priority the priority of the message * \param priority the priority of the message.
* \param fmt a printf() style message format string * \param fmt a printf() style message format string.
* \param ap a variable argument list * \param ap a variable argument list.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -352,17 +352,18 @@ extern DECLSPEC void SDLCALL SDL_LogMessage(int category,
*/ */
extern DECLSPEC void SDLCALL SDL_LogMessageV(int category, extern DECLSPEC void SDLCALL SDL_LogMessageV(int category,
SDL_LogPriority priority, SDL_LogPriority priority,
const char *fmt, va_list ap); SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(3);
/** /**
* The prototype for the log output callback function. * The prototype for the log output callback function.
* *
* This function is called by SDL when there is new text to be logged. * This function is called by SDL when there is new text to be logged.
* *
* \param userdata what was passed as `userdata` to SDL_LogSetOutputFunction() * \param userdata what was passed as `userdata` to
* \param category the category of the message * SDL_LogSetOutputFunction().
* \param priority the priority of the message * \param category the category of the message.
* \param message the message being output * \param priority the priority of the message.
* \param message the message being output.
*/ */
typedef void (SDLCALL *SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message); typedef void (SDLCALL *SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message);
@@ -370,9 +371,9 @@ typedef void (SDLCALL *SDL_LogOutputFunction)(void *userdata, int category, SDL_
* Get the current log output function. * Get the current log output function.
* *
* \param callback an SDL_LogOutputFunction filled in with the current log * \param callback an SDL_LogOutputFunction filled in with the current log
* callback * callback.
* \param userdata a pointer filled in with the pointer that is passed to * \param userdata a pointer filled in with the pointer that is passed to
* `callback` * `callback`.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -383,8 +384,8 @@ extern DECLSPEC void SDLCALL SDL_LogGetOutputFunction(SDL_LogOutputFunction *cal
/** /**
* Replace the default log output function with one of your own. * Replace the default log output function with one of your own.
* *
* \param callback an SDL_LogOutputFunction to call instead of the default * \param callback an SDL_LogOutputFunction to call instead of the default.
* \param userdata a pointer that is passed to `callback` * \param userdata a pointer that is passed to `callback`.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -25,9 +25,9 @@
#include <SDL2/SDL_stdinc.h> #include <SDL2/SDL_stdinc.h>
/** /**
* \file SDL_main.h * # CategoryMain
* *
* Redefine main() on some platforms so that it is called by SDL. * Redefine main() on some platforms so that it is called by SDL.
*/ */
#ifndef SDL_MAIN_HANDLED #ifndef SDL_MAIN_HANDLED
@@ -129,14 +129,14 @@
* *
* The application's main() function must be called with C linkage, * The application's main() function must be called with C linkage,
* and should be declared like this: * and should be declared like this:
* \code * ```c
* #ifdef __cplusplus * #ifdef __cplusplus
* extern "C" * extern "C"
* #endif * #endif
* int main(int argc, char *argv[]) * int main(int argc, char *argv[])
* { * {
* } * }
* \endcode * ```
*/ */
#if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE) #if defined(SDL_MAIN_NEEDED) || defined(SDL_MAIN_AVAILABLE)
@@ -149,7 +149,7 @@ extern "C" {
#endif #endif
/** /**
* The prototype for the application's main() function * The prototype for the application's main() function
*/ */
typedef int (*SDL_main_func)(int argc, char *argv[]); typedef int (*SDL_main_func)(int argc, char *argv[]);
extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]); extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]);
@@ -222,8 +222,8 @@ extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
/** /**
* Initialize and launch an SDL/WinRT application. * Initialize and launch an SDL/WinRT application.
* *
* \param mainFunction the SDL app's C-style main(), an SDL_main_func * \param mainFunction the SDL app's C-style main(), an SDL_main_func.
* \param reserved reserved for future use; should be NULL * \param reserved reserved for future use; should be NULL.
* \returns 0 on success or -1 on failure; call SDL_GetError() to retrieve * \returns 0 on success or -1 on failure; call SDL_GetError() to retrieve
* more information on the failure. * more information on the failure.
* *
@@ -238,10 +238,10 @@ extern DECLSPEC int SDLCALL SDL_WinRTRunApp(SDL_main_func mainFunction, void * r
/** /**
* Initializes and launches an SDL application. * Initializes and launches an SDL application.
* *
* \param argc The argc parameter from the application's main() function * \param argc The argc parameter from the application's main() function.
* \param argv The argv parameter from the application's main() function * \param argv The argv parameter from the application's main() function.
* \param mainFunction The SDL app's C-style main(), an SDL_main_func * \param mainFunction The SDL app's C-style main(), an SDL_main_func.
* \return the return value from mainFunction * \return the return value from mainFunction.
* *
* \since This function is available since SDL 2.0.10. * \since This function is available since SDL 2.0.10.
*/ */
@@ -254,8 +254,8 @@ extern DECLSPEC int SDLCALL SDL_UIKitRunApp(int argc, char *argv[], SDL_main_fun
/** /**
* Initialize and launch an SDL GDK application. * Initialize and launch an SDL GDK application.
* *
* \param mainFunction the SDL app's C-style main(), an SDL_main_func * \param mainFunction the SDL app's C-style main(), an SDL_main_func.
* \param reserved reserved for future use; should be NULL * \param reserved reserved for future use; should be NULL.
* \returns 0 on success or -1 on failure; call SDL_GetError() to retrieve * \returns 0 on success or -1 on failure; call SDL_GetError() to retrieve
* more information on the failure. * more information on the failure.
* *

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -32,9 +32,11 @@ extern "C" {
#endif #endif
/** /**
* SDL_MessageBox flags. If supported will display warning icon, etc. * SDL_MessageBox flags.
*
* If supported will display warning icon, etc.
*/ */
typedef enum typedef enum SDL_MessageBoxFlags
{ {
SDL_MESSAGEBOX_ERROR = 0x00000010, /**< error dialog */ SDL_MESSAGEBOX_ERROR = 0x00000010, /**< error dialog */
SDL_MESSAGEBOX_WARNING = 0x00000020, /**< warning dialog */ SDL_MESSAGEBOX_WARNING = 0x00000020, /**< warning dialog */
@@ -46,7 +48,7 @@ typedef enum
/** /**
* Flags for SDL_MessageBoxButtonData. * Flags for SDL_MessageBoxButtonData.
*/ */
typedef enum typedef enum SDL_MessageBoxButtonFlags
{ {
SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001, /**< Marks the default button when return is hit */ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT = 0x00000001, /**< Marks the default button when return is hit */
SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002 /**< Marks the default button when escape is hit */ SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT = 0x00000002 /**< Marks the default button when escape is hit */
@@ -55,9 +57,9 @@ typedef enum
/** /**
* Individual button data. * Individual button data.
*/ */
typedef struct typedef struct SDL_MessageBoxButtonData
{ {
Uint32 flags; /**< ::SDL_MessageBoxButtonFlags */ Uint32 flags; /**< SDL_MessageBoxButtonFlags */
int buttonid; /**< User defined button id (value returned via SDL_ShowMessageBox) */ int buttonid; /**< User defined button id (value returned via SDL_ShowMessageBox) */
const char * text; /**< The UTF-8 button text */ const char * text; /**< The UTF-8 button text */
} SDL_MessageBoxButtonData; } SDL_MessageBoxButtonData;
@@ -65,12 +67,12 @@ typedef struct
/** /**
* RGB value used in a message box color scheme * RGB value used in a message box color scheme
*/ */
typedef struct typedef struct SDL_MessageBoxColor
{ {
Uint8 r, g, b; Uint8 r, g, b;
} SDL_MessageBoxColor; } SDL_MessageBoxColor;
typedef enum typedef enum SDL_MessageBoxColorType
{ {
SDL_MESSAGEBOX_COLOR_BACKGROUND, SDL_MESSAGEBOX_COLOR_BACKGROUND,
SDL_MESSAGEBOX_COLOR_TEXT, SDL_MESSAGEBOX_COLOR_TEXT,
@@ -83,7 +85,7 @@ typedef enum
/** /**
* A set of colors to use for message box dialogs * A set of colors to use for message box dialogs
*/ */
typedef struct typedef struct SDL_MessageBoxColorScheme
{ {
SDL_MessageBoxColor colors[SDL_MESSAGEBOX_COLOR_MAX]; SDL_MessageBoxColor colors[SDL_MESSAGEBOX_COLOR_MAX];
} SDL_MessageBoxColorScheme; } SDL_MessageBoxColorScheme;
@@ -91,9 +93,9 @@ typedef struct
/** /**
* MessageBox structure containing title, text, window, etc. * MessageBox structure containing title, text, window, etc.
*/ */
typedef struct typedef struct SDL_MessageBoxData
{ {
Uint32 flags; /**< ::SDL_MessageBoxFlags */ Uint32 flags; /**< SDL_MessageBoxFlags */
SDL_Window *window; /**< Parent window, can be NULL */ SDL_Window *window; /**< Parent window, can be NULL */
const char *title; /**< UTF-8 title */ const char *title; /**< UTF-8 title */
const char *message; /**< UTF-8 message text */ const char *message; /**< UTF-8 message text */
@@ -101,7 +103,7 @@ typedef struct
int numbuttons; int numbuttons;
const SDL_MessageBoxButtonData *buttons; const SDL_MessageBoxButtonData *buttons;
const SDL_MessageBoxColorScheme *colorScheme; /**< ::SDL_MessageBoxColorScheme, can be NULL to use system settings */ const SDL_MessageBoxColorScheme *colorScheme; /**< SDL_MessageBoxColorScheme, can be NULL to use system settings */
} SDL_MessageBoxData; } SDL_MessageBoxData;
/** /**
@@ -128,8 +130,9 @@ typedef struct
* to stderr if you can. * to stderr if you can.
* *
* \param messageboxdata the SDL_MessageBoxData structure with title, text and * \param messageboxdata the SDL_MessageBoxData structure with title, text and
* other options * other options.
* \param buttonid the pointer to which user id of hit button should be copied * \param buttonid the pointer to which user id of hit button should be
* copied.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -168,10 +171,10 @@ extern DECLSPEC int SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *message
* concern, check the return value from this function and fall back to writing * concern, check the return value from this function and fall back to writing
* to stderr if you can. * to stderr if you can.
* *
* \param flags an SDL_MessageBoxFlags value * \param flags an SDL_MessageBoxFlags value.
* \param title UTF-8 title text * \param title UTF-8 title text.
* \param message UTF-8 message text * \param message UTF-8 message text.
* \param window the parent window, or NULL for no parent * \param window the parent window, or NULL for no parent.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,10 @@
*/ */
/** /**
* \file SDL_metal.h * # CategoryMetal
* *
* Header file for functions to creating Metal layers and views on SDL windows. * Header file for functions to creating Metal layers and views on SDL
* windows.
*/ */
#ifndef SDL_metal_h_ #ifndef SDL_metal_h_
@@ -37,9 +38,9 @@ extern "C" {
#endif #endif
/** /**
* \brief A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS). * A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS).
* *
* \note This can be cast directly to an NSView or UIView. * This can be cast directly to an NSView or UIView.
*/ */
typedef void *SDL_MetalView; typedef void *SDL_MetalView;
@@ -90,9 +91,9 @@ extern DECLSPEC void *SDLCALL SDL_Metal_GetLayer(SDL_MetalView view);
* Get the size of a window's underlying drawable in pixels (for use with * Get the size of a window's underlying drawable in pixels (for use with
* setting viewport, scissor & etc). * setting viewport, scissor & etc).
* *
* \param window SDL_Window from which the drawable size should be queried * \param window SDL_Window from which the drawable size should be queried.
* \param w Pointer to variable for storing the width in pixels, may be NULL * \param w Pointer to variable for storing the width in pixels, may be NULL.
* \param h Pointer to variable for storing the height in pixels, may be NULL * \param h Pointer to variable for storing the height in pixels, may be NULL.
* *
* \since This function is available since SDL 2.0.14. * \since This function is available since SDL 2.0.14.
* *

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_misc.h * # CategoryMisc
* *
* \brief Include file for SDL API functions that don't fit elsewhere. * Include file for SDL API functions that don't fit elsewhere.
*/ */
#ifndef SDL_misc_h_ #ifndef SDL_misc_h_

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_mouse.h * # CategoryMouse
* *
* Include file for SDL mouse event handling. * Include file for SDL mouse event handling.
*/ */
#ifndef SDL_mouse_h_ #ifndef SDL_mouse_h_
@@ -41,9 +41,9 @@ extern "C" {
typedef struct SDL_Cursor SDL_Cursor; /**< Implementation dependent */ typedef struct SDL_Cursor SDL_Cursor; /**< Implementation dependent */
/** /**
* \brief Cursor types for SDL_CreateSystemCursor(). * Cursor types for SDL_CreateSystemCursor().
*/ */
typedef enum typedef enum SDL_SystemCursor
{ {
SDL_SYSTEM_CURSOR_ARROW, /**< Arrow */ SDL_SYSTEM_CURSOR_ARROW, /**< Arrow */
SDL_SYSTEM_CURSOR_IBEAM, /**< I-beam */ SDL_SYSTEM_CURSOR_IBEAM, /**< I-beam */
@@ -61,9 +61,9 @@ typedef enum
} SDL_SystemCursor; } SDL_SystemCursor;
/** /**
* \brief Scroll direction types for the Scroll event * Scroll direction types for the Scroll event
*/ */
typedef enum typedef enum SDL_MouseWheelDirection
{ {
SDL_MOUSEWHEEL_NORMAL, /**< The scroll direction is normal */ SDL_MOUSEWHEEL_NORMAL, /**< The scroll direction is normal */
SDL_MOUSEWHEEL_FLIPPED /**< The scroll direction is flipped / natural */ SDL_MOUSEWHEEL_FLIPPED /**< The scroll direction is flipped / natural */
@@ -90,9 +90,9 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void);
* either `x` or `y`. * either `x` or `y`.
* *
* \param x the x coordinate of the mouse cursor position relative to the * \param x the x coordinate of the mouse cursor position relative to the
* focus window * focus window.
* \param y the y coordinate of the mouse cursor position relative to the * \param y the y coordinate of the mouse cursor position relative to the
* focus window * focus window.
* \returns a 32-bit button bitmask of the current button state. * \returns a 32-bit button bitmask of the current button state.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -120,9 +120,9 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetMouseState(int *x, int *y);
* reason to use this function, you probably want SDL_GetMouseState() instead. * reason to use this function, you probably want SDL_GetMouseState() instead.
* *
* \param x filled in with the current X coord relative to the desktop; can be * \param x filled in with the current X coord relative to the desktop; can be
* NULL * NULL.
* \param y filled in with the current Y coord relative to the desktop; can be * \param y filled in with the current Y coord relative to the desktop; can be
* NULL * NULL.
* \returns the current button state as a bitmask which can be tested using * \returns the current button state as a bitmask which can be tested using
* the SDL_BUTTON(X) macros. * the SDL_BUTTON(X) macros.
* *
@@ -141,8 +141,8 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetGlobalMouseState(int *x, int *y);
* mouse deltas since the last call to SDL_GetRelativeMouseState() or since * mouse deltas since the last call to SDL_GetRelativeMouseState() or since
* event initialization. You can pass NULL for either `x` or `y`. * event initialization. You can pass NULL for either `x` or `y`.
* *
* \param x a pointer filled with the last recorded x coordinate of the mouse * \param x a pointer filled with the last recorded x coordinate of the mouse.
* \param y a pointer filled with the last recorded y coordinate of the mouse * \param y a pointer filled with the last recorded y coordinate of the mouse.
* \returns a 32-bit button bitmask of the relative button state. * \returns a 32-bit button bitmask of the relative button state.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -162,9 +162,9 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y);
* mouse when used over Microsoft Remote Desktop. * mouse when used over Microsoft Remote Desktop.
* *
* \param window the window to move the mouse into, or NULL for the current * \param window the window to move the mouse into, or NULL for the current
* mouse focus * mouse focus.
* \param x the x coordinate within the window * \param x the x coordinate within the window.
* \param y the y coordinate within the window * \param y the y coordinate within the window.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -184,8 +184,8 @@ extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window,
* Note that this function will appear to succeed, but not actually move the * Note that this function will appear to succeed, but not actually move the
* mouse when used over Microsoft Remote Desktop. * mouse when used over Microsoft Remote Desktop.
* *
* \param x the x coordinate * \param x the x coordinate.
* \param y the y coordinate * \param y the y coordinate.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -297,14 +297,14 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void);
* Also, since SDL 2.0.0, SDL_CreateSystemCursor() is available, which * Also, since SDL 2.0.0, SDL_CreateSystemCursor() is available, which
* provides twelve readily available system cursors to pick from. * provides twelve readily available system cursors to pick from.
* *
* \param data the color value for each pixel of the cursor * \param data the color value for each pixel of the cursor.
* \param mask the mask value for each pixel of the cursor * \param mask the mask value for each pixel of the cursor.
* \param w the width of the cursor * \param w the width of the cursor.
* \param h the height of the cursor * \param h the height of the cursor.
* \param hot_x the X-axis location of the upper left corner of the cursor * \param hot_x the X-axis location of the upper left corner of the cursor
* relative to the actual mouse position * relative to the actual mouse position.
* \param hot_y the Y-axis location of the upper left corner of the cursor * \param hot_y the Y-axis location of the upper left corner of the cursor
* relative to the actual mouse position * relative to the actual mouse position.
* \returns a new cursor with the specified parameters on success or NULL on * \returns a new cursor with the specified parameters on success or NULL on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
@@ -322,9 +322,9 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data,
/** /**
* Create a color cursor. * Create a color cursor.
* *
* \param surface an SDL_Surface structure representing the cursor image * \param surface an SDL_Surface structure representing the cursor image.
* \param hot_x the x position of the cursor hot spot * \param hot_x the x position of the cursor hot spot.
* \param hot_y the y position of the cursor hot spot * \param hot_y the y position of the cursor hot spot.
* \returns the new cursor on success or NULL on failure; call SDL_GetError() * \returns the new cursor on success or NULL on failure; call SDL_GetError()
* for more information. * for more information.
* *
@@ -340,7 +340,7 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface,
/** /**
* Create a system cursor. * Create a system cursor.
* *
* \param id an SDL_SystemCursor enum value * \param id an SDL_SystemCursor enum value.
* \returns a cursor on success or NULL on failure; call SDL_GetError() for * \returns a cursor on success or NULL on failure; call SDL_GetError() for
* more information. * more information.
* *
@@ -358,7 +358,7 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id);
* the display. SDL_SetCursor(NULL) can be used to force cursor redraw, if * the display. SDL_SetCursor(NULL) can be used to force cursor redraw, if
* this is desired for any reason. * this is desired for any reason.
* *
* \param cursor a cursor to make active * \param cursor a cursor to make active.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -402,7 +402,7 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor(void);
* Use this function to free cursor resources created with SDL_CreateCursor(), * Use this function to free cursor resources created with SDL_CreateCursor(),
* SDL_CreateColorCursor() or SDL_CreateSystemCursor(). * SDL_CreateColorCursor() or SDL_CreateSystemCursor().
* *
* \param cursor the cursor to free * \param cursor the cursor to free.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -437,9 +437,9 @@ extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle);
/** /**
* Used as a mask when testing buttons in buttonstate. * Used as a mask when testing buttons in buttonstate.
* *
* - Button 1: Left mouse button * - Button 1: Left mouse button
* - Button 2: Middle mouse button * - Button 2: Middle mouse button
* - Button 3: Right mouse button * - Button 3: Right mouse button
*/ */
#define SDL_BUTTON(X) (1 << ((X)-1)) #define SDL_BUTTON(X) (1 << ((X)-1))
#define SDL_BUTTON_LEFT 1 #define SDL_BUTTON_LEFT 1

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -23,9 +23,9 @@
#define SDL_mutex_h_ #define SDL_mutex_h_
/** /**
* \file SDL_mutex.h * # CategoryMutex
* *
* Functions to provide thread synchronization primitives. * Functions to provide thread synchronization primitives.
*/ */
#include <SDL2/SDL_stdinc.h> #include <SDL2/SDL_stdinc.h>
@@ -112,13 +112,13 @@ extern "C" {
#endif #endif
/** /**
* Synchronization functions which can time out return this value * Synchronization functions which can time out return this value if they time
* if they time out. * out.
*/ */
#define SDL_MUTEX_TIMEDOUT 1 #define SDL_MUTEX_TIMEDOUT 1
/** /**
* This is the timeout value which corresponds to never time out. * This is the timeout value which corresponds to never time out.
*/ */
#define SDL_MUTEX_MAXWAIT (~(Uint32)0) #define SDL_MUTEX_MAXWAIT (~(Uint32)0)
@@ -165,7 +165,7 @@ extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void);
* unlock it the same number of times before it is actually made available for * unlock it the same number of times before it is actually made available for
* other threads in the system (this is known as a "recursive mutex"). * other threads in the system (this is known as a "recursive mutex").
* *
* \param mutex the mutex to lock * \param mutex the mutex to lock.
* \return 0, or -1 on error. * \return 0, or -1 on error.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -182,7 +182,7 @@ extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex) SDL_ACQUIRE(mutex);
* This technique is useful if you need exclusive access to a resource but * This technique is useful if you need exclusive access to a resource but
* don't want to wait for it, and will return to it to try again later. * don't want to wait for it, and will return to it to try again later.
* *
* \param mutex the mutex to try to lock * \param mutex the mutex to try to lock.
* \returns 0, `SDL_MUTEX_TIMEDOUT`, or -1 on error; call SDL_GetError() for * \returns 0, `SDL_MUTEX_TIMEDOUT`, or -1 on error; call SDL_GetError() for
* more information. * more information.
* *
@@ -224,7 +224,7 @@ extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex) SDL_RELEASE(mutex
* to destroy a locked mutex, and may result in undefined behavior depending * to destroy a locked mutex, and may result in undefined behavior depending
* on the platform. * on the platform.
* *
* \param mutex the mutex to destroy * \param mutex the mutex to destroy.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -256,7 +256,7 @@ typedef struct SDL_semaphore SDL_sem;
* is 0. Each post operation will atomically increment the semaphore value and * is 0. Each post operation will atomically increment the semaphore value and
* wake waiting threads and allow them to retry the wait operation. * wake waiting threads and allow them to retry the wait operation.
* *
* \param initial_value the starting value of the semaphore * \param initial_value the starting value of the semaphore.
* \returns a new semaphore or NULL on failure; call SDL_GetError() for more * \returns a new semaphore or NULL on failure; call SDL_GetError() for more
* information. * information.
* *
@@ -277,7 +277,7 @@ extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value);
* It is not safe to destroy a semaphore if there are threads currently * It is not safe to destroy a semaphore if there are threads currently
* waiting on it. * waiting on it.
* *
* \param sem the semaphore to destroy * \param sem the semaphore to destroy.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -301,7 +301,7 @@ extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem * sem);
* This function is the equivalent of calling SDL_SemWaitTimeout() with a time * This function is the equivalent of calling SDL_SemWaitTimeout() with a time
* length of `SDL_MUTEX_MAXWAIT`. * length of `SDL_MUTEX_MAXWAIT`.
* *
* \param sem the semaphore wait on * \param sem the semaphore wait on.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -325,7 +325,7 @@ extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem * sem);
* the semaphore doesn't have a positive value, the function immediately * the semaphore doesn't have a positive value, the function immediately
* returns SDL_MUTEX_TIMEDOUT. * returns SDL_MUTEX_TIMEDOUT.
* *
* \param sem the semaphore to wait on * \param sem the semaphore to wait on.
* \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait would * \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait would
* block, or a negative error code on failure; call SDL_GetError() * block, or a negative error code on failure; call SDL_GetError()
* for more information. * for more information.
@@ -349,8 +349,8 @@ extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem);
* signal or error, or the specified time has elapsed. If the call is * signal or error, or the specified time has elapsed. If the call is
* successful it will atomically decrement the semaphore value. * successful it will atomically decrement the semaphore value.
* *
* \param sem the semaphore to wait on * \param sem the semaphore to wait on.
* \param timeout the length of the timeout, in milliseconds * \param timeout the length of the timeout, in milliseconds.
* \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait does not * \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait does not
* succeed in the allotted time, or a negative error code on failure; * succeed in the allotted time, or a negative error code on failure;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
@@ -369,7 +369,7 @@ extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout);
/** /**
* Atomically increment a semaphore's value and wake waiting threads. * Atomically increment a semaphore's value and wake waiting threads.
* *
* \param sem the semaphore to increment * \param sem the semaphore to increment.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -387,7 +387,7 @@ extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem);
/** /**
* Get the current value of a semaphore. * Get the current value of a semaphore.
* *
* \param sem the semaphore to query * \param sem the semaphore to query.
* \returns the current value of the semaphore. * \returns the current value of the semaphore.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -427,7 +427,7 @@ extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void);
/** /**
* Destroy a condition variable. * Destroy a condition variable.
* *
* \param cond the condition variable to destroy * \param cond the condition variable to destroy.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -442,7 +442,7 @@ extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond * cond);
/** /**
* Restart one of the threads that are waiting on the condition variable. * Restart one of the threads that are waiting on the condition variable.
* *
* \param cond the condition variable to signal * \param cond the condition variable to signal.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -459,7 +459,7 @@ extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond * cond);
/** /**
* Restart all threads that are waiting on the condition variable. * Restart all threads that are waiting on the condition variable.
* *
* \param cond the condition variable to signal * \param cond the condition variable to signal.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -486,8 +486,8 @@ extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond);
* This function is the equivalent of calling SDL_CondWaitTimeout() with a * This function is the equivalent of calling SDL_CondWaitTimeout() with a
* time length of `SDL_MUTEX_MAXWAIT`. * time length of `SDL_MUTEX_MAXWAIT`.
* *
* \param cond the condition variable to wait on * \param cond the condition variable to wait on.
* \param mutex the mutex used to coordinate thread access * \param mutex the mutex used to coordinate thread access.
* \returns 0 when it is signaled or a negative error code on failure; call * \returns 0 when it is signaled or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -512,10 +512,10 @@ extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex);
* *
* The mutex must be locked before calling this function. * The mutex must be locked before calling this function.
* *
* \param cond the condition variable to wait on * \param cond the condition variable to wait on.
* \param mutex the mutex used to coordinate thread access * \param mutex the mutex used to coordinate thread access.
* \param ms the maximum time to wait, in milliseconds, or `SDL_MUTEX_MAXWAIT` * \param ms the maximum time to wait, in milliseconds, or `SDL_MUTEX_MAXWAIT`
* to wait indefinitely * to wait indefinitely.
* \returns 0 if the condition variable is signaled, `SDL_MUTEX_TIMEDOUT` if * \returns 0 if the condition variable is signaled, `SDL_MUTEX_TIMEDOUT` if
* the condition is not signaled in the allotted time, or a negative * the condition is not signaled in the allotted time, or a negative
* error code on failure; call SDL_GetError() for more information. * error code on failure; call SDL_GetError() for more information.

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -19,17 +19,11 @@
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/** /*
* \file SDL_opengl.h * This is a simple file to encapsulate the OpenGL API headers.
* *
* This is a simple file to encapsulate the OpenGL API headers. * Define NO_SDL_GLEXT if you have your own version of glext.h and want
*/ * to disable the version included in SDL_opengl.h.
/**
* \def NO_SDL_GLEXT
*
* Define this if you have your own version of glext.h and want to disable the
* version included in SDL_opengl.h.
*/ */
#ifndef SDL_opengl_h_ #ifndef SDL_opengl_h_

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -19,11 +19,10 @@
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/** /*
* \file SDL_opengles.h * This is a simple file to encapsulate the OpenGL ES 1.X API headers.
*
* This is a simple file to encapsulate the OpenGL ES 1.X API headers.
*/ */
#include <SDL2/SDL_config.h> #include <SDL2/SDL_config.h>
#ifdef __IPHONEOS__ #ifdef __IPHONEOS__

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -19,11 +19,10 @@
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/** /*
* \file SDL_opengles2.h * This is a simple file to encapsulate the OpenGL ES 2.0 API headers.
*
* This is a simple file to encapsulate the OpenGL ES 2.0 API headers.
*/ */
#include <SDL2/SDL_config.h> #include <SDL2/SDL_config.h>
#if !defined(_MSC_VER) && !defined(SDL_USE_BUILTIN_OPENGL_DEFINITIONS) #if !defined(_MSC_VER) && !defined(SDL_USE_BUILTIN_OPENGL_DEFINITIONS)

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_pixels.h * # CategoryPixels
* *
* Header for the enumerated pixel format definitions. * Header for the enumerated pixel format definitions.
*/ */
#ifndef SDL_pixels_h_ #ifndef SDL_pixels_h_
@@ -61,7 +61,10 @@ typedef enum
SDL_PIXELTYPE_ARRAYU16, SDL_PIXELTYPE_ARRAYU16,
SDL_PIXELTYPE_ARRAYU32, SDL_PIXELTYPE_ARRAYU32,
SDL_PIXELTYPE_ARRAYF16, SDL_PIXELTYPE_ARRAYF16,
SDL_PIXELTYPE_ARRAYF32 SDL_PIXELTYPE_ARRAYF32,
/* This must be at the end of the list to avoid breaking the existing ABI */
SDL_PIXELTYPE_INDEX2
} SDL_PixelType; } SDL_PixelType;
/** Bitmap pixel order, high bit -> low bit. */ /** Bitmap pixel order, high bit -> low bit. */
@@ -134,6 +137,7 @@ typedef enum
#define SDL_ISPIXELFORMAT_INDEXED(format) \ #define SDL_ISPIXELFORMAT_INDEXED(format) \
(!SDL_ISPIXELFORMAT_FOURCC(format) && \ (!SDL_ISPIXELFORMAT_FOURCC(format) && \
((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \ ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \
(SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX2) || \
(SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \ (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \
(SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8))) (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8)))
@@ -177,6 +181,12 @@ typedef enum
SDL_PIXELFORMAT_INDEX1MSB = SDL_PIXELFORMAT_INDEX1MSB =
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0, SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0,
1, 0), 1, 0),
SDL_PIXELFORMAT_INDEX2LSB =
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX2, SDL_BITMAPORDER_4321, 0,
2, 0),
SDL_PIXELFORMAT_INDEX2MSB =
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX2, SDL_BITMAPORDER_1234, 0,
2, 0),
SDL_PIXELFORMAT_INDEX4LSB = SDL_PIXELFORMAT_INDEX4LSB =
SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0, SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0,
4, 0), 4, 0),
@@ -276,11 +286,19 @@ typedef enum
SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_ARGB8888,
SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_BGRA8888,
SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_ABGR8888,
SDL_PIXELFORMAT_RGBX32 = SDL_PIXELFORMAT_RGBX8888,
SDL_PIXELFORMAT_XRGB32 = SDL_PIXELFORMAT_XRGB8888,
SDL_PIXELFORMAT_BGRX32 = SDL_PIXELFORMAT_BGRX8888,
SDL_PIXELFORMAT_XBGR32 = SDL_PIXELFORMAT_XBGR8888,
#else #else
SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_ABGR8888,
SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_BGRA8888,
SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_ARGB8888,
SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_RGBA8888,
SDL_PIXELFORMAT_RGBX32 = SDL_PIXELFORMAT_XBGR8888,
SDL_PIXELFORMAT_XRGB32 = SDL_PIXELFORMAT_BGRX8888,
SDL_PIXELFORMAT_BGRX32 = SDL_PIXELFORMAT_XRGB8888,
SDL_PIXELFORMAT_XBGR32 = SDL_PIXELFORMAT_RGBX8888,
#endif #endif
SDL_PIXELFORMAT_YV12 = /**< Planar mode: Y + V + U (3 planes) */ SDL_PIXELFORMAT_YV12 = /**< Planar mode: Y + V + U (3 planes) */
@@ -302,9 +320,10 @@ typedef enum
} SDL_PixelFormatEnum; } SDL_PixelFormatEnum;
/** /**
* The bits of this structure can be directly reinterpreted as an integer-packed * The bits of this structure can be directly reinterpreted as an
* color which uses the SDL_PIXELFORMAT_RGBA32 format (SDL_PIXELFORMAT_ABGR8888 * integer-packed color which uses the SDL_PIXELFORMAT_RGBA32 format
* on little-endian systems and SDL_PIXELFORMAT_RGBA8888 on big-endian systems). * (SDL_PIXELFORMAT_ABGR8888 on little-endian systems and
* SDL_PIXELFORMAT_RGBA8888 on big-endian systems).
*/ */
typedef struct SDL_Color typedef struct SDL_Color
{ {
@@ -324,7 +343,30 @@ typedef struct SDL_Palette
} SDL_Palette; } SDL_Palette;
/** /**
* \note Everything in the pixel format structure is read-only. * A structure that contains pixel format information.
*
* Everything in the pixel format structure is read-only.
*
* A pixel format has either a palette or masks. If a palette is used `Rmask`,
* `Gmask`, `Bmask`, and `Amask` will be 0.
*
* An SDL_PixelFormat describes the format of the pixel data stored at the
* `pixels` field of an SDL_Surface. Every surface stores an SDL_PixelFormat
* in the `format` field.
*
* If you wish to do pixel level modifications on a surface, then
* understanding how SDL stores its color information is essential.
*
* For information on modern pixel color spaces, see the following Wikipedia
* article: http://en.wikipedia.org/wiki/RGBA_color_space
*
* \sa SDL_ConvertSurface
* \sa SDL_GetRGB
* \sa SDL_GetRGBA
* \sa SDL_MapRGB
* \sa SDL_MapRGBA
* \sa SDL_AllocFormat
* \sa SDL_FreeFormat
*/ */
typedef struct SDL_PixelFormat typedef struct SDL_PixelFormat
{ {
@@ -352,7 +394,7 @@ typedef struct SDL_PixelFormat
/** /**
* Get the human readable name of a pixel format. * Get the human readable name of a pixel format.
* *
* \param format the pixel format to query * \param format the pixel format to query.
* \returns the human readable name of the specified pixel format or * \returns the human readable name of the specified pixel format or
* `SDL_PIXELFORMAT_UNKNOWN` if the format isn't recognized. * `SDL_PIXELFORMAT_UNKNOWN` if the format isn't recognized.
* *
@@ -363,12 +405,12 @@ extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format);
/** /**
* Convert one of the enumerated pixel formats to a bpp value and RGBA masks. * Convert one of the enumerated pixel formats to a bpp value and RGBA masks.
* *
* \param format one of the SDL_PixelFormatEnum values * \param format one of the SDL_PixelFormatEnum values.
* \param bpp a bits per pixel value; usually 15, 16, or 32 * \param bpp a bits per pixel value; usually 15, 16, or 32.
* \param Rmask a pointer filled in with the red mask for the format * \param Rmask a pointer filled in with the red mask for the format.
* \param Gmask a pointer filled in with the green mask for the format * \param Gmask a pointer filled in with the green mask for the format.
* \param Bmask a pointer filled in with the blue mask for the format * \param Bmask a pointer filled in with the blue mask for the format.
* \param Amask a pointer filled in with the alpha mask for the format * \param Amask a pointer filled in with the alpha mask for the format.
* \returns SDL_TRUE on success or SDL_FALSE if the conversion wasn't * \returns SDL_TRUE on success or SDL_FALSE if the conversion wasn't
* possible; call SDL_GetError() for more information. * possible; call SDL_GetError() for more information.
* *
@@ -389,12 +431,12 @@ extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format,
* This will return `SDL_PIXELFORMAT_UNKNOWN` if the conversion wasn't * This will return `SDL_PIXELFORMAT_UNKNOWN` if the conversion wasn't
* possible. * possible.
* *
* \param bpp a bits per pixel value; usually 15, 16, or 32 * \param bpp a bits per pixel value; usually 15, 16, or 32.
* \param Rmask the red mask for the format * \param Rmask the red mask for the format.
* \param Gmask the green mask for the format * \param Gmask the green mask for the format.
* \param Bmask the blue mask for the format * \param Bmask the blue mask for the format.
* \param Amask the alpha mask for the format * \param Amask the alpha mask for the format.
* \returns one of the SDL_PixelFormatEnum values * \returns one of the SDL_PixelFormatEnum values.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -413,7 +455,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp,
* allocated), and hence should not be modified, especially the palette. Weird * allocated), and hence should not be modified, especially the palette. Weird
* errors such as `Blit combination not supported` may occur. * errors such as `Blit combination not supported` may occur.
* *
* \param pixel_format one of the SDL_PixelFormatEnum values * \param pixel_format one of the SDL_PixelFormatEnum values.
* \returns the new SDL_PixelFormat structure or NULL on failure; call * \returns the new SDL_PixelFormat structure or NULL on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -426,7 +468,7 @@ extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format);
/** /**
* Free an SDL_PixelFormat structure allocated by SDL_AllocFormat(). * Free an SDL_PixelFormat structure allocated by SDL_AllocFormat().
* *
* \param format the SDL_PixelFormat structure to free * \param format the SDL_PixelFormat structure to free.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -439,7 +481,7 @@ extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format);
* *
* The palette entries are initialized to white. * The palette entries are initialized to white.
* *
* \param ncolors represents the number of color entries in the color palette * \param ncolors represents the number of color entries in the color palette.
* \returns a new SDL_Palette structure on success or NULL on failure (e.g. if * \returns a new SDL_Palette structure on success or NULL on failure (e.g. if
* there wasn't enough memory); call SDL_GetError() for more * there wasn't enough memory); call SDL_GetError() for more
* information. * information.
@@ -453,8 +495,8 @@ extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors);
/** /**
* Set the palette for a pixel format structure. * Set the palette for a pixel format structure.
* *
* \param format the SDL_PixelFormat structure that will use the palette * \param format the SDL_PixelFormat structure that will use the palette.
* \param palette the SDL_Palette structure that will be used * \param palette the SDL_Palette structure that will be used.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -469,10 +511,10 @@ extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format,
/** /**
* Set a range of colors in a palette. * Set a range of colors in a palette.
* *
* \param palette the SDL_Palette structure to modify * \param palette the SDL_Palette structure to modify.
* \param colors an array of SDL_Color structures to copy into the palette * \param colors an array of SDL_Color structures to copy into the palette.
* \param firstcolor the index of the first palette entry to modify * \param firstcolor the index of the first palette entry to modify.
* \param ncolors the number of entries to modify * \param ncolors the number of entries to modify.
* \returns 0 on success or a negative error code if not all of the colors * \returns 0 on success or a negative error code if not all of the colors
* could be set; call SDL_GetError() for more information. * could be set; call SDL_GetError() for more information.
* *
@@ -488,7 +530,7 @@ extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette,
/** /**
* Free a palette created with SDL_AllocPalette(). * Free a palette created with SDL_AllocPalette().
* *
* \param palette the SDL_Palette structure to be freed * \param palette the SDL_Palette structure to be freed.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -514,11 +556,11 @@ extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette);
* format the return value can be assigned to a Uint16, and similarly a Uint8 * format the return value can be assigned to a Uint16, and similarly a Uint8
* for an 8-bpp format). * for an 8-bpp format).
* *
* \param format an SDL_PixelFormat structure describing the pixel format * \param format an SDL_PixelFormat structure describing the pixel format.
* \param r the red component of the pixel in the range 0-255 * \param r the red component of the pixel in the range 0-255.
* \param g the green component of the pixel in the range 0-255 * \param g the green component of the pixel in the range 0-255.
* \param b the blue component of the pixel in the range 0-255 * \param b the blue component of the pixel in the range 0-255.
* \returns a pixel value * \returns a pixel value.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -548,12 +590,12 @@ extern DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format,
* for an 8-bpp format). * for an 8-bpp format).
* *
* \param format an SDL_PixelFormat structure describing the format of the * \param format an SDL_PixelFormat structure describing the format of the
* pixel * pixel.
* \param r the red component of the pixel in the range 0-255 * \param r the red component of the pixel in the range 0-255.
* \param g the green component of the pixel in the range 0-255 * \param g the green component of the pixel in the range 0-255.
* \param b the blue component of the pixel in the range 0-255 * \param b the blue component of the pixel in the range 0-255.
* \param a the alpha component of the pixel in the range 0-255 * \param a the alpha component of the pixel in the range 0-255.
* \returns a pixel value * \returns a pixel value.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -573,12 +615,12 @@ extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format,
* (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, * (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff,
* 0xff, 0xff] not [0xf8, 0xfc, 0xf8]). * 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).
* *
* \param pixel a pixel value * \param pixel a pixel value.
* \param format an SDL_PixelFormat structure describing the format of the * \param format an SDL_PixelFormat structure describing the format of the
* pixel * pixel.
* \param r a pointer filled in with the red component * \param r a pointer filled in with the red component.
* \param g a pointer filled in with the green component * \param g a pointer filled in with the green component.
* \param b a pointer filled in with the blue component * \param b a pointer filled in with the blue component.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -601,13 +643,13 @@ extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel,
* If the surface has no alpha component, the alpha will be returned as 0xff * If the surface has no alpha component, the alpha will be returned as 0xff
* (100% opaque). * (100% opaque).
* *
* \param pixel a pixel value * \param pixel a pixel value.
* \param format an SDL_PixelFormat structure describing the format of the * \param format an SDL_PixelFormat structure describing the format of the
* pixel * pixel.
* \param r a pointer filled in with the red component * \param r a pointer filled in with the red component.
* \param g a pointer filled in with the green component * \param g a pointer filled in with the green component.
* \param b a pointer filled in with the blue component * \param b a pointer filled in with the blue component.
* \param a a pointer filled in with the alpha component * \param a a pointer filled in with the alpha component.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -623,8 +665,8 @@ extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
/** /**
* Calculate a 256 entry gamma ramp for a gamma value. * Calculate a 256 entry gamma ramp for a gamma value.
* *
* \param gamma a gamma value where 0.0 is black and 1.0 is identity * \param gamma a gamma value where 0.0 is black and 1.0 is identity.
* \param ramp an array of 256 values filled in with the gamma ramp * \param ramp an array of 256 values filled in with the gamma ramp.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_platform.h * # CategoryPlatform
* *
* Try to get a standard set of platform defines. * Try to get a standard set of platform defines.
*/ */
#ifndef SDL_platform_h_ #ifndef SDL_platform_h_
@@ -73,7 +73,13 @@
#if defined(__APPLE__) #if defined(__APPLE__)
/* lets us know what version of Mac OS X we're compiling on */ /* lets us know what version of Mac OS X we're compiling on */
#include <AvailabilityMacros.h> #include <AvailabilityMacros.h>
#ifndef __has_extension /* Older compilers don't support this */
#define __has_extension(x) 0
#include <TargetConditionals.h> #include <TargetConditionals.h>
#undef __has_extension
#else
#include <TargetConditionals.h>
#endif
/* Fix building with older SDKs that don't define these /* Fix building with older SDKs that don't define these
See this for more information: See this for more information:
@@ -166,6 +172,12 @@
#define WINAPI_FAMILY_WINRT 0 #define WINAPI_FAMILY_WINRT 0
#endif /* HAVE_WINAPIFAMILY_H */ #endif /* HAVE_WINAPIFAMILY_H */
#if (HAVE_WINAPIFAMILY_H) && defined(WINAPI_FAMILY_PHONE_APP)
#define SDL_WINAPI_FAMILY_PHONE (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
#else
#define SDL_WINAPI_FAMILY_PHONE 0
#endif
#if WINAPI_FAMILY_WINRT #if WINAPI_FAMILY_WINRT
#undef __WINRT__ #undef __WINRT__
#define __WINRT__ 1 #define __WINRT__ 1
@@ -193,8 +205,10 @@
#undef __GDK__ #undef __GDK__
#define __GDK__ 1 #define __GDK__ 1
#endif #endif
#if defined(__PSP__) #if defined(__PSP__) || defined(__psp__)
#ifdef __PSP__
#undef __PSP__ #undef __PSP__
#endif
#define __PSP__ 1 #define __PSP__ 1
#endif #endif
#if defined(PS2) #if defined(PS2)

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -23,9 +23,9 @@
#define SDL_power_h_ #define SDL_power_h_
/** /**
* \file SDL_power.h * # CategoryPower
* *
* Header for the SDL power management routines. * Header for the SDL power management routines.
*/ */
#include <SDL2/SDL_stdinc.h> #include <SDL2/SDL_stdinc.h>
@@ -37,9 +37,9 @@ extern "C" {
#endif #endif
/** /**
* The basic state for the system's power supply. * The basic state for the system's power supply.
*/ */
typedef enum typedef enum SDL_PowerState
{ {
SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */ SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */
SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */ SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */
@@ -66,10 +66,10 @@ typedef enum
* *
* \param seconds seconds of battery life left, you can pass a NULL here if * \param seconds seconds of battery life left, you can pass a NULL here if
* you don't care, will return -1 if we can't determine a * you don't care, will return -1 if we can't determine a
* value, or we're not running on a battery * value, or we're not running on a battery.
* \param percent percentage of battery life left, between 0 and 100, you can * \param percent percentage of battery life left, between 0 and 100, you can
* pass a NULL here if you don't care, will return -1 if we * pass a NULL here if you don't care, will return -1 if we
* can't determine a value, or we're not running on a battery * can't determine a value, or we're not running on a battery.
* \returns an SDL_PowerState enum representing the current battery state. * \returns an SDL_PowerState enum representing the current battery state.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,20 @@
*/ */
/** /**
* \file SDL_quit.h * # CategoryQuit
* *
* Include file for SDL quit event handling. * An SDL_QUIT event is generated when the user tries to close the application
* window. If it is ignored or filtered out, the window will remain open. If
* it is not ignored or filtered, it is queued normally and the window is
* allowed to close. When the window is closed, screen updates will complete,
* but have no effect.
*
* SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) and
* SIGTERM (system termination request), if handlers do not already exist,
* that generate SDL_QUIT events as well. There is no way to determine the
* cause of an SDL_QUIT event, but setting a signal handler in your
* application will override the default generation of quit events for that
* signal.
*/ */
#ifndef SDL_quit_h_ #ifndef SDL_quit_h_
@@ -31,25 +42,6 @@
#include <SDL2/SDL_stdinc.h> #include <SDL2/SDL_stdinc.h>
#include <SDL2/SDL_error.h> #include <SDL2/SDL_error.h>
/**
* \file SDL_quit.h
*
* An ::SDL_QUIT event is generated when the user tries to close the application
* window. If it is ignored or filtered out, the window will remain open.
* If it is not ignored or filtered, it is queued normally and the window
* is allowed to close. When the window is closed, screen updates will
* complete, but have no effect.
*
* SDL_Init() installs signal handlers for SIGINT (keyboard interrupt)
* and SIGTERM (system termination request), if handlers do not already
* exist, that generate ::SDL_QUIT events as well. There is no way
* to determine the cause of an ::SDL_QUIT event, but setting a signal
* handler in your application will override the default generation of
* quit events for that signal.
*
* \sa SDL_Quit()
*/
/* There are no functions directly affecting the quit event */ /* There are no functions directly affecting the quit event */
#define SDL_QuitRequested() \ #define SDL_QuitRequested() \

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_rect.h * # CategoryRect
* *
* Header file for SDL_rect definition and management functions. * Header file for SDL_rect definition and management functions.
*/ */
#ifndef SDL_rect_h_ #ifndef SDL_rect_h_
@@ -135,8 +135,8 @@ SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b)
* *
* If either pointer is NULL the function will return SDL_FALSE. * If either pointer is NULL the function will return SDL_FALSE.
* *
* \param A an SDL_Rect structure representing the first rectangle * \param A an SDL_Rect structure representing the first rectangle.
* \param B an SDL_Rect structure representing the second rectangle * \param B an SDL_Rect structure representing the second rectangle.
* \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise. * \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -151,10 +151,10 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A,
* *
* If `result` is NULL then this function will return SDL_FALSE. * If `result` is NULL then this function will return SDL_FALSE.
* *
* \param A an SDL_Rect structure representing the first rectangle * \param A an SDL_Rect structure representing the first rectangle.
* \param B an SDL_Rect structure representing the second rectangle * \param B an SDL_Rect structure representing the second rectangle.
* \param result an SDL_Rect structure filled in with the intersection of * \param result an SDL_Rect structure filled in with the intersection of
* rectangles `A` and `B` * rectangles `A` and `B`.
* \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise. * \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -168,10 +168,10 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,
/** /**
* Calculate the union of two rectangles. * Calculate the union of two rectangles.
* *
* \param A an SDL_Rect structure representing the first rectangle * \param A an SDL_Rect structure representing the first rectangle.
* \param B an SDL_Rect structure representing the second rectangle * \param B an SDL_Rect structure representing the second rectangle.
* \param result an SDL_Rect structure filled in with the union of rectangles * \param result an SDL_Rect structure filled in with the union of rectangles
* `A` and `B` * `A` and `B`.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
*/ */
@@ -186,11 +186,11 @@ extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A,
* considered. * considered.
* *
* \param points an array of SDL_Point structures representing points to be * \param points an array of SDL_Point structures representing points to be
* enclosed * enclosed.
* \param count the number of structures in the `points` array * \param count the number of structures in the `points` array.
* \param clip an SDL_Rect used for clipping or NULL to enclose all points * \param clip an SDL_Rect used for clipping or NULL to enclose all points.
* \param result an SDL_Rect structure filled in with the minimal enclosing * \param result an SDL_Rect structure filled in with the minimal enclosing
* rectangle * rectangle.
* \returns SDL_TRUE if any points were enclosed or SDL_FALSE if all the * \returns SDL_TRUE if any points were enclosed or SDL_FALSE if all the
* points were outside of the clipping rectangle. * points were outside of the clipping rectangle.
* *
@@ -210,11 +210,11 @@ extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points,
* both ends will be clipped to the boundary of the rectangle and the new * both ends will be clipped to the boundary of the rectangle and the new
* coordinates saved in `X1`, `Y1`, `X2`, and/or `Y2` as necessary. * coordinates saved in `X1`, `Y1`, `X2`, and/or `Y2` as necessary.
* *
* \param rect an SDL_Rect structure representing the rectangle to intersect * \param rect an SDL_Rect structure representing the rectangle to intersect.
* \param X1 a pointer to the starting X-coordinate of the line * \param X1 a pointer to the starting X-coordinate of the line.
* \param Y1 a pointer to the starting Y-coordinate of the line * \param Y1 a pointer to the starting Y-coordinate of the line.
* \param X2 a pointer to the ending X-coordinate of the line * \param X2 a pointer to the ending X-coordinate of the line.
* \param Y2 a pointer to the ending Y-coordinate of the line * \param Y2 a pointer to the ending Y-coordinate of the line.
* \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise. * \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -274,8 +274,8 @@ SDL_FORCE_INLINE SDL_bool SDL_FRectEquals(const SDL_FRect *a, const SDL_FRect *b
* *
* If either pointer is NULL the function will return SDL_FALSE. * If either pointer is NULL the function will return SDL_FALSE.
* *
* \param A an SDL_FRect structure representing the first rectangle * \param A an SDL_FRect structure representing the first rectangle.
* \param B an SDL_FRect structure representing the second rectangle * \param B an SDL_FRect structure representing the second rectangle.
* \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise. * \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.22. * \since This function is available since SDL 2.0.22.
@@ -290,10 +290,10 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersectionF(const SDL_FRect * A,
* *
* If `result` is NULL then this function will return SDL_FALSE. * If `result` is NULL then this function will return SDL_FALSE.
* *
* \param A an SDL_FRect structure representing the first rectangle * \param A an SDL_FRect structure representing the first rectangle.
* \param B an SDL_FRect structure representing the second rectangle * \param B an SDL_FRect structure representing the second rectangle.
* \param result an SDL_FRect structure filled in with the intersection of * \param result an SDL_FRect structure filled in with the intersection of
* rectangles `A` and `B` * rectangles `A` and `B`.
* \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise. * \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.22. * \since This function is available since SDL 2.0.22.
@@ -307,10 +307,10 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IntersectFRect(const SDL_FRect * A,
/** /**
* Calculate the union of two rectangles with float precision. * Calculate the union of two rectangles with float precision.
* *
* \param A an SDL_FRect structure representing the first rectangle * \param A an SDL_FRect structure representing the first rectangle.
* \param B an SDL_FRect structure representing the second rectangle * \param B an SDL_FRect structure representing the second rectangle.
* \param result an SDL_FRect structure filled in with the union of rectangles * \param result an SDL_FRect structure filled in with the union of rectangles
* `A` and `B` * `A` and `B`.
* *
* \since This function is available since SDL 2.0.22. * \since This function is available since SDL 2.0.22.
*/ */
@@ -326,11 +326,11 @@ extern DECLSPEC void SDLCALL SDL_UnionFRect(const SDL_FRect * A,
* considered. * considered.
* *
* \param points an array of SDL_FPoint structures representing points to be * \param points an array of SDL_FPoint structures representing points to be
* enclosed * enclosed.
* \param count the number of structures in the `points` array * \param count the number of structures in the `points` array.
* \param clip an SDL_FRect used for clipping or NULL to enclose all points * \param clip an SDL_FRect used for clipping or NULL to enclose all points.
* \param result an SDL_FRect structure filled in with the minimal enclosing * \param result an SDL_FRect structure filled in with the minimal enclosing
* rectangle * rectangle.
* \returns SDL_TRUE if any points were enclosed or SDL_FALSE if all the * \returns SDL_TRUE if any points were enclosed or SDL_FALSE if all the
* points were outside of the clipping rectangle. * points were outside of the clipping rectangle.
* *
@@ -351,11 +351,11 @@ extern DECLSPEC SDL_bool SDLCALL SDL_EncloseFPoints(const SDL_FPoint * points,
* both ends will be clipped to the boundary of the rectangle and the new * both ends will be clipped to the boundary of the rectangle and the new
* coordinates saved in `X1`, `Y1`, `X2`, and/or `Y2` as necessary. * coordinates saved in `X1`, `Y1`, `X2`, and/or `Y2` as necessary.
* *
* \param rect an SDL_FRect structure representing the rectangle to intersect * \param rect an SDL_FRect structure representing the rectangle to intersect.
* \param X1 a pointer to the starting X-coordinate of the line * \param X1 a pointer to the starting X-coordinate of the line.
* \param Y1 a pointer to the starting Y-coordinate of the line * \param Y1 a pointer to the starting Y-coordinate of the line.
* \param X2 a pointer to the ending X-coordinate of the line * \param X2 a pointer to the ending X-coordinate of the line.
* \param Y2 a pointer to the ending Y-coordinate of the line * \param Y2 a pointer to the ending Y-coordinate of the line.
* \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise. * \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.22. * \since This function is available since SDL 2.0.22.

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,6 @@
/* Generated by updaterev.sh, do not edit */
#ifdef SDL_VENDOR_INFO #ifdef SDL_VENDOR_INFO
#define SDL_REVISION "SDL-release-2.28.3-0-g8a5ba43d0 (" SDL_VENDOR_INFO ")" #define SDL_REVISION SDL_VENDOR_INFO
#else #else
#define SDL_REVISION "SDL-release-2.28.3-0-g8a5ba43d0" #define SDL_REVISION ""
#endif #endif
#define SDL_REVISION_NUMBER 0 #define SDL_REVISION_NUMBER 0

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -19,11 +19,13 @@
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/* WIKI CATEGORY: RWOPS */
/** /**
* \file SDL_rwops.h * # CategoryRWOPS
* *
* This file provides a general interface for SDL to read and write * This file provides a general interface for SDL to read and write data
* data streams. It can easily be extended to files, memory, etc. * streams. It can easily be extended to files, memory, etc.
*/ */
#ifndef SDL_rwops_h_ #ifndef SDL_rwops_h_
@@ -57,7 +59,7 @@ typedef struct SDL_RWops
Sint64 (SDLCALL * size) (struct SDL_RWops * context); Sint64 (SDLCALL * size) (struct SDL_RWops * context);
/** /**
* Seek to \c offset relative to \c whence, one of stdio's whence values: * Seek to `offset` relative to `whence`, one of stdio's whence values:
* RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END * RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END
* *
* \return the final offset in the data stream, or -1 on error. * \return the final offset in the data stream, or -1 on error.
@@ -66,8 +68,8 @@ typedef struct SDL_RWops
int whence); int whence);
/** /**
* Read up to \c maxnum objects each of size \c size from the data * Read up to `maxnum` objects each of size `size` from the data
* stream to the area pointed at by \c ptr. * stream to the area pointed at by `ptr`.
* *
* \return the number of objects read, or 0 at error or end of file. * \return the number of objects read, or 0 at error or end of file.
*/ */
@@ -75,8 +77,8 @@ typedef struct SDL_RWops
size_t size, size_t maxnum); size_t size, size_t maxnum);
/** /**
* Write exactly \c num objects each of size \c size from the area * Write exactly `num` objects each of size `size` from the area
* pointed at by \c ptr to data stream. * pointed at by `ptr` to data stream.
* *
* \return the number of objects written, or 0 at error or end of file. * \return the number of objects written, or 0 at error or end of file.
*/ */
@@ -186,7 +188,7 @@ typedef struct SDL_RWops
* *
* Closing the SDL_RWops will close the file handle SDL is holding internally. * Closing the SDL_RWops will close the file handle SDL is holding internally.
* *
* \param file a UTF-8 string representing the filename to open * \param file a UTF-8 string representing the filename to open.
* \param mode an ASCII string representing the mode to be used for opening * \param mode an ASCII string representing the mode to be used for opening
* the file. * the file.
* \returns a pointer to the SDL_RWops structure that is created, or NULL on * \returns a pointer to the SDL_RWops structure that is created, or NULL on
@@ -224,10 +226,10 @@ extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(FILE * fp, SDL_bool autoclose);
* `FILE*`, depending on what system headers are available to SDL. It is * `FILE*`, depending on what system headers are available to SDL. It is
* always intended to be the `FILE*` type from the C runtime's stdio.h. * always intended to be the `FILE*` type from the C runtime's stdio.h.
* *
* \param fp the `FILE*` that feeds the SDL_RWops stream * \param fp the `FILE*` that feeds the SDL_RWops stream.
* \param autoclose SDL_TRUE to close the `FILE*` when closing the SDL_RWops, * \param autoclose SDL_TRUE to close the `FILE*` when closing the SDL_RWops,
* SDL_FALSE to leave the `FILE*` open when the RWops is * SDL_FALSE to leave the `FILE*` open when the RWops is
* closed * closed.
* \returns a pointer to the SDL_RWops structure that is created, or NULL on * \returns a pointer to the SDL_RWops structure that is created, or NULL on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
@@ -260,8 +262,8 @@ extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFP(void * fp,
* If you need to make sure the RWops never writes to the memory buffer, you * If you need to make sure the RWops never writes to the memory buffer, you
* should use SDL_RWFromConstMem() with a read-only buffer of memory instead. * should use SDL_RWFromConstMem() with a read-only buffer of memory instead.
* *
* \param mem a pointer to a buffer to feed an SDL_RWops stream * \param mem a pointer to a buffer to feed an SDL_RWops stream.
* \param size the buffer size, in bytes * \param size the buffer size, in bytes.
* \returns a pointer to a new SDL_RWops structure, or NULL if it fails; call * \returns a pointer to a new SDL_RWops structure, or NULL if it fails; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -295,8 +297,8 @@ extern DECLSPEC SDL_RWops *SDLCALL SDL_RWFromMem(void *mem, int size);
* If you need to write to a memory buffer, you should use SDL_RWFromMem() * If you need to write to a memory buffer, you should use SDL_RWFromMem()
* with a writable buffer of memory instead. * with a writable buffer of memory instead.
* *
* \param mem a pointer to a read-only buffer to feed an SDL_RWops stream * \param mem a pointer to a read-only buffer to feed an SDL_RWops stream.
* \param size the buffer size, in bytes * \param size the buffer size, in bytes.
* \returns a pointer to a new SDL_RWops structure, or NULL if it fails; call * \returns a pointer to a new SDL_RWops structure, or NULL if it fails; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -358,7 +360,7 @@ extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void);
* creation of the SDL_RWops is not freed by SDL_FreeRW(); the programmer must * creation of the SDL_RWops is not freed by SDL_FreeRW(); the programmer must
* be responsible for managing that memory in their **close** method. * be responsible for managing that memory in their **close** method.
* *
* \param area the SDL_RWops structure to be freed * \param area the SDL_RWops structure to be freed.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -366,6 +368,7 @@ extern DECLSPEC SDL_RWops *SDLCALL SDL_AllocRW(void);
*/ */
extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area);
/* Possible `whence` values for SDL_RWops seeking... */
#define RW_SEEK_SET 0 /**< Seek from the beginning of data */ #define RW_SEEK_SET 0 /**< Seek from the beginning of data */
#define RW_SEEK_CUR 1 /**< Seek relative to current read point */ #define RW_SEEK_CUR 1 /**< Seek relative to current read point */
#define RW_SEEK_END 2 /**< Seek relative to the end of data */ #define RW_SEEK_END 2 /**< Seek relative to the end of data */
@@ -375,7 +378,7 @@ extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area);
* *
* Prior to SDL 2.0.10, this function was a macro. * Prior to SDL 2.0.10, this function was a macro.
* *
* \param context the SDL_RWops to get the size of the data stream from * \param context the SDL_RWops to get the size of the data stream from.
* \returns the size of the data stream in the SDL_RWops on success, -1 if * \returns the size of the data stream in the SDL_RWops on success, -1 if
* unknown or a negative error code on failure; call SDL_GetError() * unknown or a negative error code on failure; call SDL_GetError()
* for more information. * for more information.
@@ -402,10 +405,10 @@ extern DECLSPEC Sint64 SDLCALL SDL_RWsize(SDL_RWops *context);
* *
* Prior to SDL 2.0.10, this function was a macro. * Prior to SDL 2.0.10, this function was a macro.
* *
* \param context a pointer to an SDL_RWops structure * \param context a pointer to an SDL_RWops structure.
* \param offset an offset in bytes, relative to **whence** location; can be * \param offset an offset in bytes, relative to **whence** location; can be
* negative * negative.
* \param whence any of `RW_SEEK_SET`, `RW_SEEK_CUR`, `RW_SEEK_END` * \param whence any of `RW_SEEK_SET`, `RW_SEEK_CUR`, `RW_SEEK_END`.
* \returns the final offset in the data stream after the seek or -1 on error. * \returns the final offset in the data stream after the seek or -1 on error.
* *
* \since This function is available since SDL 2.0.10. * \since This function is available since SDL 2.0.10.
@@ -432,7 +435,7 @@ extern DECLSPEC Sint64 SDLCALL SDL_RWseek(SDL_RWops *context,
* Prior to SDL 2.0.10, this function was a macro. * Prior to SDL 2.0.10, this function was a macro.
* *
* \param context a SDL_RWops data stream object from which to get the current * \param context a SDL_RWops data stream object from which to get the current
* offset * offset.
* \returns the current offset in the stream, or -1 if the information can not * \returns the current offset in the stream, or -1 if the information can not
* be determined. * be determined.
* *
@@ -462,10 +465,10 @@ extern DECLSPEC Sint64 SDLCALL SDL_RWtell(SDL_RWops *context);
* *
* Prior to SDL 2.0.10, this function was a macro. * Prior to SDL 2.0.10, this function was a macro.
* *
* \param context a pointer to an SDL_RWops structure * \param context a pointer to an SDL_RWops structure.
* \param ptr a pointer to a buffer to read data into * \param ptr a pointer to a buffer to read data into.
* \param size the size of each object to read, in bytes * \param size the size of each object to read, in bytes.
* \param maxnum the maximum number of objects to be read * \param maxnum the maximum number of objects to be read.
* \returns the number of objects read, or 0 at error or end of file; call * \returns the number of objects read, or 0 at error or end of file; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -496,10 +499,10 @@ extern DECLSPEC size_t SDLCALL SDL_RWread(SDL_RWops *context,
* *
* Prior to SDL 2.0.10, this function was a macro. * Prior to SDL 2.0.10, this function was a macro.
* *
* \param context a pointer to an SDL_RWops structure * \param context a pointer to an SDL_RWops structure.
* \param ptr a pointer to a buffer containing data to write * \param ptr a pointer to a buffer containing data to write.
* \param size the size of an object to write, in bytes * \param size the size of an object to write, in bytes.
* \param num the number of objects to write * \param num the number of objects to write.
* \returns the number of objects written, which will be less than **num** on * \returns the number of objects written, which will be less than **num** on
* error; call SDL_GetError() for more information. * error; call SDL_GetError() for more information.
* *
@@ -530,7 +533,7 @@ extern DECLSPEC size_t SDLCALL SDL_RWwrite(SDL_RWops *context,
* *
* Prior to SDL 2.0.10, this function was a macro. * Prior to SDL 2.0.10, this function was a macro.
* *
* \param context SDL_RWops structure to close * \param context SDL_RWops structure to close.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -555,9 +558,9 @@ extern DECLSPEC int SDLCALL SDL_RWclose(SDL_RWops *context);
* *
* The data should be freed with SDL_free(). * The data should be freed with SDL_free().
* *
* \param src the SDL_RWops to read all available data from * \param src the SDL_RWops to read all available data from.
* \param datasize if not NULL, will store the number of bytes read * \param datasize if not NULL, will store the number of bytes read.
* \param freesrc if non-zero, calls SDL_RWclose() on `src` before returning * \param freesrc if non-zero, calls SDL_RWclose() on `src` before returning.
* \returns the data, or NULL if there was an error. * \returns the data, or NULL if there was an error.
* *
* \since This function is available since SDL 2.0.6. * \since This function is available since SDL 2.0.6.
@@ -578,8 +581,8 @@ extern DECLSPEC void *SDLCALL SDL_LoadFile_RW(SDL_RWops *src,
* Prior to SDL 2.0.10, this function was a macro wrapping around * Prior to SDL 2.0.10, this function was a macro wrapping around
* SDL_LoadFile_RW. * SDL_LoadFile_RW.
* *
* \param file the path to read all available data from * \param file the path to read all available data from.
* \param datasize if not NULL, will store the number of bytes read * \param datasize if not NULL, will store the number of bytes read.
* \returns the data, or NULL if there was an error. * \returns the data, or NULL if there was an error.
* *
* \since This function is available since SDL 2.0.10. * \since This function is available since SDL 2.0.10.
@@ -596,7 +599,7 @@ extern DECLSPEC void *SDLCALL SDL_LoadFile(const char *file, size_t *datasize);
/** /**
* Use this function to read a byte from an SDL_RWops. * Use this function to read a byte from an SDL_RWops.
* *
* \param src the SDL_RWops to read from * \param src the SDL_RWops to read from.
* \returns the read byte on success or 0 on failure; call SDL_GetError() for * \returns the read byte on success or 0 on failure; call SDL_GetError() for
* more information. * more information.
* *
@@ -613,7 +616,7 @@ extern DECLSPEC Uint8 SDLCALL SDL_ReadU8(SDL_RWops * src);
* SDL byteswaps the data only if necessary, so the data returned will be in * SDL byteswaps the data only if necessary, so the data returned will be in
* the native byte order. * the native byte order.
* *
* \param src the stream from which to read data * \param src the stream from which to read data.
* \returns 16 bits of data in the native byte order of the platform. * \returns 16 bits of data in the native byte order of the platform.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -629,7 +632,7 @@ extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops * src);
* SDL byteswaps the data only if necessary, so the data returned will be in * SDL byteswaps the data only if necessary, so the data returned will be in
* the native byte order. * the native byte order.
* *
* \param src the stream from which to read data * \param src the stream from which to read data.
* \returns 16 bits of data in the native byte order of the platform. * \returns 16 bits of data in the native byte order of the platform.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -645,7 +648,7 @@ extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops * src);
* SDL byteswaps the data only if necessary, so the data returned will be in * SDL byteswaps the data only if necessary, so the data returned will be in
* the native byte order. * the native byte order.
* *
* \param src the stream from which to read data * \param src the stream from which to read data.
* \returns 32 bits of data in the native byte order of the platform. * \returns 32 bits of data in the native byte order of the platform.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -661,7 +664,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops * src);
* SDL byteswaps the data only if necessary, so the data returned will be in * SDL byteswaps the data only if necessary, so the data returned will be in
* the native byte order. * the native byte order.
* *
* \param src the stream from which to read data * \param src the stream from which to read data.
* \returns 32 bits of data in the native byte order of the platform. * \returns 32 bits of data in the native byte order of the platform.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -677,7 +680,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops * src);
* SDL byteswaps the data only if necessary, so the data returned will be in * SDL byteswaps the data only if necessary, so the data returned will be in
* the native byte order. * the native byte order.
* *
* \param src the stream from which to read data * \param src the stream from which to read data.
* \returns 64 bits of data in the native byte order of the platform. * \returns 64 bits of data in the native byte order of the platform.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -693,7 +696,7 @@ extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops * src);
* SDL byteswaps the data only if necessary, so the data returned will be in * SDL byteswaps the data only if necessary, so the data returned will be in
* the native byte order. * the native byte order.
* *
* \param src the stream from which to read data * \param src the stream from which to read data.
* \returns 64 bits of data in the native byte order of the platform. * \returns 64 bits of data in the native byte order of the platform.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -713,8 +716,8 @@ extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops * src);
/** /**
* Use this function to write a byte to an SDL_RWops. * Use this function to write a byte to an SDL_RWops.
* *
* \param dst the SDL_RWops to write to * \param dst the SDL_RWops to write to.
* \param value the byte value to write * \param value the byte value to write.
* \returns 1 on success or 0 on failure; call SDL_GetError() for more * \returns 1 on success or 0 on failure; call SDL_GetError() for more
* information. * information.
* *
@@ -732,8 +735,8 @@ extern DECLSPEC size_t SDLCALL SDL_WriteU8(SDL_RWops * dst, Uint8 value);
* specifies native format, and the data written will be in little-endian * specifies native format, and the data written will be in little-endian
* format. * format.
* *
* \param dst the stream to which data will be written * \param dst the stream to which data will be written.
* \param value the data to be written, in native format * \param value the data to be written, in native format.
* \returns 1 on successful write, 0 on error. * \returns 1 on successful write, 0 on error.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -749,8 +752,8 @@ extern DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops * dst, Uint16 value);
* SDL byteswaps the data only if necessary, so the application always * SDL byteswaps the data only if necessary, so the application always
* specifies native format, and the data written will be in big-endian format. * specifies native format, and the data written will be in big-endian format.
* *
* \param dst the stream to which data will be written * \param dst the stream to which data will be written.
* \param value the data to be written, in native format * \param value the data to be written, in native format.
* \returns 1 on successful write, 0 on error. * \returns 1 on successful write, 0 on error.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -767,8 +770,8 @@ extern DECLSPEC size_t SDLCALL SDL_WriteBE16(SDL_RWops * dst, Uint16 value);
* specifies native format, and the data written will be in little-endian * specifies native format, and the data written will be in little-endian
* format. * format.
* *
* \param dst the stream to which data will be written * \param dst the stream to which data will be written.
* \param value the data to be written, in native format * \param value the data to be written, in native format.
* \returns 1 on successful write, 0 on error. * \returns 1 on successful write, 0 on error.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -784,8 +787,8 @@ extern DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops * dst, Uint32 value);
* SDL byteswaps the data only if necessary, so the application always * SDL byteswaps the data only if necessary, so the application always
* specifies native format, and the data written will be in big-endian format. * specifies native format, and the data written will be in big-endian format.
* *
* \param dst the stream to which data will be written * \param dst the stream to which data will be written.
* \param value the data to be written, in native format * \param value the data to be written, in native format.
* \returns 1 on successful write, 0 on error. * \returns 1 on successful write, 0 on error.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -802,8 +805,8 @@ extern DECLSPEC size_t SDLCALL SDL_WriteBE32(SDL_RWops * dst, Uint32 value);
* specifies native format, and the data written will be in little-endian * specifies native format, and the data written will be in little-endian
* format. * format.
* *
* \param dst the stream to which data will be written * \param dst the stream to which data will be written.
* \param value the data to be written, in native format * \param value the data to be written, in native format.
* \returns 1 on successful write, 0 on error. * \returns 1 on successful write, 0 on error.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
@@ -819,8 +822,8 @@ extern DECLSPEC size_t SDLCALL SDL_WriteLE64(SDL_RWops * dst, Uint64 value);
* SDL byteswaps the data only if necessary, so the application always * SDL byteswaps the data only if necessary, so the application always
* specifies native format, and the data written will be in big-endian format. * specifies native format, and the data written will be in big-endian format.
* *
* \param dst the stream to which data will be written * \param dst the stream to which data will be written.
* \param value the data to be written, in native format * \param value the data to be written, in native format.
* \returns 1 on successful write, 0 on error. * \returns 1 on successful write, 0 on error.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_scancode.h * # CategoryScancode
* *
* Defines keyboard scancodes. * Defines keyboard scancodes.
*/ */
#ifndef SDL_scancode_h_ #ifndef SDL_scancode_h_
@@ -31,16 +31,16 @@
#include <SDL2/SDL_stdinc.h> #include <SDL2/SDL_stdinc.h>
/** /**
* \brief The SDL keyboard scancode representation. * The SDL keyboard scancode representation.
* *
* Values of this type are used to represent keyboard keys, among other places * Values of this type are used to represent keyboard keys, among other places
* in the \link SDL_Keysym::scancode key.keysym.scancode \endlink field of the * in the SDL_Keysym::scancode key.keysym.scancode field of the SDL_Event
* SDL_Event structure. * structure.
* *
* The values in this enumeration are based on the USB usage page standard: * The values in this enumeration are based on the USB usage page standard:
* https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf * https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf
*/ */
typedef enum typedef enum SDL_Scancode
{ {
SDL_SCANCODE_UNKNOWN = 0, SDL_SCANCODE_UNKNOWN = 0,

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,10 +20,9 @@
*/ */
/** /**
* \file SDL_sensor.h * # CategorySensor
*
* Include file for SDL sensor event handling
* *
* Include file for SDL sensor event handling
*/ */
#ifndef SDL_sensor_h_ #ifndef SDL_sensor_h_
@@ -44,7 +43,7 @@ extern "C" {
* \brief SDL_sensor.h * \brief SDL_sensor.h
* *
* In order to use these functions, SDL_Init() must have been called * In order to use these functions, SDL_Init() must have been called
* with the ::SDL_INIT_SENSOR flag. This causes SDL to scan the system * with the SDL_INIT_SENSOR flag. This causes SDL to scan the system
* for sensors, and load appropriate drivers. * for sensors, and load appropriate drivers.
*/ */
@@ -52,21 +51,67 @@ struct _SDL_Sensor;
typedef struct _SDL_Sensor SDL_Sensor; typedef struct _SDL_Sensor SDL_Sensor;
/** /**
* This is a unique ID for a sensor for the time it is connected to the system, * This is a unique ID for a sensor for the time it is connected to the
* and is never reused for the lifetime of the application. * system, and is never reused for the lifetime of the application.
* *
* The ID value starts at 0 and increments from there. The value -1 is an invalid ID. * The ID value starts at 0 and increments from there. The value -1 is an
* invalid ID.
*/ */
typedef Sint32 SDL_SensorID; typedef Sint32 SDL_SensorID;
/* The different sensors defined by SDL /**
* The different sensors defined by SDL.
* *
* Additional sensors may be available, using platform dependent semantics. * Additional sensors may be available, using platform dependent semantics.
* *
* Hare are the additional Android sensors: * Here are the additional Android sensors:
*
* https://developer.android.com/reference/android/hardware/SensorEvent.html#values * https://developer.android.com/reference/android/hardware/SensorEvent.html#values
*
* Accelerometer sensor notes:
*
* The accelerometer returns the current acceleration in SI meters per second
* squared. This measurement includes the force of gravity, so a device at
* rest will have an value of SDL_STANDARD_GRAVITY away from the center of the
* earth, which is a positive Y value.
*
* - `values[0]`: Acceleration on the x axis
* - `values[1]`: Acceleration on the y axis
* - `values[2]`: Acceleration on the z axis
*
* For phones and tablets held in natural orientation and game controllers
* held in front of you, the axes are defined as follows:
*
* - -X ... +X : left ... right
* - -Y ... +Y : bottom ... top
* - -Z ... +Z : farther ... closer
*
* The accelerometer axis data is not changed when the device is rotated.
*
* Gyroscope sensor notes:
*
* The gyroscope returns the current rate of rotation in radians per second.
* The rotation is positive in the counter-clockwise direction. That is, an
* observer looking from a positive location on one of the axes would see
* positive rotation on that axis when it appeared to be rotating
* counter-clockwise.
*
* - `values[0]`: Angular speed around the x axis (pitch)
* - `values[1]`: Angular speed around the y axis (yaw)
* - `values[2]`: Angular speed around the z axis (roll)
*
* For phones and tablets held in natural orientation and game controllers
* held in front of you, the axes are defined as follows:
*
* - -X ... +X : left ... right
* - -Y ... +Y : bottom ... top
* - -Z ... +Z : farther ... closer
*
* The gyroscope axis data is not changed when the device is rotated.
*
* \sa SDL_GetDisplayOrientation
*/ */
typedef enum typedef enum SDL_SensorType
{ {
SDL_SENSOR_INVALID = -1, /**< Returned for an invalid sensor */ SDL_SENSOR_INVALID = -1, /**< Returned for an invalid sensor */
SDL_SENSOR_UNKNOWN, /**< Unknown sensor type */ SDL_SENSOR_UNKNOWN, /**< Unknown sensor type */
@@ -79,53 +124,15 @@ typedef enum
} SDL_SensorType; } SDL_SensorType;
/** /**
* Accelerometer sensor * A constant to represent standard gravity for accelerometer sensors.
* *
* The accelerometer returns the current acceleration in SI meters per * The accelerometer returns the current acceleration in SI meters per second
* second squared. This measurement includes the force of gravity, so * squared. This measurement includes the force of gravity, so a device at
* a device at rest will have an value of SDL_STANDARD_GRAVITY away * rest will have an value of SDL_STANDARD_GRAVITY away from the center of the
* from the center of the earth, which is a positive Y value. * earth, which is a positive Y value.
*
* values[0]: Acceleration on the x axis
* values[1]: Acceleration on the y axis
* values[2]: Acceleration on the z axis
*
* For phones held in portrait mode and game controllers held in front of you,
* the axes are defined as follows:
* -X ... +X : left ... right
* -Y ... +Y : bottom ... top
* -Z ... +Z : farther ... closer
*
* The axis data is not changed when the phone is rotated.
*
* \sa SDL_GetDisplayOrientation()
*/ */
#define SDL_STANDARD_GRAVITY 9.80665f #define SDL_STANDARD_GRAVITY 9.80665f
/**
* Gyroscope sensor
*
* The gyroscope returns the current rate of rotation in radians per second.
* The rotation is positive in the counter-clockwise direction. That is,
* an observer looking from a positive location on one of the axes would
* see positive rotation on that axis when it appeared to be rotating
* counter-clockwise.
*
* values[0]: Angular speed around the x axis (pitch)
* values[1]: Angular speed around the y axis (yaw)
* values[2]: Angular speed around the z axis (roll)
*
* For phones held in portrait mode and game controllers held in front of you,
* the axes are defined as follows:
* -X ... +X : left ... right
* -Y ... +Y : bottom ... top
* -Z ... +Z : farther ... closer
*
* The axis data is not changed when the phone or controller is rotated.
*
* \sa SDL_GetDisplayOrientation()
*/
/* Function prototypes */ /* Function prototypes */
/** /**
@@ -155,7 +162,7 @@ extern DECLSPEC int SDLCALL SDL_NumSensors(void);
/** /**
* Get the implementation dependent name of a sensor. * Get the implementation dependent name of a sensor.
* *
* \param device_index The sensor to obtain name from * \param device_index The sensor to obtain name from.
* \returns the sensor name, or NULL if `device_index` is out of range. * \returns the sensor name, or NULL if `device_index` is out of range.
* *
* \since This function is available since SDL 2.0.9. * \since This function is available since SDL 2.0.9.
@@ -165,7 +172,7 @@ extern DECLSPEC const char *SDLCALL SDL_SensorGetDeviceName(int device_index);
/** /**
* Get the type of a sensor. * Get the type of a sensor.
* *
* \param device_index The sensor to get the type from * \param device_index The sensor to get the type from.
* \returns the SDL_SensorType, or `SDL_SENSOR_INVALID` if `device_index` is * \returns the SDL_SensorType, or `SDL_SENSOR_INVALID` if `device_index` is
* out of range. * out of range.
* *
@@ -176,7 +183,7 @@ extern DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetDeviceType(int device_index)
/** /**
* Get the platform dependent type of a sensor. * Get the platform dependent type of a sensor.
* *
* \param device_index The sensor to check * \param device_index The sensor to check.
* \returns the sensor platform dependent type, or -1 if `device_index` is out * \returns the sensor platform dependent type, or -1 if `device_index` is out
* of range. * of range.
* *
@@ -187,7 +194,7 @@ extern DECLSPEC int SDLCALL SDL_SensorGetDeviceNonPortableType(int device_index)
/** /**
* Get the instance ID of a sensor. * Get the instance ID of a sensor.
* *
* \param device_index The sensor to get instance id from * \param device_index The sensor to get instance id from.
* \returns the sensor instance ID, or -1 if `device_index` is out of range. * \returns the sensor instance ID, or -1 if `device_index` is out of range.
* *
* \since This function is available since SDL 2.0.9. * \since This function is available since SDL 2.0.9.
@@ -197,7 +204,7 @@ extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetDeviceInstanceID(int device_in
/** /**
* Open a sensor for use. * Open a sensor for use.
* *
* \param device_index The sensor to open * \param device_index The sensor to open.
* \returns an SDL_Sensor sensor object, or NULL if an error occurred. * \returns an SDL_Sensor sensor object, or NULL if an error occurred.
* *
* \since This function is available since SDL 2.0.9. * \since This function is available since SDL 2.0.9.
@@ -207,7 +214,7 @@ extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorOpen(int device_index);
/** /**
* Return the SDL_Sensor associated with an instance id. * Return the SDL_Sensor associated with an instance id.
* *
* \param instance_id The sensor from instance id * \param instance_id The sensor from instance id.
* \returns an SDL_Sensor object. * \returns an SDL_Sensor object.
* *
* \since This function is available since SDL 2.0.9. * \since This function is available since SDL 2.0.9.
@@ -217,7 +224,7 @@ extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorFromInstanceID(SDL_SensorID instan
/** /**
* Get the implementation dependent name of a sensor * Get the implementation dependent name of a sensor
* *
* \param sensor The SDL_Sensor object * \param sensor The SDL_Sensor object.
* \returns the sensor name, or NULL if `sensor` is NULL. * \returns the sensor name, or NULL if `sensor` is NULL.
* *
* \since This function is available since SDL 2.0.9. * \since This function is available since SDL 2.0.9.
@@ -227,7 +234,7 @@ extern DECLSPEC const char *SDLCALL SDL_SensorGetName(SDL_Sensor *sensor);
/** /**
* Get the type of a sensor. * Get the type of a sensor.
* *
* \param sensor The SDL_Sensor object to inspect * \param sensor The SDL_Sensor object to inspect.
* \returns the SDL_SensorType type, or `SDL_SENSOR_INVALID` if `sensor` is * \returns the SDL_SensorType type, or `SDL_SENSOR_INVALID` if `sensor` is
* NULL. * NULL.
* *
@@ -238,7 +245,7 @@ extern DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetType(SDL_Sensor *sensor);
/** /**
* Get the platform dependent type of a sensor. * Get the platform dependent type of a sensor.
* *
* \param sensor The SDL_Sensor object to inspect * \param sensor The SDL_Sensor object to inspect.
* \returns the sensor platform dependent type, or -1 if `sensor` is NULL. * \returns the sensor platform dependent type, or -1 if `sensor` is NULL.
* *
* \since This function is available since SDL 2.0.9. * \since This function is available since SDL 2.0.9.
@@ -248,7 +255,7 @@ extern DECLSPEC int SDLCALL SDL_SensorGetNonPortableType(SDL_Sensor *sensor);
/** /**
* Get the instance ID of a sensor. * Get the instance ID of a sensor.
* *
* \param sensor The SDL_Sensor object to inspect * \param sensor The SDL_Sensor object to inspect.
* \returns the sensor instance ID, or -1 if `sensor` is NULL. * \returns the sensor instance ID, or -1 if `sensor` is NULL.
* *
* \since This function is available since SDL 2.0.9. * \since This function is available since SDL 2.0.9.
@@ -260,9 +267,9 @@ extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetInstanceID(SDL_Sensor *sensor)
* *
* The number of values and interpretation of the data is sensor dependent. * The number of values and interpretation of the data is sensor dependent.
* *
* \param sensor The SDL_Sensor object to query * \param sensor The SDL_Sensor object to query.
* \param data A pointer filled with the current sensor state * \param data A pointer filled with the current sensor state.
* \param num_values The number of values to write to data * \param num_values The number of values to write to data.
* \returns 0 or -1 if an error occurred. * \returns 0 or -1 if an error occurred.
* *
* \since This function is available since SDL 2.0.9. * \since This function is available since SDL 2.0.9.
@@ -275,11 +282,11 @@ extern DECLSPEC int SDLCALL SDL_SensorGetData(SDL_Sensor *sensor, float *data, i
* *
* The number of values and interpretation of the data is sensor dependent. * The number of values and interpretation of the data is sensor dependent.
* *
* \param sensor The SDL_Sensor object to query * \param sensor The SDL_Sensor object to query.
* \param timestamp A pointer filled with the timestamp in microseconds of the * \param timestamp A pointer filled with the timestamp in microseconds of the
* current sensor reading if available, or 0 if not * current sensor reading if available, or 0 if not.
* \param data A pointer filled with the current sensor state * \param data A pointer filled with the current sensor state.
* \param num_values The number of values to write to data * \param num_values The number of values to write to data.
* \returns 0 or -1 if an error occurred. * \returns 0 or -1 if an error occurred.
* *
* \since This function is available since SDL 2.26.0. * \since This function is available since SDL 2.26.0.
@@ -289,7 +296,7 @@ extern DECLSPEC int SDLCALL SDL_SensorGetDataWithTimestamp(SDL_Sensor *sensor, U
/** /**
* Close a sensor previously opened with SDL_SensorOpen(). * Close a sensor previously opened with SDL_SensorOpen().
* *
* \param sensor The SDL_Sensor object to close * \param sensor The SDL_Sensor object to close.
* *
* \since This function is available since SDL 2.0.9. * \since This function is available since SDL 2.0.9.
*/ */

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -48,18 +48,18 @@ extern "C" {
* and flags. * and flags.
* *
* \param title The title of the window, in UTF-8 encoding. * \param title The title of the window, in UTF-8 encoding.
* \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or * \param x The x position of the window, SDL_WINDOWPOS_CENTERED, or
* ::SDL_WINDOWPOS_UNDEFINED. * SDL_WINDOWPOS_UNDEFINED.
* \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or * \param y The y position of the window, SDL_WINDOWPOS_CENTERED, or
* ::SDL_WINDOWPOS_UNDEFINED. * SDL_WINDOWPOS_UNDEFINED.
* \param w The width of the window. * \param w The width of the window.
* \param h The height of the window. * \param h The height of the window.
* \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with * \param flags The flags for the window, a mask of SDL_WINDOW_BORDERLESS with
* any of the following: ::SDL_WINDOW_OPENGL, * any of the following: SDL_WINDOW_OPENGL,
* ::SDL_WINDOW_INPUT_GRABBED, ::SDL_WINDOW_HIDDEN, * SDL_WINDOW_INPUT_GRABBED, SDL_WINDOW_HIDDEN,
* ::SDL_WINDOW_RESIZABLE, ::SDL_WINDOW_MAXIMIZED, * SDL_WINDOW_RESIZABLE, SDL_WINDOW_MAXIMIZED,
* ::SDL_WINDOW_MINIMIZED, ::SDL_WINDOW_BORDERLESS is always set, * SDL_WINDOW_MINIMIZED, SDL_WINDOW_BORDERLESS is always set, and
* and ::SDL_WINDOW_FULLSCREEN is always unset. * SDL_WINDOW_FULLSCREEN is always unset.
* \return the window created, or NULL if window creation failed. * \return the window created, or NULL if window creation failed.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -19,10 +19,12 @@
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/* WIKI CATEGORY: StdInc */
/** /**
* \file SDL_stdinc.h * # CategoryStdInc
* *
* This is a general header that includes C language support. * This is a general header that includes C language support.
*/ */
#ifndef SDL_stdinc_h_ #ifndef SDL_stdinc_h_
@@ -107,7 +109,7 @@
# elif defined(__MRC__) # elif defined(__MRC__)
void *alloca(unsigned); void *alloca(unsigned);
# else # else
char *alloca(); void *alloca(size_t);
# endif # endif
#endif #endif
@@ -129,15 +131,19 @@ char *alloca();
#endif #endif
/** /**
* The number of elements in an array. * The number of elements in an array.
*/ */
#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) #define SDL_arraysize(array) (sizeof(array)/sizeof(array[0]))
#define SDL_TABLESIZE(table) SDL_arraysize(table) #define SDL_TABLESIZE(table) SDL_arraysize(table)
/** /**
* Macro useful for building other macros with strings in them * Macro useful for building other macros with strings in them
* *
* e.g. #define LOG_ERROR(X) OutputDebugString(SDL_STRINGIFY_ARG(__FUNCTION__) ": " X "\n") * e.g:
*
* ```c
* #define LOG_ERROR(X) OutputDebugString(SDL_STRINGIFY_ARG(__FUNCTION__) ": " X "\n")
* ```
*/ */
#define SDL_STRINGIFY_ARG(arg) #arg #define SDL_STRINGIFY_ARG(arg) #arg
@@ -185,54 +191,61 @@ typedef enum
#endif #endif
/** /**
* \brief A signed 8-bit integer type. * A signed 8-bit integer type.
*/ */
typedef int8_t Sint8;
#define SDL_MAX_SINT8 ((Sint8)0x7F) /* 127 */ #define SDL_MAX_SINT8 ((Sint8)0x7F) /* 127 */
#define SDL_MIN_SINT8 ((Sint8)(~0x7F)) /* -128 */ #define SDL_MIN_SINT8 ((Sint8)(~0x7F)) /* -128 */
typedef int8_t Sint8;
/**
* \brief An unsigned 8-bit integer type.
*/
#define SDL_MAX_UINT8 ((Uint8)0xFF) /* 255 */
#define SDL_MIN_UINT8 ((Uint8)0x00) /* 0 */
typedef uint8_t Uint8;
/**
* \brief A signed 16-bit integer type.
*/
#define SDL_MAX_SINT16 ((Sint16)0x7FFF) /* 32767 */
#define SDL_MIN_SINT16 ((Sint16)(~0x7FFF)) /* -32768 */
typedef int16_t Sint16;
/**
* \brief An unsigned 16-bit integer type.
*/
#define SDL_MAX_UINT16 ((Uint16)0xFFFF) /* 65535 */
#define SDL_MIN_UINT16 ((Uint16)0x0000) /* 0 */
typedef uint16_t Uint16;
/**
* \brief A signed 32-bit integer type.
*/
#define SDL_MAX_SINT32 ((Sint32)0x7FFFFFFF) /* 2147483647 */
#define SDL_MIN_SINT32 ((Sint32)(~0x7FFFFFFF)) /* -2147483648 */
typedef int32_t Sint32;
/**
* \brief An unsigned 32-bit integer type.
*/
#define SDL_MAX_UINT32 ((Uint32)0xFFFFFFFFu) /* 4294967295 */
#define SDL_MIN_UINT32 ((Uint32)0x00000000) /* 0 */
typedef uint32_t Uint32;
/** /**
* \brief A signed 64-bit integer type. * An unsigned 8-bit integer type.
*/ */
typedef uint8_t Uint8;
#define SDL_MAX_UINT8 ((Uint8)0xFF) /* 255 */
#define SDL_MIN_UINT8 ((Uint8)0x00) /* 0 */
/**
* A signed 16-bit integer type.
*/
typedef int16_t Sint16;
#define SDL_MAX_SINT16 ((Sint16)0x7FFF) /* 32767 */
#define SDL_MIN_SINT16 ((Sint16)(~0x7FFF)) /* -32768 */
/**
* An unsigned 16-bit integer type.
*/
typedef uint16_t Uint16;
#define SDL_MAX_UINT16 ((Uint16)0xFFFF) /* 65535 */
#define SDL_MIN_UINT16 ((Uint16)0x0000) /* 0 */
/**
* A signed 32-bit integer type.
*/
typedef int32_t Sint32;
#define SDL_MAX_SINT32 ((Sint32)0x7FFFFFFF) /* 2147483647 */
#define SDL_MIN_SINT32 ((Sint32)(~0x7FFFFFFF)) /* -2147483648 */
/**
* An unsigned 32-bit integer type.
*/
typedef uint32_t Uint32;
#define SDL_MAX_UINT32 ((Uint32)0xFFFFFFFFu) /* 4294967295 */
#define SDL_MIN_UINT32 ((Uint32)0x00000000) /* 0 */
/**
* A signed 64-bit integer type.
*/
typedef int64_t Sint64;
#define SDL_MAX_SINT64 ((Sint64)0x7FFFFFFFFFFFFFFFll) /* 9223372036854775807 */ #define SDL_MAX_SINT64 ((Sint64)0x7FFFFFFFFFFFFFFFll) /* 9223372036854775807 */
#define SDL_MIN_SINT64 ((Sint64)(~0x7FFFFFFFFFFFFFFFll)) /* -9223372036854775808 */ #define SDL_MIN_SINT64 ((Sint64)(~0x7FFFFFFFFFFFFFFFll)) /* -9223372036854775808 */
typedef int64_t Sint64;
/** /**
* \brief An unsigned 64-bit integer type. * An unsigned 64-bit integer type.
*/ */
typedef uint64_t Uint64;
#define SDL_MAX_UINT64 ((Uint64)0xFFFFFFFFFFFFFFFFull) /* 18446744073709551615 */ #define SDL_MAX_UINT64 ((Uint64)0xFFFFFFFFFFFFFFFFull) /* 18446744073709551615 */
#define SDL_MIN_UINT64 ((Uint64)(0x0000000000000000ull)) /* 0 */ #define SDL_MIN_UINT64 ((Uint64)(0x0000000000000000ull)) /* 0 */
typedef uint64_t Uint64;
/* @} *//* Basic data types */ /* @} *//* Basic data types */
@@ -253,44 +266,44 @@ typedef uint64_t Uint64;
* <stdint.h> should define these but this is not true all platforms. * <stdint.h> should define these but this is not true all platforms.
* (for example win32) */ * (for example win32) */
#ifndef SDL_PRIs64 #ifndef SDL_PRIs64
#ifdef PRIs64 #if defined(__WIN32__) || defined(__GDK__)
#define SDL_PRIs64 PRIs64
#elif defined(__WIN32__) || defined(__GDK__)
#define SDL_PRIs64 "I64d" #define SDL_PRIs64 "I64d"
#elif defined(__LINUX__) && defined(__LP64__) #elif defined(PRId64)
#define SDL_PRIs64 PRId64
#elif defined(__LP64__) && !defined(__APPLE__) && !defined(__EMSCRIPTEN__)
#define SDL_PRIs64 "ld" #define SDL_PRIs64 "ld"
#else #else
#define SDL_PRIs64 "lld" #define SDL_PRIs64 "lld"
#endif #endif
#endif #endif
#ifndef SDL_PRIu64 #ifndef SDL_PRIu64
#ifdef PRIu64 #if defined(__WIN32__) || defined(__GDK__)
#define SDL_PRIu64 PRIu64
#elif defined(__WIN32__) || defined(__GDK__)
#define SDL_PRIu64 "I64u" #define SDL_PRIu64 "I64u"
#elif defined(__LINUX__) && defined(__LP64__) #elif defined(PRIu64)
#define SDL_PRIu64 PRIu64
#elif defined(__LP64__) && !defined(__APPLE__)
#define SDL_PRIu64 "lu" #define SDL_PRIu64 "lu"
#else #else
#define SDL_PRIu64 "llu" #define SDL_PRIu64 "llu"
#endif #endif
#endif #endif
#ifndef SDL_PRIx64 #ifndef SDL_PRIx64
#ifdef PRIx64 #if defined(__WIN32__) || defined(__GDK__)
#define SDL_PRIx64 PRIx64
#elif defined(__WIN32__) || defined(__GDK__)
#define SDL_PRIx64 "I64x" #define SDL_PRIx64 "I64x"
#elif defined(__LINUX__) && defined(__LP64__) #elif defined(PRIx64)
#define SDL_PRIx64 PRIx64
#elif defined(__LP64__) && !defined(__APPLE__)
#define SDL_PRIx64 "lx" #define SDL_PRIx64 "lx"
#else #else
#define SDL_PRIx64 "llx" #define SDL_PRIx64 "llx"
#endif #endif
#endif #endif
#ifndef SDL_PRIX64 #ifndef SDL_PRIX64
#ifdef PRIX64 #if defined(__WIN32__) || defined(__GDK__)
#define SDL_PRIX64 PRIX64
#elif defined(__WIN32__) || defined(__GDK__)
#define SDL_PRIX64 "I64X" #define SDL_PRIX64 "I64X"
#elif defined(__LINUX__) && defined(__LP64__) #elif defined(PRIX64)
#define SDL_PRIX64 PRIX64
#elif defined(__LP64__) && !defined(__APPLE__)
#define SDL_PRIX64 "lX" #define SDL_PRIX64 "lX"
#else #else
#define SDL_PRIX64 "llX" #define SDL_PRIX64 "llX"
@@ -336,7 +349,9 @@ typedef uint64_t Uint64;
#define SDL_PRINTF_FORMAT_STRING #define SDL_PRINTF_FORMAT_STRING
#define SDL_SCANF_FORMAT_STRING #define SDL_SCANF_FORMAT_STRING
#define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) #define SDL_PRINTF_VARARG_FUNC( fmtargnumber )
#define SDL_PRINTF_VARARG_FUNCV( fmtargnumber )
#define SDL_SCANF_VARARG_FUNC( fmtargnumber ) #define SDL_SCANF_VARARG_FUNC( fmtargnumber )
#define SDL_SCANF_VARARG_FUNCV( fmtargnumber )
#else #else
#if defined(_MSC_VER) && (_MSC_VER >= 1600) /* VS 2010 and above */ #if defined(_MSC_VER) && (_MSC_VER >= 1600) /* VS 2010 and above */
#include <sal.h> #include <sal.h>
@@ -362,18 +377,25 @@ typedef uint64_t Uint64;
#endif #endif
#if defined(__GNUC__) #if defined(__GNUC__)
#define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __printf__, fmtargnumber, fmtargnumber+1 ))) #define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __printf__, fmtargnumber, fmtargnumber+1 )))
#define SDL_PRINTF_VARARG_FUNCV( fmtargnumber ) __attribute__(( format( __printf__, fmtargnumber, 0 )))
#define SDL_SCANF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __scanf__, fmtargnumber, fmtargnumber+1 ))) #define SDL_SCANF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __scanf__, fmtargnumber, fmtargnumber+1 )))
#define SDL_SCANF_VARARG_FUNCV( fmtargnumber ) __attribute__(( format( __scanf__, fmtargnumber, 0 )))
#else #else
#define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) #define SDL_PRINTF_VARARG_FUNC( fmtargnumber )
#define SDL_PRINTF_VARARG_FUNCV( fmtargnumber )
#define SDL_SCANF_VARARG_FUNC( fmtargnumber ) #define SDL_SCANF_VARARG_FUNC( fmtargnumber )
#define SDL_SCANF_VARARG_FUNCV( fmtargnumber )
#endif #endif
#endif /* SDL_DISABLE_ANALYZE_MACROS */ #endif /* SDL_DISABLE_ANALYZE_MACROS */
#ifndef SDL_COMPILE_TIME_ASSERT #ifndef SDL_COMPILE_TIME_ASSERT
#if defined(__cplusplus) #if defined(__cplusplus)
/* Keep C++ case alone: Some versions of gcc will define __STDC_VERSION__ even when compiling in C++ mode. */
#if (__cplusplus >= 201103L) #if (__cplusplus >= 201103L)
#define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x) #define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x)
#endif #endif
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L)
#define SDL_COMPILE_TIME_ASSERT(name, x) static_assert(x, #x)
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
#define SDL_COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x) #define SDL_COMPILE_TIME_ASSERT(name, x) _Static_assert(x, #x)
#endif #endif
@@ -406,8 +428,8 @@ SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
/** \cond */ /** \cond */
#ifndef DOXYGEN_SHOULD_IGNORE_THIS #ifndef DOXYGEN_SHOULD_IGNORE_THIS
#if !defined(__ANDROID__) && !defined(__VITA__) && !defined(__3DS__) #if !defined(__VITA__) && !defined(__3DS__)
/* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */ /* TODO: include/SDL_stdinc.h:422: error: size of array 'SDL_dummy_enum' is negative */
typedef enum typedef enum
{ {
DUMMY_ENUM_VALUE DUMMY_ENUM_VALUE
@@ -482,8 +504,9 @@ extern DECLSPEC int SDLCALL SDL_GetNumAllocations(void);
extern DECLSPEC char *SDLCALL SDL_getenv(const char *name); extern DECLSPEC char *SDLCALL SDL_getenv(const char *name);
extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite); extern DECLSPEC int SDLCALL SDL_setenv(const char *name, const char *value, int overwrite);
extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, int (SDLCALL *compare) (const void *, const void *)); typedef int (SDLCALL *SDL_CompareCallback)(const void *, const void *);
extern DECLSPEC void * SDLCALL SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (SDLCALL *compare) (const void *, const void *)); extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, SDL_CompareCallback compare);
extern DECLSPEC void * SDLCALL SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, SDL_CompareCallback compare);
extern DECLSPEC int SDLCALL SDL_abs(int x); extern DECLSPEC int SDLCALL SDL_abs(int x);
@@ -512,6 +535,7 @@ extern DECLSPEC Uint32 SDLCALL SDL_crc32(Uint32 crc, const void *data, size_t le
extern DECLSPEC void *SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len); extern DECLSPEC void *SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c, size_t len);
/* Some safe(r) macros for zero'ing structures... */
#define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x))) #define SDL_zero(x) SDL_memset(&(x), 0, sizeof((x)))
#define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x))) #define SDL_zerop(x) SDL_memset((x), 0, sizeof(*(x)))
#define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x))) #define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x)))
@@ -603,11 +627,11 @@ extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2);
extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t len); extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t len);
extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, ...) SDL_SCANF_VARARG_FUNC(2); extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, ...) SDL_SCANF_VARARG_FUNC(2);
extern DECLSPEC int SDLCALL SDL_vsscanf(const char *text, const char *fmt, va_list ap); extern DECLSPEC int SDLCALL SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_list ap) SDL_SCANF_VARARG_FUNCV(2);
extern DECLSPEC int SDLCALL SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ... ) SDL_PRINTF_VARARG_FUNC(3); extern DECLSPEC int SDLCALL SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ... ) SDL_PRINTF_VARARG_FUNC(3);
extern DECLSPEC int SDLCALL SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap); extern DECLSPEC int SDLCALL SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(3);
extern DECLSPEC int SDLCALL SDL_asprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); extern DECLSPEC int SDLCALL SDL_asprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2);
extern DECLSPEC int SDLCALL SDL_vasprintf(char **strp, const char *fmt, va_list ap); extern DECLSPEC int SDLCALL SDL_vasprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2);
#ifndef HAVE_M_PI #ifndef HAVE_M_PI
#ifndef M_PI #ifndef M_PI
@@ -688,8 +712,8 @@ extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf,
size_t * outbytesleft); size_t * outbytesleft);
/** /**
* This function converts a buffer or string between encodings in one pass, returning a * This function converts a buffer or string between encodings in one pass,
* string that must be freed with SDL_free() or NULL on error. * returning a string that must be freed with SDL_free() or NULL on error.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
*/ */
@@ -697,9 +721,11 @@ extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode,
const char *fromcode, const char *fromcode,
const char *inbuf, const char *inbuf,
size_t inbytesleft); size_t inbytesleft);
/* Some helper macros for common cases... */
#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) #define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1)
#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) #define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1)
#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) #define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1)
#define SDL_iconv_wchar_utf8(S) SDL_iconv_string("UTF-8", "WCHAR_T", (char *)S, (SDL_wcslen(S)+1)*sizeof(wchar_t)) #define SDL_iconv_wchar_utf8(S) SDL_iconv_string("UTF-8", "WCHAR_T", (char *)S, (SDL_wcslen(S)+1)*sizeof(wchar_t))
/* force builds using Clang's static analysis tools to use literal C runtime /* force builds using Clang's static analysis tools to use literal C runtime
@@ -724,6 +750,9 @@ size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t size);
size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t size); size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t size);
#endif #endif
/* strdup is not ANSI but POSIX, and its prototype might be hidden... */
char *strdup(const char *str);
/* Starting LLVM 16, the analyser errors out if these functions do not have /* Starting LLVM 16, the analyser errors out if these functions do not have
their prototype defined (clang-diagnostic-implicit-function-declaration) */ their prototype defined (clang-diagnostic-implicit-function-declaration) */
#include <stdlib.h> #include <stdlib.h>
@@ -769,8 +798,9 @@ SDL_FORCE_INLINE void *SDL_memcpy4(SDL_OUT_BYTECAP(dwords*4) void *dst, SDL_IN_B
} }
/** /**
* If a * b would overflow, return -1. Otherwise store a * b via ret * If a * b would overflow, return -1.
* and return 0. *
* Otherwise store a * b via ret and return 0.
* *
* \since This function is available since SDL 2.24.0. * \since This function is available since SDL 2.24.0.
*/ */
@@ -799,8 +829,9 @@ SDL_FORCE_INLINE int _SDL_size_mul_overflow_builtin (size_t a,
#endif #endif
/** /**
* If a + b would overflow, return -1. Otherwise store a + b via ret * If a + b would overflow, return -1.
* and return 0. *
* Otherwise store a + b via ret and return 0.
* *
* \since This function is available since SDL 2.24.0. * \since This function is available since SDL 2.24.0.
*/ */

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_surface.h * # CategorySurface
* *
* Header file for ::SDL_Surface definition and management functions. * Header file for SDL_Surface definition and management functions.
*/ */
#ifndef SDL_surface_h_ #ifndef SDL_surface_h_
@@ -43,7 +43,7 @@ extern "C" {
/** /**
* \name Surface flags * \name Surface flags
* *
* These are the currently supported flags for the ::SDL_Surface. * These are the currently supported flags for the SDL_Surface.
* *
* \internal * \internal
* Used internally (read-only). * Used internally (read-only).
@@ -57,17 +57,17 @@ extern "C" {
/* @} *//* Surface flags */ /* @} *//* Surface flags */
/** /**
* Evaluates to true if the surface needs to be locked before access. * Evaluates to true if the surface needs to be locked before access.
*/ */
#define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0) #define SDL_MUSTLOCK(S) (((S)->flags & SDL_RLEACCEL) != 0)
typedef struct SDL_BlitMap SDL_BlitMap; /* this is an opaque type. */ typedef struct SDL_BlitMap SDL_BlitMap; /* this is an opaque type. */
/** /**
* \brief A collection of pixels used in software blitting. * A collection of pixels used in software blitting.
* *
* \note This structure should be treated as read-only, except for \c pixels, * This structure should be treated as read-only, except for `pixels`, which,
* which, if not NULL, contains the raw pixel data for the surface. * if not NULL, contains the raw pixel data for the surface.
*/ */
typedef struct SDL_Surface typedef struct SDL_Surface
{ {
@@ -97,15 +97,15 @@ typedef struct SDL_Surface
} SDL_Surface; } SDL_Surface;
/** /**
* \brief The type of function used for surface blitting functions. * The type of function used for surface blitting functions.
*/ */
typedef int (SDLCALL *SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect, typedef int (SDLCALL *SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect,
struct SDL_Surface * dst, SDL_Rect * dstrect); struct SDL_Surface * dst, SDL_Rect * dstrect);
/** /**
* \brief The formula used for converting between YUV and RGB * The formula used for converting between YUV and RGB
*/ */
typedef enum typedef enum SDL_YUV_CONVERSION_MODE
{ {
SDL_YUV_CONVERSION_JPEG, /**< Full range JPEG */ SDL_YUV_CONVERSION_JPEG, /**< Full range JPEG */
SDL_YUV_CONVERSION_BT601, /**< BT.601 (the default) */ SDL_YUV_CONVERSION_BT601, /**< BT.601 (the default) */
@@ -140,14 +140,14 @@ typedef enum
* You can change this by calling SDL_SetSurfaceBlendMode() and selecting a * You can change this by calling SDL_SetSurfaceBlendMode() and selecting a
* different `blendMode`. * different `blendMode`.
* *
* \param flags the flags are unused and should be set to 0 * \param flags the flags are unused and should be set to 0.
* \param width the width of the surface * \param width the width of the surface.
* \param height the height of the surface * \param height the height of the surface.
* \param depth the depth of the surface in bits * \param depth the depth of the surface in bits.
* \param Rmask the red mask for the pixels * \param Rmask the red mask for the pixels.
* \param Gmask the green mask for the pixels * \param Gmask the green mask for the pixels.
* \param Bmask the blue mask for the pixels * \param Bmask the blue mask for the pixels.
* \param Amask the alpha mask for the pixels * \param Amask the alpha mask for the pixels.
* \returns the new SDL_Surface structure that is created or NULL if it fails; * \returns the new SDL_Surface structure that is created or NULL if it fails;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
@@ -171,10 +171,10 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface
* of providing pixel color masks, you provide it with a predefined format * of providing pixel color masks, you provide it with a predefined format
* from SDL_PixelFormatEnum. * from SDL_PixelFormatEnum.
* *
* \param flags the flags are unused and should be set to 0 * \param flags the flags are unused and should be set to 0.
* \param width the width of the surface * \param width the width of the surface.
* \param height the height of the surface * \param height the height of the surface.
* \param depth the depth of the surface in bits * \param depth the depth of the surface in bits.
* \param format the SDL_PixelFormatEnum for the new surface's pixel format. * \param format the SDL_PixelFormatEnum for the new surface's pixel format.
* \returns the new SDL_Surface structure that is created or NULL if it fails; * \returns the new SDL_Surface structure that is created or NULL if it fails;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
@@ -198,15 +198,15 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormat
* No copy is made of the pixel data. Pixel data is not managed automatically; * No copy is made of the pixel data. Pixel data is not managed automatically;
* you must free the surface before you free the pixel data. * you must free the surface before you free the pixel data.
* *
* \param pixels a pointer to existing pixel data * \param pixels a pointer to existing pixel data.
* \param width the width of the surface * \param width the width of the surface.
* \param height the height of the surface * \param height the height of the surface.
* \param depth the depth of the surface in bits * \param depth the depth of the surface in bits.
* \param pitch the pitch of the surface in bytes * \param pitch the pitch of the surface in bytes.
* \param Rmask the red mask for the pixels * \param Rmask the red mask for the pixels.
* \param Gmask the green mask for the pixels * \param Gmask the green mask for the pixels.
* \param Bmask the blue mask for the pixels * \param Bmask the blue mask for the pixels.
* \param Amask the alpha mask for the pixels * \param Amask the alpha mask for the pixels.
* \returns the new SDL_Surface structure that is created or NULL if it fails; * \returns the new SDL_Surface structure that is created or NULL if it fails;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
@@ -214,6 +214,7 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormat
* *
* \sa SDL_CreateRGBSurface * \sa SDL_CreateRGBSurface
* \sa SDL_CreateRGBSurfaceWithFormat * \sa SDL_CreateRGBSurfaceWithFormat
* \sa SDL_CreateRGBSurfaceWithFormatFrom
* \sa SDL_FreeSurface * \sa SDL_FreeSurface
*/ */
extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
@@ -239,11 +240,11 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
* No copy is made of the pixel data. Pixel data is not managed automatically; * No copy is made of the pixel data. Pixel data is not managed automatically;
* you must free the surface before you free the pixel data. * you must free the surface before you free the pixel data.
* *
* \param pixels a pointer to existing pixel data * \param pixels a pointer to existing pixel data.
* \param width the width of the surface * \param width the width of the surface.
* \param height the height of the surface * \param height the height of the surface.
* \param depth the depth of the surface in bits * \param depth the depth of the surface in bits.
* \param pitch the pitch of the surface in bytes * \param pitch the pitch of the surface in bytes.
* \param format the SDL_PixelFormatEnum for the new surface's pixel format. * \param format the SDL_PixelFormatEnum for the new surface's pixel format.
* \returns the new SDL_Surface structure that is created or NULL if it fails; * \returns the new SDL_Surface structure that is created or NULL if it fails;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
@@ -278,8 +279,8 @@ extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface);
* *
* A single palette can be shared with many surfaces. * A single palette can be shared with many surfaces.
* *
* \param surface the SDL_Surface structure to update * \param surface the SDL_Surface structure to update.
* \param palette the SDL_Palette structure to use * \param palette the SDL_Palette structure to use.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -300,7 +301,7 @@ extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface,
* 0, then you can read and write to the surface at any time, and the pixel * 0, then you can read and write to the surface at any time, and the pixel
* format of the surface will not change. * format of the surface will not change.
* *
* \param surface the SDL_Surface structure to be locked * \param surface the SDL_Surface structure to be locked.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -314,7 +315,7 @@ extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface);
/** /**
* Release a surface after directly accessing the pixels. * Release a surface after directly accessing the pixels.
* *
* \param surface the SDL_Surface structure to be unlocked * \param surface the SDL_Surface structure to be unlocked.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -329,11 +330,11 @@ extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface);
* result in a memory leak. * result in a memory leak.
* *
* src is an open SDL_RWops buffer, typically loaded with SDL_RWFromFile. * src is an open SDL_RWops buffer, typically loaded with SDL_RWFromFile.
* Alternitavely, you might also use the macro SDL_LoadBMP to load a bitmap * Alternatively, you might also use the macro SDL_LoadBMP to load a bitmap
* from a file, convert it to an SDL_Surface and then close the file. * from a file, convert it to an SDL_Surface and then close the file.
* *
* \param src the data stream for the surface * \param src the data stream for the surface.
* \param freesrc non-zero to close the stream after being read * \param freesrc non-zero to close the stream after being read.
* \returns a pointer to a new SDL_Surface structure or NULL if there was an * \returns a pointer to a new SDL_Surface structure or NULL if there was an
* error; call SDL_GetError() for more information. * error; call SDL_GetError() for more information.
* *
@@ -363,9 +364,9 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src,
* surface before they are saved. YUV and paletted 1-bit and 4-bit formats are * surface before they are saved. YUV and paletted 1-bit and 4-bit formats are
* not supported. * not supported.
* *
* \param surface the SDL_Surface structure containing the image to be saved * \param surface the SDL_Surface structure containing the image to be saved.
* \param dst a data stream to save to * \param dst a data stream to save to.
* \param freedst non-zero to close the stream after being written * \param freedst non-zero to close the stream after being written.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -378,9 +379,9 @@ extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
(SDL_Surface * surface, SDL_RWops * dst, int freedst); (SDL_Surface * surface, SDL_RWops * dst, int freedst);
/** /**
* Save a surface to a file. * Save a surface to a file.
* *
* Convenience macro. * Convenience macro.
*/ */
#define SDL_SaveBMP(surface, file) \ #define SDL_SaveBMP(surface, file) \
SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
@@ -391,8 +392,8 @@ extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
* If RLE is enabled, color key and alpha blending blits are much faster, but * If RLE is enabled, color key and alpha blending blits are much faster, but
* the surface must be locked before directly accessing the pixels. * the surface must be locked before directly accessing the pixels.
* *
* \param surface the SDL_Surface structure to optimize * \param surface the SDL_Surface structure to optimize.
* \param flag 0 to disable, non-zero to enable RLE acceleration * \param flag 0 to disable, non-zero to enable RLE acceleration.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -410,7 +411,7 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface,
* *
* It is safe to pass a NULL `surface` here; it will return SDL_FALSE. * It is safe to pass a NULL `surface` here; it will return SDL_FALSE.
* *
* \param surface the SDL_Surface structure to query * \param surface the SDL_Surface structure to query.
* \returns SDL_TRUE if the surface is RLE enabled, SDL_FALSE otherwise. * \returns SDL_TRUE if the surface is RLE enabled, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.14. * \since This function is available since SDL 2.0.14.
@@ -432,9 +433,9 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasSurfaceRLE(SDL_Surface * surface);
* RLE acceleration can substantially speed up blitting of images with large * RLE acceleration can substantially speed up blitting of images with large
* horizontal runs of transparent pixels. See SDL_SetSurfaceRLE() for details. * horizontal runs of transparent pixels. See SDL_SetSurfaceRLE() for details.
* *
* \param surface the SDL_Surface structure to update * \param surface the SDL_Surface structure to update.
* \param flag SDL_TRUE to enable color key, SDL_FALSE to disable color key * \param flag SDL_TRUE to enable color key, SDL_FALSE to disable color key.
* \param key the transparent pixel * \param key the transparent pixel.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -451,7 +452,7 @@ extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface,
* *
* It is safe to pass a NULL `surface` here; it will return SDL_FALSE. * It is safe to pass a NULL `surface` here; it will return SDL_FALSE.
* *
* \param surface the SDL_Surface structure to query * \param surface the SDL_Surface structure to query.
* \return SDL_TRUE if the surface has a color key, SDL_FALSE otherwise. * \return SDL_TRUE if the surface has a color key, SDL_FALSE otherwise.
* *
* \since This function is available since SDL 2.0.9. * \since This function is available since SDL 2.0.9.
@@ -469,8 +470,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasColorKey(SDL_Surface * surface);
* *
* If the surface doesn't have color key enabled this function returns -1. * If the surface doesn't have color key enabled this function returns -1.
* *
* \param surface the SDL_Surface structure to query * \param surface the SDL_Surface structure to query.
* \param key a pointer filled in with the transparent pixel * \param key a pointer filled in with the transparent pixel.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -491,10 +492,10 @@ extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface,
* *
* `srcC = srcC * (color / 255)` * `srcC = srcC * (color / 255)`
* *
* \param surface the SDL_Surface structure to update * \param surface the SDL_Surface structure to update.
* \param r the red color value multiplied into blit operations * \param r the red color value multiplied into blit operations.
* \param g the green color value multiplied into blit operations * \param g the green color value multiplied into blit operations.
* \param b the blue color value multiplied into blit operations * \param b the blue color value multiplied into blit operations.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -510,10 +511,10 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface,
/** /**
* Get the additional color value multiplied into blit operations. * Get the additional color value multiplied into blit operations.
* *
* \param surface the SDL_Surface structure to query * \param surface the SDL_Surface structure to query.
* \param r a pointer filled in with the current red color value * \param r a pointer filled in with the current red color value.
* \param g a pointer filled in with the current green color value * \param g a pointer filled in with the current green color value.
* \param b a pointer filled in with the current blue color value * \param b a pointer filled in with the current blue color value.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -534,8 +535,8 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface,
* *
* `srcA = srcA * (alpha / 255)` * `srcA = srcA * (alpha / 255)`
* *
* \param surface the SDL_Surface structure to update * \param surface the SDL_Surface structure to update.
* \param alpha the alpha value multiplied into blit operations * \param alpha the alpha value multiplied into blit operations.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -550,8 +551,8 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface,
/** /**
* Get the additional alpha value used in blit operations. * Get the additional alpha value used in blit operations.
* *
* \param surface the SDL_Surface structure to query * \param surface the SDL_Surface structure to query.
* \param alpha a pointer filled in with the current alpha value * \param alpha a pointer filled in with the current alpha value.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -570,8 +571,8 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface,
* existing data, the blendmode of the SOURCE surface should be set to * existing data, the blendmode of the SOURCE surface should be set to
* `SDL_BLENDMODE_NONE`. * `SDL_BLENDMODE_NONE`.
* *
* \param surface the SDL_Surface structure to update * \param surface the SDL_Surface structure to update.
* \param blendMode the SDL_BlendMode to use for blit blending * \param blendMode the SDL_BlendMode to use for blit blending.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -585,8 +586,8 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface,
/** /**
* Get the blend mode used for blit operations. * Get the blend mode used for blit operations.
* *
* \param surface the SDL_Surface structure to query * \param surface the SDL_Surface structure to query.
* \param blendMode a pointer filled in with the current SDL_BlendMode * \param blendMode a pointer filled in with the current SDL_BlendMode.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -606,9 +607,9 @@ extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface,
* Note that blits are automatically clipped to the edges of the source and * Note that blits are automatically clipped to the edges of the source and
* destination surfaces. * destination surfaces.
* *
* \param surface the SDL_Surface structure to be clipped * \param surface the SDL_Surface structure to be clipped.
* \param rect the SDL_Rect structure representing the clipping rectangle, or * \param rect the SDL_Rect structure representing the clipping rectangle, or
* NULL to disable clipping * NULL to disable clipping.
* \returns SDL_TRUE if the rectangle intersects the surface, otherwise * \returns SDL_TRUE if the rectangle intersects the surface, otherwise
* SDL_FALSE and blits will be completely clipped. * SDL_FALSE and blits will be completely clipped.
* *
@@ -627,9 +628,9 @@ extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface,
* rectangle is drawn into. * rectangle is drawn into.
* *
* \param surface the SDL_Surface structure representing the surface to be * \param surface the SDL_Surface structure representing the surface to be
* clipped * clipped.
* \param rect an SDL_Rect structure filled in with the clipping rectangle for * \param rect an SDL_Rect structure filled in with the clipping rectangle for
* the surface * the surface.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -658,11 +659,11 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface * surface)
* surface. The new, optimized surface can then be used as the source for * surface. The new, optimized surface can then be used as the source for
* future blits, making them faster. * future blits, making them faster.
* *
* \param src the existing SDL_Surface structure to convert * \param src the existing SDL_Surface structure to convert.
* \param fmt the SDL_PixelFormat structure that the new surface is optimized * \param fmt the SDL_PixelFormat structure that the new surface is optimized
* for * for.
* \param flags the flags are unused and should be set to 0; this is a * \param flags the flags are unused and should be set to 0; this is a
* leftover from SDL 1.2's API * leftover from SDL 1.2's API.
* \returns the new SDL_Surface structure that is created or NULL if it fails; * \returns the new SDL_Surface structure that is created or NULL if it fails;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
@@ -683,11 +684,11 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface
* it might be easier to call but it doesn't have access to palette * it might be easier to call but it doesn't have access to palette
* information for the destination surface, in case that would be important. * information for the destination surface, in case that would be important.
* *
* \param src the existing SDL_Surface structure to convert * \param src the existing SDL_Surface structure to convert.
* \param pixel_format the SDL_PixelFormatEnum that the new surface is * \param pixel_format the SDL_PixelFormatEnum that the new surface is
* optimized for * optimized for.
* \param flags the flags are unused and should be set to 0; this is a * \param flags the flags are unused and should be set to 0; this is a
* leftover from SDL 1.2's API * leftover from SDL 1.2's API.
* \returns the new SDL_Surface structure that is created or NULL if it fails; * \returns the new SDL_Surface structure that is created or NULL if it fails;
* call SDL_GetError() for more information. * call SDL_GetError() for more information.
* *
@@ -703,14 +704,14 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat
/** /**
* Copy a block of pixels of one format to another format. * Copy a block of pixels of one format to another format.
* *
* \param width the width of the block to copy, in pixels * \param width the width of the block to copy, in pixels.
* \param height the height of the block to copy, in pixels * \param height the height of the block to copy, in pixels.
* \param src_format an SDL_PixelFormatEnum value of the `src` pixels format * \param src_format an SDL_PixelFormatEnum value of the `src` pixels format.
* \param src a pointer to the source pixels * \param src a pointer to the source pixels.
* \param src_pitch the pitch of the source pixels, in bytes * \param src_pitch the pitch of the source pixels, in bytes.
* \param dst_format an SDL_PixelFormatEnum value of the `dst` pixels format * \param dst_format an SDL_PixelFormatEnum value of the `dst` pixels format.
* \param dst a pointer to be filled in with new pixel data * \param dst a pointer to be filled in with new pixel data.
* \param dst_pitch the pitch of the destination pixels, in bytes * \param dst_pitch the pitch of the destination pixels, in bytes.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -729,14 +730,14 @@ extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height,
* *
* This function is currently only implemented for SDL_PIXELFORMAT_ARGB8888. * This function is currently only implemented for SDL_PIXELFORMAT_ARGB8888.
* *
* \param width the width of the block to convert, in pixels * \param width the width of the block to convert, in pixels.
* \param height the height of the block to convert, in pixels * \param height the height of the block to convert, in pixels.
* \param src_format an SDL_PixelFormatEnum value of the `src` pixels format * \param src_format an SDL_PixelFormatEnum value of the `src` pixels format.
* \param src a pointer to the source pixels * \param src a pointer to the source pixels.
* \param src_pitch the pitch of the source pixels, in bytes * \param src_pitch the pitch of the source pixels, in bytes.
* \param dst_format an SDL_PixelFormatEnum value of the `dst` pixels format * \param dst_format an SDL_PixelFormatEnum value of the `dst` pixels format.
* \param dst a pointer to be filled in with premultiplied pixel data * \param dst a pointer to be filled in with premultiplied pixel data.
* \param dst_pitch the pitch of the destination pixels, in bytes * \param dst_pitch the pitch of the destination pixels, in bytes.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -760,10 +761,10 @@ extern DECLSPEC int SDLCALL SDL_PremultiplyAlpha(int width, int height,
* SDL_SetClipRect()), then this function will fill based on the intersection * SDL_SetClipRect()), then this function will fill based on the intersection
* of the clip rectangle and `rect`. * of the clip rectangle and `rect`.
* *
* \param dst the SDL_Surface structure that is the drawing target * \param dst the SDL_Surface structure that is the drawing target.
* \param rect the SDL_Rect structure representing the rectangle to fill, or * \param rect the SDL_Rect structure representing the rectangle to fill, or
* NULL to fill the entire surface * NULL to fill the entire surface.
* \param color the color to fill with * \param color the color to fill with.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -786,10 +787,10 @@ extern DECLSPEC int SDLCALL SDL_FillRect
* SDL_SetClipRect()), then this function will fill based on the intersection * SDL_SetClipRect()), then this function will fill based on the intersection
* of the clip rectangle and `rect`. * of the clip rectangle and `rect`.
* *
* \param dst the SDL_Surface structure that is the drawing target * \param dst the SDL_Surface structure that is the drawing target.
* \param rects an array of SDL_Rects representing the rectangles to fill. * \param rects an array of SDL_Rect representing the rectangles to fill.
* \param count the number of rectangles in the array * \param count the number of rectangles in the array.
* \param color the color to fill with * \param color the color to fill with.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -801,62 +802,64 @@ extern DECLSPEC int SDLCALL SDL_FillRects
(SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color); (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color);
/* !!! FIXME: merge this documentation with the wiki */ /* !!! FIXME: merge this documentation with the wiki */
/** /**
* Performs a fast blit from the source surface to the destination surface. * Performs a fast blit from the source surface to the destination surface.
* *
* This assumes that the source and destination rectangles are * This assumes that the source and destination rectangles are the same size.
* the same size. If either \c srcrect or \c dstrect are NULL, the entire * If either `srcrect` or `dstrect` are NULL, the entire surface (`src` or
* surface (\c src or \c dst) is copied. The final blit rectangles are saved * `dst`) is copied. The final blit rectangles are saved in `srcrect` and
* in \c srcrect and \c dstrect after all clipping is performed. * `dstrect` after all clipping is performed.
* *
* \returns 0 if the blit is successful, otherwise it returns -1. * The blit function should not be called on a locked surface.
* *
* The blit function should not be called on a locked surface. * The blit semantics for surfaces with and without blending and colorkey are
* defined as follows:
* *
* The blit semantics for surfaces with and without blending and colorkey * ```
* are defined as follows: * RGBA->RGB:
* \verbatim * Source surface blend mode set to SDL_BLENDMODE_BLEND:
RGBA->RGB: * alpha-blend (using the source alpha-channel and per-surface alpha)
Source surface blend mode set to SDL_BLENDMODE_BLEND: * SDL_SRCCOLORKEY ignored.
alpha-blend (using the source alpha-channel and per-surface alpha) * Source surface blend mode set to SDL_BLENDMODE_NONE:
SDL_SRCCOLORKEY ignored. * copy RGB.
Source surface blend mode set to SDL_BLENDMODE_NONE: * if SDL_SRCCOLORKEY set, only copy the pixels matching the
copy RGB. * RGB values of the source color key, ignoring alpha in the
if SDL_SRCCOLORKEY set, only copy the pixels matching the * comparison.
RGB values of the source color key, ignoring alpha in the
comparison.
RGB->RGBA:
Source surface blend mode set to SDL_BLENDMODE_BLEND:
alpha-blend (using the source per-surface alpha)
Source surface blend mode set to SDL_BLENDMODE_NONE:
copy RGB, set destination alpha to source per-surface alpha value.
both:
if SDL_SRCCOLORKEY set, only copy the pixels matching the
source color key.
RGBA->RGBA:
Source surface blend mode set to SDL_BLENDMODE_BLEND:
alpha-blend (using the source alpha-channel and per-surface alpha)
SDL_SRCCOLORKEY ignored.
Source surface blend mode set to SDL_BLENDMODE_NONE:
copy all of RGBA to the destination.
if SDL_SRCCOLORKEY set, only copy the pixels matching the
RGB values of the source color key, ignoring alpha in the
comparison.
RGB->RGB:
Source surface blend mode set to SDL_BLENDMODE_BLEND:
alpha-blend (using the source per-surface alpha)
Source surface blend mode set to SDL_BLENDMODE_NONE:
copy RGB.
both:
if SDL_SRCCOLORKEY set, only copy the pixels matching the
source color key.
\endverbatim
* *
* You should call SDL_BlitSurface() unless you know exactly how SDL * RGB->RGBA:
* blitting works internally and how to use the other blit functions. * Source surface blend mode set to SDL_BLENDMODE_BLEND:
* alpha-blend (using the source per-surface alpha)
* Source surface blend mode set to SDL_BLENDMODE_NONE:
* copy RGB, set destination alpha to source per-surface alpha value.
* both:
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
* source color key.
*
* RGBA->RGBA:
* Source surface blend mode set to SDL_BLENDMODE_BLEND:
* alpha-blend (using the source alpha-channel and per-surface alpha)
* SDL_SRCCOLORKEY ignored.
* Source surface blend mode set to SDL_BLENDMODE_NONE:
* copy all of RGBA to the destination.
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
* RGB values of the source color key, ignoring alpha in the
* comparison.
*
* RGB->RGB:
* Source surface blend mode set to SDL_BLENDMODE_BLEND:
* alpha-blend (using the source per-surface alpha)
* Source surface blend mode set to SDL_BLENDMODE_NONE:
* copy RGB.
* both:
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
* source color key.
* ```
*
* You should call SDL_BlitSurface() unless you know exactly how SDL blitting
* works internally and how to use the other blit functions.
*
* \returns 0 if the blit is successful, otherwise it returns -1.
*/ */
#define SDL_BlitSurface SDL_UpperBlit #define SDL_BlitSurface SDL_UpperBlit
@@ -883,12 +886,12 @@ extern DECLSPEC int SDLCALL SDL_UpperBlit
* Unless you know what you're doing, you should be using SDL_BlitSurface() * Unless you know what you're doing, you should be using SDL_BlitSurface()
* instead. * instead.
* *
* \param src the SDL_Surface structure to be copied from * \param src the SDL_Surface structure to be copied from.
* \param srcrect the SDL_Rect structure representing the rectangle to be * \param srcrect the SDL_Rect structure representing the rectangle to be
* copied, or NULL to copy the entire surface * copied, or NULL to copy the entire surface.
* \param dst the SDL_Surface structure that is the blit target * \param dst the SDL_Surface structure that is the blit target.
* \param dstrect the SDL_Rect structure representing the rectangle that is * \param dstrect the SDL_Rect structure representing the rectangle that is
* copied into * copied into.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -925,8 +928,6 @@ extern DECLSPEC int SDLCALL SDL_SoftStretchLinear(SDL_Surface * src,
const SDL_Rect * dstrect); const SDL_Rect * dstrect);
#define SDL_BlitScaled SDL_UpperBlitScaled
/** /**
* Perform a scaled surface copy to a destination surface. * Perform a scaled surface copy to a destination surface.
* *
@@ -941,18 +942,21 @@ extern DECLSPEC int SDLCALL SDL_UpperBlitScaled
(SDL_Surface * src, const SDL_Rect * srcrect, (SDL_Surface * src, const SDL_Rect * srcrect,
SDL_Surface * dst, SDL_Rect * dstrect); SDL_Surface * dst, SDL_Rect * dstrect);
#define SDL_BlitScaled SDL_UpperBlitScaled
/** /**
* Perform low-level surface scaled blitting only. * Perform low-level surface scaled blitting only.
* *
* This is a semi-private function and it performs low-level surface blitting, * This is a semi-private function and it performs low-level surface blitting,
* assuming the input rectangles have already been clipped. * assuming the input rectangles have already been clipped.
* *
* \param src the SDL_Surface structure to be copied from * \param src the SDL_Surface structure to be copied from.
* \param srcrect the SDL_Rect structure representing the rectangle to be * \param srcrect the SDL_Rect structure representing the rectangle to be
* copied * copied.
* \param dst the SDL_Surface structure that is the blit target * \param dst the SDL_Surface structure that is the blit target.
* \param dstrect the SDL_Rect structure representing the rectangle that is * \param dstrect the SDL_Rect structure representing the rectangle that is
* copied into * copied into.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_system.h * # CategorySystem
* *
* Include file for platform specific SDL API functions * Include file for platform specific SDL API functions
*/ */
#ifndef SDL_system_h_ #ifndef SDL_system_h_
@@ -49,7 +49,7 @@ typedef void (SDLCALL * SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsi
* Set a callback for every Windows message, run before TranslateMessage(). * Set a callback for every Windows message, run before TranslateMessage().
* *
* \param callback The SDL_WindowsMessageHook function to call. * \param callback The SDL_WindowsMessageHook function to call.
* \param userdata a pointer to pass to every iteration of `callback` * \param userdata a pointer to pass to every iteration of `callback`.
* *
* \since This function is available since SDL 2.0.4. * \since This function is available since SDL 2.0.4.
*/ */
@@ -66,7 +66,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook ca
* controls on which monitor a full screen application will appear. * controls on which monitor a full screen application will appear.
* *
* \param displayIndex the display index for which to get the D3D9 adapter * \param displayIndex the display index for which to get the D3D9 adapter
* index * index.
* \returns the D3D9 adapter index on success or a negative error code on * \returns the D3D9 adapter index on success or a negative error code on
* failure; call SDL_GetError() for more information. * failure; call SDL_GetError() for more information.
* *
@@ -82,7 +82,7 @@ typedef struct IDirect3DDevice9 IDirect3DDevice9;
* Once you are done using the device, you should release it to avoid a * Once you are done using the device, you should release it to avoid a
* resource leak. * resource leak.
* *
* \param renderer the renderer from which to get the associated D3D device * \param renderer the renderer from which to get the associated D3D device.
* \returns the D3D9 device associated with given renderer or NULL if it is * \returns the D3D9 device associated with given renderer or NULL if it is
* not a D3D9 renderer; call SDL_GetError() for more information. * not a D3D9 renderer; call SDL_GetError() for more information.
* *
@@ -98,7 +98,7 @@ typedef struct ID3D11Device ID3D11Device;
* Once you are done using the device, you should release it to avoid a * Once you are done using the device, you should release it to avoid a
* resource leak. * resource leak.
* *
* \param renderer the renderer from which to get the associated D3D11 device * \param renderer the renderer from which to get the associated D3D11 device.
* \returns the D3D11 device associated with given renderer or NULL if it is * \returns the D3D11 device associated with given renderer or NULL if it is
* not a D3D11 renderer; call SDL_GetError() for more information. * not a D3D11 renderer; call SDL_GetError() for more information.
* *
@@ -118,7 +118,7 @@ typedef struct ID3D12Device ID3D12Device;
* Once you are done using the device, you should release it to avoid a * Once you are done using the device, you should release it to avoid a
* resource leak. * resource leak.
* *
* \param renderer the renderer from which to get the associated D3D12 device * \param renderer the renderer from which to get the associated D3D12 device.
* \returns the D3D12 device associated with given renderer or NULL if it is * \returns the D3D12 device associated with given renderer or NULL if it is
* not a D3D12 renderer; call SDL_GetError() for more information. * not a D3D12 renderer; call SDL_GetError() for more information.
* *
@@ -140,9 +140,9 @@ extern DECLSPEC ID3D12Device* SDLCALL SDL_RenderGetD3D12Device(SDL_Renderer* ren
* Before SDL 2.0.4 this function did not return a value. Since SDL 2.0.4 it * Before SDL 2.0.4 this function did not return a value. Since SDL 2.0.4 it
* returns an SDL_bool. * returns an SDL_bool.
* *
* \param displayIndex the display index for which to get both indices * \param displayIndex the display index for which to get both indices.
* \param adapterIndex a pointer to be filled in with the adapter index * \param adapterIndex a pointer to be filled in with the adapter index.
* \param outputIndex a pointer to be filled in with the output index * \param outputIndex a pointer to be filled in with the output index.
* \returns SDL_TRUE on success or SDL_FALSE on failure; call SDL_GetError() * \returns SDL_TRUE on success or SDL_FALSE on failure; call SDL_GetError()
* for more information. * for more information.
* *
@@ -176,7 +176,7 @@ extern DECLSPEC int SDLCALL SDL_LinuxSetThreadPriority(Sint64 threadID, int prio
* \param threadID The Unix thread ID to change priority of. * \param threadID The Unix thread ID to change priority of.
* \param sdlPriority The new SDL_ThreadPriority value. * \param sdlPriority The new SDL_ThreadPriority value.
* \param schedPolicy The new scheduling policy (SCHED_FIFO, SCHED_RR, * \param schedPolicy The new scheduling policy (SCHED_FIFO, SCHED_RR,
* SCHED_OTHER, etc...) * SCHED_OTHER, etc...).
* \returns 0 on success, or -1 on error. * \returns 0 on success, or -1 on error.
* *
* \since This function is available since SDL 2.0.18. * \since This function is available since SDL 2.0.18.
@@ -188,7 +188,7 @@ extern DECLSPEC int SDLCALL SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID,
/* Platform specific functions for iOS */ /* Platform specific functions for iOS */
#ifdef __IPHONEOS__ #ifdef __IPHONEOS__
#define SDL_iOSSetAnimationCallback(window, interval, callback, callbackParam) SDL_iPhoneSetAnimationCallback(window, interval, callback, callbackParam) typedef void (SDLCALL *SDL_iOSAnimationCallback)(void*);
/** /**
* Use this function to set the animation callback on Apple iOS. * Use this function to set the animation callback on Apple iOS.
@@ -210,9 +210,9 @@ extern DECLSPEC int SDLCALL SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID,
* This functions is also accessible using the macro * This functions is also accessible using the macro
* SDL_iOSSetAnimationCallback() since SDL 2.0.4. * SDL_iOSSetAnimationCallback() since SDL 2.0.4.
* *
* \param window the window for which the animation callback should be set * \param window the window for which the animation callback should be set.
* \param interval the number of frames after which **callback** will be * \param interval the number of frames after which **callback** will be
* called * called.
* \param callback the function to call for every frame. * \param callback the function to call for every frame.
* \param callbackParam a pointer that is passed to `callback`. * \param callbackParam a pointer that is passed to `callback`.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
@@ -222,9 +222,10 @@ extern DECLSPEC int SDLCALL SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID,
* *
* \sa SDL_iPhoneSetEventPump * \sa SDL_iPhoneSetEventPump
*/ */
extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, void (SDLCALL *callback)(void*), void *callbackParam); extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window, int interval, SDL_iOSAnimationCallback callback, void *callbackParam);
#define SDL_iOSSetAnimationCallback(window, interval, callback, callbackParam) SDL_iPhoneSetAnimationCallback(window, interval, callback, callbackParam)
#define SDL_iOSSetEventPump(enabled) SDL_iPhoneSetEventPump(enabled)
/** /**
* Use this function to enable or disable the SDL event pump on Apple iOS. * Use this function to enable or disable the SDL event pump on Apple iOS.
@@ -234,7 +235,7 @@ extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window,
* This functions is also accessible using the macro SDL_iOSSetEventPump() * This functions is also accessible using the macro SDL_iOSSetEventPump()
* since SDL 2.0.4. * since SDL 2.0.4.
* *
* \param enabled SDL_TRUE to enable the event pump, SDL_FALSE to disable it * \param enabled SDL_TRUE to enable the event pump, SDL_FALSE to disable it.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *
@@ -242,6 +243,9 @@ extern DECLSPEC int SDLCALL SDL_iPhoneSetAnimationCallback(SDL_Window * window,
*/ */
extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled); extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled);
#define SDL_iOSSetEventPump(enabled) SDL_iPhoneSetEventPump(enabled)
/* end of iOS-specific functions. */
#endif /* __IPHONEOS__ */ #endif /* __IPHONEOS__ */
@@ -356,9 +360,9 @@ extern DECLSPEC SDL_bool SDLCALL SDL_IsDeXMode(void);
extern DECLSPEC void SDLCALL SDL_AndroidBackButton(void); extern DECLSPEC void SDLCALL SDL_AndroidBackButton(void);
/** /**
See the official Android developer guide for more information: * See the official Android developer guide for more information:
http://developer.android.com/guide/topics/data/data-storage.html * http://developer.android.com/guide/topics/data/data-storage.html
*/ */
#define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01 #define SDL_ANDROID_EXTERNAL_STORAGE_READ 0x01
#define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02 #define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02
@@ -441,11 +445,11 @@ extern DECLSPEC SDL_bool SDLCALL SDL_AndroidRequestPermission(const char *permis
* *
* https://developer.android.com/reference/android/view/Gravity * https://developer.android.com/reference/android/view/Gravity
* *
* \param message text message to be shown * \param message text message to be shown.
* \param duration 0=short, 1=long * \param duration 0=short, 1=long.
* \param gravity where the notification should appear on the screen. * \param gravity where the notification should appear on the screen.
* \param xoffset set this parameter only when gravity >=0 * \param xoffset set this parameter only when gravity >=0.
* \param yoffset set this parameter only when gravity >=0 * \param yoffset set this parameter only when gravity >=0.
* \returns 0 if success, -1 if any error occurs. * \returns 0 if success, -1 if any error occurs.
* *
* \since This function is available since SDL 2.0.16. * \since This function is available since SDL 2.0.16.
@@ -457,8 +461,8 @@ extern DECLSPEC int SDLCALL SDL_AndroidShowToast(const char* message, int durati
* *
* Override "boolean onUnhandledMessage(Message msg)" to handle the message. * Override "boolean onUnhandledMessage(Message msg)" to handle the message.
* *
* \param command user command that must be greater or equal to 0x8000 * \param command user command that must be greater or equal to 0x8000.
* \param param user parameter * \param param user parameter.
* *
* \since This function is available since SDL 2.0.22. * \since This function is available since SDL 2.0.22.
*/ */
@@ -470,9 +474,9 @@ extern DECLSPEC int SDLCALL SDL_AndroidSendMessage(Uint32 command, int param);
#ifdef __WINRT__ #ifdef __WINRT__
/** /**
* \brief WinRT / Windows Phone path types * WinRT / Windows Phone path types
*/ */
typedef enum typedef enum SDL_WinRT_Path
{ {
/** \brief The installed app's root directory. /** \brief The installed app's root directory.
Files here are likely to be read-only. */ Files here are likely to be read-only. */
@@ -494,9 +498,9 @@ typedef enum
/** /**
* \brief WinRT Device Family * WinRT Device Family
*/ */
typedef enum typedef enum SDL_WinRT_DeviceFamily
{ {
/** \brief Unknown family */ /** \brief Unknown family */
SDL_WINRT_DEVICEFAMILY_UNKNOWN, SDL_WINRT_DEVICEFAMILY_UNKNOWN,
@@ -524,7 +528,7 @@ typedef enum
* *
* https://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx * https://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
* *
* \param pathType the type of path to retrieve, one of SDL_WinRT_Path * \param pathType the type of path to retrieve, one of SDL_WinRT_Path.
* \returns a UCS-2 string (16-bit, wide-char) containing the path, or NULL if * \returns a UCS-2 string (16-bit, wide-char) containing the path, or NULL if
* the path is not available for any reason; call SDL_GetError() for * the path is not available for any reason; call SDL_GetError() for
* more information. * more information.
@@ -547,7 +551,7 @@ extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path
* *
* https://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx * https://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx
* *
* \param pathType the type of path to retrieve, one of SDL_WinRT_Path * \param pathType the type of path to retrieve, one of SDL_WinRT_Path.
* \returns a UTF-8 string (8-bit, multi-byte) containing the path, or NULL if * \returns a UTF-8 string (8-bit, multi-byte) containing the path, or NULL if
* the path is not available for any reason; call SDL_GetError() for * the path is not available for any reason; call SDL_GetError() for
* more information. * more information.
@@ -593,7 +597,8 @@ extern DECLSPEC void SDLCALL SDL_OnApplicationDidChangeStatusBarOrientation(void
/* Functions used only by GDK */ /* Functions used only by GDK */
#if defined(__GDK__) #if defined(__GDK__)
typedef struct XTaskQueueObject * XTaskQueueHandle; typedef struct XTaskQueueObject *XTaskQueueHandle;
typedef struct XUser *XUserHandle;
/** /**
* Gets a reference to the global async task queue handle for GDK, * Gets a reference to the global async task queue handle for GDK,
@@ -610,6 +615,20 @@ typedef struct XTaskQueueObject * XTaskQueueHandle;
*/ */
extern DECLSPEC int SDLCALL SDL_GDKGetTaskQueue(XTaskQueueHandle * outTaskQueue); extern DECLSPEC int SDLCALL SDL_GDKGetTaskQueue(XTaskQueueHandle * outTaskQueue);
/**
* Gets a reference to the default user handle for GDK.
*
* This is effectively a synchronous version of XUserAddAsync, which always
* prefers the default user and allows a sign-in UI.
*
* \param outUserHandle a pointer to be filled in with the default user
* handle.
* \returns 0 if success, -1 if any error occurs.
*
* \since This function is available since SDL 2.28.0.
*/
extern DECLSPEC int SDLCALL SDL_GDKGetDefaultUser(XUserHandle * outUserHandle);
#endif #endif
/* Ends C function definitions when using C++ */ /* Ends C function definitions when using C++ */

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -19,10 +19,17 @@
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/** /* WIKI CATEGORY: SYSWM */
* \file SDL_syswm.h
/*
* # CategorySYSWM
* *
* Include file for SDL custom system window manager hooks. * Include file for SDL custom system window manager hooks.
*
* Your application has access to a special type of event SDL_SYSWMEVENT,
* which contains window-manager specific information and arrives whenever
* an unhandled window event occurs. This event is ignored by default, but
* you can enable it with SDL_EventState().
*/ */
#ifndef SDL_syswm_h_ #ifndef SDL_syswm_h_
@@ -33,14 +40,6 @@
#include <SDL2/SDL_video.h> #include <SDL2/SDL_video.h>
#include <SDL2/SDL_version.h> #include <SDL2/SDL_version.h>
/**
* \brief SDL_syswm.h
*
* Your application has access to a special type of event ::SDL_SYSWMEVENT,
* which contains window-manager specific information and arrives whenever
* an unhandled window event occurs. This event is ignored by default, but
* you can enable it with SDL_EventState().
*/
struct SDL_SysWMinfo; struct SDL_SysWMinfo;
#if !defined(SDL_PROTOTYPES_ONLY) #if !defined(SDL_PROTOTYPES_ONLY)
@@ -129,10 +128,11 @@ extern "C" {
#endif #endif
#if !defined(SDL_PROTOTYPES_ONLY) #if !defined(SDL_PROTOTYPES_ONLY)
/** /**
* These are the various supported windowing subsystems * These are the various supported windowing subsystems
*/ */
typedef enum typedef enum SDL_SYSWM_TYPE
{ {
SDL_SYSWM_UNKNOWN, SDL_SYSWM_UNKNOWN,
SDL_SYSWM_WINDOWS, SDL_SYSWM_WINDOWS,
@@ -152,7 +152,7 @@ typedef enum
} SDL_SYSWM_TYPE; } SDL_SYSWM_TYPE;
/** /**
* The custom event structure. * The custom event structure.
*/ */
struct SDL_SysWMmsg struct SDL_SysWMmsg
{ {
@@ -218,10 +218,10 @@ struct SDL_SysWMmsg
}; };
/** /**
* The custom window manager information structure. * The custom window manager information structure.
* *
* When this structure is returned, it holds information about which * When this structure is returned, it holds information about which low level
* low level system it is using, and will be one of SDL_SYSWM_TYPE. * system it is using, and will be one of SDL_SYSWM_TYPE.
*/ */
struct SDL_SysWMinfo struct SDL_SysWMinfo
{ {
@@ -363,8 +363,8 @@ typedef struct SDL_SysWMinfo SDL_SysWMinfo;
* `SDL_VERSION(&info.version)`, and then this function will fill in the rest * `SDL_VERSION(&info.version)`, and then this function will fill in the rest
* of the structure with information about the given window. * of the structure with information about the given window.
* *
* \param window the window about which information is being requested * \param window the window about which information is being requested.
* \param info an SDL_SysWMinfo structure filled in with window information * \param info an SDL_SysWMinfo structure filled in with window information.
* \returns SDL_TRUE if the function is implemented and the `version` member * \returns SDL_TRUE if the function is implemented and the `version` member
* of the `info` struct is valid, or SDL_FALSE if the information * of the `info` struct is valid, or SDL_FALSE if the information
* could not be retrieved; call SDL_GetError() for more information. * could not be retrieved; call SDL_GetError() for more information.

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -23,9 +23,9 @@
#define SDL_thread_h_ #define SDL_thread_h_
/** /**
* \file SDL_thread.h * # CategoryThread
* *
* Header for the SDL thread management routines. * Header for the SDL thread management routines.
*/ */
#include <SDL2/SDL_stdinc.h> #include <SDL2/SDL_stdinc.h>
@@ -63,16 +63,18 @@ typedef unsigned long SDL_threadID;
typedef unsigned int SDL_TLSID; typedef unsigned int SDL_TLSID;
/** /**
* The SDL thread priority. * The SDL thread priority.
* *
* SDL will make system changes as necessary in order to apply the thread priority. * SDL will make system changes as necessary in order to apply the thread
* Code which attempts to control thread state related to priority should be aware * priority. Code which attempts to control thread state related to priority
* that calling SDL_SetThreadPriority may alter such state. * should be aware that calling SDL_SetThreadPriority may alter such state.
* SDL_HINT_THREAD_PRIORITY_POLICY can be used to control aspects of this behavior. * SDL_HINT_THREAD_PRIORITY_POLICY can be used to control aspects of this
* behavior.
* *
* \note On many systems you require special privileges to set high or time critical priority. * On many systems you require special privileges to set high or time critical
* priority.
*/ */
typedef enum { typedef enum SDL_ThreadPriority {
SDL_THREAD_PRIORITY_LOW, SDL_THREAD_PRIORITY_LOW,
SDL_THREAD_PRIORITY_NORMAL, SDL_THREAD_PRIORITY_NORMAL,
SDL_THREAD_PRIORITY_HIGH, SDL_THREAD_PRIORITY_HIGH,
@@ -82,7 +84,7 @@ typedef enum {
/** /**
* The function passed to SDL_CreateThread(). * The function passed to SDL_CreateThread().
* *
* \param data what was passed as `data` to SDL_CreateThread() * \param data what was passed as `data` to SDL_CreateThread().
* \returns a value that can be reported through SDL_WaitThread(). * \returns a value that can be reported through SDL_WaitThread().
*/ */
typedef int (SDLCALL * SDL_ThreadFunction) (void *data); typedef int (SDLCALL * SDL_ThreadFunction) (void *data);
@@ -192,9 +194,9 @@ SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const siz
* SDL_CreateThreadWithStackSize(fn, name, 0, data); * SDL_CreateThreadWithStackSize(fn, name, 0, data);
* ``` * ```
* *
* \param fn the SDL_ThreadFunction function to call in the new thread * \param fn the SDL_ThreadFunction function to call in the new thread.
* \param name the name of the thread * \param name the name of the thread.
* \param data a pointer that is passed to `fn` * \param data a pointer that is passed to `fn`.
* \returns an opaque pointer to the new thread object on success, NULL if the * \returns an opaque pointer to the new thread object on success, NULL if the
* new thread could not be created; call SDL_GetError() for more * new thread could not be created; call SDL_GetError() for more
* information. * information.
@@ -238,10 +240,10 @@ SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data);
* function, but for backwards compatibility, this is currently a separate * function, but for backwards compatibility, this is currently a separate
* function. * function.
* *
* \param fn the SDL_ThreadFunction function to call in the new thread * \param fn the SDL_ThreadFunction function to call in the new thread.
* \param name the name of the thread * \param name the name of the thread.
* \param stacksize the size, in bytes, to allocate for the new thread stack. * \param stacksize the size, in bytes, to allocate for the new thread stack.
* \param data a pointer that is passed to `fn` * \param data a pointer that is passed to `fn`.
* \returns an opaque pointer to the new thread object on success, NULL if the * \returns an opaque pointer to the new thread object on success, NULL if the
* new thread could not be created; call SDL_GetError() for more * new thread could not be created; call SDL_GetError() for more
* information. * information.
@@ -261,7 +263,7 @@ SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const siz
* This is internal memory, not to be freed by the caller, and remains valid * This is internal memory, not to be freed by the caller, and remains valid
* until the specified thread is cleaned up by SDL_WaitThread(). * until the specified thread is cleaned up by SDL_WaitThread().
* *
* \param thread the thread to query * \param thread the thread to query.
* \returns a pointer to a UTF-8 string that names the specified thread, or * \returns a pointer to a UTF-8 string that names the specified thread, or
* NULL if it doesn't have a name. * NULL if it doesn't have a name.
* *
@@ -296,7 +298,7 @@ extern DECLSPEC SDL_threadID SDLCALL SDL_ThreadID(void);
* If SDL is running on a platform that does not support threads the return * If SDL is running on a platform that does not support threads the return
* value will always be zero. * value will always be zero.
* *
* \param thread the thread to query * \param thread the thread to query.
* \returns the ID of the specified thread, or the ID of the current thread if * \returns the ID of the specified thread, or the ID of the current thread if
* `thread` is NULL. * `thread` is NULL.
* *
@@ -313,7 +315,7 @@ extern DECLSPEC SDL_threadID SDLCALL SDL_GetThreadID(SDL_Thread * thread);
* promote the thread to a higher priority) at all, and some require you to be * promote the thread to a higher priority) at all, and some require you to be
* an administrator account. Be prepared for this to fail. * an administrator account. Be prepared for this to fail.
* *
* \param priority the SDL_ThreadPriority to set * \param priority the SDL_ThreadPriority to set.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -344,7 +346,7 @@ extern DECLSPEC int SDLCALL SDL_SetThreadPriority(SDL_ThreadPriority priority);
* afterward. * afterward.
* *
* \param thread the SDL_Thread pointer that was returned from the * \param thread the SDL_Thread pointer that was returned from the
* SDL_CreateThread() call that started this thread * SDL_CreateThread() call that started this thread.
* \param status pointer to an integer that will receive the value returned * \param status pointer to an integer that will receive the value returned
* from the thread function by its 'return', or NULL to not * from the thread function by its 'return', or NULL to not
* receive such value back. * receive such value back.
@@ -383,7 +385,7 @@ extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread * thread, int *status);
* It is safe to pass NULL to this function; it is a no-op. * It is safe to pass NULL to this function; it is a no-op.
* *
* \param thread the SDL_Thread pointer that was returned from the * \param thread the SDL_Thread pointer that was returned from the
* SDL_CreateThread() call that started this thread * SDL_CreateThread() call that started this thread.
* *
* \since This function is available since SDL 2.0.2. * \since This function is available since SDL 2.0.2.
* *
@@ -410,7 +412,7 @@ extern DECLSPEC SDL_TLSID SDLCALL SDL_TLSCreate(void);
/** /**
* Get the current thread's value associated with a thread local storage ID. * Get the current thread's value associated with a thread local storage ID.
* *
* \param id the thread local storage ID * \param id the thread local storage ID.
* \returns the value associated with the ID for the current thread or NULL if * \returns the value associated with the ID for the current thread or NULL if
* no value has been set; call SDL_GetError() for more information. * no value has been set; call SDL_GetError() for more information.
* *
@@ -421,6 +423,8 @@ extern DECLSPEC SDL_TLSID SDLCALL SDL_TLSCreate(void);
*/ */
extern DECLSPEC void * SDLCALL SDL_TLSGet(SDL_TLSID id); extern DECLSPEC void * SDLCALL SDL_TLSGet(SDL_TLSID id);
typedef void (SDLCALL *SDL_TLSDestructorCallback)(void*);
/** /**
* Set the current thread's value associated with a thread local storage ID. * Set the current thread's value associated with a thread local storage ID.
* *
@@ -432,10 +436,10 @@ extern DECLSPEC void * SDLCALL SDL_TLSGet(SDL_TLSID id);
* *
* where its parameter `value` is what was passed as `value` to SDL_TLSSet(). * where its parameter `value` is what was passed as `value` to SDL_TLSSet().
* *
* \param id the thread local storage ID * \param id the thread local storage ID.
* \param value the value to associate with the ID for the current thread * \param value the value to associate with the ID for the current thread.
* \param destructor a function called when the thread exits, to free the * \param destructor a function called when the thread exits, to free the
* value * value.
* \returns 0 on success or a negative error code on failure; call * \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
@@ -444,7 +448,7 @@ extern DECLSPEC void * SDLCALL SDL_TLSGet(SDL_TLSID id);
* \sa SDL_TLSCreate * \sa SDL_TLSCreate
* \sa SDL_TLSGet * \sa SDL_TLSGet
*/ */
extern DECLSPEC int SDLCALL SDL_TLSSet(SDL_TLSID id, const void *value, void (SDLCALL *destructor)(void*)); extern DECLSPEC int SDLCALL SDL_TLSSet(SDL_TLSID id, const void *value, SDL_TLSDestructorCallback destructor);
/** /**
* Cleanup all TLS data for this thread. * Cleanup all TLS data for this thread.

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -23,9 +23,9 @@
#define SDL_timer_h_ #define SDL_timer_h_
/** /**
* \file SDL_timer.h * # CategoryTimer
* *
* Header for the SDL time management routines. * Header for the SDL time management routines.
*/ */
#include <SDL2/SDL_stdinc.h> #include <SDL2/SDL_stdinc.h>
@@ -89,8 +89,8 @@ extern DECLSPEC Uint64 SDLCALL SDL_GetTicks64(void);
* days, but should _not_ be used with SDL_GetTicks64(), which does not have * days, but should _not_ be used with SDL_GetTicks64(), which does not have
* that problem. * that problem.
* *
* For example, with SDL_GetTicks(), if you want to wait 100 ms, you could * For example, with SDL_GetTicks(), if you want to wait 100 ms, you could do
* do this: * this:
* *
* ```c * ```c
* const Uint32 timeout = SDL_GetTicks() + 100; * const Uint32 timeout = SDL_GetTicks() + 100;
@@ -99,9 +99,9 @@ extern DECLSPEC Uint64 SDLCALL SDL_GetTicks64(void);
* } * }
* ``` * ```
* *
* Note that this does not handle tick differences greater * Note that this does not handle tick differences greater than 2^31 so take
* than 2^31 so take care when using the above kind of code * care when using the above kind of code with large timeout delays (tens of
* with large timeout delays (tens of days). * days).
*/ */
#define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0) #define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0)
@@ -140,7 +140,7 @@ extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceFrequency(void);
* waits at least the specified time, but possibly longer due to OS * waits at least the specified time, but possibly longer due to OS
* scheduling. * scheduling.
* *
* \param ms the number of milliseconds to delay * \param ms the number of milliseconds to delay.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
*/ */
@@ -149,10 +149,10 @@ extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms);
/** /**
* Function prototype for the timer callback function. * Function prototype for the timer callback function.
* *
* The callback function is passed the current timer interval and returns * The callback function is passed the current timer interval and returns the
* the next timer interval. If the returned value is the same as the one * next timer interval. If the returned value is the same as the one passed
* passed in, the periodic alarm continues, otherwise a new alarm is * in, the periodic alarm continues, otherwise a new alarm is scheduled. If
* scheduled. If the callback returns 0, the periodic alarm is cancelled. * the callback returns 0, the periodic alarm is cancelled.
*/ */
typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param); typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param);
@@ -182,10 +182,10 @@ typedef int SDL_TimerID;
* time with SDL_GetTicks() or SDL_GetPerformanceCounter() in case your * time with SDL_GetTicks() or SDL_GetPerformanceCounter() in case your
* callback needs to adjust for variances. * callback needs to adjust for variances.
* *
* \param interval the timer delay, in milliseconds, passed to `callback` * \param interval the timer delay, in milliseconds, passed to `callback`.
* \param callback the SDL_TimerCallback function to call when the specified * \param callback the SDL_TimerCallback function to call when the specified
* `interval` elapses * `interval` elapses.
* \param param a pointer that is passed to `callback` * \param param a pointer that is passed to `callback`.
* \returns a timer ID or 0 if an error occurs; call SDL_GetError() for more * \returns a timer ID or 0 if an error occurs; call SDL_GetError() for more
* information. * information.
* *
@@ -200,7 +200,7 @@ extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval,
/** /**
* Remove a timer created with SDL_AddTimer(). * Remove a timer created with SDL_AddTimer().
* *
* \param id the ID of the timer to remove * \param id the ID of the timer to remove.
* \returns SDL_TRUE if the timer is removed or SDL_FALSE if the timer wasn't * \returns SDL_TRUE if the timer is removed or SDL_FALSE if the timer wasn't
* found. * found.
* *

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_touch.h * # CategoryTouch
* *
* Include file for SDL touch event handling. * Include file for SDL touch event handling.
*/ */
#ifndef SDL_touch_h_ #ifndef SDL_touch_h_
@@ -85,7 +85,7 @@ extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void);
/** /**
* Get the touch ID with the given index. * Get the touch ID with the given index.
* *
* \param index the touch device index * \param index the touch device index.
* \returns the touch ID with the given index on success or 0 if the index is * \returns the touch ID with the given index on success or 0 if the index is
* invalid; call SDL_GetError() for more information. * invalid; call SDL_GetError() for more information.
* *
@@ -113,7 +113,7 @@ extern DECLSPEC SDL_TouchDeviceType SDLCALL SDL_GetTouchDeviceType(SDL_TouchID t
/** /**
* Get the number of active fingers for a given touch device. * Get the number of active fingers for a given touch device.
* *
* \param touchID the ID of a touch device * \param touchID the ID of a touch device.
* \returns the number of active fingers for a given touch device on success * \returns the number of active fingers for a given touch device on success
* or 0 on failure; call SDL_GetError() for more information. * or 0 on failure; call SDL_GetError() for more information.
* *
@@ -128,8 +128,8 @@ extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID);
* *
* The returned resource is owned by SDL and should not be deallocated. * The returned resource is owned by SDL and should not be deallocated.
* *
* \param touchID the ID of the requested touch device * \param touchID the ID of the requested touch device.
* \param index the index of the requested finger * \param index the index of the requested finger.
* \returns a pointer to the SDL_Finger object or NULL if no object at the * \returns a pointer to the SDL_Finger object or NULL if no object at the
* given ID and index could be found. * given ID and index could be found.
* *

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -19,11 +19,6 @@
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/**
* \file SDL_types.h
*
* \deprecated
*/
/* DEPRECATED */ /* DEPRECATED */
#include <SDL2/SDL_stdinc.h> #include <SDL2/SDL_stdinc.h>

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_version.h * # CategoryVersion
* *
* This header defines the current SDL version. * This header defines the current SDL version.
*/ */
#ifndef SDL_version_h_ #ifndef SDL_version_h_
@@ -40,10 +40,9 @@ extern "C" {
* Information about the version of SDL in use. * Information about the version of SDL in use.
* *
* Represents the library's version as three levels: major revision * Represents the library's version as three levels: major revision
* (increments with massive changes, additions, and enhancements), * (increments with massive changes, additions, and enhancements), minor
* minor revision (increments with backwards-compatible changes to the * revision (increments with backwards-compatible changes to the major
* major revision), and patchlevel (increments with fixes to the minor * revision), and patchlevel (increments with fixes to the minor revision).
* revision).
* *
* \sa SDL_VERSION * \sa SDL_VERSION
* \sa SDL_GetVersion * \sa SDL_GetVersion
@@ -58,18 +57,17 @@ typedef struct SDL_version
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
*/ */
#define SDL_MAJOR_VERSION 2 #define SDL_MAJOR_VERSION 2
#define SDL_MINOR_VERSION 28 #define SDL_MINOR_VERSION 32
#define SDL_PATCHLEVEL 3 #define SDL_PATCHLEVEL 2
/** /**
* Macro to determine SDL version program was compiled against. * Macro to determine SDL version program was compiled against.
* *
* This macro fills in a SDL_version structure with the version of the * This macro fills in a SDL_version structure with the version of the library
* library you compiled against. This is determined by what header the * you compiled against. This is determined by what header the compiler uses.
* compiler uses. Note that if you dynamically linked the library, you might * Note that if you dynamically linked the library, you might have a slightly
* have a slightly newer or older version at runtime. That version can be * newer or older version at runtime. That version can be determined with
* determined with SDL_GetVersion(), which, unlike SDL_VERSION(), * SDL_GetVersion(), which, unlike SDL_VERSION(), is not a macro.
* is not a macro.
* *
* \param x A pointer to a SDL_version struct to initialize. * \param x A pointer to a SDL_version struct to initialize.
* *
@@ -85,37 +83,40 @@ typedef struct SDL_version
/* TODO: Remove this whole block in SDL 3 */ /* TODO: Remove this whole block in SDL 3 */
#if SDL_MAJOR_VERSION < 3 #if SDL_MAJOR_VERSION < 3
/** /**
* This macro turns the version numbers into a numeric value: * This macro turns the version numbers into a numeric value:
* \verbatim
(1,2,3) -> (1203)
\endverbatim
* *
* This assumes that there will never be more than 100 patchlevels. * ```
* (1,2,3) -> (1203)
* ```
* *
* In versions higher than 2.9.0, the minor version overflows into * This assumes that there will never be more than 100 patchlevels.
* the thousands digit: for example, 2.23.0 is encoded as 4300, *
* and 2.255.99 would be encoded as 25799. * In versions higher than 2.9.0, the minor version overflows into the
* This macro will not be available in SDL 3.x. * thousands digit: for example, 2.23.0 is encoded as 4300, and 2.255.99 would
* be encoded as 25799.
*
* This macro will not be available in SDL 3.x.
*/ */
#define SDL_VERSIONNUM(X, Y, Z) \ #define SDL_VERSIONNUM(X, Y, Z) \
((X)*1000 + (Y)*100 + (Z)) ((X)*1000 + (Y)*100 + (Z))
/** /**
* This is the version number macro for the current SDL version. * This is the version number macro for the current SDL version.
* *
* In versions higher than 2.9.0, the minor version overflows into * In versions higher than 2.9.0, the minor version overflows into the
* the thousands digit: for example, 2.23.0 is encoded as 4300. * thousands digit: for example, 2.23.0 is encoded as 4300. This macro will
* This macro will not be available in SDL 3.x. * not be available in SDL 3.x.
* *
* Deprecated, use SDL_VERSION_ATLEAST or SDL_VERSION instead. * Deprecated, use SDL_VERSION_ATLEAST or SDL_VERSION instead.
*/ */
#define SDL_COMPILEDVERSION \ #define SDL_COMPILEDVERSION \
SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
#endif /* SDL_MAJOR_VERSION < 3 */ #endif /* SDL_MAJOR_VERSION < 3 */
/** /**
* This macro will evaluate to true if compiled with SDL at least X.Y.Z. * This macro will evaluate to true if compiled with SDL at least X.Y.Z.
*/ */
#define SDL_VERSION_ATLEAST(X, Y, Z) \ #define SDL_VERSION_ATLEAST(X, Y, Z) \
((SDL_MAJOR_VERSION >= X) && \ ((SDL_MAJOR_VERSION >= X) && \
@@ -132,7 +133,7 @@ typedef struct SDL_version
* *
* This function may be called safely at any time, even before SDL_Init(). * This function may be called safely at any time, even before SDL_Init().
* *
* \param ver the SDL_version structure that contains the version information * \param ver the SDL_version structure that contains the version information.
* *
* \since This function is available since SDL 2.0.0. * \since This function is available since SDL 2.0.0.
* *

File diff suppressed because it is too large Load Diff

View File

@@ -20,9 +20,9 @@
*/ */
/** /**
* \file SDL_vulkan.h * # CategoryVulkan
* *
* Header file for functions to creating Vulkan surfaces on SDL windows. * Header file for functions to creating Vulkan surfaces on SDL windows.
*/ */
#ifndef SDL_vulkan_h_ #ifndef SDL_vulkan_h_
@@ -52,6 +52,10 @@ extern "C" {
VK_DEFINE_HANDLE(VkInstance) VK_DEFINE_HANDLE(VkInstance)
VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR) VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR)
/* Make sure to undef to avoid issues in case of later vulkan include */
#undef VK_DEFINE_HANDLE
#undef VK_DEFINE_NON_DISPATCHABLE_HANDLE
#endif /* !NO_SDL_VULKAN_TYPEDEFS */ #endif /* !NO_SDL_VULKAN_TYPEDEFS */
typedef VkInstance SDL_vulkanInstance; typedef VkInstance SDL_vulkanInstance;
@@ -97,13 +101,13 @@ typedef VkSurfaceKHR SDL_vulkanSurface; /* for compatibility with Tizen */
* supported. Either do not link to the Vulkan loader or link to a dynamic * supported. Either do not link to the Vulkan loader or link to a dynamic
* library version. * library version.
* *
* \param path The platform dependent Vulkan loader library name or NULL * \param path The platform dependent Vulkan loader library name or NULL.
* \returns 0 on success or -1 if the library couldn't be loaded; call * \returns 0 on success or -1 if the library couldn't be loaded; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 2.0.6. * \since This function is available since SDL 2.0.6.
* *
* \sa SDL_Vulkan_GetVkInstanceProcAddr * \sa SDL_Vulkan_GetVkGetInstanceProcAddr
* \sa SDL_Vulkan_UnloadLibrary * \sa SDL_Vulkan_UnloadLibrary
*/ */
extern DECLSPEC int SDLCALL SDL_Vulkan_LoadLibrary(const char *path); extern DECLSPEC int SDLCALL SDL_Vulkan_LoadLibrary(const char *path);
@@ -146,11 +150,11 @@ extern DECLSPEC void SDLCALL SDL_Vulkan_UnloadLibrary(void);
* however, this parameter will likely be removed in future releases * however, this parameter will likely be removed in future releases
* *
* \param window A window for which the required Vulkan instance extensions * \param window A window for which the required Vulkan instance extensions
* should be retrieved (will be deprecated in a future release) * should be retrieved (will be deprecated in a future release).
* \param pCount A pointer to an unsigned int corresponding to the number of * \param pCount A pointer to an unsigned int corresponding to the number of
* extensions to be returned * extensions to be returned.
* \param pNames NULL or a pointer to an array to be filled with required * \param pNames NULL or a pointer to an array to be filled with required
* Vulkan instance extensions * Vulkan instance extensions.
* \returns SDL_TRUE on success, SDL_FALSE on error. * \returns SDL_TRUE on success, SDL_FALSE on error.
* *
* \since This function is available since SDL 2.0.6. * \since This function is available since SDL 2.0.6.
@@ -168,10 +172,10 @@ extern DECLSPEC SDL_bool SDLCALL SDL_Vulkan_GetInstanceExtensions(SDL_Window *wi
* `instance` must have been created with extensions returned by * `instance` must have been created with extensions returned by
* SDL_Vulkan_GetInstanceExtensions() enabled. * SDL_Vulkan_GetInstanceExtensions() enabled.
* *
* \param window The window to which to attach the Vulkan surface * \param window The window to which to attach the Vulkan surface.
* \param instance The Vulkan instance handle * \param instance The Vulkan instance handle.
* \param surface A pointer to a VkSurfaceKHR handle to output the newly * \param surface A pointer to a VkSurfaceKHR handle to output the newly
* created surface * created surface.
* \returns SDL_TRUE on success, SDL_FALSE on error. * \returns SDL_TRUE on success, SDL_FALSE on error.
* *
* \since This function is available since SDL 2.0.6. * \since This function is available since SDL 2.0.6.
@@ -191,9 +195,9 @@ extern DECLSPEC SDL_bool SDLCALL SDL_Vulkan_CreateSurface(SDL_Window *window,
* platform with high-DPI support (Apple calls this "Retina"), and not * platform with high-DPI support (Apple calls this "Retina"), and not
* disabled by the `SDL_HINT_VIDEO_HIGHDPI_DISABLED` hint. * disabled by the `SDL_HINT_VIDEO_HIGHDPI_DISABLED` hint.
* *
* \param window an SDL_Window for which the size is to be queried * \param window an SDL_Window for which the size is to be queried.
* \param w Pointer to the variable to write the width to or NULL * \param w Pointer to the variable to write the width to or NULL.
* \param h Pointer to the variable to write the height to or NULL * \param h Pointer to the variable to write the height to or NULL.
* *
* \since This function is available since SDL 2.0.6. * \since This function is available since SDL 2.0.6.
* *

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
@@ -19,12 +19,12 @@
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
/* WIKI CATEGORY: BeginCode */
/** /**
* \file begin_code.h * begin_code.h sets things up for C dynamic library function definitions,
* * static inlined functions, and structures aligned at 4-byte alignment.
* This file sets things up for C dynamic library function definitions, * If you don't like ugly C preprocessor code, don't look at this file. :)
* static inlined functions, and structures aligned at 4-byte alignment.
* If you don't like ugly C preprocessor code, don't look at this file. :)
*/ */
/* This shouldn't be nested -- included it around code only. */ /* This shouldn't be nested -- included it around code only. */
@@ -36,6 +36,8 @@
#ifndef SDL_DEPRECATED #ifndef SDL_DEPRECATED
# if defined(__GNUC__) && (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */ # if defined(__GNUC__) && (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */
# define SDL_DEPRECATED __attribute__((deprecated)) # define SDL_DEPRECATED __attribute__((deprecated))
# elif defined(_MSC_VER)
# define SDL_DEPRECATED __declspec(deprecated)
# else # else
# define SDL_DEPRECATED # define SDL_DEPRECATED
# endif # endif
@@ -170,7 +172,7 @@
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L) (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L)
#define SDL_FALLTHROUGH [[fallthrough]] #define SDL_FALLTHROUGH [[fallthrough]]
#else #else
#if defined(__has_attribute) #if defined(__has_attribute) && !defined(__SUNPRO_C) && !defined(__SUNPRO_CC)
#define SDL_HAS_FALLTHROUGH __has_attribute(__fallthrough__) #define SDL_HAS_FALLTHROUGH __has_attribute(__fallthrough__)
#else #else
#define SDL_HAS_FALLTHROUGH 0 #define SDL_HAS_FALLTHROUGH 0

View File

@@ -1,6 +1,6 @@
/* /*
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

View File

@@ -31,8 +31,15 @@ endmacro()
set(SDL2_FOUND TRUE) set(SDL2_FOUND TRUE)
string(REGEX REPLACE "SDL2\\.framework.*" "SDL2.framework" SDL2_FRAMEWORK_PATH "${CMAKE_CURRENT_LIST_DIR}") # Compute the installation prefix relative to this file.
string(REGEX REPLACE "SDL2\\.framework.*" "" SDL2_FRAMEWORK_PARENT_PATH "${CMAKE_CURRENT_LIST_DIR}") set(SDL2_FRAMEWORK_PATH "${CMAKE_CURRENT_LIST_DIR}") # > /SDL2.framework/Resources/CMake/
get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" REALPATH) # > /SDL2.framework/Versions/Current/Resources/CMake
get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" REALPATH) # > /SDL2.framework/Versions/A/Resources/CMake/
get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" PATH) # > /SDL2.framework/Versions/A/Resources/
get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" PATH) # > /SDL2.framework/Versions/A/
get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" PATH) # > /SDL2.framework/Versions/
get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" PATH) # > /SDL2.framework/
get_filename_component(SDL2_FRAMEWORK_PARENT_PATH "${SDL2_FRAMEWORK_PATH}" PATH) # > /
# For compatibility with autotools sdl2-config.cmake, provide SDL2_* variables. # For compatibility with autotools sdl2-config.cmake, provide SDL2_* variables.
@@ -49,12 +56,12 @@ set(SDL2_LIBRARIES "SDL2::SDL2")
# This is done for compatibility with CMake generated SDL2-target.cmake files. # This is done for compatibility with CMake generated SDL2-target.cmake files.
if(NOT TARGET SDL2::SDL2) if(NOT TARGET SDL2::SDL2)
add_library(SDL2::SDL2 INTERFACE IMPORTED) add_library(SDL2::SDL2 SHARED IMPORTED)
set_target_properties(SDL2::SDL2 set_target_properties(SDL2::SDL2
PROPERTIES PROPERTIES
INTERFACE_COMPILE_OPTIONS "SHELL:-F \"${SDL2_FRAMEWORK_PARENT_PATH}\"" FRAMEWORK "TRUE"
IMPORTED_LOCATION "${SDL2_FRAMEWORK_PATH}/Versions/A/SDL2"
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}" INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}"
INTERFACE_LINK_OPTIONS "SHELL:-F \"${SDL2_FRAMEWORK_PARENT_PATH}\";SHELL:-framework SDL2"
COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED" COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED"
INTERFACE_SDL2_SHARED "ON" INTERFACE_SDL2_SHARED "ON"
COMPATIBLE_INTERFACE_STRING "SDL_VERSION" COMPATIBLE_INTERFACE_STRING "SDL_VERSION"

View File

@@ -3,7 +3,7 @@
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>BuildMachineOSBuild</key> <key>BuildMachineOSBuild</key>
<string>22F82</string> <string>23H311</string>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>English</string> <string>English</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
@@ -19,7 +19,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>2.28.3</string> <string>2.32.2</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>SDLX</string> <string>SDLX</string>
<key>CFBundleSupportedPlatforms</key> <key>CFBundleSupportedPlatforms</key>
@@ -27,7 +27,7 @@
<string>MacOSX</string> <string>MacOSX</string>
</array> </array>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>2.28.3</string> <string>2.32.2</string>
<key>DTCompiler</key> <key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string> <string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key> <key>DTPlatformBuild</key>
@@ -35,15 +35,15 @@
<key>DTPlatformName</key> <key>DTPlatformName</key>
<string>macosx</string> <string>macosx</string>
<key>DTPlatformVersion</key> <key>DTPlatformVersion</key>
<string>13.3</string> <string>14.5</string>
<key>DTSDKBuild</key> <key>DTSDKBuild</key>
<string>22E245</string> <string>23F73</string>
<key>DTSDKName</key> <key>DTSDKName</key>
<string>macosx13.3</string> <string>macosx14.5</string>
<key>DTXcode</key> <key>DTXcode</key>
<string>1431</string> <string>1540</string>
<key>DTXcodeBuild</key> <key>DTXcodeBuild</key>
<string>14E300c</string> <string>15F31d</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>10.11</string> <string>10.11</string>
</dict> </dict>

View File

@@ -1,6 +1,6 @@
Simple DirectMedia Layer Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org> Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

BIN
release/SDL2.framework/Versions/A/SDL2 Normal file → Executable file

Binary file not shown.

View File

@@ -10,15 +10,15 @@
</data> </data>
<key>Resources/CMake/sdl2-config.cmake</key> <key>Resources/CMake/sdl2-config.cmake</key>
<data> <data>
s2hXhDxzy/ilC+gLamGy/Kq13jo= HFjU0snuPDDpVpeJJsOGAfWEqrU=
</data> </data>
<key>Resources/Info.plist</key> <key>Resources/Info.plist</key>
<data> <data>
O0+yH6th+YqPy5qBlROGAOJkywk= Dy9w1XfagXeZ0e81ZSWsFJg+azY=
</data> </data>
<key>Resources/License.txt</key> <key>Resources/License.txt</key>
<data> <data>
fCUUBjJ4JuUAC8MRSCszNcY21v8= KX1rSrXSX56fKz5R5KaZfmWONHY=
</data> </data>
<key>Resources/ReadMe.txt</key> <key>Resources/ReadMe.txt</key>
<data> <data>
@@ -26,7 +26,7 @@
</data> </data>
<key>Resources/default.metallib</key> <key>Resources/default.metallib</key>
<data> <data>
07w7GQmm31+NEK8ne4mSo7m70Do= BO5njZwigEYbd1h6TX/xkchzM2o=
</data> </data>
</dict> </dict>
<key>files2</key> <key>files2</key>
@@ -35,385 +35,385 @@
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
hzPz83uejvKAqzL0Xoi6aO8h8jw= kXZkl2ZSSQyVrmrJOXBRaAtXY0I=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
9u/or17IhYmY6rFVU14yva0lEIgG9DmS4LbiwXBLBL8= xDumk5UiAj/35enjtwvoNz9i9FWhFvojHs4+59cpnbI=
</data> </data>
</dict> </dict>
<key>Headers/SDL_assert.h</key> <key>Headers/SDL_assert.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
S50t60okfb3/ykWKavFC3tnkGgE= lr3sQSBPznWi8vveV34dIyAW8BM=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
uPZQOi25pO/BZWjREOhxmXsoreSNJyZrNOnVJ/TyYzs= BGNHXTS5rBD3wuyUkKhgbl50o8FUh12u96oFkrA4KFo=
</data> </data>
</dict> </dict>
<key>Headers/SDL_atomic.h</key> <key>Headers/SDL_atomic.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
yrv6uC/CjYpeCteZDUbBFr2nwiU= R5vrwDefFJeaJsnGkly4WqJ7UPw=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
Mrfc980NeBAvQ5I040V8xusL6cHBcFfPaA9B2prA4dw= DgHR+hJ6x1M3+NB4wUNI4S8Xj2awpMe4dWD1hJ6C+Ak=
</data> </data>
</dict> </dict>
<key>Headers/SDL_audio.h</key> <key>Headers/SDL_audio.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
ATRDpv42XjNUWqjKPDAPYqIqvDY= vD35LoraUn0dXRtYXURSOA2fmzo=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
MThYj7HEVNC7MdUTbzgyHDqlDMDS9g664b6M5d7tsdY= 7GEn/t1dKLeDAz+dClqETucnBCg0JQiRgVOxmOn7JFM=
</data> </data>
</dict> </dict>
<key>Headers/SDL_bits.h</key> <key>Headers/SDL_bits.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
Y7zU8XCX6cvmN/FK9COruPP8VGs= m/yLRLFvcyhpnaReaUyzn+DrKjY=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
5bLOm9HAk5AScYemc5V1usN7NqP685ZYN5MOBjzC2IE= o2NLdv2ji2kQE1gvsKNW/xcd1txMxhXGRX6D9LXZpA0=
</data> </data>
</dict> </dict>
<key>Headers/SDL_blendmode.h</key> <key>Headers/SDL_blendmode.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
ThQw2vcWPo/mLtvKmhQrjhSQhLk= ZhDDvn1XJCv+eMyWGDNz26CFI58=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
o3UtzbWJqnTeh6+r+oLVdOzcJZ1b3XhfPINDjKHftu4= bQjeL6hATkceL0ngnlzrYY2Zp7jNdLW26Cr3Mt7eM6o=
</data> </data>
</dict> </dict>
<key>Headers/SDL_clipboard.h</key> <key>Headers/SDL_clipboard.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
pFjnEWnFn2vCXZrSDQ6m8N6h0MM= uq20kABjWOFzXdejk/Q8rC8a5AM=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
t9Fr9UxC9zwgfkCY5P5DW9k3TndMFRn+tU/heffUOQk= u9qUforELEcJfq+QEHCgZ3wd8g5tPW9JI1+zj4xEm5E=
</data> </data>
</dict> </dict>
<key>Headers/SDL_config.h</key> <key>Headers/SDL_config.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
B13VD2wcb7zADcKXB+B/kBYhpHw= hI+pWoBtzhWnuh9kOELW4J4hs8o=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
LmXzL1O6PasyaBOUhPezJnqtqwCV9rqOyiJNEvGKgHo= s/hYepaQobM/ewrw1MULpg/LKbyWnIHEVZQ4sbSY7ws=
</data> </data>
</dict> </dict>
<key>Headers/SDL_config_macosx.h</key> <key>Headers/SDL_config_macosx.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
/CrGe7lmePlmR7DD9sqN4LHqM/0= GlLgLXuBTBmhZyraeiSZZfvLusQ=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
EpnSzka/wAuxi4wcgIktwQnuYWsMAATYMt6yDmo4zOg= ouwOfhautxowjLZuYmCpXZ89bZkmIoOrawg13ReI0vE=
</data> </data>
</dict> </dict>
<key>Headers/SDL_copying.h</key> <key>Headers/SDL_copying.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
OzEuv+IaGVfj3A2BEoXc87vV+Wk= 7PsNEqTRutlWBeYrk5he8dfe/wA=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
5zsYMLhj8aKXm4gWJoGHC55ipiUi1OIxXdOtUIHQQw4= P5C+RwwY+Z9K7zlETpN07boWbP6xuQ+Z81KGzDOSRkI=
</data> </data>
</dict> </dict>
<key>Headers/SDL_cpuinfo.h</key> <key>Headers/SDL_cpuinfo.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
4/UkY/aNgAY5RsZ61XSnwtCXW9I= C0H58cl/xghA4cpTvltFa5zADSc=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
pWPZkQcmPyAzgZNKcmiYutw8VFjBcHOinO+VVKIBeN0= JpncPWHkqqQ39WvjWBFvdMLGOAhlGvwtEdtEflUSwwQ=
</data> </data>
</dict> </dict>
<key>Headers/SDL_endian.h</key> <key>Headers/SDL_endian.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
j6/tuHiJfdv8YaI9k3fogDw4bNc= Oo+H5bGafn8oIzZ5A2DI+6yJsNI=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
P5KOVzR2wBlhdSw7biIJ3O78dnYnoGdi4pHxvyFcLdY= ejsqpRB8uahMk/Zo2KMVUes2H9nWrrSMDXtypIMmAUE=
</data> </data>
</dict> </dict>
<key>Headers/SDL_error.h</key> <key>Headers/SDL_error.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
6cwM6B1MfW2wTFB+g6c1GO9UH7g= ZxWtU4QHHrwxJbxAg+0wA/BX2OA=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
ULQrtxP4RfbnV5GGj3i+PrYSI/rzDYskl0XQtCd72SU= SsWIV+Yerb7smmRk25OcD33qX1UCM94jrw0iu38zQco=
</data> </data>
</dict> </dict>
<key>Headers/SDL_events.h</key> <key>Headers/SDL_events.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
feHsZTKREoq2xXa4dv/4lzZqzUc= 34TF6C56a/HKmGg7hzyO88NJle4=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
FVz2yvXnjsUNWBsWQOcBqaZrXCCdohSRWDh1l3SKqRY= 2Po+gCuGCGxgmR6DdLPrWu2deTHFLhWAFPZUCkap8Mo=
</data> </data>
</dict> </dict>
<key>Headers/SDL_filesystem.h</key> <key>Headers/SDL_filesystem.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
sicIJ2kroxv3QVkoKklHGN3tbWo= 5OC/DWaJoiaHRxExqCHZ1QPRP4Y=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
k3ybgbDF/Ap8kf4vKxLVZnRXoXtZwpFb4Nsk8GWqDCY= tZpKt7pLk5yKvjAiPMqdoeFsNWGZlwY390pZAzyeCLM=
</data> </data>
</dict> </dict>
<key>Headers/SDL_gamecontroller.h</key> <key>Headers/SDL_gamecontroller.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
DGpJeIYXN/t/Yyqilband2kKOSk= I/FIRlgGO0GQxPa7tmoA9QbfT8s=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
hgAaf8SQwVfc94yXKjNFA3VpsTCYwL65W5X6lXEnsgI= kcdn3wsLxbvOYUIfT6RjZ6PVwEJyiP19UHCVZ1SK0Xg=
</data> </data>
</dict> </dict>
<key>Headers/SDL_gesture.h</key> <key>Headers/SDL_gesture.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
iBwReSkmy4b/H3FD3mZZtLNdCMk= clELTT6eZHcdLgYclKLVVihe3vU=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
H7K4JyorBvI9vlJegmEZ6NvapE7/l/2bhOGeQ9zudiE= jcGQi63lLK6d0mKPptalC8oIPHIYkJXVFmB+Ph03FIc=
</data> </data>
</dict> </dict>
<key>Headers/SDL_guid.h</key> <key>Headers/SDL_guid.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
jTpr9nvDtYvix2njIOclQs9xYuk= dgThPofjZztWJ48hlLrifr+7Dtc=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
ifUKQBbQRJdNqsJBO7Mor3KqQyqDulvyNC82/RWPXhs= +2lkD4yu0yhf1fO7Cbd91+Zw7rsW1R7oVeT9Z6YOwZU=
</data> </data>
</dict> </dict>
<key>Headers/SDL_haptic.h</key> <key>Headers/SDL_haptic.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
+Wt7zxeuXghMudXSohdJr12ueGM= yhzVxf1Kdqq1Xr2Sg+pJbTqkwQ0=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
VhCeKNAvsH+lrvZW9g65G84lg0FofrbORvS0TqPWaRQ= q4GVfzAB4sSEDj+jIPWp9Xw2B3HauyTHo/o060eaygQ=
</data> </data>
</dict> </dict>
<key>Headers/SDL_hidapi.h</key> <key>Headers/SDL_hidapi.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
CBwPZQMZ5wsa03aBND8rQvsLfUg= z+fSffaSHzN3Y/+Fvx/Q3ZxzlvM=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
CJEdgW9T0b2VRNRFaEZqPeCTg3FjsEFOHZvwuJbVHX0= CBbGekbczUMw0zOsfPZwjkntaN1nlc4fho8S5LTQbTc=
</data> </data>
</dict> </dict>
<key>Headers/SDL_hints.h</key> <key>Headers/SDL_hints.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
SWTHcoPzInj/HwBHNEFfQGmL6Dw= x8pHmxmobsfIdGQ3U8T/wVTr4pc=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
BQwW6YWVYXbaOLc9Id+ZjuKHs2VIfcSjM/Oo9JBI6Yk= 6tHFNKbAt52Tfvnd9I5945Lgf9zMlRYqeRuWrPW2wfo=
</data> </data>
</dict> </dict>
<key>Headers/SDL_joystick.h</key> <key>Headers/SDL_joystick.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
Y/dkiMb7+9Wmo8oyyOuh4igQK4o= 6XHQGqWAhtUqF+5nJXvM5qTYwRE=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
d3rYIj9RV45IuiYZAbOQyNe3iR4DORkkqwYiSA81c6k= uKjhvX3KIhPTT/lpAu1Y3q/KMqIQXVfi2H+VFfmb4mg=
</data> </data>
</dict> </dict>
<key>Headers/SDL_keyboard.h</key> <key>Headers/SDL_keyboard.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
4jiEP+XRfvz8VFmNWlHkcsMS2nI= Ml+MLe134SMquN/d5bx948jSG2k=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
EPdkxf3E/uXb/dm3gpxepX+d5JNWswuHP+PG/c33p84= SO9J+my4T35L6w60ZTEC98mabEy2W14U3bXg8ZMSodQ=
</data> </data>
</dict> </dict>
<key>Headers/SDL_keycode.h</key> <key>Headers/SDL_keycode.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
j4z7vftDr05ahrBr5bZnBxZ3Ufs= m7xeznNONTBfKkVWp/d041JqNxc=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
abAEws/ibkdlWSE/bP/uq0oIjcebU59aul5g4Lu0pbA= wl5XcoxPLKXuZfRaVMHaN5CjnygVgrSNowFRESevpd8=
</data> </data>
</dict> </dict>
<key>Headers/SDL_loadso.h</key> <key>Headers/SDL_loadso.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
1fe02ZD9+yDX75ZVM1rk7RqDLCc= 5L842bJf5iUWjoTpu+UQFgKa09I=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
eOcuzAcWhFDvl3bV+3m54GtOrTQztPLIiFHK6NOQuZM= zryjqdnh9zWQRgbBLaH8ZzFYHxS0/wEeBXqq9KW8wds=
</data> </data>
</dict> </dict>
<key>Headers/SDL_locale.h</key> <key>Headers/SDL_locale.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
UOhBMG0JOnoQAEGMY7S6as755IY= PIHUy1X2+y0z6c3pxt/ge6pBcvo=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
yM4RN7sKzLhnVlwbW1pJX3S6YLZl2LM/0qsLyQf5GXM= /rfGMxdMoHftVV0QUdzzyMCV5DNBVAJ2t2fDfmXGEo0=
</data> </data>
</dict> </dict>
<key>Headers/SDL_log.h</key> <key>Headers/SDL_log.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
Ij4wEHg0aIMC28dTUSur/CAxQss= +/4vJepf9ntrZJr5bivvVp/QUio=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
A1Xc1+qvTtDHCz8f4e6oWq8SlifqizcVZ1Q37GJkhG0= CIY407VUnS9pLPMOxgjJpAGcv3zny3Ls+Y7yhVO0qqE=
</data> </data>
</dict> </dict>
<key>Headers/SDL_main.h</key> <key>Headers/SDL_main.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
j0/bBvlkrYcnXeoB6sWoCQiIlV0= E0g/VXfi2wtzpgsPenS2Si+WzoU=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
QOjL/8v8HMC/N+1jocNxIGBB5pifTDWxbwOvD7wJtRg= t7yYbM3kL+w4Cjbt6cIcyLJ59lDFO7YwlCxbNXPf7/8=
</data> </data>
</dict> </dict>
<key>Headers/SDL_messagebox.h</key> <key>Headers/SDL_messagebox.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
TZHRdWCuyxbRdc1GZjnTjHdKV5A= S/UqHw1xzOq/G5whAbsqqR83zFE=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
Y+cutYk+JQOcbC9kbCdqbLr4oIBCxcX8HIzKJW+MOTE= 9aB/qv/nBBV7BOwuqIY4MXSD6bpDrkA4afejIwfNBp8=
</data> </data>
</dict> </dict>
<key>Headers/SDL_metal.h</key> <key>Headers/SDL_metal.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
yggpDR8fWdb4ZAxZDLO7ztOMa84= fmU5Aftuv130e3jkyJpHaPg3eqM=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
aVk9kP7LRPopLu52brj5b7qNwMeUyUOwDPVyXwOm4O0= hwRNMv854qroz8h1X0Aaab5nt3a6JLY0GSILyvaBvCk=
</data> </data>
</dict> </dict>
<key>Headers/SDL_misc.h</key> <key>Headers/SDL_misc.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
wkzkXLc/0JwEBj+pVGBGODS/N7g= R+Xst5koKUN3c8Q7ABjNFogS7S4=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
qClRwcNymRF0gmpjyJ+EQ7fChV48OUN8NAAM2x8NsRM= lczD5q4vVNJ0MwkE9oLIYaZsWesbVlAu1cLQ1Dg+nmM=
</data> </data>
</dict> </dict>
<key>Headers/SDL_mouse.h</key> <key>Headers/SDL_mouse.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
AL6jjX5llLXh3nscuX0MJQQJ7C0= n11vFqL98fGtKLlIjg5mmNQIL68=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
8R3uVCCs2wF9vtwJEqAi+xjYtAtJ1F6UIqCPUhiBwxU= MDPaWpoGwlvOF7QxkDl0rh6bjsPhvf4oRwDOdTzWjTA=
</data> </data>
</dict> </dict>
<key>Headers/SDL_mutex.h</key> <key>Headers/SDL_mutex.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
c4s6haEURwhr1L/ZsIoQHgDC1Rw= +P42iYJpHbiwGZ7bBhCJFWSQgos=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
L1kG6r9N1C+njGEvU0sAJeAVFwr6gkCCwGcBxsjDuNU= EcYUNrtTCWC+fr7AUjZLpWNxq0TH0NmEZ3LkjVV9/TE=
</data> </data>
</dict> </dict>
<key>Headers/SDL_name.h</key> <key>Headers/SDL_name.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
86Aic9zf8RE0YQGymeyFxdGck34= f29xmTe3SPKpaOPghsKTawVSasI=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
U6Hh9de6D0JfccwHBmoAy/zaFw30VuNT1ofo30X7cCw= /cbGSHNCIChQVq2LgnNRHHXVvgDRf8HqPrTAZSaxP6M=
</data> </data>
</dict> </dict>
<key>Headers/SDL_opengl.h</key> <key>Headers/SDL_opengl.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
a83WQIdV8u+rut4US8joNjpA6kA= 3leUh6Gq18sJB4BEcKQy+iQolc0=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
HxWMmpZ2o+Z1atgt7Ou2sf5/4s2raLbApxzyqqzQcGY= k8R1LV5eKvkCsaMBHfJ1lNNI7I/dqmIbqr+qjbsRn64=
</data> </data>
</dict> </dict>
<key>Headers/SDL_opengl_glext.h</key> <key>Headers/SDL_opengl_glext.h</key>
@@ -431,22 +431,22 @@
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
Vc//lrKlqY/bME9ocSWczplleP4= P5Pj7wk9Nf1ixGBxO3GiEwSI0TU=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
hJHBadVAgpV3dIMW++DPSJKqsNOCvkA8qNrMoFbXd5g= 7UPklt2GVWwjaLS9BScuAQJ1VnJfzyOWQ7XffOUgKF4=
</data> </data>
</dict> </dict>
<key>Headers/SDL_opengles2.h</key> <key>Headers/SDL_opengles2.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
gyrJUUv02Am+DYc5V42xH7EQev4= iaFWK+305+CdfRcsenhRwwxW348=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
T7CsPQJXfeZ3+pVjGLqzKBfEjyHX2Ne0vV44iZMKDgs= p6YaZQLVlsW+Xtmwq2apbUUN0V5PQBqbL+Kb50ty874=
</data> </data>
</dict> </dict>
<key>Headers/SDL_opengles2_gl2.h</key> <key>Headers/SDL_opengles2_gl2.h</key>
@@ -497,264 +497,264 @@
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
4PRTgauh2fx03ubJfuuHNOPhN28= HOeOsR1S852BPw+GyoQxCu8dnrk=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
GZQPt4sz55DRDRzw6E2c1WMjhNqInkQA3gxLQiTPQlw= DMnCgERmRqNhjIu8bEnce3WOlhLueJ7/2VQlkld0cqM=
</data> </data>
</dict> </dict>
<key>Headers/SDL_platform.h</key> <key>Headers/SDL_platform.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
Ey0u3gHjhY9CsV6rnGPL6l/Lqx4= 2EuaPqxxPCCnhQT8TgXVlAGPVd0=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
n9zH0IFb2hWb/ZQ3TBMQxLzDre/VQcI6Obhdmq8O7QU= /UdCUiELMW5LpnyQtiRIrltB0fmsOUuo5PcJfihUSP4=
</data> </data>
</dict> </dict>
<key>Headers/SDL_power.h</key> <key>Headers/SDL_power.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
SmO5g1nUZ1IAgDQGIlzbR8F5udg= OcflGeCM0fbVTFzZKWdM1eKVKlg=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
Lmp/XdN6xQbqR/eAmoKFcpqk+MM65gGxjv1cLYUqG8c= u80xdoA8Qm6LjBYuxop4mIHrpcCya4BL5oxrH9I+DaM=
</data> </data>
</dict> </dict>
<key>Headers/SDL_quit.h</key> <key>Headers/SDL_quit.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
xxqxk2GqAVUt7s8YiRcGMegy160= UesdW/A6uv3gPVlX0rttt2qUYY8=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
cd4fDfe+MqMZ35xoFn5VPkGBafcN9tPvL9J74IeKtXI= 1orkEGymBZUzW8+XfZkjeGEbgKcXPxZkwleDgdTXWFU=
</data> </data>
</dict> </dict>
<key>Headers/SDL_rect.h</key> <key>Headers/SDL_rect.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
AtB+xgoXRW94PDzzbBVBYyAW0gI= 0tzoAGRmXs2qe4YGcW7xEB44mgI=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
rFxcleBxja/rwskrEIytxw3evL+Drkx3YsihtllIw78= 4a+aTUFeNyT8FcphJmUM2TJsOqpZr5pDXXmKjQWfwLA=
</data> </data>
</dict> </dict>
<key>Headers/SDL_render.h</key> <key>Headers/SDL_render.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
5yyytzTD1eS/K13NSzW6faLAUlA= ixhZ1LVMllogghoxkbkrnjkmfm0=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
+ljWDPQHFdheD/Z6QxHzbpNQVg/XVlqx5+B3ovMbIF0= YKCPJJ9GkJ8hiZ95O876mXtZ5SvBv5ViiUsgYkuykPs=
</data> </data>
</dict> </dict>
<key>Headers/SDL_revision.h</key> <key>Headers/SDL_revision.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
ACsjWsXuUQwHVlG5aPLRf54/dIQ= wlRT2sTA0dP97Vvcah+M13dM6Ng=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
FdzvRtvvNjmf4LikKB9CV7MkieGdfgsJbfoN4kxwtqs= Dn4kx2zaANESjNuADThOyPh3QukKZMRvUrIcDo8vIR4=
</data> </data>
</dict> </dict>
<key>Headers/SDL_rwops.h</key> <key>Headers/SDL_rwops.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
sCmzKOj8q3vee6JV6acptKOzBoQ= RoEkA5bj0f8XwVQyVcYHxlRLH+M=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
j6rnTfnMJaCsq2CviHQP8obbVNgrElC0OXJBt3ltyVg= x/9RNtJfolHcK7DxJwPH3corQGd2BbzC8PgvzzHSxX8=
</data> </data>
</dict> </dict>
<key>Headers/SDL_scancode.h</key> <key>Headers/SDL_scancode.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
JPnDQuCIC32+ugD3OX3igjdGfmE= uT6v61MI9lFx99szDhZfL4N/rGc=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
vC/EC0A66ywzXwlp8iGE7nlOpWGZ18iHhEdS7BsM3VU= MzwGUSgeP0Cmj7z20owSg5EsfpwV9yfG7bIFUqgzric=
</data> </data>
</dict> </dict>
<key>Headers/SDL_sensor.h</key> <key>Headers/SDL_sensor.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
J+9woN1Qec074rah/rly1BHM5sY= 5r6P94IS5vfiIJMZhrMZNpabid0=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
sEfbN4S8Lpxm0XDblgOvnVV0fsgx/zo/q0s5h9OvhmE= gAFmGVEIFr3q+SQiXmHBctnS1qMa9guogUbp2JDeDdk=
</data> </data>
</dict> </dict>
<key>Headers/SDL_shape.h</key> <key>Headers/SDL_shape.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
Hv8O7XLnXLIVAOf6cjF56yyrRkg= jmzKazW1l/+89mfDEsa68yfO+M0=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
XFA3qPWL1vJ3EQtae2baJlOZ9ESEmhB1FMYI3fITLZY= zrlHT6aGBYNFY5OOhnuPp6/HUIq32NzHq7RcHEnY4ww=
</data> </data>
</dict> </dict>
<key>Headers/SDL_stdinc.h</key> <key>Headers/SDL_stdinc.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
iliyExriwpoxEAgG8CI8CG8go54= ghpA/MCplmhdO4hJb25EXKh4+s4=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
I4aI+ExJq+16kZfDjF++Uaa2lHZjUWmuFc83IUDfuIk= cSrXM8EyC4v/PujaxFfax4TvFm2zt24dFebf53otApM=
</data> </data>
</dict> </dict>
<key>Headers/SDL_surface.h</key> <key>Headers/SDL_surface.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
Toy3u0xKUfSMmknlIToaUmf5vwE= 4Ep9Q21aB+MvJ4ohfIaIobCiERU=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
CDctL0QJDSDvlB+uXO69kLW2uA0Xdc0xiJBN8h3pX74= HBm9M4a5z2TAO7jYrEREEBPmFIZ10He+SyiAhJ90C6M=
</data> </data>
</dict> </dict>
<key>Headers/SDL_system.h</key> <key>Headers/SDL_system.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
I1i3X5zfVBg7YFzag2Dj43RzuUI= kBnA4mSoS+aU91if04kxha03KHY=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
mt328KSVoSMSjZ4Wy268tC04JQmyCAsDM60TWeG3K4s= EV4kDREc7p2kR4LtHoOuY6J2Rsm+KX65ZQv58y+QVz8=
</data> </data>
</dict> </dict>
<key>Headers/SDL_syswm.h</key> <key>Headers/SDL_syswm.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
7sdDIYSuCZbE13gdwZ+rmiqUBEk= yIC4ZT4qln13hliROuzUyx3FhyY=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
6QWGeehhVCpiwN9fQv1by5vpdNg8JqxY1XgR48Fxpdc= rXp/rtBhEjRJoZnGV9F6IrAIdoE5WJdtUtwNypSUF7E=
</data> </data>
</dict> </dict>
<key>Headers/SDL_thread.h</key> <key>Headers/SDL_thread.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
rdWafQMEiS2pSqeEGdRXDjaU96Q= OFKWGOtypbrEI7UTrkw42voWf20=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
pVkN+av2tjneOX9IafFyXjDRaWe/ROSrLwUQRfCrYYA= 7qn2qV503yS1JbYFUB2HvCHoN1AzetzjrmZWZIIf3qo=
</data> </data>
</dict> </dict>
<key>Headers/SDL_timer.h</key> <key>Headers/SDL_timer.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
Nstsm7GCSSnoH66923lImFIE0fY= GIT08iK8cG99/tVgSH4+ACwG9mU=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
6jmEztIQClT68gsMRHHP9tVPF5TxqLfBgmkTqOA00fs= Q8Bv8+1i2eKfGySzfRXZT03Clzce9l8uP9QDjGTzzVc=
</data> </data>
</dict> </dict>
<key>Headers/SDL_touch.h</key> <key>Headers/SDL_touch.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
LWDPymUVgQxlg3DwBCJ8klXPq6U= QmkTEEIiL2jICJu6ecf2wLwyhAU=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
y/Kqn35XtKznNX9foqsPjC+jlnbRvBuF8A1MzKIjBmY= MOw1u2X8Zk9fljCdbfSRRyEXEbgT+caV26N+T0NjF0s=
</data> </data>
</dict> </dict>
<key>Headers/SDL_types.h</key> <key>Headers/SDL_types.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
8xeioL5fy1QauaS4i9g5UdMotoM= Uh90u3TkJONniC7ql41abwXUPa4=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
Em64WSsB0scWcgjtDOAhVyy4XoRBRciw+YaG3vyn6hM= jrJoMRTqqOrdJC6jL9UHPmZHjACvE7fU8poxxLLjKd8=
</data> </data>
</dict> </dict>
<key>Headers/SDL_version.h</key> <key>Headers/SDL_version.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
RxJkcIBwFx85nADiCWZgVRs8k7g= 0p5YxpDU0ZKVW3O7oaiUEbQvQgM=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
0lwD8QVtsPTM6vhZbDu05D8v6so3iTdjrj3mVjcfhWA= EtiQXi0LseubTFgUWQb2VmPg9hMBLtbyUYL/q744sqo=
</data> </data>
</dict> </dict>
<key>Headers/SDL_video.h</key> <key>Headers/SDL_video.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
oDSfm7hvyakVAn3MJ/vPYpDiTi8= pbav/kF15VNS1e5QTP2fYMa9u+E=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
4kgMp+1L702uCbe5U3mPNYx/zonCSDmAoqKxZGMWlC0= XyZkUty0lOswE4c3LokQs92335pjv6Mdqu/eFkB0XNo=
</data> </data>
</dict> </dict>
<key>Headers/SDL_vulkan.h</key> <key>Headers/SDL_vulkan.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
k22upiGXgz0TzSKkWtDwaKrV2fw= gLQPn/TnSR9Mw0SzIieM7cyPPQY=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
kg2f48mMRh4+Ev5cnsEDDyQqf6YbP7YqWNhykRYzgDo= gqb0mAn18Ax0d7+3MwoDmO2kMJ2wXR900U/Kxs7QP8A=
</data> </data>
</dict> </dict>
<key>Headers/begin_code.h</key> <key>Headers/begin_code.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
BXr58UQDjOvu3YEpLqbL6MzdnEw= F5WwG4LxINu6xsjkDri880RDPAQ=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
lZjnBGKuQiSupwtm3kZTliIMMPlHVmUsVTRtQ7E0WMU= mAPasp+0UizjUAq3iSYOliLfYwfOkPkq0gwYCOGcTns=
</data> </data>
</dict> </dict>
<key>Headers/close_code.h</key> <key>Headers/close_code.h</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
b9BWGnHVTllZJNggBlv8S0bczLA= Hv+nlnxXg4WGAt4qPpTk93cX3R0=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
/x8Gxc1GaIoziXOz/sebI7d0PytDiEWi8kWZfjkp0Ww= RZnpztunRR/wemMG8LdTG+7QWxxaZbGiYT0bdxvkP9o=
</data> </data>
</dict> </dict>
<key>Resources/CMake/sdl2-config-version.cmake</key> <key>Resources/CMake/sdl2-config-version.cmake</key>
@@ -772,33 +772,33 @@
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
s2hXhDxzy/ilC+gLamGy/Kq13jo= HFjU0snuPDDpVpeJJsOGAfWEqrU=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
DuTUW8idzRp7WT1FT5x/m1C1SbVH0FKvKRKOgVlRVhU= 3CcBgLSrIjtN3CnKminQz7NzcDt2kcMM2AW/PSX3/0Q=
</data> </data>
</dict> </dict>
<key>Resources/Info.plist</key> <key>Resources/Info.plist</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
O0+yH6th+YqPy5qBlROGAOJkywk= Dy9w1XfagXeZ0e81ZSWsFJg+azY=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
sIWVXC/W1heu51j6IrNeI7fFPvxyVxJPCvMlZ8YpVFA= BAddkaN2r4dEHPxmdAwZ33wKCEuHqn1y3xUe9sQ/wtY=
</data> </data>
</dict> </dict>
<key>Resources/License.txt</key> <key>Resources/License.txt</key>
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
fCUUBjJ4JuUAC8MRSCszNcY21v8= KX1rSrXSX56fKz5R5KaZfmWONHY=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
d+3CuMuNTuvjYs+HODz44b3nsOHwwJqlcyQOq7qhAPc= N7l1tSc3NOoVf7HjY9BhkQNvKJ7Kd2f3NpZ4Fr7dFW8=
</data> </data>
</dict> </dict>
<key>Resources/ReadMe.txt</key> <key>Resources/ReadMe.txt</key>
@@ -816,11 +816,11 @@
<dict> <dict>
<key>hash</key> <key>hash</key>
<data> <data>
07w7GQmm31+NEK8ne4mSo7m70Do= BO5njZwigEYbd1h6TX/xkchzM2o=
</data> </data>
<key>hash2</key> <key>hash2</key>
<data> <data>
vmrmeHQ4l7Q4flA5dILQw27M4T0Sc70MQIfP+lFY/do= Fe5XhVrmpOq2Hqk5Jy7Yhqd+IXcB/PDUI58bHeKR4Cg=
</data> </data>
</dict> </dict>
</dict> </dict>

View File

@@ -1 +0,0 @@
A

View File

@@ -0,0 +1 @@
A

View File

@@ -1,11 +1,11 @@
#include "animated_sprite.h" #include "animated_sprite.h"
#include <stddef.h> // Para size_t #include <SDL3/SDL_log.h> // Para SDL_LogWarn, SDL_LogCategory, SDL_LogError
#include <fstream> // Para basic_ostream, basic_istream, operator<<, basic... #include <stddef.h> // Para size_t
#include <iostream> // Para cout, cerr #include <fstream> // Para basic_istream, basic_ifstream, basic_ios
#include <sstream> // Para basic_stringstream #include <sstream> // Para basic_stringstream
#include <stdexcept> // Para runtime_error #include <stdexcept> // Para runtime_error
#include "texture.h" // Para Texture #include "texture.h" // Para Texture
#include "utils.h" // Para printWithDots #include "utils.h" // Para printWithDots
// Carga las animaciones en un vector(Animations) desde un fichero // Carga las animaciones en un vector(Animations) desde un fichero
AnimationsFileBuffer loadAnimationsFromFile(const std::string &file_path) AnimationsFileBuffer loadAnimationsFromFile(const std::string &file_path)
@@ -13,7 +13,7 @@ AnimationsFileBuffer loadAnimationsFromFile(const std::string &file_path)
std::ifstream file(file_path); std::ifstream file(file_path);
if (!file) if (!file)
{ {
std::cerr << "Error: Fichero no encontrado " << file_path << std::endl; SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error: Fichero no encontrado %s", file_path.c_str());
throw std::runtime_error("Fichero no encontrado: " + file_path); throw std::runtime_error("Fichero no encontrado: " + file_path);
} }
@@ -52,7 +52,7 @@ AnimatedSprite::AnimatedSprite(std::shared_ptr<Texture> texture, const Animation
} }
} }
// Obtiene el indice de la animación a partir del nombre // Obtiene el índice de la animación a partir del nombre
int AnimatedSprite::getIndex(const std::string &name) int AnimatedSprite::getIndex(const std::string &name)
{ {
auto index = -1; auto index = -1;
@@ -65,7 +65,7 @@ int AnimatedSprite::getIndex(const std::string &name)
return index; return index;
} }
} }
std::cout << "** Warning: could not find \"" << name.c_str() << "\" animation" << std::endl; SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "** Warning: could not find \"%s\" animation", name.c_str());
return -1; return -1;
} }
@@ -156,8 +156,8 @@ void AnimatedSprite::resetAnimation()
// Carga la animación desde un vector de cadenas // Carga la animación desde un vector de cadenas
void AnimatedSprite::loadFromAnimationsFileBuffer(const AnimationsFileBuffer &source) void AnimatedSprite::loadFromAnimationsFileBuffer(const AnimationsFileBuffer &source)
{ {
int frame_width = 1; float frame_width = 1;
int frame_height = 1; float frame_height = 1;
int frames_per_row = 1; int frames_per_row = 1;
int max_tiles = 1; int max_tiles = 1;
@@ -169,7 +169,7 @@ void AnimatedSprite::loadFromAnimationsFileBuffer(const AnimationsFileBuffer &so
// Parsea el fichero para buscar variables y valores // Parsea el fichero para buscar variables y valores
if (line != "[animation]") if (line != "[animation]")
{ {
// Encuentra la posición del caracter '=' // Encuentra la posición del carácter '='
size_t pos = line.find("="); size_t pos = line.find("=");
// Procesa las dos subcadenas // Procesa las dos subcadenas
@@ -182,7 +182,7 @@ void AnimatedSprite::loadFromAnimationsFileBuffer(const AnimationsFileBuffer &so
else if (key == "frame_height") else if (key == "frame_height")
frame_height = value; frame_height = value;
else else
std::cout << "Warning: unknown parameter " << key << std::endl; SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Warning: unknown parameter %s", key.c_str());
frames_per_row = texture_->getWidth() / frame_width; frames_per_row = texture_->getWidth() / frame_width;
const int w = texture_->getWidth() / frame_width; const int w = texture_->getWidth() / frame_width;
@@ -191,7 +191,7 @@ void AnimatedSprite::loadFromAnimationsFileBuffer(const AnimationsFileBuffer &so
} }
} }
// Si la linea contiene el texto [animation] se realiza el proceso de carga de una animación // Si la línea contiene el texto [animation] se realiza el proceso de carga de una animación
if (line == "[animation]") if (line == "[animation]")
{ {
Animation animation; Animation animation;
@@ -217,10 +217,10 @@ void AnimatedSprite::loadFromAnimationsFileBuffer(const AnimationsFileBuffer &so
// Se introducen los valores separados por comas en un vector // Se introducen los valores separados por comas en un vector
std::stringstream ss(value); std::stringstream ss(value);
std::string tmp; std::string tmp;
SDL_Rect rect = {0, 0, frame_width, frame_height}; SDL_FRect rect = {0, 0, frame_width, frame_height};
while (getline(ss, tmp, ',')) while (getline(ss, tmp, ','))
{ {
// Comprueba que el tile no sea mayor que el maximo indice permitido // Comprueba que el tile no sea mayor que el máximo índice permitido
const int num_tile = std::stoi(tmp); const int num_tile = std::stoi(tmp);
if (num_tile <= max_tiles) if (num_tile <= max_tiles)
{ {
@@ -230,9 +230,8 @@ void AnimatedSprite::loadFromAnimationsFileBuffer(const AnimationsFileBuffer &so
} }
} }
} }
else else
std::cout << "Warning: unknown parameter " << key << std::endl; SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Warning: unknown parameter %s", key.c_str());
} }
} while (line != "[/animation]"); } while (line != "[/animation]");
@@ -240,7 +239,7 @@ void AnimatedSprite::loadFromAnimationsFileBuffer(const AnimationsFileBuffer &so
animations_.emplace_back(animation); animations_.emplace_back(animation);
} }
// Una vez procesada la linea, aumenta el indice para pasar a la siguiente // Una vez procesada la línea, aumenta el índice para pasar a la siguiente
index++; index++;
} }

View File

@@ -1,66 +1,63 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect #include <SDL3/SDL_rect.h>
#include <memory> // Para shared_ptr #include <memory>
#include <string> // Para string #include <string>
#include <vector> // Para vector #include <vector>
#include "moving_sprite.h" // Para MovingSprite
class Texture; // lines 9-9
#include "moving_sprite.h"
// Declaración adelantada
class Texture;
// Estructura de Animación
struct Animation struct Animation
{ {
std::string name; // Nombre de la animacion std::string name; // Nombre de la animación
std::vector<SDL_Rect> frames; // Cada uno de los frames que componen la animación std::vector<SDL_FRect> frames; // Frames que componen la animación
int speed; // Velocidad de la animación int speed; // Velocidad de reproducción
int loop; // Indica a que frame vuelve la animación al terminar. -1 para que no vuelva int loop; // Frame de vuelta al terminar (-1 para no repetir)
bool completed; // Indica si ha finalizado la animación bool completed; // Indica si la animación ha finalizado
int current_frame; // Frame actual int current_frame; // Frame actual en reproducción
int counter; // Contador para las animaciones int counter; // Contador para la animación
Animation() : name(std::string()), speed(5), loop(0), completed(false), current_frame(0), counter(0) {} Animation() : name(std::string()), speed(5), loop(0), completed(false), current_frame(0), counter(0) {}
}; };
// Alias de tipo para buffer de animaciones
using AnimationsFileBuffer = std::vector<std::string>; using AnimationsFileBuffer = std::vector<std::string>;
// Carga las animaciones en un vector(Animations) desde un fichero // Carga las animaciones desde un fichero en un vector de strings
AnimationsFileBuffer loadAnimationsFromFile(const std::string &file_path); AnimationsFileBuffer loadAnimationsFromFile(const std::string &file_path);
// Clase AnimatedSprite: Sprite animado que hereda de MovingSprite
class AnimatedSprite : public MovingSprite class AnimatedSprite : public MovingSprite
{ {
protected:
// Variables
std::vector<Animation> animations_; // Vector con las diferentes animaciones
int current_animation_ = 0; // Animacion activa
// Calcula el frame correspondiente a la animación actual
void animate();
// Carga la animación desde un vector de cadenas
void loadFromAnimationsFileBuffer(const AnimationsFileBuffer &source);
public: public:
// Constructor // --- Constructores y destructor ---
AnimatedSprite(std::shared_ptr<Texture> texture, const std::string &file_path); AnimatedSprite(std::shared_ptr<Texture> texture, const std::string &file_path);
AnimatedSprite(std::shared_ptr<Texture> texture, const AnimationsFileBuffer &animations); AnimatedSprite(std::shared_ptr<Texture> texture, const AnimationsFileBuffer &animations);
explicit AnimatedSprite(std::shared_ptr<Texture> texture) explicit AnimatedSprite(std::shared_ptr<Texture> texture) : MovingSprite(texture) {}
: MovingSprite(texture) {}
// Destructor
virtual ~AnimatedSprite() override = default; virtual ~AnimatedSprite() override = default;
// Actualiza las variables del objeto // --- Métodos principales ---
void update() override; void update() override; // Actualiza la animación
// Comprueba si ha terminado la animación // --- Control de animaciones ---
bool animationIsCompleted(); void setCurrentAnimation(const std::string &name = "default"); // Establece la animación por nombre
void setCurrentAnimation(int index = 0); // Establece la animación por índice
void resetAnimation(); // Reinicia la animación actual
// Obtiene el indice de la animación a partir del nombre // --- Consultas ---
int getIndex(const std::string &name); bool animationIsCompleted(); // Comprueba si la animación ha terminado
int getIndex(const std::string &name); // Obtiene el índice de una animación por nombre
// Establece la animacion actual protected:
void setCurrentAnimation(const std::string &name = "default"); // --- Datos de animación ---
void setCurrentAnimation(int index = 0); std::vector<Animation> animations_; // Vector de animaciones disponibles
int current_animation_ = 0; // Índice de la animación activa
// Reinicia la animación // --- Métodos internos ---
void resetAnimation(); void animate(); // Calcula el frame actual de la animación
void loadFromAnimationsFileBuffer(const AnimationsFileBuffer &source); // Carga animaciones desde un buffer
}; };

View File

@@ -1,30 +1,21 @@
#include "asset.h" #include "asset.h"
#include <algorithm> // Para find_if, max #include <SDL3/SDL_log.h> // Para SDL_LogInfo, SDL_LogCategory, SDL_LogError
#include <fstream> // Para basic_ostream, operator<<, basic_ifstream, endl #include <algorithm> // Para find_if, max
#include <iostream> // Para cout #include <fstream> // Para basic_ifstream, ifstream
#include <string> // Para allocator, char_traits, string, operator+, oper... #include <string> // Para allocator, string, char_traits, operator+
#include "utils.h" // Para getFileName, printWithDots #include "utils.h" // Para getFileName
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado // Singleton
Asset *Asset::asset_ = nullptr; Asset *Asset::instance_ = nullptr;
// [SINGLETON] Crearemos el objeto asset con esta función estática // Inicializa la instancia única del singleton
void Asset::init(const std::string &executable_path) void Asset::init(const std::string &executable_path) { Asset::instance_ = new Asset(executable_path); }
{
Asset::asset_ = new Asset(executable_path);
}
// [SINGLETON] Destruiremos el objeto asset con esta función estática // Libera la instancia
void Asset::destroy() void Asset::destroy() { delete Asset::instance_; }
{
delete Asset::asset_;
}
// [SINGLETON] Con este método obtenemos el objeto asset y podemos trabajar con él // Obtiene la instancia
Asset *Asset::get() Asset *Asset::get() { return Asset::instance_; }
{
return Asset::asset_;
}
// Añade un elemento a la lista // Añade un elemento a la lista
void Asset::add(const std::string &file, AssetType type, bool required, bool absolute) void Asset::add(const std::string &file, AssetType type, bool required, bool absolute)
@@ -48,7 +39,7 @@ std::string Asset::get(const std::string &text) const
} }
else else
{ {
std::cout << "Warning: file " << text << " not found" << std::endl; SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, "Warning: file %s not found", text.c_str());
return ""; return "";
} }
} }
@@ -58,12 +49,9 @@ bool Asset::check() const
{ {
bool success = true; bool success = true;
std::cout << "\n** CHECKING FILES" << std::endl; SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n** CHECKING FILES");
// std::cout << "Executable path is: " << executable_path_ << std::endl; // Comprueba la lista de ficheros clasificándolos por tipo
// std::cout << "Sample filepath: " << file_list_.back().file << std::endl;
// Comprueba la lista de ficheros clasificandolos por tipo
for (int type = 0; type < static_cast<int>(AssetType::MAX_ASSET_TYPE); ++type) for (int type = 0; type < static_cast<int>(AssetType::MAX_ASSET_TYPE); ++type)
{ {
// Comprueba si hay ficheros de ese tipo // Comprueba si hay ficheros de ese tipo
@@ -80,7 +68,7 @@ bool Asset::check() const
// Si hay ficheros de ese tipo, comprueba si existen // Si hay ficheros de ese tipo, comprueba si existen
if (any) if (any)
{ {
std::cout << "\n>> " << getTypeName(static_cast<AssetType>(type)).c_str() << " FILES" << std::endl; SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n>> %s FILES", getTypeName(static_cast<AssetType>(type)).c_str());
for (const auto &f : file_list_) for (const auto &f : file_list_)
{ {
@@ -90,12 +78,19 @@ bool Asset::check() const
} }
} }
if (success) if (success)
std::cout << " All files are OK." << std::endl; SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, " All files are OK.");
} }
} }
// Resultado // Resultado
std::cout << (success ? "\n** CHECKING FILES COMPLETED.\n" : "\n** CHECKING FILES FAILED.\n") << std::endl; if (success)
{
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "\n** CHECKING FILES COMPLETED.\n");
}
else
{
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "\n** CHECKING FILES FAILED.\n");
}
return success; return success;
} }
@@ -108,7 +103,9 @@ bool Asset::checkFile(const std::string &path) const
file.close(); file.close();
if (!success) if (!success)
printWithDots("Checking file : ", getFileName(path), "[ ERROR ]"); {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Checking file: %s [ ERROR ]", getFileName(path).c_str());
}
return success; return success;
} }
@@ -120,43 +117,24 @@ std::string Asset::getTypeName(AssetType type) const
{ {
case AssetType::BITMAP: case AssetType::BITMAP:
return "BITMAP"; return "BITMAP";
break;
case AssetType::MUSIC: case AssetType::MUSIC:
return "MUSIC"; return "MUSIC";
break;
case AssetType::SOUND: case AssetType::SOUND:
return "SOUND"; return "SOUND";
break;
case AssetType::FONT: case AssetType::FONT:
return "FONT"; return "FONT";
break;
case AssetType::LANG: case AssetType::LANG:
return "LANG"; return "LANG";
break;
case AssetType::DATA: case AssetType::DATA:
return "DATA"; return "DATA";
break;
case AssetType::ANIMATION: case AssetType::ANIMATION:
return "ANIMATION"; return "ANIMATION";
break;
case AssetType::PALETTE: case AssetType::PALETTE:
return "PALETTE"; return "PALETTE";
break;
case AssetType::ITEM: case AssetType::ITEM:
return "ITEM"; return "ITEM";
break;
default: default:
return "ERROR"; return "ERROR";
break;
} }
} }

View File

@@ -1,9 +1,12 @@
#pragma once #pragma once
#include <string> // Para string, basic_string #include <string>
#include <vector> // Para vector #include <vector>
#include <memory>
#include <iostream>
#include "utils.h" #include "utils.h"
// Tipos de recursos gestionados por Asset
enum class AssetType : int enum class AssetType : int
{ {
BITMAP, BITMAP,
@@ -18,62 +21,49 @@ enum class AssetType : int
MAX_ASSET_TYPE, MAX_ASSET_TYPE,
}; };
// Clase Asset // Clase Asset: gestor de recursos (singleton)
class Asset class Asset
{ {
private: public:
// [SINGLETON] Objeto asset privado para Don Melitón // --- Métodos de singleton ---
static Asset *asset_; static void init(const std::string &executable_path); // Inicializa el objeto Asset
static void destroy(); // Libera el objeto Asset
static Asset *get(); // Obtiene el puntero al objeto Asset
// Estructura para definir un item // --- Métodos para la gestión de recursos ---
void add(const std::string &file, AssetType type, bool required = true, bool absolute = false); // Añade un recurso a la lista
std::string get(const std::string &text) const; // Obtiene la ruta completa de un recurso a partir de su nombre
bool check() const; // Verifica la existencia de todos los recursos requeridos
std::vector<std::string> getListByType(AssetType type) const; // Devuelve una lista de archivos de un tipo concreto
private:
// --- Estructura interna para almacenar información de cada recurso ---
struct AssetItem struct AssetItem
{ {
std::string file; // Ruta del fichero desde la raíz del directorio std::string file; // Ruta del fichero desde la raíz del directorio
AssetType type; // Indica el tipo de recurso AssetType type; // Tipo de recurso
bool required; // Indica si es un fichero que debe de existir bool required; // Indica si el fichero es obligatorio
// Constructor
AssetItem(const std::string &filePath, AssetType assetType, bool isRequired) AssetItem(const std::string &filePath, AssetType assetType, bool isRequired)
: file(filePath), type(assetType), required(isRequired) {} : file(filePath), type(assetType), required(isRequired) {}
}; };
// Variables // --- Variables internas ---
int longest_name_ = 0; // Contiene la longitud del nombre de fichero mas largo int longest_name_ = 0; // Longitud del nombre s largo
std::vector<AssetItem> file_list_; // Listado con todas las rutas a los ficheros std::vector<AssetItem> file_list_; // Lista con todas las rutas de recursos
std::string executable_path_; // Ruta al ejecutable std::string executable_path_; // Ruta del ejecutable
// Comprueba que existe un fichero // --- Métodos internos ---
bool checkFile(const std::string &path) const; bool checkFile(const std::string &path) const; // Verifica si un archivo existe
std::string getTypeName(AssetType type) const; // Devuelve el nombre textual del tipo de recurso
// Devuelve el nombre del tipo de recurso // --- Patrón Singleton ---
std::string getTypeName(AssetType type) const;
// Constructor
explicit Asset(const std::string &executable_path) explicit Asset(const std::string &executable_path)
: executable_path_(getPath(executable_path)) {} : executable_path_(executable_path) {}
// Destructor
~Asset() = default; ~Asset() = default;
Asset(const Asset &) = delete;
Asset &operator=(const Asset &) = delete;
public: // --- Singleton ---
// [SINGLETON] Crearemos el objeto con esta función estática static Asset *instance_;
static void init(const std::string &executable_path);
// [SINGLETON] Destruiremos el objeto con esta función estática
static void destroy();
// [SINGLETON] Con este método obtenemos el objeto y podemos trabajar con él
static Asset *get();
// Añade un elemento a la lista
void add(const std::string &file, AssetType type, bool required = true, bool absolute = false);
// Devuelve la ruta completa a un fichero a partir de una cadena
std::string get(const std::string &text) const;
// Comprueba que existen todos los elementos
bool check() const;
// Devuelve la lista de recursos de un tipo
std::vector<std::string> getListByType(AssetType type) const;
}; };

117
source/audio.cpp Normal file
View File

@@ -0,0 +1,117 @@
#include "audio.h"
#include "jail_audio.h"
#include "options.h"
#include "resource.h"
#include <SDL3/SDL.h>
// Singleton
Audio *Audio::instance_ = nullptr;
// Inicializa la instancia única del singleton
void Audio::init() { Audio::instance_ = new Audio(); }
// Libera la instancia
void Audio::destroy() { delete Audio::instance_; }
// Obtiene la instancia
Audio *Audio::get() { return Audio::instance_; }
// Constructor
Audio::Audio()
{
// Inicializa SDL
if (!SDL_Init(SDL_INIT_AUDIO))
{
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_AUDIO could not initialize! SDL Error: %s", SDL_GetError());
}
else
{
SDL_LogInfo(SDL_LOG_CATEGORY_TEST, "\n** SDL_AUDIO: INITIALIZING\n");
JA_Init(48000, SDL_AUDIO_S16LE, 2);
enable(options.audio.enabled);
setMusicVolume(options.audio.music.volume);
setSoundVolume(options.audio.sound.volume);
SDL_LogInfo(SDL_LOG_CATEGORY_TEST, "** SDL_AUDIO: INITIALIZATION COMPLETE\n");
}
}
// Destructor
Audio::~Audio() { JA_Quit(); }
// Reproduce la música
void Audio::playMusic(const std::string &name, const int loop)
{
if (enabled_ && music_enabled_)
{
JA_PlayMusic(Resource::get()->getMusic(name), loop);
}
}
// Pausa la música
void Audio::pauseMusic()
{
if (enabled_ && music_enabled_)
{
JA_PauseMusic();
}
}
// Detiene la música
void Audio::stopMusic()
{
if (enabled_ && music_enabled_)
{
JA_StopMusic();
}
}
// Reproduce un sonido
void Audio::playSound(const std::string &name)
{
if (enabled_ && sound_enabled_)
{
JA_PlaySound(Resource::get()->getSound(name));
}
}
// Detiene todos los sonidos
void Audio::stopAllSounds()
{
if (enabled_ && sound_enabled_)
{
JA_StopChannel(-1);
}
}
// Realiza un fundido de salida de la música
void Audio::fadeOutMusic(int milliseconds)
{
if (enabled_ && music_enabled_)
{
JA_FadeOutMusic(milliseconds);
}
}
// Establece el volumen de los sonidos
void Audio::setSoundVolume(int volume)
{
if (enabled_ && sound_enabled_)
{
volume = std::clamp(volume, 0, 100);
const int COVERTED_VOLUME = static_cast<int>((volume / 100.0) * 128);
JA_SetSoundVolume(COVERTED_VOLUME);
}
}
// Establece el volumen de la música
void Audio::setMusicVolume(int volume)
{
if (enabled_ && music_enabled_)
{
volume = std::clamp(volume, 0, 100);
const int COVERTED_VOLUME = static_cast<int>((volume / 100.0) * 128);
JA_SetMusicVolume(COVERTED_VOLUME);
}
}

60
source/audio.h Normal file
View File

@@ -0,0 +1,60 @@
#pragma once
#include <string>
// Clase Audio: gestor de audio (singleton)
class Audio
{
public:
// --- Métodos de singleton ---
static void init(); // Inicializa el objeto Audio
static void destroy(); // Libera el objeto Audio
static Audio *get(); // Obtiene el puntero al objeto Audio
// --- Control de Música ---
void playMusic(const std::string &name, int loop = -1); // Reproducir música en bucle
void pauseMusic(); // Pausar reproducción de música
void stopMusic(); // Detener completamente la música
void fadeOutMusic(int milliseconds); // Fundido de salida de la música
// --- Control de Sonidos ---
void playSound(const std::string &name); // Reproducir sonido puntual
void stopAllSounds(); // Detener todos los sonidos
// --- Configuración General ---
void enable() { enabled_ = true; } // Habilitar audio
void disable() { enabled_ = false; } // Deshabilitar audio
void enable(bool value) { enabled_ = value; } // Establecer estado general
void toggleEnabled() { enabled_ = !enabled_; } // Alternar estado general
// --- Configuración de Sonidos ---
void enableSound() { sound_enabled_ = true; } // Habilitar sonidos
void disableSound() { sound_enabled_ = false; } // Deshabilitar sonidos
void enableSound(bool value) { sound_enabled_ = value; } // Establecer estado de sonidos
void toggleSound() { sound_enabled_ = !sound_enabled_; } // Alternar estado de sonidos
// --- Configuración de Música ---
void enableMusic() { music_enabled_ = true; } // Habilitar música
void disableMusic() { music_enabled_ = false; } // Deshabilitar música
void enableMusic(bool value) { music_enabled_ = value; } // Establecer estado de música
void toggleMusic() { music_enabled_ = !music_enabled_; } // Alternar estado de música
// --- Control de Volumen ---
void setSoundVolume(int volume); // Ajustar volumen de efectos
void setMusicVolume(int volume); // Ajustar volumen de música
private:
// --- Variables de Estado ---
bool enabled_ = true; // Estado general del audio
bool sound_enabled_ = true; // Estado de los efectos de sonido
bool music_enabled_ = true; // Estado de la música
// --- Patrón Singleton ---
Audio(); // Constructor privado
~Audio(); // Destructor privado
Audio(const Audio &) = delete; // Evitar copia
Audio &operator=(const Audio &) = delete; // Evitar asignación
// --- Singleton ---
static Audio *instance_;
};

View File

@@ -1,6 +1,7 @@
#define _USE_MATH_DEFINES
#include "background.h" #include "background.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND #include <SDL3/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888 #include <SDL3/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <algorithm> // Para clamp, max #include <algorithm> // Para clamp, max
#include <cmath> #include <cmath>
#include "moving_sprite.h" // Para MovingSprite #include "moving_sprite.h" // Para MovingSprite
@@ -22,7 +23,7 @@ Background::Background()
sun_texture_(Resource::get()->getTexture("game_sun.png")), sun_texture_(Resource::get()->getTexture("game_sun.png")),
moon_texture_(Resource::get()->getTexture("game_moon.png")), moon_texture_(Resource::get()->getTexture("game_moon.png")),
rect_({0, 0, gradients_texture_->getWidth() / 2, gradients_texture_->getHeight() / 2}), rect_(SDL_FRect{0, 0, static_cast<float>(gradients_texture_->getWidth() / 2), static_cast<float>(gradients_texture_->getHeight() / 2)}),
src_rect_({0, 0, 320, 240}), src_rect_({0, 0, 320, 240}),
dst_rect_({0, 0, 320, 240}), dst_rect_({0, 0, 320, 240}),
base_(rect_.h), base_(rect_.h),
@@ -42,25 +43,25 @@ Background::Background()
gradient_rect_[2] = {0, rect_.h, rect_.w, rect_.h}; gradient_rect_[2] = {0, rect_.h, rect_.w, rect_.h};
gradient_rect_[3] = {rect_.w, rect_.h, rect_.w, rect_.h}; gradient_rect_[3] = {rect_.w, rect_.h, rect_.w, rect_.h};
const int top_clouds_texture_height = top_clouds_texture_->getHeight() / 4; const float TOP_CLOUDS_TEXTURE_HEIGHT = top_clouds_texture_->getHeight() / 4;
const int bottom_clouds_texture_height = bottom_clouds_texture_->getHeight() / 4; const float BOTTOM_CLOUDS_TEXTURE_HEIGHT = bottom_clouds_texture_->getHeight() / 4;
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
{ {
top_clouds_rect_[i] = {0, i * top_clouds_texture_height, top_clouds_texture_->getWidth(), top_clouds_texture_height}; top_clouds_rect_[i] = {0, i * TOP_CLOUDS_TEXTURE_HEIGHT, static_cast<float>(top_clouds_texture_->getWidth()), TOP_CLOUDS_TEXTURE_HEIGHT};
bottom_clouds_rect_[i] = {0, i * bottom_clouds_texture_height, bottom_clouds_texture_->getWidth(), bottom_clouds_texture_height}; bottom_clouds_rect_[i] = {0, i * BOTTOM_CLOUDS_TEXTURE_HEIGHT, static_cast<float>(bottom_clouds_texture_->getWidth()), BOTTOM_CLOUDS_TEXTURE_HEIGHT};
} }
} }
// Crea los sprites // Crea los sprites
{ {
const int top_clouds_y = base_ - 165; const float TOP_CLOUDS_Y = base_ - 165;
const int bottom_clouds_y = base_ - 101; const float BOTTOM_CLOUDS_Y = base_ - 101;
top_clouds_sprite_a_ = std::make_unique<MovingSprite>(top_clouds_texture_, (SDL_Rect){0, top_clouds_y, rect_.w, top_clouds_texture_->getHeight()}); top_clouds_sprite_a_ = std::make_unique<MovingSprite>(top_clouds_texture_, (SDL_FRect){0, TOP_CLOUDS_Y, rect_.w, static_cast<float>(top_clouds_texture_->getHeight())});
top_clouds_sprite_b_ = std::make_unique<MovingSprite>(top_clouds_texture_, (SDL_Rect){rect_.w, top_clouds_y, rect_.w, top_clouds_texture_->getHeight()}); top_clouds_sprite_b_ = std::make_unique<MovingSprite>(top_clouds_texture_, (SDL_FRect){rect_.w, TOP_CLOUDS_Y, rect_.w, static_cast<float>(top_clouds_texture_->getHeight())});
bottom_clouds_sprite_a_ = std::make_unique<MovingSprite>(bottom_clouds_texture_, (SDL_Rect){0, bottom_clouds_y, rect_.w, bottom_clouds_texture_->getHeight()}); bottom_clouds_sprite_a_ = std::make_unique<MovingSprite>(bottom_clouds_texture_, (SDL_FRect){0, BOTTOM_CLOUDS_Y, rect_.w, static_cast<float>(bottom_clouds_texture_->getHeight())});
bottom_clouds_sprite_b_ = std::make_unique<MovingSprite>(bottom_clouds_texture_, (SDL_Rect){rect_.w, bottom_clouds_y, rect_.w, bottom_clouds_texture_->getHeight()}); bottom_clouds_sprite_b_ = std::make_unique<MovingSprite>(bottom_clouds_texture_, (SDL_FRect){rect_.w, BOTTOM_CLOUDS_Y, rect_.w, static_cast<float>(bottom_clouds_texture_->getHeight())});
buildings_sprite_ = std::make_unique<Sprite>(buildings_texture_); buildings_sprite_ = std::make_unique<Sprite>(buildings_texture_);
gradient_sprite_ = std::make_unique<Sprite>(gradients_texture_, 0, 0, rect_.w, rect_.h); gradient_sprite_ = std::make_unique<Sprite>(gradients_texture_, 0, 0, rect_.w, rect_.h);
@@ -220,10 +221,10 @@ void Background::fillCanvas()
void Background::render() void Background::render()
{ {
// Fondo // Fondo
SDL_RenderCopy(renderer_, canvas_, &src_rect_, &dst_rect_); SDL_RenderTexture(renderer_, canvas_, &src_rect_, &dst_rect_);
// Atenuación // Atenuación
SDL_RenderCopy(renderer_, color_texture_, &src_rect_, &dst_rect_); SDL_RenderTexture(renderer_, color_texture_, &src_rect_, &dst_rect_);
} }
// Ajusta el valor de la variable // Ajusta el valor de la variable
@@ -245,7 +246,7 @@ void Background::setTransition(float value)
} }
// Establece la posición del objeto // Establece la posición del objeto
void Background::setPos(SDL_Rect pos) void Background::setPos(SDL_FRect pos)
{ {
dst_rect_ = pos; dst_rect_ = pos;
@@ -336,21 +337,21 @@ void Background::updateClouds()
// Precalcula el vector con el recorrido del sol // Precalcula el vector con el recorrido del sol
void Background::createSunPath() void Background::createSunPath()
{ {
constexpr int CENTER_X = 170; constexpr float CENTER_X = 170;
const int center_y = base_ - 80; const float center_y = base_ - 80;
constexpr int RADIUS = 120; constexpr float RADIUS = 120;
// Generar puntos de la curva desde 90 a 180 grados // Generar puntos de la curva desde 90 a 180 grados
for (double theta = M_PI / 2; theta <= M_PI; theta += 0.01) for (double theta = M_PI / 2; theta <= M_PI; theta += 0.01)
{ {
int x = CENTER_X + static_cast<int>(RADIUS * cos(theta)); float x = CENTER_X + (RADIUS * cos(theta));
int y = center_y - static_cast<int>(RADIUS * sin(theta)); float y = center_y - (RADIUS * sin(theta));
sun_path_.push_back({x, y}); sun_path_.push_back({x, y});
} }
// Agregar puntos en línea recta después de la curva // Agregar puntos en línea recta después de la curva
constexpr int EXTRA_PIXELS = 40; constexpr int EXTRA_PIXELS = 40;
SDL_Point last_point = sun_path_.back(); SDL_FPoint last_point = sun_path_.back();
for (int i = 1; i <= EXTRA_PIXELS; ++i) for (int i = 1; i <= EXTRA_PIXELS; ++i)
{ {
sun_path_.push_back({last_point.x, last_point.y + i}); sun_path_.push_back({last_point.x, last_point.y + i});
@@ -360,15 +361,15 @@ void Background::createSunPath()
// Precalcula el vector con el recorrido de la luna // Precalcula el vector con el recorrido de la luna
void Background::createMoonPath() void Background::createMoonPath()
{ {
constexpr int CENTER_X = 100; constexpr float CENTER_X = 100;
const int center_y = base_ - 50; const float center_y = base_ - 50;
constexpr int RADIUS = 140; constexpr float RADIUS = 140;
// Generar puntos de la curva desde 0 a 90 grados // Generar puntos de la curva desde 0 a 90 grados
for (double theta = 0; theta <= M_PI / 2; theta += 0.01) for (double theta = 0; theta <= M_PI / 2; theta += 0.01)
{ {
int x = CENTER_X + static_cast<int>(RADIUS * cos(theta)); float x = CENTER_X + (RADIUS * cos(theta));
int y = center_y - static_cast<int>(RADIUS * sin(theta)); float y = center_y - (RADIUS * sin(theta));
moon_path_.push_back({x, y}); moon_path_.push_back({x, y});
} }
} }

View File

@@ -1,154 +1,113 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect, SDL_Point #include <SDL3/SDL_rect.h> // Para SDL_FRect, SDL_FPoint
#include <SDL2/SDL_render.h> // Para SDL_Texture, SDL_Renderer #include <SDL3/SDL_render.h> // Para SDL_Texture, SDL_Renderer
#include <stddef.h> // Para size_t #include <stddef.h> // Para size_t
#include <memory> // Para unique_ptr, shared_ptr #include <memory> // Para unique_ptr, shared_ptr
#include <vector> // Para vector #include <vector> // Para vector
#include "utils.h" // Para Color #include "utils.h" // Para Color
class MovingSprite; // lines 7-7
class Sprite; // lines 8-8 class MovingSprite;
class Texture; // lines 9-9 class Sprite;
class Texture;
/* /*
Esta clase es la encargada de dibujar el fondo que aparece durante la sección Esta clase gestiona el fondo que aparece en la sección jugable.
jugable.
Utiliza una textura donde compone la imagen y luego tiene una textura superior Usa una textura compuesta y una capa superior con un color sólido cuya opacidad es ajustable.
rellena de un color sólido cuya opacidad se puede modificar. Su área total está definida por "rect", pero solo se pinta la región "srcRect" en la pantalla en "dstRect".
El objeto tiene un tamaño total definido en la variable "rect". En principio este Métodos clave:
tamaño coincide con el tamaño de la ventana o resolución del juego, pero se pinta - setCloudsSpeed(float value) -> Define la velocidad de las nubes
solo el rectangulo definido en srcRect en la posición de la pantalla definida en - setGradientNumber(int value) -> Ajusta el índice del color de cielo
dstRect. - setTransition(float value) -> Configura la transición entre texturas
- setColor(Color color) -> Aplica un color de atenuación
Ambos rectangulos han de coincidir en tamaño y por definición, el punto comun es el inferior derecho el rectangulo. - setAlpha(int alpha) -> Ajusta la transparencia de la capa de atenuación
Utiliza varios métodos para definir su comportamiento:
- setCloudsSpeed(float value)
Velocidad a la que se desplazan las nubes cada frame
- setGradientNumber(int value)
Escoge el índice de la textura de fondo a usar (el color del cielo)
- setTransition(float value)
Porcentaje (entre 0.0f (textura actual) y 1.0f (textura siguiente)) para mostrar entre la textura de fondo actual y la siguiente
- setColor(Color color)
Establece el color de la textura de superposición
- setAlpha(int alpha)
Establece la transparencia de la textura de superposición
*/ */
// Clase Background
class Background class Background
{ {
public:
// Constructor y Destructor
Background();
~Background();
// Actualización y renderizado
void update(); // Actualiza la lógica del objeto
void render(); // Dibuja el objeto
// Configuración de posición
void setPos(SDL_FRect pos); // Establece la posición del objeto
// Configuración de animaciones y efectos
void setCloudsSpeed(float value); // Ajusta la velocidad de desplazamiento de las nubes
void setGradientNumber(int value); // Establece el degradado de fondo a usar
void setTransition(float value); // Ajusta la transición entre texturas de fondo
// Configuración de efectos visuales
void setColor(Color color); // Establece el color de atenuación
void setAlpha(int alpha); // Ajusta la transparencia del fondo
// Configuración del sol y la luna
void setSunProgression(float progress); // Establece la posición del sol
void setMoonProgression(float progress); // Establece la posición de la luna
private: private:
// Objetos y punteros // Objetos y punteros
SDL_Renderer *renderer_; // El renderizador de la ventana SDL_Renderer *renderer_; // Renderizador de la ventana
std::shared_ptr<Texture> buildings_texture_; // Textura con los edificios de fondo // Texturas
std::shared_ptr<Texture> top_clouds_texture_; // Textura con las nubes de fondo std::shared_ptr<Texture> buildings_texture_;
std::shared_ptr<Texture> bottom_clouds_texture_; // Textura con las nubes de fondo std::shared_ptr<Texture> top_clouds_texture_;
std::shared_ptr<Texture> grass_texture_; // Textura con la hierba del suelo std::shared_ptr<Texture> bottom_clouds_texture_;
std::shared_ptr<Texture> gradients_texture_; // Textura con los diferentes colores de fondo del juego std::shared_ptr<Texture> grass_texture_;
std::shared_ptr<Texture> sun_texture_; // Textura con el sol std::shared_ptr<Texture> gradients_texture_;
std::shared_ptr<Texture> moon_texture_; // Textura con la luna std::shared_ptr<Texture> sun_texture_;
std::shared_ptr<Texture> moon_texture_;
std::unique_ptr<MovingSprite> top_clouds_sprite_a_; // Sprite para las nubes superiores // Sprites
std::unique_ptr<MovingSprite> top_clouds_sprite_b_; // Sprite para las nubes superiores std::unique_ptr<MovingSprite> top_clouds_sprite_a_;
std::unique_ptr<MovingSprite> bottom_clouds_sprite_a_; // Sprite para las nubes inferiores std::unique_ptr<MovingSprite> top_clouds_sprite_b_;
std::unique_ptr<MovingSprite> bottom_clouds_sprite_b_; // Sprite para las nubes inferiores std::unique_ptr<MovingSprite> bottom_clouds_sprite_a_;
std::unique_ptr<MovingSprite> bottom_clouds_sprite_b_;
std::unique_ptr<Sprite> buildings_sprite_; // Sprite con los edificios de fondo std::unique_ptr<Sprite> buildings_sprite_;
std::unique_ptr<Sprite> gradient_sprite_; // Sprite con los graficos del degradado de color de fondo std::unique_ptr<Sprite> gradient_sprite_;
std::unique_ptr<Sprite> grass_sprite_; // Sprite para la hierba std::unique_ptr<Sprite> grass_sprite_;
std::unique_ptr<Sprite> sun_sprite_; // Sprite para el sol std::unique_ptr<Sprite> sun_sprite_;
std::unique_ptr<Sprite> moon_sprite_; // Sprite para la luna std::unique_ptr<Sprite> moon_sprite_;
// Buffers de renderizado
SDL_Texture *canvas_; // Textura para componer el fondo SDL_Texture *canvas_; // Textura para componer el fondo
SDL_Texture *color_texture_; // Textura para atenuar el fondo SDL_Texture *color_texture_; // Textura para atenuar el fondo
// Variables // Variables de control
SDL_Rect gradient_rect_[4]; // Vector con las coordenadas de los 4 degradados para el cielo SDL_FRect gradient_rect_[4];
SDL_Rect top_clouds_rect_[4]; // Vector con las coordenadas de los 4 nubes de arriba SDL_FRect top_clouds_rect_[4];
SDL_Rect bottom_clouds_rect_[4]; // Vector con las coordenadas de los 4 nubes de abajo SDL_FRect bottom_clouds_rect_[4];
int gradient_number_ = 0; // Indica el número de degradado de fondo que se va a dibujar int gradient_number_ = 0;
int alpha_ = 0; // Transparencia entre los dos degradados int alpha_ = 0;
float clouds_speed_ = 0; // Velocidad a la que se desplazan las nubes float clouds_speed_ = 0;
float transition_ = 0; // Nivel de transición del fondo 0..1 float transition_ = 0;
int counter_ = 0; // Contador interno int counter_ = 0;
SDL_Rect rect_; // Tamaño del objeto fondo SDL_FRect rect_;
SDL_Rect src_rect_; // Parte del objeto fondo que se va a dibujará en pantalla SDL_FRect src_rect_;
SDL_Rect dst_rect_; // Posición donde dibujar la parte del objeto fondo que se dibujará en pantalla SDL_FRect dst_rect_;
int base_; // Linea de fondo coincidente con el area inferior de la zona de juego int base_;
Color attenuate_color_; // Color para atenuar el fondo Color attenuate_color_;
int alpha_color_text_; // Alpha para atenuar el fondo int alpha_color_text_;
int alpha_color_text_temp_; // Valor temporal para hacer la transición de alpha int alpha_color_text_temp_;
std::vector<SDL_Point> sun_path_; // Vector con el recorrido del sol std::vector<SDL_FPoint> sun_path_;
std::vector<SDL_Point> moon_path_; // Vector con el recorrido de la luna std::vector<SDL_FPoint> moon_path_;
size_t sun_index_ = 0; // Posición del vector del recorrido del sol size_t sun_index_ = 0;
size_t moon_index_ = 0; // Posición del vector del recorrido de la luna size_t moon_index_ = 0;
// Dibuja el gradiente de fondo // Métodos internos
void renderGradient(); void renderGradient(); // Dibuja el gradiente de fondo
void renderTopClouds(); // Dibuja las nubes superiores
// Dibuja las nubes de arriba void renderBottomClouds(); // Dibuja las nubes inferiores
void renderTopClouds(); void fillCanvas(); // Compone todos los elementos en la textura
void updateAlphaColorTexture(); // Actualiza el alpha de la textura de atenuación
// Dibuja las nubes de abajo void updateClouds(); // Actualiza el movimiento de las nubes
void renderBottomClouds(); void createSunPath(); // Precalcula el recorrido del sol
void createMoonPath(); // Precalcula el recorrido de la luna
// Compone todos los elementos del fondo en la textura };
void fillCanvas();
// Actualiza el valor de alpha
void updateAlphaColorTexture();
// Actualiza las nubes
void updateClouds();
// Precalcula el vector con el recorrido del sol
void createSunPath();
// Precalcula el vector con el recorrido de la luna
void createMoonPath();
public:
// Constructor
Background();
// Destructor
~Background();
// Actualiza la lógica del objeto
void update();
// Dibuja el objeto
void render();
// Establece la posición del objeto
void setPos(SDL_Rect pos);
// Ajusta el valor de la variable
void setCloudsSpeed(float value);
// Ajusta el valor de la variable
void setGradientNumber(int value);
// Ajusta el valor de la variable
void setTransition(float value);
// Establece el color de atenuación
void setColor(Color color);
// Establece la transparencia de la atenuación
void setAlpha(int alpha);
// Establece la posición del sol
void setSunProgression(float progress);
// Establece la posición de la luna
void setMoonProgression(float progress);
};

View File

@@ -6,10 +6,10 @@
#include "sprite.h" // Para Sprite #include "sprite.h" // Para Sprite
#include "texture.h" // Para Texture #include "texture.h" // Para Texture
#include "resource.h" #include "resource.h"
#include "jail_audio.h" #include "audio.h"
// Constructor // Constructor
Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel_x, float speed, Uint16 creation_timer, SDL_Rect play_area, std::shared_ptr<Texture> texture, const std::vector<std::string> &animation) Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel_x, float speed, Uint16 creation_timer, SDL_FRect play_area, std::shared_ptr<Texture> texture, const std::vector<std::string> &animation)
: sprite_(std::make_unique<AnimatedSprite>(texture, animation)), : sprite_(std::make_unique<AnimatedSprite>(texture, animation)),
x_(x), x_(x),
y_(y), y_(y),
@@ -117,7 +117,7 @@ void Balloon::render()
// Renderiza la estrella // Renderiza la estrella
if (!invulnerable_) if (!invulnerable_)
{ {
SDL_Point p = {24, 24}; SDL_FPoint p = {24.0f, 24.0f};
sprite_->setRotatingCenter(p); sprite_->setRotatingCenter(p);
sprite_->render(); sprite_->render();
} }
@@ -414,6 +414,6 @@ void Balloon::playSound()
{ {
if (sound_enabled_) if (sound_enabled_)
{ {
JA_PlaySound(Resource::get()->getSound(sound_)); Audio::get()->playSound(sound_);
} }
} }

View File

@@ -1,25 +1,24 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect #include <SDL3/SDL_rect.h> // Para SDL_FRect
#include <SDL2/SDL_stdinc.h> // Para Uint8, Uint16, Uint32 #include <SDL3/SDL_stdinc.h> // Para Uint8, Uint16, Uint32
#include <memory> // Para shared_ptr, unique_ptr #include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para string #include <string> // Para string
#include <vector> // Para vector #include <vector> // Para vector
#include "animated_sprite.h" // Para AnimatedSprite #include "animated_sprite.h" // Para AnimatedSprite
#include "utils.h" // Para Circle #include "utils.h" // Para Circle
class Texture; // lines 9-9
// Cantidad de elementos del vector con los valores de la deformación del globo al rebotar class Texture;
constexpr int MAX_BOUNCE = 10;
// --- Constantes relacionadas con globos ---
constexpr int MAX_BOUNCE = 10; // Cantidad de elementos del vector de deformación
// Puntos de globo
constexpr int BALLOON_SCORE[] = {50, 100, 200, 400}; constexpr int BALLOON_SCORE[] = {50, 100, 200, 400};
constexpr int BALLOON_POWER[] = {1, 3, 7, 15}; constexpr int BALLOON_POWER[] = {1, 3, 7, 15};
constexpr int BALLOON_MENACE[] = {1, 2, 4, 8}; constexpr int BALLOON_MENACE[] = {1, 2, 4, 8};
constexpr int BALLOON_SIZE[] = {10, 16, 26, 48, 49}; constexpr int BALLOON_SIZE[] = {10, 16, 26, 48, 49};
const std::string BALLOON_SOUND[] = {"bubble1.wav", "bubble2.wav", "bubble3.wav", "bubble4.wav"}; const std::string BALLOON_SOUND[] = {"bubble1.wav", "bubble2.wav", "bubble3.wav", "bubble4.wav"};
// Tamaños de globo
enum class BalloonSize : Uint8 enum class BalloonSize : Uint8
{ {
SIZE1 = 0, SIZE1 = 0,
@@ -28,7 +27,6 @@ enum class BalloonSize : Uint8
SIZE4 = 3, SIZE4 = 3,
}; };
// Clases de globo
enum class BalloonType : Uint8 enum class BalloonType : Uint8
{ {
BALLOON = 0, BALLOON = 0,
@@ -36,116 +34,23 @@ enum class BalloonType : Uint8
POWERBALL = 2, POWERBALL = 2,
}; };
// Velocidad del globo
constexpr float BALLOON_VELX_POSITIVE = 0.7f; constexpr float BALLOON_VELX_POSITIVE = 0.7f;
constexpr float BALLOON_VELX_NEGATIVE = -0.7f; constexpr float BALLOON_VELX_NEGATIVE = -0.7f;
// Indice para las animaciones de los globos
constexpr int BALLOON_MOVING_ANIMATION = 0; constexpr int BALLOON_MOVING_ANIMATION = 0;
constexpr int BALLOON_POP_ANIMATION = 1; constexpr int BALLOON_POP_ANIMATION = 1;
constexpr int BALLOON_BORN_ANIMATION = 2; constexpr int BALLOON_BORN_ANIMATION = 2;
// Velocidades a las que se mueven los globos
constexpr float BALLOON_SPEED[] = {0.60f, 0.70f, 0.80f, 0.90f, 1.00f}; constexpr float BALLOON_SPEED[] = {0.60f, 0.70f, 0.80f, 0.90f, 1.00f};
// PowerBall
constexpr int POWERBALL_SCREENPOWER_MINIMUM = 10; constexpr int POWERBALL_SCREENPOWER_MINIMUM = 10;
constexpr int POWERBALL_COUNTER = 8; constexpr int POWERBALL_COUNTER = 8;
// Clase Balloon // --- Clase Balloon ---
class Balloon class Balloon
{ {
private:
// Estructura para el efecto de los rebotes en los globos
struct Bouncing
{
bool enabled = false; // Si el efecto está activo
Uint8 counter = 0; // Contador para el efecto
Uint8 speed = 2; // Velocidad a la que transcurre el efecto
float zoomW = 1.0f; // Zoom aplicado a la anchura
float zoomH = 1.0f; // Zoom aplicado a la altura
float despX = 0.0f; // Desplazamiento de pixeles en el eje X antes de pintar el objeto con zoom
float despY = 0.0f; // Desplazamiento de pixeles en el eje Y antes de pintar el objeto con zoom
float w[MAX_BOUNCE] = {1.10f, 1.05f, 1.00f, 0.95f, 0.90f, 0.95f, 1.00f, 1.02f, 1.05f, 1.02f}; // Vector con los valores de zoom para el ancho del globo
float h[MAX_BOUNCE] = {0.90f, 0.95f, 1.00f, 1.05f, 1.10f, 1.05f, 1.00f, 0.98f, 0.95f, 0.98f}; // Vector con los valores de zoom para el alto del globo
// Constructor por defecto
Bouncing() = default;
// Método reset
void reset()
{
counter = 0;
zoomW = 1.0f;
zoomH = 1.0f;
despX = 0.0f;
despY = 0.0f;
}
} bouncing_;
// Objetos y punteros
std::unique_ptr<AnimatedSprite> sprite_; // Sprite del objeto globo
// Variables
float x_; // Posición en el eje X
float y_; // Posición en el eje Y
Uint8 w_; // Ancho
Uint8 h_; // Alto
float vx_; // Velocidad en el eje X. Cantidad de pixeles a desplazarse
float vy_; // Velocidad en el eje Y. Cantidad de pixeles a desplazarse
float gravity_; // Aceleración en el eje Y. Modifica la velocidad
float default_vy_; // Velocidad inicial que tienen al rebotar contra el suelo
float max_vy_; // Máxima velocidad que puede alcanzar el objeto en el eje Y
bool being_created_; // Indica si el globo se está creando
bool enabled_ = true; // Indica si el globo esta activo
bool invulnerable_; // Indica si el globo es invulnerable
bool stopped_; // Indica si el globo está parado
bool use_reversed_colors_ = false; // Indica si se ha de usar el color secundario del globo como color principal
Circle collider_; // Circulo de colisión del objeto
Uint16 creation_counter_; // Temporizador para controlar el estado "creandose"
Uint16 creation_counter_ini_; // Valor inicial para el temporizador para controlar el estado "creandose"
Uint16 score_; // Puntos que da el globo al ser destruido
BalloonType type_; // Clase de globo
BalloonSize size_; // Tamaño del globo
Uint8 menace_; // Cantidad de amenaza que genera el globo
Uint32 counter_ = 0; // Contador interno
float travel_y_ = 1.0f; // Distancia que ha de recorrer el globo en el eje Y antes de que se le aplique la gravedad
float speed_; // Velocidad a la que se mueven los globos
Uint8 power_; // Cantidad de poder que alberga el globo
SDL_Rect play_area_; // Zona por donde se puede mover el globo
std::string sound_; // Archivo de sonido que hace el globo al rebotar
bool sound_enabled_ = false; // Indica si ha de sonar el sonido del globo al rebotar
// Alinea el circulo de colisión con la posición del objeto globo
void shiftColliders();
// Alinea el sprite con la posición del objeto globo
void shiftSprite();
// Establece el nivel de zoom del sprite
void zoomSprite();
// Activa el efecto
void enableBounce();
// Detiene el efecto
void disableBounce();
// Aplica el efecto
void updateBounce();
// Actualiza los estados del globo
void updateState();
// Establece la animación correspondiente
void setAnimation();
// Reproduce el sonido al rebotar
void playSound();
public: public:
// Constructor // --- Constructores y destructor ---
Balloon( Balloon(
float x, float x,
float y, float y,
@@ -154,38 +59,24 @@ public:
float vel_x, float vel_x,
float speed, float speed,
Uint16 creation_timer, Uint16 creation_timer,
SDL_Rect play_area, SDL_FRect play_area,
std::shared_ptr<Texture> texture, std::shared_ptr<Texture> texture,
const std::vector<std::string> &animation); const std::vector<std::string> &animation);
// Destructor
~Balloon() = default; ~Balloon() = default;
// Centra el globo en la posición X // --- Métodos principales ---
void alignTo(int x); void alignTo(int x); // Centra el globo en la posición X
void render(); // Pinta el globo en la pantalla
void move(); // Actualiza la posición y estados del globo
void update(); // Actualiza el globo (posición, animación, contadores)
void stop(); // Detiene el globo
void start(); // Pone el globo en movimiento
// Pinta el globo en la pantalla // --- Métodos de color ---
void render(); void useReverseColor(); // Pone el color alternativo en el globo
void useNormalColor(); // Pone el color normal en el globo
// Actualiza la posición y estados del globo // --- Getters ---
void move();
// Actualiza al globo a su posicion, animación y controla los contadores
void update();
// Detiene el globo
void stop();
// Pone el globo en movimiento
void start();
// Pone el color alternativo en el globo
void useReverseColor();
// Pone el color normal en el globo
void useNormalColor();
// Getters
float getPosX() const { return x_; } float getPosX() const { return x_; }
float getPosY() const { return y_; } float getPosY() const { return y_; }
int getWidth() const { return w_; } int getWidth() const { return w_; }
@@ -204,10 +95,80 @@ public:
bool isUsingReversedColor() { return use_reversed_colors_; } bool isUsingReversedColor() { return use_reversed_colors_; }
bool canBePopped() const { return !isBeingCreated(); } bool canBePopped() const { return !isBeingCreated(); }
// Setters // --- Setters ---
void setVelY(float vel_y) { vy_ = vel_y; } void setVelY(float vel_y) { vy_ = vel_y; }
void setSpeed(float speed) { speed_ = speed; } void setSpeed(float speed) { speed_ = speed; }
void setInvulnerable(bool value) { invulnerable_ = value; } void setInvulnerable(bool value) { invulnerable_ = value; }
void setSound(bool value) { sound_enabled_ = value; } void setSound(bool value) { sound_enabled_ = value; }
void disable() { enabled_ = false; } void disable() { enabled_ = false; }
private:
// --- Estructura para el efecto de rebote ---
struct Bouncing
{
bool enabled = false; // Si el efecto está activo
Uint8 counter = 0; // Contador para el efecto
Uint8 speed = 2; // Velocidad del efecto
float zoomW = 1.0f; // Zoom en anchura
float zoomH = 1.0f; // Zoom en altura
float despX = 0.0f; // Desplazamiento X antes de pintar
float despY = 0.0f; // Desplazamiento Y antes de pintar
float w[MAX_BOUNCE] = {1.10f, 1.05f, 1.00f, 0.95f, 0.90f, 0.95f, 1.00f, 1.02f, 1.05f, 1.02f}; // Zoom ancho
float h[MAX_BOUNCE] = {0.90f, 0.95f, 1.00f, 1.05f, 1.10f, 1.05f, 1.00f, 0.98f, 0.95f, 0.98f}; // Zoom alto
Bouncing() = default;
void reset()
{
counter = 0;
zoomW = 1.0f;
zoomH = 1.0f;
despX = 0.0f;
despY = 0.0f;
}
} bouncing_;
// --- Objetos y punteros ---
std::unique_ptr<AnimatedSprite> sprite_; // Sprite del objeto globo
// --- Variables de estado y físicas ---
float x_; // Posición X
float y_; // Posición Y
float w_; // Ancho
float h_; // Alto
float vx_; // Velocidad X
float vy_; // Velocidad Y
float gravity_; // Aceleración en Y
float default_vy_; // Velocidad inicial al rebotar
float max_vy_; // Máxima velocidad en Y
bool being_created_; // Si el globo se está creando
bool enabled_ = true; // Si el globo está activo
bool invulnerable_; // Si el globo es invulnerable
bool stopped_; // Si el globo está parado
bool use_reversed_colors_ = false; // Si se usa el color alternativo
Circle collider_; // Círculo de colisión
Uint16 creation_counter_; // Temporizador de creación
Uint16 creation_counter_ini_; // Valor inicial del temporizador de creación
Uint16 score_; // Puntos al destruir el globo
BalloonType type_; // Tipo de globo
BalloonSize size_; // Tamaño de globo
Uint8 menace_; // Amenaza que genera el globo
Uint32 counter_ = 0; // Contador interno
float travel_y_ = 1.0f; // Distancia a recorrer en Y antes de aplicar gravedad
float speed_; // Velocidad del globo
Uint8 power_; // Poder que alberga el globo
SDL_FRect play_area_; // Zona de movimiento del globo
std::string sound_; // Archivo de sonido al rebotar
bool sound_enabled_ = false; // Si debe sonar el globo al rebotar
// --- Métodos internos ---
void shiftColliders(); // Alinea el círculo de colisión
void shiftSprite(); // Alinea el sprite
void zoomSprite(); // Establece el nivel de zoom del sprite
void enableBounce(); // Activa el efecto de rebote
void disableBounce(); // Detiene el efecto de rebote
void updateBounce(); // Aplica el efecto de rebote
void updateState(); // Actualiza los estados del globo
void setAnimation(); // Establece la animación correspondiente
void playSound(); // Reproduce el sonido al rebotar
}; };

View File

@@ -3,11 +3,13 @@
#include "balloon.h" // Para BALLOON_VELX_NEGATIVE, BALLOON_VELX_POSITIVE #include "balloon.h" // Para BALLOON_VELX_NEGATIVE, BALLOON_VELX_POSITIVE
#include <vector> #include <vector>
// --- Constantes de configuración ---
constexpr int NUMBER_OF_BALLOON_FORMATIONS = 100; constexpr int NUMBER_OF_BALLOON_FORMATIONS = 100;
constexpr int MAX_NUMBER_OF_BALLOONS_IN_A_FORMATION = 50; constexpr int MAX_NUMBER_OF_BALLOONS_IN_A_FORMATION = 50;
constexpr int NUMBER_OF_SETS_PER_POOL = 10; constexpr int NUMBER_OF_SETS_PER_POOL = 10;
constexpr int NUMBER_OF_STAGES = 10; constexpr int NUMBER_OF_STAGES = 10;
// --- Estructuras de datos ---
struct BalloonFormationParams struct BalloonFormationParams
{ {
int x = 0; // Posición en el eje X donde crear el globo int x = 0; // Posición en el eje X donde crear el globo
@@ -30,41 +32,39 @@ struct BalloonFormationUnit
int number_of_balloons; // Cantidad de globos que forman la formación int number_of_balloons; // Cantidad de globos que forman la formación
std::vector<BalloonFormationParams> init; // Vector con todas las inicializaciones de los globos de la formación std::vector<BalloonFormationParams> init; // Vector con todas las inicializaciones de los globos de la formación
// Constructor // Constructor con parámetros
BalloonFormationUnit(int num_balloons, const std::vector<BalloonFormationParams> &init_params) BalloonFormationUnit(int num_balloons, const std::vector<BalloonFormationParams> &init_params)
: number_of_balloons(num_balloons), init(init_params) {} : number_of_balloons(num_balloons), init(init_params) {}
// Default constructor // Constructor por defecto
BalloonFormationUnit() : number_of_balloons(0), init() {} BalloonFormationUnit() : number_of_balloons(0), init() {}
}; };
using BalloonFormationPool = std::vector<const BalloonFormationUnit *>; using BalloonFormationPool = std::vector<const BalloonFormationUnit *>;
// --- Clase BalloonFormations ---
class BalloonFormations class BalloonFormations
{ {
private:
std::vector<BalloonFormationUnit> balloon_formation_; // Vector con todas las formaciones enemigas
std::vector<BalloonFormationPool> balloon_formation_pool_; // Variable con los diferentes conjuntos de formaciones enemigas
// Inicializa las formaciones enemigas
void initBalloonFormations();
// Inicializa los conjuntos de formaciones
void initBalloonFormationPools();
public: public:
// Constructor // --- Constructor y destructor ---
BalloonFormations() BalloonFormations()
{ {
initBalloonFormations(); initBalloonFormations();
initBalloonFormationPools(); initBalloonFormationPools();
} }
// Destructor
~BalloonFormations() = default; ~BalloonFormations() = default;
// Getters // --- Getters ---
const BalloonFormationPool &getPool(int pool) { return balloon_formation_pool_.at(pool); } const BalloonFormationPool &getPool(int pool) { return balloon_formation_pool_.at(pool); }
const BalloonFormationUnit &getSet(int pool, int set) { return *balloon_formation_pool_.at(pool).at(set); } const BalloonFormationUnit &getSet(int pool, int set) { return *balloon_formation_pool_.at(pool).at(set); }
const BalloonFormationUnit &getSet(int set) const { return balloon_formation_.at(set); } const BalloonFormationUnit &getSet(int set) const { return balloon_formation_.at(set); }
private:
// --- Datos ---
std::vector<BalloonFormationUnit> balloon_formation_; // Vector con todas las formaciones enemigas
std::vector<BalloonFormationPool> balloon_formation_pool_; // Conjuntos de formaciones enemigas
// --- Métodos internos de inicialización ---
void initBalloonFormations();
void initBalloonFormationPools();
}; };

View File

@@ -5,7 +5,7 @@
#include "balloon.h" // Para Balloon, BALLOON_SCORE, BALLOON_VELX... #include "balloon.h" // Para Balloon, BALLOON_SCORE, BALLOON_VELX...
#include "balloon_formations.h" // Para BalloonFormationParams, BalloonForma... #include "balloon_formations.h" // Para BalloonFormationParams, BalloonForma...
#include "explosions.h" // Para Explosions #include "explosions.h" // Para Explosions
#include "jail_audio.h" // Para JA_PlaySound #include "audio.h" // Para JA_PlaySound
#include "param.h" // Para Param, ParamGame, param #include "param.h" // Para Param, ParamGame, param
#include "resource.h" // Para Resource #include "resource.h" // Para Resource
#include "screen.h" // Para Screen #include "screen.h" // Para Screen
@@ -216,19 +216,19 @@ void BalloonManager::createPowerBall()
{ {
if (can_deploy_balloons_) if (can_deploy_balloons_)
{ {
constexpr int values = 6; constexpr int VALUES = 6;
constexpr int pos_y = -BALLOON_SIZE[4]; constexpr float POS_Y = -BALLOON_SIZE[4];
constexpr int creation_time = 0; constexpr int CREATION_TIME = 0;
const auto left = param.game.play_area.rect.x; const float LEFT = param.game.play_area.rect.x;
const auto center = param.game.play_area.center_x - (BALLOON_SIZE[4] / 2); const float CENTER = param.game.play_area.center_x - (BALLOON_SIZE[4] / 2);
const auto right = param.game.play_area.rect.w - BALLOON_SIZE[4]; const float RIGHT = param.game.play_area.rect.w - BALLOON_SIZE[4];
const auto luck = rand() % values; const int LUCK = rand() % VALUES;
const int x[values] = {left, left, center, center, right, right}; const float POS_X[VALUES] = {LEFT, LEFT, CENTER, CENTER, RIGHT, RIGHT};
const float vx[values] = {BALLOON_VELX_POSITIVE, BALLOON_VELX_POSITIVE, BALLOON_VELX_POSITIVE, BALLOON_VELX_NEGATIVE, BALLOON_VELX_NEGATIVE, BALLOON_VELX_NEGATIVE}; const float VEL_X[VALUES] = {BALLOON_VELX_POSITIVE, BALLOON_VELX_POSITIVE, BALLOON_VELX_POSITIVE, BALLOON_VELX_NEGATIVE, BALLOON_VELX_NEGATIVE, BALLOON_VELX_NEGATIVE};
balloons_.emplace_back(std::make_unique<Balloon>(x[luck], pos_y, BalloonType::POWERBALL, BalloonSize::SIZE4, vx[luck], balloon_speed_, creation_time, play_area_, balloon_textures_[4], balloon_animations_[4])); balloons_.emplace_back(std::make_unique<Balloon>(POS_X[LUCK], POS_Y, BalloonType::POWERBALL, BalloonSize::SIZE4, VEL_X[LUCK], balloon_speed_, CREATION_TIME, play_area_, balloon_textures_[4], balloon_animations_[4]));
balloons_.back()->setInvulnerable(true); balloons_.back()->setInvulnerable(true);
power_ball_enabled_ = true; power_ball_enabled_ = true;
@@ -320,8 +320,8 @@ int BalloonManager::destroyAllBalloons()
} }
balloon_deploy_counter_ = 300; balloon_deploy_counter_ = 300;
JA_PlaySound(Resource::get()->getSound("power_ball_explosion.wav")); Audio::get()->playSound("power_ball_explosion.wav");
Screen::get()->flash(flash_color, 3); Screen::get()->flash(FLASH_COLOR, 3);
Screen::get()->shake(); Screen::get()->shake();
return score; return score;
@@ -381,7 +381,7 @@ void BalloonManager::createRandomBalloons()
const int num_balloons = 2 + rand() % 4; const int num_balloons = 2 + rand() % 4;
for (int i = 0; i < num_balloons; ++i) for (int i = 0; i < num_balloons; ++i)
{ {
const float x = param.game.game_area.rect.x + (rand() % param.game.game_area.rect.w) - BALLOON_SIZE[3]; const float x = param.game.game_area.rect.x + (rand() % static_cast<int>(param.game.game_area.rect.w)) - BALLOON_SIZE[3];
const int y = param.game.game_area.rect.y + (rand() % 50); const int y = param.game.game_area.rect.y + (rand() % 50);
const BalloonSize size = static_cast<BalloonSize>(rand() % 4); const BalloonSize size = static_cast<BalloonSize>(rand() % 4);
const float vel_x = (rand() % 2 == 0) ? BALLOON_VELX_POSITIVE : BALLOON_VELX_NEGATIVE; const float vel_x = (rand() % 2 == 0) ? BALLOON_VELX_POSITIVE : BALLOON_VELX_NEGATIVE;

View File

@@ -1,6 +1,6 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect #include <SDL3/SDL_rect.h> // Para SDL_FRect
#include <memory> // Para shared_ptr, unique_ptr #include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para string #include <string> // Para string
#include <vector> // Para vector #include <vector> // Para vector
@@ -9,122 +9,92 @@
#include "explosions.h" // Para Explosions #include "explosions.h" // Para Explosions
#include "param.h" // Para Param, ParamGame, param #include "param.h" // Para Param, ParamGame, param
#include "utils.h" // Para Zone #include "utils.h" // Para Zone
class Texture; // lines 10-10 class Texture;
using Balloons = std::vector<std::shared_ptr<Balloon>>; using Balloons = std::vector<std::shared_ptr<Balloon>>;
// Clase BalloonManager
class BalloonManager class BalloonManager
{ {
private:
Balloons balloons_; // Vector con los globos
std::unique_ptr<Explosions> explosions_; // Objeto para dibujar explosiones
std::unique_ptr<BalloonFormations> balloon_formations_; // Objeto para gestionar las oleadas enemigas
std::vector<std::shared_ptr<Texture>> balloon_textures_; // Vector con las texturas de los globos
std::vector<std::shared_ptr<Texture>> explosions_textures_; // Vector con las texturas de las explosiones
std::vector<std::vector<std::string>> balloon_animations_; // Vector con las animaciones de los globos
std::vector<std::vector<std::string>> explosions_animations_; // Vector con las animaciones de las explosiones
float balloon_speed_ = BALLOON_SPEED[0]; // Velocidad a la que se mueven los enemigos
float default_balloon_speed_ = BALLOON_SPEED[0]; // Velocidad base de los enemigos, sin incrementar
int balloon_deploy_counter_ = 0; // Cuando se lanza una formación, se le da un valor y no sale otra hasta que llegue a cero
bool power_ball_enabled_ = false; // Indica si hay una powerball ya activa
int power_ball_counter_ = 0; // Contador de formaciones enemigas entre la aparicion de una PowerBall y otra
int last_balloon_deploy_ = 0; // Guarda cual ha sido la última formación desplegada para no repetir;
SDL_Rect play_area_ = param.game.play_area.rect; // Zona por donde se moveran los globos
bool creation_time_enabled_ = true; // Indica si los globos se crean con tiempo
bool can_deploy_balloons_ = true; // Indica si creará globos
// Inicializa
void init();
public: public:
// Constructor // Constructor y Destructor
BalloonManager(); BalloonManager();
// Destructor
~BalloonManager() = default; ~BalloonManager() = default;
// Actualiza // Actualización y Renderizado
void update(); void update(); // Actualiza el estado de los globos
void render(); // Renderiza los globos en pantalla
// Renderiza los globos // Gestión de globos
void render(); void freeBalloons(); // Libera globos que ya no sirven
// Vacia del vector de globos los globos que ya no sirven // Creación de formaciones enemigas
void freeBalloons(); void deployBalloonFormation(int stage); // Crea una formación de enemigos aleatoria
void deploySet(int set); // Crea una formación específica
void deploySet(int set, int y); // Crea una formación específica con coordenadas
// Crea una formación de enemigos al azar // Creación de globos
void deployBalloonFormation(int stage); std::shared_ptr<Balloon> createBalloon(float x, int y, BalloonType type, BalloonSize size, float velx, float speed, int creation_timer); // Crea un nuevo globo
void createChildBalloon(const std::shared_ptr<Balloon> &balloon, const std::string &direction); // Crea un globo a partir de otro
void createPowerBall(); // Crea una PowerBall
void createTwoBigBalloons(); // Crea dos globos grandes
void createRandomBalloons(); // Crea una disposición aleatoria de globos
// Crea una formación de enemigos específica // Control de velocidad y despliegue
void deploySet(int set); void setBalloonSpeed(float speed); // Ajusta la velocidad de los globos
void deploySet(int set, int y); void setDefaultBalloonSpeed(float speed) { default_balloon_speed_ = speed; }; // Establece la velocidad base
void resetBalloonSpeed() { setBalloonSpeed(default_balloon_speed_); }; // Restablece la velocidad de los globos
void updateBalloonDeployCounter(); // Actualiza el contador de despliegue
bool canPowerBallBeCreated(); // Indica si se puede crear una PowerBall
int calculateScreenPower(); // Calcula el poder de los globos en pantalla
// Actualiza la variable enemyDeployCounter // Manipulación de globos existentes
void updateBalloonDeployCounter(); int popBalloon(std::shared_ptr<Balloon> balloon); // Explosiona un globo, creando otros si aplica
int destroyBalloon(std::shared_ptr<Balloon> &balloon); // Explosiona un globo sin crear otros
int destroyAllBalloons(); // Destruye todos los globos
void stopAllBalloons(); // Detiene el movimiento de los globos
void startAllBalloons(); // Reactiva el movimiento de los globos
// Indica si se puede crear una powerball // Cambios de apariencia
bool canPowerBallBeCreated(); void reverseColorsToAllBalloons(); // Invierte los colores de los globos
void normalColorsToAllBalloons(); // Restaura los colores originales
// Calcula el poder actual de los globos en pantalla // Configuración de sonido
int calculateScreenPower(); void setSounds(bool value); // Activa o desactiva los sonidos de los globos
// Crea un globo nuevo en el vector de globos // Configuración de juego
std::shared_ptr<Balloon> createBalloon(float x, int y, BalloonType type, BalloonSize size, float velx, float speed, int creation_timer); void setPlayArea(SDL_FRect play_area) { play_area_ = play_area; }; // Define el área de juego
void setCreationTimeEnabled(bool value) { creation_time_enabled_ = value; }; // Activa o desactiva el tiempo de creación de globos
void setDeployBalloons(bool value) { can_deploy_balloons_ = value; }; // Activa o desactiva la generación de globos
// Crea un globo a partir de otro globo // Obtención de información
void createChildBalloon(const std::shared_ptr<Balloon> &balloon, const std::string &direction); int getMenace(); // Obtiene el nivel de amenaza generado por los globos
// Crea una PowerBall
void createPowerBall();
// Establece la velocidad de los globos
void setBalloonSpeed(float speed);
// Explosiona un globo. Lo destruye y crea otros dos si es el caso
int popBalloon(std::shared_ptr<Balloon> balloon);
// Explosiona un globo. Lo destruye = no crea otros globos
int destroyBalloon(std::shared_ptr<Balloon> &balloon);
// Destruye todos los globos
int destroyAllBalloons();
// Detiene todos los globos
void stopAllBalloons();
// Pone en marcha todos los globos
void startAllBalloons();
// Cambia el color de todos los globos
void reverseColorsToAllBalloons();
// Cambia el color de todos los globos
void normalColorsToAllBalloons();
// Crea dos globos gordos
void createTwoBigBalloons();
// Crea una disposición de globos aleatoria
void createRandomBalloons();
// Obtiene el nivel de ameza actual generado por los globos
int getMenace();
// Establece el sonido de los globos
void setSounds(bool value);
// Getters
float getBalloonSpeed() const { return balloon_speed_; } float getBalloonSpeed() const { return balloon_speed_; }
Balloons &getBalloons() { return balloons_; } Balloons &getBalloons() { return balloons_; }
int getNumBalloons() const { return balloons_.size(); } int getNumBalloons() const { return balloons_.size(); }
// Setters private:
void setDefaultBalloonSpeed(float speed) { default_balloon_speed_ = speed; } Balloons balloons_; // Vector con los globos activos
void resetBalloonSpeed() { setBalloonSpeed(default_balloon_speed_); } std::unique_ptr<Explosions> explosions_; // Objeto para gestionar explosiones
void setPlayArea(SDL_Rect play_area) { play_area_ = play_area; } std::unique_ptr<BalloonFormations> balloon_formations_; // Objeto para manejar formaciones enemigas
void setCreationTimeEnabled(bool value) { creation_time_enabled_ = value; }
void setDeployBalloons(bool value) { can_deploy_balloons_ = value; } std::vector<std::shared_ptr<Texture>> balloon_textures_; // Texturas de los globos
}; std::vector<std::shared_ptr<Texture>> explosions_textures_; // Texturas de explosiones
std::vector<std::vector<std::string>> balloon_animations_; // Animaciones de los globos
std::vector<std::vector<std::string>> explosions_animations_; // Animaciones de las explosiones
// Variables de control de globos
float balloon_speed_ = BALLOON_SPEED[0];
float default_balloon_speed_ = BALLOON_SPEED[0];
int balloon_deploy_counter_ = 0;
bool power_ball_enabled_ = false;
int power_ball_counter_ = 0;
int last_balloon_deploy_ = 0;
SDL_FRect play_area_ = param.game.play_area.rect;
bool creation_time_enabled_ = true;
bool can_deploy_balloons_ = true;
// Inicialización interna
void init();
};

View File

@@ -1,13 +1,13 @@
#include "bullet.h" #include "bullet.h"
#include <SDL2/SDL_rect.h> // Para SDL_Rect #include <SDL3/SDL_rect.h> // Para SDL_FRect
#include <memory> // Para unique_ptr, make_unique, shared_ptr #include <memory> // Para unique_ptr, make_unique, shared_ptr
#include "param.h" // Para Param, ParamGame, param #include "param.h" // Para Param, ParamGame, param
#include "sprite.h" // Para Sprite #include "sprite.h" // Para Sprite
class Texture; // lines 5-5 class Texture; // lines 5-5
// Constructor // Constructor
Bullet::Bullet(int x, int y, BulletType bullet_type, bool powered_up, int owner, std::shared_ptr<Texture> texture) Bullet::Bullet(float x, float y, BulletType bullet_type, bool powered_up, int owner, std::shared_ptr<Texture> texture)
: sprite_(std::make_unique<Sprite>(texture, SDL_Rect{x, y, BULLET_WIDTH_, BULLET_HEIGHT_})), : sprite_(std::make_unique<Sprite>(texture, SDL_FRect{x, y, BULLET_WIDTH_, BULLET_HEIGHT_})),
pos_x_(x), pos_x_(x),
pos_y_(y), pos_y_(y),
bullet_type_(bullet_type), bullet_type_(bullet_type),

View File

@@ -1,10 +1,10 @@
#pragma once #pragma once
#include <SDL2/SDL_stdinc.h> // Para Uint8 #include <SDL3/SDL_stdinc.h> // Para Uint8
#include <memory> // Para shared_ptr, unique_ptr #include <memory> // Para shared_ptr, unique_ptr
#include "sprite.h" // Para Sprite #include "sprite.h" // Para Sprite
#include "utils.h" // Para Circle #include "utils.h" // Para Circle
class Texture; // lines 8-8 class Texture;
// Tipos de balas // Tipos de balas
enum class BulletType : Uint8 enum class BulletType : Uint8
@@ -25,47 +25,43 @@ enum class BulletMoveStatus : Uint8
// Clase Bullet // Clase Bullet
class Bullet class Bullet
{ {
private:
// Constantes
static constexpr int BULLET_WIDTH_ = 12;
static constexpr int BULLET_HEIGHT_ = 12;
static constexpr int BULLET_VEL_Y_ = -3;
static constexpr int BULLET_VEL_X_LEFT_ = -2;
static constexpr int BULLET_VEL_X_RIGHT_ = 2;
std::unique_ptr<Sprite> sprite_; // Sprite con los gráficos y métodos de pintado
int pos_x_; // Posición en el eje X
int pos_y_; // Posición en el eje Y
int vel_x_; // Velocidad en el eje X
BulletType bullet_type_; // Tipo de objeto
int owner_; // Identificador del dueño del objeto
Circle collider_; // Círculo de colisión del objeto
void shiftColliders(); // Alinea el círculo de colisión con el objeto
void shiftSprite(); // Alinea el sprite con el objeto
public: public:
// Constructor // Constructor y Destructor
Bullet(int x, int y, BulletType bullet_type, bool powered_up, int owner, std::shared_ptr<Texture> texture); Bullet(float x, float y, BulletType bullet_type, bool powered_up, int owner, std::shared_ptr<Texture> texture);
// Destructor
~Bullet() = default; ~Bullet() = default;
// Pinta el objeto en pantalla // Métodos principales
void render(); void render(); // Dibuja la bala en pantalla
BulletMoveStatus move(); // Mueve la bala y devuelve su estado
// Actualiza la posición y estado del objeto // Estado de la bala
BulletMoveStatus move(); bool isEnabled() const; // Comprueba si está activa
void disable(); // Desactiva la bala
// Comprueba si el objeto está habilitado // Getters
bool isEnabled() const; int getOwner() const; // Devuelve el identificador del dueño
Circle &getCollider(); // Devuelve el círculo de colisión
// Deshabilita el objeto private:
void disable(); // Constantes
static constexpr float BULLET_WIDTH_ = 12.0f;
static constexpr float BULLET_HEIGHT_ = 12.0f;
static constexpr float BULLET_VEL_Y_ = -3.0f;
static constexpr float BULLET_VEL_X_LEFT_ = -2.0f;
static constexpr float BULLET_VEL_X_RIGHT_ = 2.0f;
// Obtiene parámetros // Propiedades
int getOwner() const; std::unique_ptr<Sprite> sprite_; // Sprite con los gráficos
Circle &getCollider();
float pos_x_; // Posición en el eje X
float pos_y_; // Posición en el eje Y
float vel_x_; // Velocidad en el eje X
BulletType bullet_type_; // Tipo de bala
int owner_; // Identificador del dueño
Circle collider_; // Círculo de colisión
// Métodos internos
void shiftColliders(); // Ajusta el círculo de colisión
void shiftSprite(); // Ajusta el sprite
}; };

View File

@@ -1,27 +1,26 @@
// IWYU pragma: no_include <bits/std_abs.h> // IWYU pragma: no_include <bits/std_abs.h>
#include "credits.h" #include "credits.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND #include <SDL3/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_QUIT #include <SDL3/SDL_events.h> // Para SDL_PollEvent, SDL_Event
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888 #include <SDL3/SDL_pixels.h> // Para SDL_PixelFormat
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks #include <SDL3/SDL_timer.h> // Para SDL_GetTicks
#include <algorithm> // Para max, min, clamp #include <algorithm> // Para max, min, clamp
#include <cstdlib> // Para abs #include <array> // Para array
#include <stdexcept> // Para runtime_error #include <stdexcept> // Para runtime_error
#include <string> // Para basic_string, string #include <string> // Para basic_string, string
#include <vector> // Para vector #include <vector> // Para vector
#include <array> // Para vector
#include "balloon_manager.h" // Para BalloonManager #include "balloon_manager.h" // Para BalloonManager
#include "fade.h" // Para Fade, FadeType, FadeMode #include "fade.h" // Para Fade, FadeType, FadeMode
#include "global_events.h" // Para check
#include "global_inputs.h" // Para check, update #include "global_inputs.h" // Para check, update
#include "input.h" // Para Input #include "input.h" // Para Input, INPUT_ALLOW_REPEAT
#include "jail_audio.h" // Para JA_GetMusicState, JA_SetMusicVolume #include "audio.h" // Para JA_GetMusicState, JA_SetMusicVolume
#include "lang.h" // Para getText #include "lang.h" // Para getText
#include "global_events.h" // Para handleEvent
#include "param.h" // Para Param, ParamGame, param #include "param.h" // Para Param, ParamGame, param
#include "player.h" // Para Player, PlayerState #include "player.h" // Para Player, PlayerState
#include "resource.h" // Para Resource #include "resource.h" // Para Resource
#include "screen.h" // Para Screen #include "screen.h" // Para Screen
#include "section.h" // Para Name, name, Options, options #include "section.h" // Para Name, name
#include "sprite.h" // Para Sprite #include "sprite.h" // Para Sprite
#include "text.h" // Para Text, TEXT_CENTER, TEXT_SHADOW #include "text.h" // Para Text, TEXT_CENTER, TEXT_SHADOW
#include "texture.h" // Para Texture #include "texture.h" // Para Texture
@@ -34,11 +33,11 @@ constexpr const char TEXT_COPYRIGHT[] = "@2020,2025 JailDesigner";
// Constructor // Constructor
Credits::Credits() Credits::Credits()
: balloon_manager_(std::make_unique<BalloonManager>()), : balloon_manager_(std::make_unique<BalloonManager>()),
text_texture_(SDL_CreateTexture(Screen::get()->getRenderer(), SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height)),
canvas_(SDL_CreateTexture(Screen::get()->getRenderer(), SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height)),
tiled_bg_(std::make_unique<TiledBG>(param.game.game_area.rect, TiledBGMode::DIAGONAL)), tiled_bg_(std::make_unique<TiledBG>(param.game.game_area.rect, TiledBGMode::DIAGONAL)),
fade_in_(std::make_unique<Fade>()), fade_in_(std::make_unique<Fade>()),
fade_out_(std::make_unique<Fade>()) fade_out_(std::make_unique<Fade>()),
text_texture_(SDL_CreateTexture(Screen::get()->getRenderer(), SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height)),
canvas_(SDL_CreateTexture(Screen::get()->getRenderer(), SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height))
{ {
if (!text_texture_) if (!text_texture_)
{ {
@@ -47,7 +46,7 @@ Credits::Credits()
section::name = section::Name::CREDITS; section::name = section::Name::CREDITS;
balloon_manager_->setPlayArea(play_area_); balloon_manager_->setPlayArea(play_area_);
fade_in_->setColor(fade_color.r, fade_color.g, fade_color.b); fade_in_->setColor(FADE_COLOR.r, FADE_COLOR.g, FADE_COLOR.b);
fade_in_->setType(FadeType::FULLSCREEN); fade_in_->setType(FadeType::FULLSCREEN);
fade_in_->setPostDuration(50); fade_in_->setPostDuration(50);
fade_in_->setMode(FadeMode::IN); fade_in_->setMode(FadeMode::IN);
@@ -72,7 +71,7 @@ Credits::~Credits()
SDL_DestroyTexture(text_texture_); SDL_DestroyTexture(text_texture_);
SDL_DestroyTexture(canvas_); SDL_DestroyTexture(canvas_);
resetVolume(); resetVolume();
JA_StopMusic(); Audio::get()->stopMusic();
} }
// Bucle principal // Bucle principal
@@ -110,7 +109,6 @@ void Credits::update()
} }
Screen::get()->update(); Screen::get()->update();
globalInputs::update();
fillCanvas(); fillCanvas();
} }
@@ -123,7 +121,7 @@ void Credits::render()
Screen::get()->start(); Screen::get()->start();
// Copia la textura con la zona de juego a la pantalla // Copia la textura con la zona de juego a la pantalla
SDL_RenderCopy(Screen::get()->getRenderer(), canvas_, nullptr, nullptr); SDL_RenderTexture(Screen::get()->getRenderer(), canvas_, nullptr, nullptr);
// Vuelca el contenido del renderizador en pantalla // Vuelca el contenido del renderizador en pantalla
Screen::get()->render(); Screen::get()->render();
@@ -186,46 +184,46 @@ void Credits::fillTextTexture()
int y = (param.game.height - TEXTS_HEIGHT) / 2; int y = (param.game.height - TEXTS_HEIGHT) / 2;
y = 0; y = 0;
text->setPalette(1); text->setPalette(1);
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(0), 1, no_color, 1, shdw_txt_color); text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(0), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
text->setPalette(0); text->setPalette(0);
y += SPACE_POST_TITLE; y += SPACE_POST_TITLE;
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(4), 1, no_color, 1, shdw_txt_color); text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(4), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
y += SPACE_PRE_TITLE; y += SPACE_PRE_TITLE;
text->setPalette(1); text->setPalette(1);
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(1), 1, no_color, 1, shdw_txt_color); text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(1), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
text->setPalette(0); text->setPalette(0);
y += SPACE_POST_TITLE; y += SPACE_POST_TITLE;
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(4), 1, no_color, 1, shdw_txt_color); text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(4), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
y += SPACE_PRE_TITLE; y += SPACE_PRE_TITLE;
text->setPalette(1); text->setPalette(1);
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(2), 1, no_color, 1, shdw_txt_color); text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(2), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
text->setPalette(0); text->setPalette(0);
y += SPACE_POST_TITLE; y += SPACE_POST_TITLE;
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(5), 1, no_color, 1, shdw_txt_color); text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(5), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
y += SPACE_POST_TITLE; y += SPACE_POST_TITLE;
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(6), 1, no_color, 1, shdw_txt_color); text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(6), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
y += SPACE_PRE_TITLE; y += SPACE_PRE_TITLE;
text->setPalette(1); text->setPalette(1);
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(3), 1, no_color, 1, shdw_txt_color); text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(3), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
text->setPalette(0); text->setPalette(0);
y += SPACE_POST_TITLE; y += SPACE_POST_TITLE;
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(7), 1, no_color, 1, shdw_txt_color); text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(7), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
y += SPACE_POST_TITLE; y += SPACE_POST_TITLE;
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(8), 1, no_color, 1, shdw_txt_color); text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(8), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
y += SPACE_POST_TITLE; y += SPACE_POST_TITLE;
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(9), 1, no_color, 1, shdw_txt_color); text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXTS.at(9), 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
// Mini logo // Mini logo
y += SPACE_PRE_TITLE; y += SPACE_PRE_TITLE;
mini_logo_rect_src_.y = y; mini_logo_rect_src_.y = y;
auto mini_logo_sprite = std::make_unique<Sprite>(Resource::get()->getTexture("logo_jailgames_mini.png")); auto mini_logo_sprite = std::make_unique<Sprite>(Resource::get()->getTexture("logo_jailgames_mini.png"));
mini_logo_sprite->setPosition(1 + param.game.game_area.center_x - mini_logo_sprite->getWidth() / 2, 1 + y); mini_logo_sprite->setPosition(1 + param.game.game_area.center_x - mini_logo_sprite->getWidth() / 2, 1 + y);
Resource::get()->getTexture("logo_jailgames_mini.png")->setColor(shdw_txt_color.r, shdw_txt_color.g, shdw_txt_color.b); Resource::get()->getTexture("logo_jailgames_mini.png")->setColor(SHADOW_TEXT_COLOR.r, SHADOW_TEXT_COLOR.g, SHADOW_TEXT_COLOR.b);
mini_logo_sprite->render(); mini_logo_sprite->render();
mini_logo_sprite->setPosition(param.game.game_area.center_x - mini_logo_sprite->getWidth() / 2, y); mini_logo_sprite->setPosition(param.game.game_area.center_x - mini_logo_sprite->getWidth() / 2, y);
@@ -234,7 +232,7 @@ void Credits::fillTextTexture()
// Texto con el copyright // Texto con el copyright
y += mini_logo_sprite->getHeight() + 3; y += mini_logo_sprite->getHeight() + 3;
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXT_COPYRIGHT, 1, no_color, 1, shdw_txt_color); text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXT_COPYRIGHT, 1, NO_COLOR, 1, SHADOW_TEXT_COLOR);
// Resetea el renderizador // Resetea el renderizador
SDL_SetRenderTarget(Screen::get()->getRenderer(), nullptr); SDL_SetRenderTarget(Screen::get()->getRenderer(), nullptr);
@@ -262,10 +260,10 @@ void Credits::fillCanvas()
} }
// Dibuja los titulos de credito // Dibuja los titulos de credito
SDL_RenderCopy(Screen::get()->getRenderer(), text_texture_, &credits_rect_src_, &credits_rect_dst_); SDL_RenderTexture(Screen::get()->getRenderer(), text_texture_, &credits_rect_src_, &credits_rect_dst_);
// Dibuja el mini_logo // Dibuja el mini_logo
SDL_RenderCopy(Screen::get()->getRenderer(), text_texture_, &mini_logo_rect_src_, &mini_logo_rect_dst_); SDL_RenderTexture(Screen::get()->getRenderer(), text_texture_, &mini_logo_rect_src_, &mini_logo_rect_dst_);
// Dibuja los rectangulos negros // Dibuja los rectangulos negros
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 0xFF); SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 0xFF);
@@ -276,12 +274,12 @@ void Credits::fillCanvas()
// Dibuja el rectangulo rojo // Dibuja el rectangulo rojo
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0xFF, 0, 0, 0xFF); SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0xFF, 0, 0, 0xFF);
SDL_RenderDrawRect(Screen::get()->getRenderer(), &red_rect); SDL_RenderRect(Screen::get()->getRenderer(), &red_rect);
// Si el mini_logo está en su destino, lo dibuja encima de lo anterior // Si el mini_logo está en su destino, lo dibuja encima de lo anterior
if (mini_logo_on_position_) if (mini_logo_on_position_)
{ {
SDL_RenderCopy(Screen::get()->getRenderer(), text_texture_, &mini_logo_rect_src_, &mini_logo_rect_dst_); SDL_RenderTexture(Screen::get()->getRenderer(), text_texture_, &mini_logo_rect_src_, &mini_logo_rect_dst_);
} }
// Dibuja el fade sobre el resto de elementos // Dibuja el fade sobre el resto de elementos
@@ -439,7 +437,7 @@ void Credits::updateBlackRects()
{ {
// Si los rectangulos izquierdo y derecho han llegado al centro // Si los rectangulos izquierdo y derecho han llegado al centro
setVolume(0); setVolume(0);
JA_StopMusic(); Audio::get()->stopMusic();
if (counter_pre_fade_ == 400) if (counter_pre_fade_ == 400)
{ {
fade_out_->activate(); fade_out_->activate();
@@ -473,10 +471,7 @@ void Credits::updateAllFades()
fade_in_->update(); fade_in_->update();
if (fade_in_->hasEnded()) if (fade_in_->hasEnded())
{ {
if (JA_GetMusicState() == JA_MUSIC_INVALID || JA_GetMusicState() == JA_MUSIC_STOPPED) Audio::get()->playMusic("credits.ogg");
{
JA_PlayMusic(Resource::get()->getMusic("credits.ogg"));
}
} }
fade_out_->update(); fade_out_->update();
@@ -490,14 +485,14 @@ void Credits::updateAllFades()
void Credits::setVolume(int amount) void Credits::setVolume(int amount)
{ {
options.audio.music.volume = std::clamp(amount, 0, 100); options.audio.music.volume = std::clamp(amount, 0, 100);
JA_SetMusicVolume(to_JA_volume(options.audio.music.volume)); Audio::get()->setMusicVolume(options.audio.music.volume);
} }
// Reestablece el nivel de volumen // Reestablece el nivel de volumen
void Credits::resetVolume() void Credits::resetVolume()
{ {
options.audio.music.volume = initial_volume_; options.audio.music.volume = initial_volume_;
JA_SetMusicVolume(to_JA_volume(options.audio.music.volume)); Audio::get()->setMusicVolume(options.audio.music.volume);
} }
// Cambia el color del fondo // Cambia el color del fondo

View File

@@ -1,113 +1,128 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect #include <SDL3/SDL_rect.h>
#include <SDL2/SDL_render.h> // Para SDL_Texture #include <SDL3/SDL_render.h>
#include <SDL2/SDL_stdinc.h> // Para Uint32 #include <SDL3/SDL_stdinc.h>
#include <memory> // Para unique_ptr, shared_ptr #include <memory>
#include <vector> // Para vector #include <vector>
#include "options.h" // Para Options, OptionsAudio, OptionsMusic
#include "param.h" // Para Param, ParamGame, param
#include "utils.h" // Para Zone
class BalloonManager; // lines 8-8
class Fade; // lines 11-11
class Player; // lines 10-10
class TiledBG; // lines 9-9
constexpr int PLAY_AREA_HEIGHT = 200; #include "options.h"
#include "param.h"
#include "utils.h"
// Declaraciones adelantadas
class BalloonManager;
class Fade;
class Player;
class TiledBG;
class Credits class Credits
{ {
public:
// --- Constructores y destructor ---
Credits();
~Credits();
// --- Bucle principal ---
void run();
private: private:
// Objetos // --- Constantes de clase ---
std::unique_ptr<BalloonManager> balloon_manager_; // Objeto para gestionar los globos static constexpr int PLAY_AREA_HEIGHT = 200;
SDL_Texture *text_texture_; // Textura con el texto
SDL_Texture *canvas_; // Textura donde dibujarlo todo
std::unique_ptr<TiledBG> tiled_bg_; // Objeto para dibujar el mosaico animado de fondo
std::unique_ptr<Fade> fade_in_; // Objeto para realizar el fundido de entrada
std::unique_ptr<Fade> fade_out_; // Objeto para realizar el fundido de salida
std::vector<std::shared_ptr<Player>> players_; // Vector con los jugadores
// Variables // --- Objetos principales ---
Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa std::unique_ptr<BalloonManager> balloon_manager_; // Gestión de globos
Uint32 counter_ = 0; // Contador para la lógica de la clase std::unique_ptr<TiledBG> tiled_bg_; // Mosaico animado de fondo
Uint32 counter_pre_fade_ = 0; // Contador para activar el fundido final std::unique_ptr<Fade> fade_in_; // Fundido de entrada
Uint32 counter_prevent_endless_ = 0; // Contador para evitar que el juego se quede para siempre en los creditos std::unique_ptr<Fade> fade_out_; // Fundido de salida
int black_bars_size_ = (param.game.game_area.rect.h - PLAY_AREA_HEIGHT) / 2; // Tamaño de las barras negras std::vector<std::shared_ptr<Player>> players_; // Vector de jugadores
int mini_logo_final_pos_ = 0; // Ubicación donde se detiene el minilogo
bool fading_ = false; // Indica si se está realizando el fade final
bool want_to_pass_ = false; // Indica si el jugador quiere saltarse los titulos de crédito
bool mini_logo_on_position_ = false; // Indica si el minilogo ya se ha quedado en su posición
int initial_volume_ = options.audio.music.volume; // Volumen actual al crear el objeto
int steps_ = 0; // Cantidad de pasos a dar para ir reduciendo el audio
// Rectangulos // --- Gestión de texturas ---
SDL_Rect credits_rect_src_ = param.game.game_area.rect; // Rectangulo con el texto de los créditos (origen) SDL_Texture *text_texture_; // Textura con el texto de créditos
SDL_Rect credits_rect_dst_ = param.game.game_area.rect; // Rectangulo con el texto de los créditos (destino) SDL_Texture *canvas_; // Textura donde se dibuja todo
SDL_Rect mini_logo_rect_src_ = param.game.game_area.rect; // Rectangulo con el mini logo de JailGames y el texto de copyright (origen)
SDL_Rect mini_logo_rect_dst_ = param.game.game_area.rect; // Rectangulo con el mini logo de JailGames y el texto de copyright (destino) // --- Temporización y contadores ---
SDL_Rect play_area_ = { Uint64 ticks_ = 0; // Control de velocidad del programa
Uint32 counter_ = 0; // Contador principal de lógica
Uint32 counter_pre_fade_ = 0; // Activación del fundido final
Uint32 counter_prevent_endless_ = 0; // Prevención de bucle infinito
// --- Variables de estado ---
bool fading_ = false; // Estado del fade final
bool want_to_pass_ = false; // Jugador quiere saltarse créditos
bool mini_logo_on_position_ = false; // Minilogo en posición final
// --- Diseño y posicionamiento ---
float black_bars_size_ = (param.game.game_area.rect.h - PLAY_AREA_HEIGHT) / 2; // Tamaño de las barras negras
int mini_logo_final_pos_ = 0; // Posición final del minilogo
// --- Control de audio ---
int initial_volume_ = options.audio.music.volume; // Volumen inicial
int steps_ = 0; // Pasos para reducir audio
// --- Rectángulos de renderizado ---
// Texto de créditos
SDL_FRect credits_rect_src_ = param.game.game_area.rect;
SDL_FRect credits_rect_dst_ = param.game.game_area.rect;
// Mini logo
SDL_FRect mini_logo_rect_src_ = param.game.game_area.rect;
SDL_FRect mini_logo_rect_dst_ = param.game.game_area.rect;
// Definición del área de juego
SDL_FRect play_area_ = {
param.game.game_area.rect.x, param.game.game_area.rect.x,
param.game.game_area.rect.y + black_bars_size_, param.game.game_area.rect.y + black_bars_size_,
param.game.game_area.rect.w, param.game.game_area.rect.w,
PLAY_AREA_HEIGHT}; // Area visible para los creditos PLAY_AREA_HEIGHT};
SDL_Rect top_black_rect_ = {play_area_.x, param.game.game_area.rect.y, play_area_.w, black_bars_size_}; // Rectangulo negro superior
SDL_Rect bottom_black_rect_ = {play_area_.x, param.game.game_area.rect.h - black_bars_size_, play_area_.w, black_bars_size_}; // Rectangulo negro inferior
SDL_Rect left_black_rect_ = {play_area_.x, param.game.game_area.center_y - 1, 0, 2}; // Rectangulo negro situado a la izquierda
SDL_Rect right_black_rect_ = {play_area_.x + play_area_.w, param.game.game_area.center_y - 1, 0, 2}; // Rectangulo negro situado a la derecha
SDL_Rect red_rect = play_area_; // Rectangulo rojo para delimitar la ventana
// Actualiza las variables // Barras negras para efecto letterbox
void update(); SDL_FRect top_black_rect_ = {
play_area_.x,
param.game.game_area.rect.y,
play_area_.w,
black_bars_size_};
SDL_FRect bottom_black_rect_ = {
play_area_.x,
param.game.game_area.rect.h - black_bars_size_,
play_area_.w,
black_bars_size_};
SDL_FRect left_black_rect_ = {
play_area_.x,
param.game.game_area.center_y - 1,
0,
2};
SDL_FRect right_black_rect_ = {
play_area_.x + play_area_.w,
param.game.game_area.center_y - 1,
0,
2};
// Dibuja en pantalla // Borde para la ventana
void render(); SDL_FRect red_rect = play_area_; // Delimitador de ventana
// Comprueba el manejador de eventos // --- Métodos del bucle principal ---
void checkEvents(); void update(); // Actualización principal de la lógica
void render(); // Renderizado de la escena
void checkEvents(); // Manejo de eventos
void checkInput(); // Procesamiento de entrada
// Comprueba las entradas // --- Métodos de renderizado ---
void checkInput(); void fillTextTexture(); // Crear textura de texto de créditos
void fillCanvas(); // Renderizar todos los sprites y fondos
void updateTextureDstRects(); // Actualizar destinos de texturas
// Crea la textura con el texto // --- Métodos de lógica del juego ---
void fillTextTexture(); void throwBalloons(); // Lanzar globos al escenario
void initPlayers(); // Inicializar jugadores
void updateAllFades(); // Actualizar estados de fade
void cycleColors(); // Cambiar colores de fondo
// Dibuja todos los sprites en la textura // --- Métodos de interfaz ---
void fillCanvas(); void updateBlackRects(); // Actualizar rectángulos negros (letterbox)
void updateRedRect(); // Actualizar rectángulo rojo (borde)
// Actualiza el destino de los rectangulos de las texturas // --- Métodos de audio ---
void updateTextureDstRects(); void setVolume(int amount); // Establecer volumen
void resetVolume(); // Restablecer volumen
// Tira globos al escenario
void throwBalloons();
// Inicializa los jugadores
void initPlayers();
// Actualiza los rectangulos negros
void updateBlackRects();
// Actualiza el rectangulo rojo
void updateRedRect();
// Actualiza el estado de fade
void updateAllFades();
// Establece el nivel de volumen
void setVolume(int amount);
// Reestablece el nivel de volumen
void resetVolume();
// Cambia el color del fondo
void cycleColors();
public:
// Constructor
Credits();
// Destructor
~Credits();
// Bucle principal
void run();
}; };

View File

@@ -1,45 +0,0 @@
#include "dbgtxt.h"
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_rwops.h> // Para SDL_RWFromMem
#include <SDL2/SDL_surface.h> // Para SDL_LoadBMP_RW
namespace
{
SDL_Texture *dbg_tex = nullptr;
SDL_Renderer *dbg_ren = nullptr;
}
void dbg_init(SDL_Renderer *renderer)
{
dbg_ren = renderer;
Uint8 font[448] = {0x42, 0x4D, 0xC0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x01, 0x00, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x18, 0xF3, 0x83, 0x83, 0xCF, 0x83, 0x87, 0x00, 0x00, 0xF3, 0x39, 0x39, 0xCF, 0x79, 0xF3, 0x00, 0x00, 0x01, 0xF9, 0x39, 0xCF, 0x61, 0xF9, 0x00, 0x00, 0x33, 0xF9, 0x03, 0xE7, 0x87, 0x81, 0x00, 0x00, 0x93, 0x03, 0x3F, 0xF3, 0x1B, 0x39, 0x00, 0x00, 0xC3, 0x3F, 0x9F, 0x39, 0x3B, 0x39, 0x00, 0x41, 0xE3, 0x03, 0xC3, 0x01, 0x87, 0x83, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xE7, 0x01, 0xC7, 0x81, 0x01, 0x83, 0x00, 0x00, 0xE7, 0x1F, 0x9B, 0xE7, 0x1F, 0x39, 0x00, 0x00, 0xE7, 0x8F, 0x39, 0xE7, 0x87, 0xF9, 0x00, 0x00, 0xC3, 0xC7, 0x39, 0xE7, 0xC3, 0xC3, 0x00, 0x00, 0x99, 0xE3, 0x39, 0xE7, 0xF1, 0xE7, 0x00, 0x00, 0x99, 0xF1, 0xB3, 0xC7, 0x39, 0xF3, 0x00, 0x00, 0x99, 0x01, 0xC7, 0xE7, 0x83, 0x81, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x83, 0xE7, 0x83, 0xEF, 0x39, 0x39, 0x00, 0x00, 0x39, 0xE7, 0x39, 0xC7, 0x11, 0x11, 0x00, 0x00, 0xF9, 0xE7, 0x39, 0x83, 0x01, 0x83, 0x00, 0x00, 0x83, 0xE7, 0x39, 0x11, 0x01, 0xC7, 0x00, 0x00, 0x3F, 0xE7, 0x39, 0x39, 0x29, 0x83, 0x00, 0x00, 0x33, 0xE7, 0x39, 0x39, 0x39, 0x11, 0x00, 0x00, 0x87, 0x81, 0x39, 0x39, 0x39, 0x39, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x39, 0x39, 0x83, 0x3F, 0x85, 0x31, 0x00, 0x00, 0x39, 0x31, 0x39, 0x3F, 0x33, 0x23, 0x00, 0x00, 0x29, 0x21, 0x39, 0x03, 0x21, 0x07, 0x00, 0x00, 0x01, 0x01, 0x39, 0x39, 0x39, 0x31, 0x00, 0x00, 0x01, 0x09, 0x39, 0x39, 0x39, 0x39, 0x00, 0x00, 0x11, 0x19, 0x39, 0x39, 0x39, 0x39, 0x00, 0x00, 0x39, 0x39, 0x83, 0x03, 0x83, 0x03, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xC1, 0x39, 0x81, 0x83, 0x31, 0x01, 0x00, 0x00, 0x99, 0x39, 0xE7, 0x39, 0x23, 0x3F, 0x00, 0x00, 0x39, 0x39, 0xE7, 0xF9, 0x07, 0x3F, 0x00, 0x00, 0x31, 0x01, 0xE7, 0xF9, 0x0F, 0x3F, 0x00, 0x00, 0x3F, 0x39, 0xE7, 0xF9, 0x27, 0x3F, 0x00, 0x00, 0x9F, 0x39, 0xE7, 0xF9, 0x33, 0x3F, 0x00, 0x00, 0xC1, 0x39, 0x81, 0xF9, 0x39, 0x3F, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x39, 0x03, 0xC3, 0x07, 0x01, 0x3F, 0x00, 0x00, 0x39, 0x39, 0x99, 0x33, 0x3F, 0x3F, 0x00, 0x00, 0x01, 0x39, 0x3F, 0x39, 0x3F, 0x3F, 0x00, 0x00, 0x39, 0x03, 0x3F, 0x39, 0x03, 0x03, 0x00, 0x00, 0x39, 0x39, 0x3F, 0x39, 0x3F, 0x3F, 0x00, 0x00, 0x93, 0x39, 0x99, 0x33, 0x3F, 0x3F, 0x00, 0x00, 0xC7, 0x03, 0xC3, 0x07, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00};
dbg_tex = SDL_CreateTextureFromSurface(dbg_ren, SDL_LoadBMP_RW(SDL_RWFromMem(font, 448), 1));
}
void dbg_print(int x, int y, const char *text, Uint8 r, Uint8 g, Uint8 b)
{
int cc = 0;
SDL_SetTextureColorMod(dbg_tex, r, g, b);
SDL_Rect src = {0, 0, 8, 8};
SDL_Rect dst = {x, y, 8, 8};
while (text[cc] != 0)
{
if (text[cc] != 32)
{
if (text[cc] >= 65)
{
src.x = ((text[cc] - 65) % 6) * 8;
src.y = ((text[cc] - 65) / 6) * 8;
}
else
{
src.x = ((text[cc] - 22) % 6) * 8;
src.y = ((text[cc] - 22) / 6) * 8;
}
SDL_RenderCopy(dbg_ren, dbg_tex, &src, &dst);
}
cc++;
dst.x += 8;
}
}

Some files were not shown because too many files have changed in this diff Show More