mirror of https://github.com/encounter/SDL.git
raspberry: expose second display.
This lets apps see and choose between both an HDMI and DSI-connected display, such as a television and the Pi Foundation's official touchscreen. It only exposes the second display if the hardware reports that it is connected.
This commit is contained in:
parent
90a075d75f
commit
6fbe9e23fa
|
@ -154,28 +154,34 @@ VideoBootStrap RPI_bootstrap = {
|
||||||
RPI_Create
|
RPI_Create
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* SDL Video and Display initialization/handling functions */
|
/* SDL Video and Display initialization/handling functions */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
int
|
|
||||||
RPI_VideoInit(_THIS)
|
static void
|
||||||
|
AddDispManXDisplay(const int display_id)
|
||||||
{
|
{
|
||||||
|
DISPMANX_MODEINFO_T modeinfo;
|
||||||
|
DISPMANX_DISPLAY_HANDLE_T handle;
|
||||||
SDL_VideoDisplay display;
|
SDL_VideoDisplay display;
|
||||||
SDL_DisplayMode current_mode;
|
SDL_DisplayMode current_mode;
|
||||||
SDL_DisplayData *data;
|
SDL_DisplayData *data;
|
||||||
uint32_t w,h;
|
|
||||||
|
|
||||||
/* Initialize BCM Host */
|
handle = vc_dispmanx_display_open(display_id);
|
||||||
bcm_host_init();
|
if (!handle) {
|
||||||
|
return; /* this display isn't available */
|
||||||
SDL_zero(current_mode);
|
|
||||||
|
|
||||||
if (graphics_get_display_size( 0, &w, &h) < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
current_mode.w = w;
|
if (vc_dispmanx_display_get_info(handle, &modeinfo) < 0) {
|
||||||
current_mode.h = h;
|
vc_dispmanx_display_close(handle);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* RPI_GetRefreshRate() doesn't distinguish between displays. I'm not sure the hardware distinguishes either */
|
||||||
|
SDL_zero(current_mode);
|
||||||
|
current_mode.w = modeinfo.width;
|
||||||
|
current_mode.h = modeinfo.height;
|
||||||
current_mode.refresh_rate = RPI_GetRefreshRate();
|
current_mode.refresh_rate = RPI_GetRefreshRate();
|
||||||
/* 32 bpp for default */
|
/* 32 bpp for default */
|
||||||
current_mode.format = SDL_PIXELFORMAT_ABGR8888;
|
current_mode.format = SDL_PIXELFORMAT_ABGR8888;
|
||||||
|
@ -189,14 +195,25 @@ RPI_VideoInit(_THIS)
|
||||||
/* Allocate display internal data */
|
/* Allocate display internal data */
|
||||||
data = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
|
data = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData));
|
||||||
if (data == NULL) {
|
if (data == NULL) {
|
||||||
return SDL_OutOfMemory();
|
vc_dispmanx_display_close(handle);
|
||||||
|
return; /* oh well */
|
||||||
}
|
}
|
||||||
|
|
||||||
data->dispman_display = vc_dispmanx_display_open( 0 /* LCD */);
|
data->dispman_display = handle;
|
||||||
|
|
||||||
display.driverdata = data;
|
display.driverdata = data;
|
||||||
|
|
||||||
SDL_AddVideoDisplay(&display);
|
SDL_AddVideoDisplay(&display);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
RPI_VideoInit(_THIS)
|
||||||
|
{
|
||||||
|
/* Initialize BCM Host */
|
||||||
|
bcm_host_init();
|
||||||
|
|
||||||
|
AddDispManXDisplay(DISPMANX_ID_MAIN_LCD); /* your default display */
|
||||||
|
AddDispManXDisplay(DISPMANX_ID_FORCE_OTHER); /* an "other" display...maybe DSI-connected screen while HDMI is your main */
|
||||||
|
|
||||||
#ifdef SDL_INPUT_LINUXEV
|
#ifdef SDL_INPUT_LINUXEV
|
||||||
if (SDL_EVDEV_Init() < 0) {
|
if (SDL_EVDEV_Init() < 0) {
|
||||||
|
|
Loading…
Reference in New Issue