From 35b2ffc8f51d69b33678586c82e8d6953d017dfc Mon Sep 17 00:00:00 2001 From: Jools Wills Date: Sat, 12 Sep 2015 19:44:33 +0100 Subject: [PATCH 01/11] update debian control/rules for retropie --- debian/control | 14 ++++++-------- debian/{libsdl2.install => libsdl2-2.0-0.install} | 0 debian/rules | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) rename debian/{libsdl2.install => libsdl2-2.0-0.install} (100%) diff --git a/debian/control b/debian/control index e116e9b34..844a52e08 100644 --- a/debian/control +++ b/debian/control @@ -12,8 +12,6 @@ Build-Depends: debhelper (>= 9), dh-autoreconf, dpkg-dev (>= 1.16.1~), libasound2-dev [linux-any], - libgl1-mesa-dev, - libpulse-dev, libudev-dev [linux-any], libdbus-1-dev [linux-any], libusb2-dev [kfreebsd-any], @@ -29,16 +27,16 @@ Build-Depends: debhelper (>= 9), libxxf86vm-dev Homepage: http://www.libsdl.org/ -Package: libsdl2 +Package: libsdl2-2.0-0 Architecture: any Multi-Arch: same Pre-Depends: ${misc:Pre-Depends} Depends: ${misc:Depends}, ${shlibs:Depends}, - libudev0 [linux-any], + libudev0 | libudev1 [linux-any], libdbus-1-3 [linux-any] -Conflicts: libsdl-1.3-0 -Replaces: libsdl-1.3-0 +Conflicts: libsdl-1.3-0, libsdl2 +Replaces: libsdl-1.3-0, libsdl2 Description: Simple DirectMedia Layer SDL is a library that allows programs portable low level access to a video framebuffer, audio output, mouse, and keyboard. @@ -50,7 +48,7 @@ Section: libdevel Architecture: any Multi-Arch: same Depends: ${misc:Depends}, - libsdl2 (= ${binary:Version}), + libsdl2-2.0-0 (= ${binary:Version}), libc6-dev, libgl1-mesa-dev Conflicts: libsdl-1.3-dev @@ -67,7 +65,7 @@ Section: debug Architecture: any Multi-Arch: same Depends: ${misc:Depends}, - libsdl2 (= ${binary:Version}), + libsdl2-2.0-0 (= ${binary:Version}), Description: Simple DirectMedia Layer debug files SDL is a library that allows programs portable low level access to a video framebuffer, audio output, mouse, and keyboard. diff --git a/debian/libsdl2.install b/debian/libsdl2-2.0-0.install similarity index 100% rename from debian/libsdl2.install rename to debian/libsdl2-2.0-0.install diff --git a/debian/rules b/debian/rules index 4bde8f325..ba24ae163 100755 --- a/debian/rules +++ b/debian/rules @@ -6,7 +6,7 @@ DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) confflags = --disable-rpath --disable-video-directfb \ --disable-nas --disable-esd --disable-arts \ --disable-alsa-shared --disable-pulseaudio-shared \ - --disable-x11-shared + --disable-x11-shared --host=armv6l-raspberry-linux-gnueabihf --disable-video-opengl --enable-video-gles --disable-esd --disable-pulseaudio %: dh $@ --parallel From 73e9772ad3a444407880b3bf04fe6e9bd4def5e8 Mon Sep 17 00:00:00 2001 From: Jools Wills Date: Sun, 22 Nov 2015 15:54:43 +0000 Subject: [PATCH 02/11] split configure options onto multiple lines --- debian/rules | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/rules b/debian/rules index ba24ae163..2aa196c45 100755 --- a/debian/rules +++ b/debian/rules @@ -6,7 +6,9 @@ DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) confflags = --disable-rpath --disable-video-directfb \ --disable-nas --disable-esd --disable-arts \ --disable-alsa-shared --disable-pulseaudio-shared \ - --disable-x11-shared --host=armv6l-raspberry-linux-gnueabihf --disable-video-opengl --enable-video-gles --disable-esd --disable-pulseaudio + --disable-x11-shared --disable-video-opengl --enable-video-gles \ + --disable-esd --disable-pulseaudio \ + --host=armv6l-raspberry-linux-gnueabihf %: dh $@ --parallel From a991a65cf1b7831bb425674f187840c833f506fc Mon Sep 17 00:00:00 2001 From: Jools Wills Date: Sun, 22 Nov 2015 15:55:38 +0000 Subject: [PATCH 03/11] disable tslib as it doesn't exist in Debian Jessie but does exist in Raspbian Jessie and we want to use the same binaries on both --- debian/rules | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/rules b/debian/rules index 2aa196c45..400c154c4 100755 --- a/debian/rules +++ b/debian/rules @@ -8,6 +8,7 @@ confflags = --disable-rpath --disable-video-directfb \ --disable-alsa-shared --disable-pulseaudio-shared \ --disable-x11-shared --disable-video-opengl --enable-video-gles \ --disable-esd --disable-pulseaudio \ + --disable-input-tslib \ --host=armv6l-raspberry-linux-gnueabihf %: From 220c56e1118d8897197b605f42544ebf814bb020 Mon Sep 17 00:00:00 2001 From: Jools Wills Date: Sun, 22 Nov 2015 16:34:38 +0000 Subject: [PATCH 04/11] correct configure option to enable opengles --- debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/rules b/debian/rules index 400c154c4..e3a2e88bb 100755 --- a/debian/rules +++ b/debian/rules @@ -6,7 +6,7 @@ DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) confflags = --disable-rpath --disable-video-directfb \ --disable-nas --disable-esd --disable-arts \ --disable-alsa-shared --disable-pulseaudio-shared \ - --disable-x11-shared --disable-video-opengl --enable-video-gles \ + --disable-x11-shared --disable-video-opengl --enable-video-opengles \ --disable-esd --disable-pulseaudio \ --disable-input-tslib \ --host=armv6l-raspberry-linux-gnueabihf From 0e43d4b1e07a035031b0b5c73e4b0e2e37fdc35d Mon Sep 17 00:00:00 2001 From: Jools Wills Date: Sun, 22 Nov 2015 17:00:52 +0000 Subject: [PATCH 05/11] remove gl1-mesa-dev dependency --- debian/control | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/debian/control b/debian/control index 844a52e08..2dceefc30 100644 --- a/debian/control +++ b/debian/control @@ -49,8 +49,7 @@ Architecture: any Multi-Arch: same Depends: ${misc:Depends}, libsdl2-2.0-0 (= ${binary:Version}), - libc6-dev, - libgl1-mesa-dev + libc6-dev Conflicts: libsdl-1.3-dev Replaces: libsdl-1.3-dev Description: Simple DirectMedia Layer development files From 5ae53916772ca29bf15c4be6dee6f32a6a09332f Mon Sep 17 00:00:00 2001 From: Jools Wills Date: Sun, 13 Dec 2015 03:22:49 +0000 Subject: [PATCH 06/11] added libx11-dev dependency for libsdl2-dev --- debian/control | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 2dceefc30..e4959485d 100644 --- a/debian/control +++ b/debian/control @@ -49,7 +49,8 @@ Architecture: any Multi-Arch: same Depends: ${misc:Depends}, libsdl2-2.0-0 (= ${binary:Version}), - libc6-dev + libc6-dev, + libx11-dev Conflicts: libsdl-1.3-dev Replaces: libsdl-1.3-dev Description: Simple DirectMedia Layer development files From 6b81462524209907eaa4aba72637eedbee205add Mon Sep 17 00:00:00 2001 From: Jools Wills Date: Wed, 17 Feb 2016 14:23:53 +0000 Subject: [PATCH 07/11] added /usr/lib/*/cmake/SDL2 to installed files --- debian/libsdl2-dev.install | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/libsdl2-dev.install b/debian/libsdl2-dev.install index 7f99ff427..e28e5df88 100644 --- a/debian/libsdl2-dev.install +++ b/debian/libsdl2-dev.install @@ -5,4 +5,5 @@ usr/lib/*/libSDL2.a usr/lib/*/libSDL2main.a usr/lib/*/libSDL2_test.a usr/lib/*/pkgconfig/sdl2.pc +usr/lib/*/cmake/SDL2 usr/share/aclocal/sdl2.m4 From 57fc057a74168974d7db52e6c8ae4bee9b764930 Mon Sep 17 00:00:00 2001 From: Jools Wills Date: Sat, 9 Apr 2016 22:07:12 +0100 Subject: [PATCH 08/11] Revert "Linux joystick: Look at entire axis namespace for controls (thanks, "spaz16"!)." This reverts commit 4cb7923f251543c1175c1702f8cf8b4201ce9054. see https://github.com/RetroPie/RetroPie-Setup/issues/1297 --- src/joystick/linux/SDL_sysjoystick.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index 8c73859ea..44e541357 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -492,7 +492,7 @@ ConfigJoystick(SDL_Joystick * joystick, int fd) ++joystick->nbuttons; } } - for (i = 0; i < ABS_MAX; ++i) { + for (i = 0; i < ABS_MISC; ++i) { /* Skip hats */ if (i == ABS_HAT0X) { i = ABS_HAT3Y; @@ -753,6 +753,10 @@ HandleInputEvents(SDL_Joystick * joystick) } break; case EV_ABS: + if (code >= ABS_MISC) { + break; + } + switch (code) { case ABS_HAT0X: case ABS_HAT0Y: From dbd2aa77539e9ace9d761e5781be5bb3b60b322b Mon Sep 17 00:00:00 2001 From: Jools Wills Date: Fri, 22 Apr 2016 20:36:23 +0100 Subject: [PATCH 09/11] silence log output for unknown input --- src/core/linux/SDL_evdev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/linux/SDL_evdev.c b/src/core/linux/SDL_evdev.c index a8f2b138e..741b4e4a5 100644 --- a/src/core/linux/SDL_evdev.c +++ b/src/core/linux/SDL_evdev.c @@ -712,9 +712,11 @@ SDL_EVDEV_translate_keycode(int keycode) if (keycode < SDL_arraysize(EVDEV_Keycodes)) { scancode = EVDEV_Keycodes[keycode]; } + /* if (scancode == SDL_SCANCODE_UNKNOWN) { SDL_Log("The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL mailing list EVDEV KeyCode %d \n", keycode); } + */ return scancode; } From c1a44d38a0bd9e0c8728ade16be188b2bc9da673 Mon Sep 17 00:00:00 2001 From: Stefan Date: Wed, 6 Jul 2016 21:53:43 +0200 Subject: [PATCH 10/11] Use dispmanx scaling (#1) * Use dispmanx scaling * There is the new SDL hint SDL_VIDEO_RPI_SCALE_MODE. There are three values. * The variable can be set to the following values: * "0" - Window resolution is desktop resolution. * This is the behaviour of SDL <= 2.0.4. (default) * "1" - Requested video resolution will be scaled to desktop resolution. * Aspect ratio of requested video resolution will be respected. * "2" - Requested video resolution will be scaled to desktop resolution. * Add aspect ratio hint --- include/SDL_hints.h | 23 ++++++++++ src/video/raspberry/SDL_rpivideo.c | 67 ++++++++++++++++++++++++++---- 2 files changed, 81 insertions(+), 9 deletions(-) diff --git a/include/SDL_hints.h b/include/SDL_hints.h index 3bd5435fb..d245243f7 100644 --- a/include/SDL_hints.h +++ b/include/SDL_hints.h @@ -621,6 +621,29 @@ extern "C" { */ #define SDL_HINT_NO_SIGNAL_HANDLERS "SDL_NO_SIGNAL_HANDLERS" +/** + * \brief Tell dispmanx to stretch the SDL window to fill the display. + * + * This hint only applies to the rpi video driver. + * + * The variable can be set to the following values: + * "0" - Window resolution is desktop resolution. + * This is the behaviour of SDL <= 2.0.4. (default) + * "1" - Requested video resolution will be scaled to desktop resolution. + * Aspect ratio of requested video resolution will be respected. + * "2" - Requested video resolution will be scaled to desktop resolution. + */ +#define SDL_HINT_VIDEO_RPI_SCALE_MODE "SDL_VIDEO_RPI_SCALE_MODE" + +/** + * \brief Tell dispmanx to set an specific aspect ratio. + * + * This hint only applies to the rpi video driver. + * + * Must be set together with SDL_HINT_VIDEO_RPI_SCALE_MODE=1. + */ +#define SDL_HINT_VIDEO_RPI_RATIO "SDL_VIDEO_RPI_RATIO" + /** * \brief Tell SDL not to generate window-close events for Alt+F4 on Windows. * diff --git a/src/video/raspberry/SDL_rpivideo.c b/src/video/raspberry/SDL_rpivideo.c index 539c88c9b..1886674bb 100644 --- a/src/video/raspberry/SDL_rpivideo.c +++ b/src/video/raspberry/SDL_rpivideo.c @@ -31,6 +31,7 @@ */ /* SDL internals */ +#include "SDL_hints.h" #include "../SDL_sysvideo.h" #include "SDL_version.h" #include "SDL_syswm.h" @@ -214,6 +215,9 @@ RPI_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) int RPI_CreateWindow(_THIS, SDL_Window * window) { + const char *hintScale = SDL_GetHint(SDL_HINT_VIDEO_RPI_SCALE_MODE); + const char *hintRatio = SDL_GetHint(SDL_HINT_VIDEO_RPI_RATIO); + char scalemode = '0'; SDL_WindowData *wdata; SDL_VideoDisplay *display; SDL_DisplayData *displaydata; @@ -235,23 +239,68 @@ RPI_CreateWindow(_THIS, SDL_Window * window) display = SDL_GetDisplayForWindow(window); displaydata = (SDL_DisplayData *) display->driverdata; - /* Windows have one size for now */ - window->w = display->desktop_mode.w; - window->h = display->desktop_mode.h; + float srcAspect = 1; + float dstAspect = 1; - /* OpenGL ES is the law here, buddy */ - window->flags |= SDL_WINDOW_OPENGL; + if (hintScale != NULL) + scalemode = *hintScale; /* Create a dispman element and associate a window to it */ - dst_rect.x = 0; - dst_rect.y = 0; - dst_rect.width = window->w; - dst_rect.height = window->h; + switch(scalemode) { + case '1': + /* Fullscreen mode. */ + /* Calculate source and destination aspect ratios. */ + if (hintRatio != NULL) + srcAspect = strtof(hintRatio, NULL); + else + srcAspect = (float)window->w / (float)window->h; + /* only allow sensible aspect ratios */ + if (srcAspect < 0.2f || srcAspect > 6.0f) + srcAspect = (float)window->w / (float)window->h; + dstAspect = (float)display->desktop_mode.w / (float)display->desktop_mode.h; + /* If source and destination aspect ratios are not equal correct destination width. */ + if (srcAspect < dstAspect) { + dst_rect.width = (unsigned)(display->desktop_mode.h * srcAspect); + dst_rect.height = display->desktop_mode.h; + } + else if (srcAspect > dstAspect) { + dst_rect.width = display->desktop_mode.w; + dst_rect.height = (unsigned)((float)display->desktop_mode.w / srcAspect); + } + else { + dst_rect.width = display->desktop_mode.w; + dst_rect.height = display->desktop_mode.h; + } + /* Center window. */ + dst_rect.x = (display->desktop_mode.w - dst_rect.width) / 2; + dst_rect.y = (display->desktop_mode.h - dst_rect.height) / 2; + break; + case '2': + /* Fullscreen streched mode. */ + dst_rect.x = 0; + dst_rect.y = 0; + dst_rect.width = display->desktop_mode.w; + dst_rect.height = display->desktop_mode.h; + break; + default: + /* Default mode. */ + window->w = display->desktop_mode.w; + window->h = display->desktop_mode.h; + + dst_rect.x = 0; + dst_rect.y = 0; + dst_rect.width = window->w; + dst_rect.height = window->h; + break; + } src_rect.x = 0; src_rect.y = 0; src_rect.width = window->w << 16; src_rect.height = window->h << 16; + + /* OpenGL ES is the law here, buddy */ + window->flags |= SDL_WINDOW_OPENGL; dispman_update = vc_dispmanx_update_start( 0 ); wdata->dispman_window.element = vc_dispmanx_element_add ( dispman_update, displaydata->dispman_display, SDL_RPI_VIDEOLAYER /* layer */, &dst_rect, 0/*src*/, &src_rect, DISPMANX_PROTECTION_NONE, &dispman_alpha /*alpha*/, 0/*clamp*/, 0/*transform*/); From ed92568fb6a7ff20a22159def2f586f8ff304120 Mon Sep 17 00:00:00 2001 From: Stefan Date: Thu, 14 Jul 2016 21:12:29 +0200 Subject: [PATCH 11/11] Add integer scaling option (#2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds option ‚3‘ integer scaling. dst_rect is an integral multiple of src_rect. Should prevent scaling artifacts. --- include/SDL_hints.h | 6 +++++- src/video/raspberry/SDL_rpivideo.c | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/SDL_hints.h b/include/SDL_hints.h index d245243f7..5fc5f5c70 100644 --- a/include/SDL_hints.h +++ b/include/SDL_hints.h @@ -632,11 +632,15 @@ extern "C" { * "1" - Requested video resolution will be scaled to desktop resolution. * Aspect ratio of requested video resolution will be respected. * "2" - Requested video resolution will be scaled to desktop resolution. + * "3" - Requested video resolution will be scaled to desktop resolution. + * Aspect ratio of requested video resolution will be respected. + * If possible output resolution will be integral multiple of video + * resolution. */ #define SDL_HINT_VIDEO_RPI_SCALE_MODE "SDL_VIDEO_RPI_SCALE_MODE" /** - * \brief Tell dispmanx to set an specific aspect ratio. + * \brief Tell dispmanx to set a specific aspect ratio. * * This hint only applies to the rpi video driver. * diff --git a/src/video/raspberry/SDL_rpivideo.c b/src/video/raspberry/SDL_rpivideo.c index 1886674bb..a2fcf6f1e 100644 --- a/src/video/raspberry/SDL_rpivideo.c +++ b/src/video/raspberry/SDL_rpivideo.c @@ -241,12 +241,33 @@ RPI_CreateWindow(_THIS, SDL_Window * window) float srcAspect = 1; float dstAspect = 1; + int factor_x = 0; + int factor_y = 0; if (hintScale != NULL) scalemode = *hintScale; /* Create a dispman element and associate a window to it */ switch(scalemode) { + case '3': + /* Pixel perfect scaling mode. */ + factor_x = (display->desktop_mode.w / window->w); + factor_y = (display->desktop_mode.h / window->h); + if ((factor_x != 0) && (factor_y != 0)) { + if (factor_x >= factor_y) { + dst_rect.width = window->w * factor_y; + dst_rect.height = window->h * factor_y; + } + else { + dst_rect.width = window->w * factor_x; + dst_rect.height = window->h * factor_x; + } + /* Center window. */ + dst_rect.x = (display->desktop_mode.w - dst_rect.width) / 2; + dst_rect.y = (display->desktop_mode.h - dst_rect.height) / 2; + break; + } + /* If integer scale is not possible fallback to mode 1. */ case '1': /* Fullscreen mode. */ /* Calculate source and destination aspect ratios. */