aboutsummaryrefslogtreecommitdiff
path: root/emulators/yuzu/files/patch-sdl2
blob: 2a55b9750e86099faa8c16027920480c4ae7c65c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252371

CMake Error at CMakeLists.txt:397 (find_package):
  Could not find a configuration file for package "SDL2" that is compatible
  with requested version "2.0.18".

  The following configuration files were considered but not accepted:

    /usr/local/lib/cmake/SDL2/sdl2-config.cmake, version: 2.0.12

--- CMakeLists.txt.orig	2021-12-06 23:09:30 UTC
+++ CMakeLists.txt
@@ -398,7 +398,7 @@ if (ENABLE_SDL2)
 endif()
 
 if (NOT YUZU_USE_BUNDLED_SDL2 AND NOT YUZU_USE_EXTERNAL_SDL2)
-        find_package(SDL2 2.0.18 REQUIRED)
+        find_package(SDL2 2.0.12 REQUIRED)
 
         # Some installations don't set SDL2_LIBRARIES
         if("${SDL2_LIBRARIES}" STREQUAL "")
--- src/input_common/drivers/sdl_driver.cpp.orig	2021-12-18 10:33:07 UTC
+++ src/input_common/drivers/sdl_driver.cpp
@@ -39,6 +39,7 @@ class SDLJoystick { (public)
     }
 
     void EnableMotion() {
+#if SDL_VERSION_ATLEAST(2,0,14)
         if (sdl_controller) {
             SDL_GameController* controller = sdl_controller.get();
             if (SDL_GameControllerHasSensor(controller, SDL_SENSOR_ACCEL) && !has_accel) {
@@ -50,6 +51,7 @@ class SDLJoystick { (public)
                 has_gyro = true;
             }
         }
+#endif
     }
 
     bool HasGyro() const {
@@ -60,6 +62,7 @@ class SDLJoystick { (public)
         return has_accel;
     }
 
+#if SDL_VERSION_ATLEAST(2,0,14)
     bool UpdateMotion(SDL_ControllerSensorEvent event) {
         constexpr float gravity_constant = 9.80665f;
         std::lock_guard lock{mutex};
@@ -87,6 +90,7 @@ class SDLJoystick { (public)
         motion.delta_timestamp = time_difference * 1000;
         return true;
     }
+#endif
 
     const BasicMotion& GetMotion() const {
         return motion;
@@ -362,6 +366,7 @@ void SDLDriver::HandleGameControllerEvent(const SDL_Ev
         }
         break;
     }
+#if SDL_VERSION_ATLEAST(2,0,14)
     case SDL_CONTROLLERSENSORUPDATE: {
         if (auto joystick = GetSDLJoystickBySDLID(event.csensor.which)) {
             if (joystick->UpdateMotion(event.csensor)) {
@@ -371,6 +376,7 @@ void SDLDriver::HandleGameControllerEvent(const SDL_Ev
         }
         break;
     }
+#endif
     case SDL_JOYDEVICEREMOVED:
         LOG_DEBUG(Input, "Controller removed with Instance_ID {}", event.jdevice.which);
         CloseJoystick(SDL_JoystickFromInstanceID(event.jdevice.which));
@@ -390,7 +396,7 @@ void SDLDriver::CloseJoysticks() {
 SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_engine_)) {
     if (!Settings::values.enable_raw_input) {
         // Disable raw input. When enabled this setting causes SDL to die when a web applet opens
-        SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT, "0");
+        SDL_SetHint("SDL_JOYSTICK_RAWINPUT", "0");
     }
 
     // Prevent SDL from adding undesired axis
@@ -398,12 +404,12 @@ SDLDriver::SDLDriver(std::string input_engine_) : Inpu
 
     // Enable HIDAPI rumble. This prevents SDL from disabling motion on PS4 and PS5 controllers
     SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1");
-    SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1");
+    SDL_SetHint("SDL_JOYSTICK_HIDAPI_PS5_RUMBLE", "1");
     SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
 
     // Use hidapi driver for joycons. This will allow joycons to be detected as a GameController and
     // not a generic one
-    SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "1");
+    SDL_SetHint("SDL_JOYSTICK_HIDAPI_JOY_CONS", "1");
 
     // Disable hidapi driver for xbox. Already default on Windows, this causes conflict with native
     // driver on Linux.
@@ -672,6 +678,7 @@ ButtonBindings SDLDriver::GetNintendoButtonBinding(
     auto sl_button = SDL_CONTROLLER_BUTTON_LEFTSHOULDER;
     auto sr_button = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER;
 
+#if SDL_VERSION_ATLEAST(2,0,14)
     if (joystick->IsJoyconLeft()) {
         sl_button = SDL_CONTROLLER_BUTTON_PADDLE2;
         sr_button = SDL_CONTROLLER_BUTTON_PADDLE4;
@@ -680,6 +687,7 @@ ButtonBindings SDLDriver::GetNintendoButtonBinding(
         sl_button = SDL_CONTROLLER_BUTTON_PADDLE3;
         sr_button = SDL_CONTROLLER_BUTTON_PADDLE1;
     }
+#endif
 
     return {
         std::pair{Settings::NativeButton::A, SDL_CONTROLLER_BUTTON_A},