You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Add support for SDL3 joystick input driver
Made possible by EIREXE, xsellier and the SDL team. This commit includes statically linked SDL3 for Windows, Linux and macOS. The vendored copy of SDL3 was setup to only build the required subsystems for gamepad/joystick support, with some patches to be able to make it as minimal as possible and reduce the impact on binary size and code size. Co-authored-by: Álex Román Núñez <eirexe123@gmail.com> Co-authored-by: Xavier Sellier <xsellier@gmail.com> Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
This commit is contained in:
committed by
Rémi Verschelde
parent
987832be46
commit
0b3496fb4f
@@ -32,6 +32,9 @@
|
||||
|
||||
#include "core/io/certs_compressed.gen.h"
|
||||
#include "core/io/dir_access.h"
|
||||
#ifdef SDL_ENABLED
|
||||
#include "drivers/sdl/joypad_sdl.h"
|
||||
#endif
|
||||
#include "main/main.h"
|
||||
#include "servers/display_server.h"
|
||||
#include "servers/rendering_server.h"
|
||||
@@ -158,8 +161,13 @@ void OS_LinuxBSD::initialize() {
|
||||
}
|
||||
|
||||
void OS_LinuxBSD::initialize_joypads() {
|
||||
#ifdef JOYDEV_ENABLED
|
||||
joypad = memnew(JoypadLinux(Input::get_singleton()));
|
||||
#ifdef SDL_ENABLED
|
||||
joypad_sdl = memnew(JoypadSDL());
|
||||
if (joypad_sdl->initialize() != OK) {
|
||||
ERR_PRINT("Couldn't initialize SDL joypad input driver.");
|
||||
memdelete(joypad_sdl);
|
||||
joypad_sdl = nullptr;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -241,9 +249,9 @@ void OS_LinuxBSD::finalize() {
|
||||
driver_alsamidi.close();
|
||||
#endif
|
||||
|
||||
#ifdef JOYDEV_ENABLED
|
||||
if (joypad) {
|
||||
memdelete(joypad);
|
||||
#ifdef SDL_ENABLED
|
||||
if (joypad_sdl) {
|
||||
memdelete(joypad_sdl);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -973,8 +981,10 @@ void OS_LinuxBSD::run() {
|
||||
|
||||
while (true) {
|
||||
DisplayServer::get_singleton()->process_events(); // get rid of pending events
|
||||
#ifdef JOYDEV_ENABLED
|
||||
joypad->process_joypads();
|
||||
#ifdef SDL_ENABLED
|
||||
if (joypad_sdl) {
|
||||
joypad_sdl->process_events();
|
||||
}
|
||||
#endif
|
||||
if (Main::iteration()) {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user