Browse Source

Merge pull request #1874 from MikuAuahDark/sdl209

Bump minimum SDL version to 2.0.9
Sasha Szpakowski 2 years ago
parent
commit
8119b87b89

+ 1 - 1
CMakeLists.txt

@@ -172,7 +172,7 @@ Please see https://github.com/love2d/megasource
 	find_package(ModPlug REQUIRED)
 	find_package(ModPlug REQUIRED)
 	find_package(OpenAL REQUIRED)
 	find_package(OpenAL REQUIRED)
 	find_package(OpenGL REQUIRED)
 	find_package(OpenGL REQUIRED)
-	find_package(SDL2 REQUIRED)
+	find_package(SDL2 2.0.9 REQUIRED)
 	find_package(Theora REQUIRED)
 	find_package(Theora REQUIRED)
 	find_package(Vorbis REQUIRED)
 	find_package(Vorbis REQUIRED)
 	find_package(ZLIB REQUIRED)
 	find_package(ZLIB REQUIRED)

+ 1 - 1
platform/unix/deps.m4

@@ -21,7 +21,7 @@ AC_DEFUN([ACLOVE_DEP_LIBM], [
 
 
 AC_DEFUN([ACLOVE_DEP_SDL2], [
 AC_DEFUN([ACLOVE_DEP_SDL2], [
 	aclove_sdl2_found=no
 	aclove_sdl2_found=no
-	AM_PATH_SDL2([], [aclove_sdl2_found=yes], [])
+	AM_PATH_SDL2([2.0.9], [aclove_sdl2_found=yes], [])
 	AS_VAR_IF([aclove_sdl2_found], [no], [LOVE_MSG_ERROR([SDL 2])], [])])
 	AS_VAR_IF([aclove_sdl2_found], [no], [LOVE_MSG_ERROR([SDL 2])], [])])
 
 
 AC_DEFUN([ACLOVE_DEP_PTHREAD], [
 AC_DEFUN([ACLOVE_DEP_PTHREAD], [

+ 3 - 22
src/modules/event/sdl/Event.cpp

@@ -193,10 +193,6 @@ Message *Event::convert(const SDL_Event &e)
 	love::touch::Touch::TouchInfo touchinfo;
 	love::touch::Touch::TouchInfo touchinfo;
 #endif
 #endif
 
 
-#ifdef LOVE_LINUX
-	static bool touchNormalizationBug = false;
-#endif
-
 	switch (e.type)
 	switch (e.type)
 	{
 	{
 	case SDL_KEYDOWN:
 	case SDL_KEYDOWN:
@@ -315,22 +311,9 @@ Message *Event::convert(const SDL_Event &e)
 		touchinfo.dy = e.tfinger.dy;
 		touchinfo.dy = e.tfinger.dy;
 		touchinfo.pressure = e.tfinger.pressure;
 		touchinfo.pressure = e.tfinger.pressure;
 
 
-#ifdef LOVE_LINUX
-		// FIXME: hacky workaround for SDL not normalizing touch coordinates in
-		// its X11 backend: https://bugzilla.libsdl.org/show_bug.cgi?id=2307
-		if (touchNormalizationBug || fabs(touchinfo.x) >= 1.5 || fabs(touchinfo.y) >= 1.5 || fabs(touchinfo.dx) >= 1.5 || fabs(touchinfo.dy) >= 1.5)
-		{
-			touchNormalizationBug = true;
-			windowToDPICoords(&touchinfo.x, &touchinfo.y);
-			windowToDPICoords(&touchinfo.dx, &touchinfo.dy);
-		}
-		else
-#endif
-		{
-			// SDL's coords are normalized to [0, 1], but we want screen coords.
-			normalizedToDPICoords(&touchinfo.x, &touchinfo.y);
-			normalizedToDPICoords(&touchinfo.dx, &touchinfo.dy);
-		}
+		// SDL's coords are normalized to [0, 1], but we want screen coords.
+		normalizedToDPICoords(&touchinfo.x, &touchinfo.y);
+		normalizedToDPICoords(&touchinfo.dx, &touchinfo.dy);
 
 
 		// We need to update the love.touch.sdl internal state from here.
 		// We need to update the love.touch.sdl internal state from here.
 		touchmodule = (touch::sdl::Touch *) Module::getInstance("love.touch.sdl");
 		touchmodule = (touch::sdl::Touch *) Module::getInstance("love.touch.sdl");
@@ -374,7 +357,6 @@ Message *Event::convert(const SDL_Event &e)
 	case SDL_WINDOWEVENT:
 	case SDL_WINDOWEVENT:
 		msg = convertWindowEvent(e);
 		msg = convertWindowEvent(e);
 		break;
 		break;
-#if SDL_VERSION_ATLEAST(2, 0, 9)
 	case SDL_DISPLAYEVENT:
 	case SDL_DISPLAYEVENT:
 		if (e.display.event == SDL_DISPLAYEVENT_ORIENTATION)
 		if (e.display.event == SDL_DISPLAYEVENT_ORIENTATION)
 		{
 		{
@@ -408,7 +390,6 @@ Message *Event::convert(const SDL_Event &e)
 			msg = new Message("displayrotated", vargs);
 			msg = new Message("displayrotated", vargs);
 		}
 		}
 		break;
 		break;
-#endif
 	case SDL_DROPFILE:
 	case SDL_DROPFILE:
 		filesystem = Module::getInstance<filesystem::Filesystem>(Module::M_FILESYSTEM);
 		filesystem = Module::getInstance<filesystem::Filesystem>(Module::M_FILESYSTEM);
 		if (filesystem != nullptr)
 		if (filesystem != nullptr)

+ 0 - 6
src/modules/joystick/sdl/Joystick.cpp

@@ -413,7 +413,6 @@ int Joystick::getID() const
 
 
 void Joystick::getDeviceInfo(int &vendorID, int &productID, int &productVersion) const
 void Joystick::getDeviceInfo(int &vendorID, int &productID, int &productVersion) const
 {
 {
-#if SDL_VERSION_ATLEAST(2, 0, 6)
 	if (joyhandle != nullptr)
 	if (joyhandle != nullptr)
 	{
 	{
 		vendorID = SDL_JoystickGetVendor(joyhandle);
 		vendorID = SDL_JoystickGetVendor(joyhandle);
@@ -421,7 +420,6 @@ void Joystick::getDeviceInfo(int &vendorID, int &productID, int &productVersion)
 		productVersion = SDL_JoystickGetProductVersion(joyhandle);
 		productVersion = SDL_JoystickGetProductVersion(joyhandle);
 	}
 	}
 	else
 	else
-#endif
 	{
 	{
 		vendorID = 0;
 		vendorID = 0;
 		productID = 0;
 		productID = 0;
@@ -525,10 +523,8 @@ bool Joystick::setVibration(float left, float right, float duration)
 
 
 	bool success = false;
 	bool success = false;
 
 
-#if SDL_VERSION_ATLEAST(2, 0, 9)
 	if (SDL_JoystickRumble(joyhandle, (Uint16)(left * LOVE_UINT16_MAX), (Uint16)(right * LOVE_UINT16_MAX), length) == 0)
 	if (SDL_JoystickRumble(joyhandle, (Uint16)(left * LOVE_UINT16_MAX), (Uint16)(right * LOVE_UINT16_MAX), length) == 0)
 		success = true;
 		success = true;
-#endif
 
 
 	if (!success && !checkCreateHaptic())
 	if (!success && !checkCreateHaptic())
 		return false;
 		return false;
@@ -610,10 +606,8 @@ bool Joystick::setVibration()
 {
 {
 	bool success = false;
 	bool success = false;
 
 
-#if SDL_VERSION_ATLEAST(2, 0, 9)
 	if (!success)
 	if (!success)
 		success = isConnected() && SDL_JoystickRumble(joyhandle, 0, 0, 0) == 0;
 		success = isConnected() && SDL_JoystickRumble(joyhandle, 0, 0, 0) == 0;
-#endif
 
 
 	if (!success && SDL_WasInit(SDL_INIT_HAPTIC) && haptic && SDL_HapticIndex(haptic) != -1)
 	if (!success && SDL_WasInit(SDL_INIT_HAPTIC) && haptic && SDL_HapticIndex(haptic) != -1)
 		success = (SDL_HapticStopEffect(haptic, vibration.id) == 0);
 		success = (SDL_HapticStopEffect(haptic, vibration.id) == 0);

+ 0 - 10
src/modules/window/sdl/Window.cpp

@@ -588,12 +588,8 @@ bool Window::setWindow(int width, int height, WindowSettings *settings)
 		if (!f.fullscreen)
 		if (!f.fullscreen)
 			SDL_SetWindowSize(window, width, height);
 			SDL_SetWindowSize(window, width, height);
 
 
-		// On linux systems 2.0.5+ might not be available...
-		// TODO: require at least 2.0.5?
-#if SDL_VERSION_ATLEAST(2, 0, 5)
 		if (this->settings.resizable != f.resizable)
 		if (this->settings.resizable != f.resizable)
 			SDL_SetWindowResizable(window, f.resizable ? SDL_TRUE : SDL_FALSE);
 			SDL_SetWindowResizable(window, f.resizable ? SDL_TRUE : SDL_FALSE);
-#endif
 
 
 		if (this->settings.borderless != f.borderless)
 		if (this->settings.borderless != f.borderless)
 			SDL_SetWindowBordered(window, f.borderless ? SDL_FALSE : SDL_TRUE);
 			SDL_SetWindowBordered(window, f.borderless ? SDL_FALSE : SDL_TRUE);
@@ -909,9 +905,6 @@ const char *Window::getDisplayName(int displayindex) const
 
 
 Window::DisplayOrientation Window::getDisplayOrientation(int displayindex) const
 Window::DisplayOrientation Window::getDisplayOrientation(int displayindex) const
 {
 {
-	// TODO: We can expose this everywhere, we just need to watch out for the
-	// SDL binary being older than the headers on Linux.
-#if SDL_VERSION_ATLEAST(2, 0, 9) && (defined(LOVE_ANDROID) || !defined(LOVE_LINUX))
 	switch (SDL_GetDisplayOrientation(displayindex))
 	switch (SDL_GetDisplayOrientation(displayindex))
 	{
 	{
 		case SDL_ORIENTATION_UNKNOWN: return ORIENTATION_UNKNOWN;
 		case SDL_ORIENTATION_UNKNOWN: return ORIENTATION_UNKNOWN;
@@ -920,9 +913,6 @@ Window::DisplayOrientation Window::getDisplayOrientation(int displayindex) const
 		case SDL_ORIENTATION_PORTRAIT: return ORIENTATION_PORTRAIT;
 		case SDL_ORIENTATION_PORTRAIT: return ORIENTATION_PORTRAIT;
 		case SDL_ORIENTATION_PORTRAIT_FLIPPED: return ORIENTATION_PORTRAIT_FLIPPED;
 		case SDL_ORIENTATION_PORTRAIT_FLIPPED: return ORIENTATION_PORTRAIT_FLIPPED;
 	}
 	}
-#else
-	LOVE_UNUSED(displayindex);
-#endif
 
 
 	return ORIENTATION_UNKNOWN;
 	return ORIENTATION_UNKNOWN;
 }
 }