Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 10 additions & 0 deletions COPYRIGHT.txt
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,16 @@ Comment: RVO2
Copyright: 2016, University of North Carolina at Chapel Hill
License: Apache-2.0

Files: thirdparty/sdl/*
Comment: SDL
Copyright: 1997-2025, Sam Lantinga
License: Zlib

Files: thirdparty/sdl/hidapi/*
Comment: hidapi
Copyright: 2010, Alan Ott, Signal 11 Software
License: BSD-3-Clause

Files: thirdparty/spirv-cross/*
Comment: SPIRV-Cross
Copyright: 2015-2021, Arm Limited
Expand Down
10 changes: 6 additions & 4 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,14 @@ opts.Add(
opts.Add(BoolVariable("minizip", "Enable ZIP archive support using minizip", True))
opts.Add(BoolVariable("brotli", "Enable Brotli for decompression and WOFF2 fonts support", True))
opts.Add(BoolVariable("xaudio2", "Enable the XAudio2 audio driver on supported platforms", False))
opts.Add(BoolVariable("vulkan", "Enable the vulkan rendering driver", True))
opts.Add(BoolVariable("vulkan", "Enable the Vulkan rendering driver", True))
opts.Add(BoolVariable("opengl3", "Enable the OpenGL/GLES3 rendering driver", True))
opts.Add(BoolVariable("d3d12", "Enable the Direct3D 12 rendering driver on supported platforms", False))
opts.Add(BoolVariable("metal", "Enable the Metal rendering driver on supported platforms (Apple arm64 only)", False))
opts.Add(BoolVariable("use_volk", "Use the volk library to load the Vulkan loader dynamically", True))
opts.Add(BoolVariable("disable_exceptions", "Force disabling exception handling code", True))
opts.Add("custom_modules", "A list of comma-separated directory paths containing custom modules to build.", "")
opts.Add(BoolVariable("custom_modules_recursive", "Detect custom modules recursively for each specified path.", True))
opts.Add(BoolVariable("accesskit", "Use AccessKit C SDK", True))
opts.Add(("accesskit_sdk_path", "Path to the AccessKit C SDK", ""))
opts.Add(BoolVariable("sdl", "Enable the SDL3 input driver", True))

# Advanced options
opts.Add(
Expand Down Expand Up @@ -233,6 +231,7 @@ opts.Add("object_prefix", "Custom prefix added to the base filename of all gener
opts.Add(BoolVariable("vsproj", "Generate a Visual Studio solution", False))
opts.Add("vsproj_name", "Name of the Visual Studio solution", "godot")
opts.Add("import_env_vars", "A comma-separated list of environment variables to copy from the outer environment.", "")
opts.Add(BoolVariable("disable_exceptions", "Force disabling exception handling code", True))
opts.Add(BoolVariable("disable_3d", "Disable 3D nodes for a smaller executable", False))
opts.Add(BoolVariable("disable_advanced_gui", "Disable advanced GUI nodes and behaviors", False))
opts.Add(BoolVariable("disable_physics_2d", "Disable 2D physics nodes and server", False))
Expand All @@ -241,6 +240,8 @@ opts.Add(BoolVariable("disable_navigation_2d", "Disable 2D navigation features",
opts.Add(BoolVariable("disable_navigation_3d", "Disable 3D navigation features", False))
opts.Add(BoolVariable("disable_xr", "Disable XR nodes and server", False))
opts.Add("build_profile", "Path to a file containing a feature build profile", "")
opts.Add("custom_modules", "A list of comma-separated directory paths containing custom modules to build.", "")
opts.Add(BoolVariable("custom_modules_recursive", "Detect custom modules recursively for each specified path.", True))
opts.Add(BoolVariable("modules_enabled_by_default", "If no, disable all modules except ones explicitly enabled", True))
opts.Add(BoolVariable("no_editor_splash", "Don't use the custom splash screen for the editor", True))
opts.Add(
Expand Down Expand Up @@ -275,6 +276,7 @@ opts.Add(BoolVariable("builtin_msdfgen", "Use the built-in MSDFgen library", Tru
opts.Add(BoolVariable("builtin_glslang", "Use the built-in glslang library", True))
opts.Add(BoolVariable("builtin_graphite", "Use the built-in Graphite library", True))
opts.Add(BoolVariable("builtin_harfbuzz", "Use the built-in HarfBuzz library", True))
opts.Add(BoolVariable("builtin_sdl", "Use the built-in SDL library", True))
opts.Add(BoolVariable("builtin_icu4c", "Use the built-in ICU library", True))
opts.Add(BoolVariable("builtin_libjpeg_turbo", "Use the built-in libjpeg-turbo library", True))
opts.Add(BoolVariable("builtin_libogg", "Use the built-in libogg library", True))
Expand Down
10 changes: 7 additions & 3 deletions core/input/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,13 @@ void Input::joy_connection_changed(int p_idx, bool p_connected, const String &p_
js.uid = uidname;
js.connected = true;
int mapping = fallback_mapping;
for (int i = 0; i < map_db.size(); i++) {
if (js.uid == map_db[i].uid) {
mapping = i;
// Bypass the mapping system if the joypad's mapping is already handled by its driver
// (for example, the SDL joypad driver).
if (!p_joypad_info.get("mapping_handled", false)) {
for (int i = 0; i < map_db.size(); i++) {
if (js.uid == map_db[i].uid) {
mapping = i;
}
}
}
_set_joypad_mapping(js, mapping);
Expand Down
5 changes: 5 additions & 0 deletions drivers/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ if env["metal"]:
Exit(255)
SConscript("metal/SCsub")

# Input drivers
if env["sdl"] and env["platform"] in ["linuxbsd", "macos", "windows"]:
# TODO: Evaluate support for Android, iOS, and Web.
SConscript("sdl/SCsub")

# Core dependencies
SConscript("png/SCsub")

Expand Down
209 changes: 209 additions & 0 deletions drivers/sdl/SCsub
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
#!/usr/bin/env python
from misc.utility.scons_hints import *

Import("env")

env_sdl = env.Clone()

# Thirdparty source files

thirdparty_obj = []

if env["builtin_sdl"]:
thirdparty_dir = "#thirdparty/sdl/"

# Use our own SDL_build_config_private.h.
env_sdl.Prepend(CPPDEFINES=["SDL_PLATFORM_PRIVATE"])

# Common sources.

env_sdl.Prepend(
CPPPATH=[
thirdparty_dir,
thirdparty_dir + "include",
thirdparty_dir + "include/build_config",
".", # SDL_build_config_private.h
]
)

thirdparty_sources = [
"SDL.c",
"SDL_assert.c",
"SDL_error.c",
"SDL_guid.c",
"SDL_hashtable.c",
"SDL_hints.c",
"SDL_list.c",
"SDL_log.c",
"SDL_properties.c",
"SDL_utils.c",
"atomic/SDL_atomic.c",
"atomic/SDL_spinlock.c",
"events/SDL_events.c",
"events/SDL_eventwatch.c",
"haptic/SDL_haptic.c",
"io/SDL_iostream.c",
"joystick/SDL_gamepad.c",
"joystick/SDL_joystick.c",
"joystick/SDL_steam_virtual_gamepad.c",
"joystick/controller_type.c",
"libm/e_atan2.c",
"libm/e_exp.c",
"libm/e_fmod.c",
"libm/e_log.c",
"libm/e_log10.c",
"libm/e_pow.c",
"libm/e_rem_pio2.c",
"libm/e_sqrt.c",
"libm/k_cos.c",
"libm/k_rem_pio2.c",
"libm/k_sin.c",
"libm/k_tan.c",
"libm/s_atan.c",
"libm/s_copysign.c",
"libm/s_cos.c",
"libm/s_fabs.c",
"libm/s_floor.c",
"libm/s_isinf.c",
"libm/s_isinff.c",
"libm/s_isnan.c",
"libm/s_isnanf.c",
"libm/s_modf.c",
"libm/s_scalbn.c",
"libm/s_sin.c",
"libm/s_tan.c",
"sensor/SDL_sensor.c",
"sensor/dummy/SDL_dummysensor.c",
"stdlib/SDL_crc16.c",
"stdlib/SDL_crc32.c",
"stdlib/SDL_getenv.c",
"stdlib/SDL_iconv.c",
"stdlib/SDL_malloc.c",
"stdlib/SDL_memcpy.c",
"stdlib/SDL_memmove.c",
"stdlib/SDL_memset.c",
"stdlib/SDL_mslibc.c",
"stdlib/SDL_murmur3.c",
"stdlib/SDL_qsort.c",
"stdlib/SDL_random.c",
"stdlib/SDL_stdlib.c",
"stdlib/SDL_string.c",
"stdlib/SDL_strtokr.c",
"thread/SDL_thread.c",
"thread/generic/SDL_syscond.c",
"thread/generic/SDL_sysrwlock.c",
"thread/generic/SDL_systhread.c",
"timer/SDL_timer.c",
]

# HIDAPI
thirdparty_sources += [
"hidapi/SDL_hidapi.c",
"joystick/hidapi/SDL_hidapi_combined.c",
"joystick/hidapi/SDL_hidapi_gamecube.c",
"joystick/hidapi/SDL_hidapijoystick.c",
"joystick/hidapi/SDL_hidapi_luna.c",
"joystick/hidapi/SDL_hidapi_ps3.c",
"joystick/hidapi/SDL_hidapi_ps4.c",
"joystick/hidapi/SDL_hidapi_ps5.c",
"joystick/hidapi/SDL_hidapi_rumble.c",
"joystick/hidapi/SDL_hidapi_shield.c",
"joystick/hidapi/SDL_hidapi_stadia.c",
"joystick/hidapi/SDL_hidapi_steam.c",
"joystick/hidapi/SDL_hidapi_steamdeck.c",
"joystick/hidapi/SDL_hidapi_steam_hori.c",
"joystick/hidapi/SDL_hidapi_switch.c",
"joystick/hidapi/SDL_hidapi_wii.c",
"joystick/hidapi/SDL_hidapi_xbox360.c",
"joystick/hidapi/SDL_hidapi_xbox360w.c",
"joystick/hidapi/SDL_hidapi_xboxone.c",
]

# Platform specific sources.

if env["platform"] == "linuxbsd":
# TODO: Check support for BSD systems.
env_sdl.Append(CPPDEFINES=["SDL_PLATFORM_LINUX"])
thirdparty_sources += [
"core/linux/SDL_dbus.c",
"core/linux/SDL_evdev.c",
"core/linux/SDL_evdev_capabilities.c",
"core/linux/SDL_evdev_kbd.c",
"core/linux/SDL_fcitx.c",
"core/linux/SDL_ibus.c",
"core/linux/SDL_ime.c",
"core/linux/SDL_system_theme.c",
"core/linux/SDL_threadprio.c",
"core/linux/SDL_udev.c",
"core/unix/SDL_appid.c",
"core/unix/SDL_poll.c",
"haptic/linux/SDL_syshaptic.c",
"joystick/linux/SDL_sysjoystick.c",
"loadso/dlopen/SDL_sysloadso.c",
"thread/pthread/SDL_syscond.c",
"thread/pthread/SDL_sysmutex.c",
"thread/pthread/SDL_sysrwlock.c",
"thread/pthread/SDL_syssem.c",
"thread/pthread/SDL_systhread.c",
"thread/pthread/SDL_systls.c",
"timer/unix/SDL_systimer.c",
]

elif env["platform"] == "macos":
env_sdl.Append(CPPDEFINES=["SDL_PLATFORM_MACOS"])
thirdparty_sources += [
"core/unix/SDL_appid.c",
"core/unix/SDL_poll.c",
"haptic/darwin/SDL_syshaptic.c",
"joystick/darwin/SDL_iokitjoystick.c",
"joystick/apple/SDL_mfijoystick.m",
"thread/pthread/SDL_syscond.c",
"thread/pthread/SDL_sysmutex.c",
"thread/pthread/SDL_sysrwlock.c",
"thread/pthread/SDL_syssem.c",
"thread/pthread/SDL_systhread.c",
"thread/pthread/SDL_systls.c",
"timer/unix/SDL_systimer.c",
]

elif env["platform"] == "windows":
env_sdl.Append(CPPDEFINES=["SDL_PLATFORM_WINDOWS"])
thirdparty_sources += [
"core/windows/SDL_gameinput.c",
"core/windows/SDL_hid.c",
"core/windows/SDL_immdevice.c",
"core/windows/SDL_windows.c",
"core/windows/SDL_xinput.c",
"core/windows/pch.c",
"haptic/windows/SDL_dinputhaptic.c",
"haptic/windows/SDL_windowshaptic.c",
"joystick/windows/SDL_dinputjoystick.c",
"joystick/windows/SDL_rawinputjoystick.c",
"joystick/windows/SDL_windows_gaming_input.c",
"joystick/windows/SDL_windowsjoystick.c",
"joystick/windows/SDL_xinputjoystick.c",
"thread/windows/SDL_syscond_cv.c",
"thread/windows/SDL_sysmutex.c",
"thread/windows/SDL_sysrwlock_srw.c",
"thread/windows/SDL_syssem.c",
"thread/windows/SDL_systhread.c",
"thread/windows/SDL_systls.c",
"timer/windows/SDL_systimer.c",
]

thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]

env_thirdparty = env_sdl.Clone()
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
env.drivers_sources += thirdparty_obj

# Godot source files

driver_obj = []

env_sdl.add_source_files(driver_obj, "*.cpp")
env.drivers_sources += driver_obj

# Needed to force rebuilding the driver files when the thirdparty library is updated.
env.Depends(driver_obj, thirdparty_obj)
Loading