Compare commits
9 commits
master
...
retropie-2
Author | SHA1 | Date | |
---|---|---|---|
|
ebfc9cfa45 | ||
|
96760a1e9e | ||
|
b294229dab | ||
|
ce8750827f | ||
|
a84d1ed7f9 | ||
|
844d54629e | ||
|
d9927c706c | ||
|
248d8c8447 | ||
|
8895abe2ce |
8 changed files with 149 additions and 102 deletions
17
debian/control
vendored
17
debian/control
vendored
|
@ -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],
|
||||
libibus-1.0-dev[linux-any],
|
||||
|
@ -30,16 +28,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.
|
||||
|
@ -51,9 +49,10 @@ Section: libdevel
|
|||
Architecture: any
|
||||
Multi-Arch: same
|
||||
Depends: ${misc:Depends},
|
||||
libsdl2 (= ${binary:Version}),
|
||||
libsdl2-2.0-0 (= ${binary:Version}),
|
||||
libc6-dev,
|
||||
libgl1-mesa-dev
|
||||
libgl1-mesa-dev,
|
||||
libx11-dev
|
||||
Conflicts: libsdl-1.3-dev
|
||||
Replaces: libsdl-1.3-dev
|
||||
Description: Simple DirectMedia Layer development files
|
||||
|
@ -68,7 +67,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.
|
||||
|
|
5
debian/rules
vendored
5
debian/rules
vendored
|
@ -6,7 +6,10 @@ 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 --disable-video-opengl --enable-video-opengles \
|
||||
--disable-esd --disable-pulseaudio \
|
||||
--disable-input-tslib \
|
||||
--host=armv6l-raspberry-linux-gnueabihf
|
||||
|
||||
%:
|
||||
dh $@ --parallel
|
||||
|
|
|
@ -660,6 +660,33 @@ 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.
|
||||
* "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 a 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.
|
||||
*
|
||||
|
|
|
@ -314,20 +314,9 @@ ALSA_PlayDevice(_THIS)
|
|||
swizzle_alsa_channels(this, this->hidden->mixbuf, frames_left);
|
||||
|
||||
while ( frames_left > 0 && SDL_AtomicGet(&this->enabled) ) {
|
||||
int status;
|
||||
|
||||
/* This wait is a work-around for a hang when USB devices are
|
||||
unplugged. Normally it should not result in any waiting,
|
||||
but in the case of a USB unplug, it serves as a way to
|
||||
join the playback thread after the timeout occurs */
|
||||
status = ALSA_snd_pcm_wait(this->hidden->pcm_handle, 1000);
|
||||
if (status == 0) {
|
||||
/*fprintf(stderr, "ALSA timeout waiting for available buffer space\n");*/
|
||||
SDL_OpenedAudioDeviceDisconnected(this);
|
||||
return;
|
||||
}
|
||||
|
||||
status = ALSA_snd_pcm_writei(this->hidden->pcm_handle,
|
||||
/* !!! FIXME: This works, but needs more testing before going live */
|
||||
/* ALSA_snd_pcm_wait(this->hidden->pcm_handle, -1); */
|
||||
int status = ALSA_snd_pcm_writei(this->hidden->pcm_handle,
|
||||
sample_buf, frames_left);
|
||||
|
||||
if (status < 0) {
|
||||
|
|
|
@ -99,7 +99,7 @@ typedef struct SDL_EVDEV_PrivateData
|
|||
int num_devices;
|
||||
int ref_count;
|
||||
int console_fd;
|
||||
int kb_mode;
|
||||
int old_kb_mode;
|
||||
} SDL_EVDEV_PrivateData;
|
||||
|
||||
#define _THIS SDL_EVDEV_PrivateData *_this
|
||||
|
@ -126,23 +126,8 @@ static Uint8 EVDEV_MouseButtons[] = {
|
|||
SDL_BUTTON_X2 + 3 /* BTN_TASK 0x117 */
|
||||
};
|
||||
|
||||
static const char* EVDEV_consoles[] = {
|
||||
/* "/proc/self/fd/0",
|
||||
"/dev/tty",
|
||||
"/dev/tty0", */ /* the tty ioctl's prohibit these */
|
||||
"/dev/tty1",
|
||||
"/dev/tty2",
|
||||
"/dev/tty3",
|
||||
"/dev/tty4",
|
||||
"/dev/tty5",
|
||||
"/dev/tty6",
|
||||
"/dev/tty7", /* usually X is spawned in tty7 */
|
||||
"/dev/vc/0",
|
||||
"/dev/console"
|
||||
};
|
||||
|
||||
static int SDL_EVDEV_is_console(int fd) {
|
||||
int type;
|
||||
char type;
|
||||
|
||||
return isatty(fd) && ioctl(fd, KDGKBTYPE, &type) == 0 &&
|
||||
(type == KB_101 || type == KB_84);
|
||||
|
@ -159,58 +144,19 @@ static int SDL_EVDEV_mute_keyboard(int tty_fd, int* old_kb_mode)
|
|||
return SDL_SetError("Failed to get keyboard mode during muting");
|
||||
}
|
||||
|
||||
/* FIXME: atm this absolutely ruins the vt, and KDSKBMUTE isn't implemented
|
||||
in the kernel */
|
||||
/*
|
||||
if (ioctl(tty_fd, KDSKBMODE, K_OFF) < 0) {
|
||||
return SDL_SetError("Failed to set keyboard mode during muting");
|
||||
}
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Restore the keyboard mode for given tty */
|
||||
static void SDL_EVDEV_unmute_keyboard(int tty_fd, int kb_mode)
|
||||
static void SDL_EVDEV_unmute_keyboard(int tty_fd, int old_kb_mode)
|
||||
{
|
||||
/* read above */
|
||||
/*
|
||||
if (ioctl(tty_fd, KDSKBMODE, kb_mode) < 0) {
|
||||
SDL_Log("Failed to unmute keyboard");
|
||||
if (ioctl(tty_fd, KDSKBMODE, old_kb_mode) < 0) {
|
||||
SDL_Log("Failed to set keyboard mode");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
static int SDL_EVDEV_get_active_tty()
|
||||
{
|
||||
int i, fd, ret, tty = 0;
|
||||
char tiocl;
|
||||
struct vt_stat vt_state;
|
||||
char path[PATH_MAX + 1];
|
||||
|
||||
for(i = 0; i < SDL_arraysize(EVDEV_consoles); i++) {
|
||||
fd = open(EVDEV_consoles[i], O_RDONLY);
|
||||
|
||||
if (fd < 0 && !SDL_EVDEV_is_console(fd))
|
||||
break;
|
||||
|
||||
tiocl = TIOCL_GETFGCONSOLE;
|
||||
if ((ret = ioctl(fd, TIOCLINUX, &tiocl)) >= 0)
|
||||
tty = ret + 1;
|
||||
else if (ioctl(fd, VT_GETSTATE, &vt_state) == 0)
|
||||
tty = vt_state.v_active;
|
||||
|
||||
close(fd);
|
||||
|
||||
if (tty) {
|
||||
sprintf(path, "/dev/tty%u", tty);
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd >= 0 && SDL_EVDEV_is_console(fd))
|
||||
return fd;
|
||||
}
|
||||
}
|
||||
|
||||
return SDL_SetError("Failed to determine active tty");
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -242,14 +188,15 @@ SDL_EVDEV_Init(void)
|
|||
#else
|
||||
/* TODO: Scan the devices manually, like a caveman */
|
||||
#endif /* SDL_USE_LIBUDEV */
|
||||
|
||||
/* We need a physical terminal (not PTS) to be able to translate key
|
||||
code to symbols via the kernel tables */
|
||||
_this->console_fd = SDL_EVDEV_get_active_tty();
|
||||
|
||||
|
||||
/* This might fail if we're not connected to a tty (e.g. on the Steam Link) */
|
||||
_this->console_fd = open("/dev/tty", O_RDONLY);
|
||||
|
||||
/* Mute the keyboard so keystrokes only generate evdev events and do not
|
||||
leak through to the console */
|
||||
SDL_EVDEV_mute_keyboard(_this->console_fd, &_this->kb_mode);
|
||||
if (_this->console_fd >= 0) {
|
||||
SDL_EVDEV_mute_keyboard(_this->console_fd, &_this->old_kb_mode);
|
||||
}
|
||||
}
|
||||
|
||||
_this->ref_count += 1;
|
||||
|
@ -273,7 +220,7 @@ SDL_EVDEV_Quit(void)
|
|||
#endif /* SDL_USE_LIBUDEV */
|
||||
|
||||
if (_this->console_fd >= 0) {
|
||||
SDL_EVDEV_unmute_keyboard(_this->console_fd, _this->kb_mode);
|
||||
SDL_EVDEV_unmute_keyboard(_this->console_fd, _this->old_kb_mode);
|
||||
close(_this->console_fd);
|
||||
}
|
||||
|
||||
|
@ -319,7 +266,8 @@ void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_class,
|
|||
#ifdef SDL_INPUT_LINUXKD
|
||||
/* this logic is pulled from kbd_keycode() in drivers/tty/vt/keyboard.c in the
|
||||
Linux kernel source */
|
||||
static void SDL_EVDEV_do_text_input(unsigned short keycode) {
|
||||
static void SDL_EVDEV_do_text_input(unsigned short keycode)
|
||||
{
|
||||
char shift_state;
|
||||
int locks_state;
|
||||
struct kbentry kbe;
|
||||
|
@ -343,6 +291,12 @@ static void SDL_EVDEV_do_text_input(unsigned short keycode) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (kbe.kb_value == K_HOLE || kbe.kb_value == K_NOSUCHMAP) {
|
||||
return;
|
||||
}
|
||||
|
||||
kbe.kb_value ^= 0xf000;
|
||||
|
||||
type = KTYP(kbe.kb_value);
|
||||
|
||||
if (type < 0xf0) {
|
||||
|
@ -571,11 +525,13 @@ SDL_EVDEV_translate_keycode(int keycode)
|
|||
if (keycode < SDL_arraysize(linux_scancode_table))
|
||||
scancode = linux_scancode_table[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 "
|
||||
"<sdl@libsdl.org> EVDEV KeyCode %d\n", keycode);
|
||||
}
|
||||
*/
|
||||
|
||||
return scancode;
|
||||
}
|
||||
|
|
|
@ -459,7 +459,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;
|
||||
|
@ -720,6 +720,10 @@ HandleInputEvents(SDL_Joystick * joystick)
|
|||
}
|
||||
break;
|
||||
case EV_ABS:
|
||||
if (code >= ABS_MISC) {
|
||||
break;
|
||||
}
|
||||
|
||||
switch (code) {
|
||||
case ABS_HAT0X:
|
||||
case ABS_HAT0Y:
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
*/
|
||||
|
||||
/* SDL internals */
|
||||
#include "SDL_hints.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "SDL_version.h"
|
||||
#include "SDL_syswm.h"
|
||||
|
@ -215,6 +216,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;
|
||||
|
@ -224,6 +228,10 @@ RPI_CreateWindow(_THIS, SDL_Window * window)
|
|||
DISPMANX_UPDATE_HANDLE_T dispman_update;
|
||||
uint32_t layer = SDL_RPI_VIDEOLAYER;
|
||||
const char *env;
|
||||
float srcAspect = 1;
|
||||
float dstAspect = 1;
|
||||
int factor_x = 0;
|
||||
int factor_y = 0;
|
||||
|
||||
/* Disable alpha, otherwise the app looks composed with whatever dispman is showing (X11, console,etc) */
|
||||
dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS;
|
||||
|
@ -238,23 +246,84 @@ 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;
|
||||
|
||||
/* 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 '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. */
|
||||
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;
|
||||
|
||||
env = SDL_GetHint(SDL_HINT_RPI_VIDEO_LAYER);
|
||||
if (env) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue