mirror of
https://github.com/libretro/RetroArch
synced 2025-02-06 00:39:53 +00:00
Split up video_driver code to separate file
This commit is contained in:
parent
7283ce17bc
commit
0e5a9f03fe
@ -98,6 +98,7 @@ OBJ += frontend/frontend.o \
|
||||
libretro-sdk/file/file_path.o \
|
||||
hash.o \
|
||||
audio/audio_driver.o \
|
||||
video_driver.o \
|
||||
driver.o \
|
||||
settings.o \
|
||||
settings_list.o \
|
||||
|
148
driver.c
148
driver.c
@ -40,111 +40,6 @@
|
||||
|
||||
driver_t driver;
|
||||
|
||||
static const video_driver_t *video_drivers[] = {
|
||||
#ifdef HAVE_OPENGL
|
||||
&video_gl,
|
||||
#endif
|
||||
#ifdef XENON
|
||||
&video_xenon360,
|
||||
#endif
|
||||
#if defined(_XBOX) && (defined(HAVE_D3D8) || defined(HAVE_D3D9)) || defined(HAVE_WIN32_D3D9)
|
||||
&video_d3d,
|
||||
#endif
|
||||
#ifdef SN_TARGET_PSP2
|
||||
&video_vita,
|
||||
#endif
|
||||
#ifdef PSP
|
||||
&video_psp1,
|
||||
#endif
|
||||
#ifdef HAVE_SDL
|
||||
&video_sdl,
|
||||
#endif
|
||||
#ifdef HAVE_SDL2
|
||||
&video_sdl2,
|
||||
#endif
|
||||
#ifdef HAVE_XVIDEO
|
||||
&video_xvideo,
|
||||
#endif
|
||||
#ifdef GEKKO
|
||||
&video_gx,
|
||||
#endif
|
||||
#ifdef HAVE_VG
|
||||
&video_vg,
|
||||
#endif
|
||||
#ifdef HAVE_OMAP
|
||||
&video_omap,
|
||||
#endif
|
||||
#ifdef HAVE_EXYNOS
|
||||
&video_exynos,
|
||||
#endif
|
||||
&video_null,
|
||||
NULL,
|
||||
};
|
||||
|
||||
/**
|
||||
* video_driver_find_handle:
|
||||
* @index : index of driver to get handle to.
|
||||
*
|
||||
* Returns: handle to video driver at index. Can be NULL
|
||||
* if nothing found.
|
||||
**/
|
||||
static const void *video_driver_find_handle(int index)
|
||||
{
|
||||
const void *drv = video_drivers[index];
|
||||
if (!drv)
|
||||
return NULL;
|
||||
return drv;
|
||||
}
|
||||
|
||||
/**
|
||||
* video_driver_find_ident:
|
||||
* @index : index of driver to get handle to.
|
||||
*
|
||||
* Returns: Human-readable identifier of video driver at index. Can be NULL
|
||||
* if nothing found.
|
||||
**/
|
||||
static const char *video_driver_find_ident(int index)
|
||||
{
|
||||
const video_driver_t *drv = video_drivers[index];
|
||||
if (!drv)
|
||||
return NULL;
|
||||
return drv->ident;
|
||||
}
|
||||
|
||||
/**
|
||||
* config_get_video_driver_options:
|
||||
*
|
||||
* Get an enumerated list of all video driver names, separated by '|'.
|
||||
*
|
||||
* Returns: string listing of all video driver names, separated by '|'.
|
||||
**/
|
||||
const char* config_get_video_driver_options(void)
|
||||
{
|
||||
union string_list_elem_attr attr;
|
||||
unsigned i;
|
||||
char *options = NULL;
|
||||
int options_len = 0;
|
||||
struct string_list *options_l = string_list_new();
|
||||
|
||||
attr.i = 0;
|
||||
|
||||
for (i = 0; video_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = video_driver_find_ident(i);
|
||||
options_len += strlen(opt) + 1;
|
||||
string_list_append(options_l, opt, attr);
|
||||
}
|
||||
|
||||
options = (char*)calloc(options_len, sizeof(char));
|
||||
|
||||
string_list_join_concat(options, options_len, options_l, "|");
|
||||
|
||||
string_list_free(options_l);
|
||||
options_l = NULL;
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
static const input_driver_t *input_drivers[] = {
|
||||
#ifdef __CELLOS_LV2__
|
||||
&input_ps3,
|
||||
@ -1081,49 +976,6 @@ static void find_menu_driver(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void find_video_driver(void)
|
||||
{
|
||||
int i;
|
||||
#if defined(HAVE_OPENGL) && defined(HAVE_FBO)
|
||||
if (g_extern.system.hw_render_callback.context_type)
|
||||
{
|
||||
RARCH_LOG("Using HW render, OpenGL driver forced.\n");
|
||||
driver.video = &video_gl;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (driver.frontend_ctx &&
|
||||
driver.frontend_ctx->get_video_driver)
|
||||
{
|
||||
driver.video = driver.frontend_ctx->get_video_driver();
|
||||
|
||||
if (driver.video)
|
||||
return;
|
||||
RARCH_WARN("Frontend supports get_video_driver() but did not specify one.\n");
|
||||
}
|
||||
|
||||
i = find_driver_index("video_driver", g_settings.video.driver);
|
||||
if (i >= 0)
|
||||
driver.video = video_driver_find_handle(i);
|
||||
else
|
||||
{
|
||||
unsigned d;
|
||||
RARCH_ERR("Couldn't find any video driver named \"%s\"\n",
|
||||
g_settings.video.driver);
|
||||
RARCH_LOG_OUTPUT("Available video drivers are:\n");
|
||||
for (d = 0; video_driver_find_handle(d); d++)
|
||||
RARCH_LOG_OUTPUT("\t%s\n", video_driver_find_ident(d));
|
||||
RARCH_WARN("Going to default to first video driver...\n");
|
||||
|
||||
driver.video = video_driver_find_handle(0);
|
||||
|
||||
if (!driver.video)
|
||||
rarch_fail(1, "find_video_driver()");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void find_input_driver(void)
|
||||
{
|
||||
int i = find_driver_index("input_driver", g_settings.input.driver);
|
||||
|
216
driver.h
216
driver.h
@ -25,16 +25,12 @@
|
||||
#include <compat/posix_string.h>
|
||||
#include "gfx/scaler/scaler.h"
|
||||
#include "gfx/image/image.h"
|
||||
#include "gfx/shader/shader_parse.h"
|
||||
#include "input/input_context.h"
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
#include "input/overlay.h"
|
||||
#endif
|
||||
|
||||
#include "frontend/frontend_context.h"
|
||||
#include <retro_miscellaneous.h>
|
||||
|
||||
#include "video_driver.h"
|
||||
#include "audio/audio_driver.h"
|
||||
|
||||
#include "menu/menu_driver.h"
|
||||
@ -137,50 +133,6 @@ enum
|
||||
RARCH_BIND_LIST_END_NULL
|
||||
};
|
||||
|
||||
struct retro_keybind
|
||||
{
|
||||
bool valid;
|
||||
unsigned id;
|
||||
const char *desc;
|
||||
enum retro_key key;
|
||||
|
||||
uint64_t joykey;
|
||||
/* Default key binding value - for resetting bind to default */
|
||||
uint64_t def_joykey;
|
||||
|
||||
uint32_t joyaxis;
|
||||
uint32_t def_joyaxis;
|
||||
|
||||
/* Used by input_{push,pop}_analog_dpad(). */
|
||||
uint32_t orig_joyaxis;
|
||||
|
||||
char joykey_label[256];
|
||||
char joyaxis_label[256];
|
||||
};
|
||||
|
||||
typedef struct video_info
|
||||
{
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
bool fullscreen;
|
||||
bool vsync;
|
||||
bool force_aspect;
|
||||
#ifdef GEKKO
|
||||
/* TODO - we can't really have driver system-specific
|
||||
* variables in here. There should be some
|
||||
* kind of publicly accessible driver implementation
|
||||
* video struct for specific things like this.
|
||||
*/
|
||||
unsigned viwidth;
|
||||
#endif
|
||||
bool vfilter;
|
||||
bool smooth;
|
||||
/* Maximum input size: RARCH_SCALE_BASE * input_scale */
|
||||
unsigned input_scale;
|
||||
/* Use 32bit RGBA rather than native XBGR1555. */
|
||||
bool rgb32;
|
||||
} video_info_t;
|
||||
|
||||
#define AXIS_NEG(x) (((uint32_t)(x) << 16) | UINT16_C(0xFFFF))
|
||||
#define AXIS_POS(x) ((uint32_t)(x) | UINT32_C(0xFFFF0000))
|
||||
#define AXIS_NONE UINT32_C(0xFFFFFFFF)
|
||||
@ -213,27 +165,6 @@ enum analog_dpad_mode
|
||||
ANALOG_DPAD_LAST
|
||||
};
|
||||
|
||||
typedef struct input_driver
|
||||
{
|
||||
void *(*init)(void);
|
||||
void (*poll)(void *data);
|
||||
int16_t (*input_state)(void *data,
|
||||
const struct retro_keybind **retro_keybinds,
|
||||
unsigned port, unsigned device, unsigned index, unsigned id);
|
||||
bool (*key_pressed)(void *data, int key);
|
||||
void (*free)(void *data);
|
||||
bool (*set_sensor_state)(void *data, unsigned port,
|
||||
enum retro_sensor_action action, unsigned rate);
|
||||
float (*get_sensor_input)(void *data, unsigned port, unsigned id);
|
||||
uint64_t (*get_capabilities)(void *data);
|
||||
const char *ident;
|
||||
|
||||
void (*grab_mouse)(void *data, bool state);
|
||||
bool (*set_rumble)(void *data, unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t state);
|
||||
const rarch_joypad_driver_t *(*get_joypad_driver)(void *data);
|
||||
} input_driver_t;
|
||||
|
||||
typedef struct input_osk_driver
|
||||
{
|
||||
void *(*init)(size_t size);
|
||||
@ -285,118 +216,6 @@ typedef struct location_driver
|
||||
const char *ident;
|
||||
} location_driver_t;
|
||||
|
||||
struct rarch_viewport;
|
||||
|
||||
struct font_params
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float scale;
|
||||
/* Drop shadow color multiplier. */
|
||||
float drop_mod;
|
||||
/* Drop shadow offset.
|
||||
* If both are 0, no drop shadow will be rendered. */
|
||||
int drop_x, drop_y;
|
||||
/* ABGR. Use the macros. */
|
||||
uint32_t color;
|
||||
bool full_screen;
|
||||
};
|
||||
#define FONT_COLOR_RGBA(r, g, b, a) (((r) << 0) | ((g) << 8) | ((b) << 16) | ((a) << 24))
|
||||
#define FONT_COLOR_GET_RED(col) (((col) >> 0) & 0xff)
|
||||
#define FONT_COLOR_GET_GREEN(col) (((col) >> 8) & 0xff)
|
||||
#define FONT_COLOR_GET_BLUE(col) (((col) >> 16) & 0xff)
|
||||
#define FONT_COLOR_GET_ALPHA(col) (((col) >> 24) & 0xff)
|
||||
|
||||
/* Optionally implemented interface to poke more
|
||||
* deeply into video driver. */
|
||||
|
||||
typedef struct video_poke_interface
|
||||
{
|
||||
void (*set_filtering)(void *data, unsigned index, bool smooth);
|
||||
#ifdef HAVE_FBO
|
||||
uintptr_t (*get_current_framebuffer)(void *data);
|
||||
retro_proc_address_t (*get_proc_address)(void *data, const char *sym);
|
||||
#endif
|
||||
void (*set_aspect_ratio)(void *data, unsigned aspectratio_index);
|
||||
void (*apply_state_changes)(void *data);
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
/* Update texture. */
|
||||
void (*set_texture_frame)(void *data, const void *frame, bool rgb32,
|
||||
unsigned width, unsigned height, float alpha);
|
||||
|
||||
/* Enable or disable rendering. */
|
||||
void (*set_texture_enable)(void *data, bool enable, bool full_screen);
|
||||
#endif
|
||||
void (*set_osd_msg)(void *data, const char *msg,
|
||||
const struct font_params *params, void *font);
|
||||
|
||||
void (*show_mouse)(void *data, bool state);
|
||||
void (*grab_mouse_toggle)(void *data);
|
||||
|
||||
struct gfx_shader *(*get_current_shader)(void *data);
|
||||
} video_poke_interface_t;
|
||||
|
||||
typedef struct video_driver
|
||||
{
|
||||
/* Should the video driver act as an input driver as well?
|
||||
* The video initialization might preinitialize an input driver
|
||||
* to override the settings in case the video driver relies on
|
||||
* input driver for event handling. */
|
||||
void *(*init)(const video_info_t *video, const input_driver_t **input,
|
||||
void **input_data);
|
||||
|
||||
/* msg is for showing a message on the screen along with the video frame. */
|
||||
bool (*frame)(void *data, const void *frame, unsigned width,
|
||||
unsigned height, unsigned pitch, const char *msg);
|
||||
|
||||
/* Should we care about syncing to vblank? Fast forwarding. */
|
||||
void (*set_nonblock_state)(void *data, bool toggle);
|
||||
|
||||
/* Is the window still active? */
|
||||
bool (*alive)(void *data);
|
||||
|
||||
/* Does the window have focus? */
|
||||
bool (*focus)(void *data);
|
||||
|
||||
/* Does the graphics conext support windowed mode? */
|
||||
bool (*has_windowed)(void *data);
|
||||
|
||||
/* Sets shader. Might not be implemented. Will be moved to
|
||||
* poke_interface later. */
|
||||
bool (*set_shader)(void *data, enum rarch_shader_type type,
|
||||
const char *path);
|
||||
|
||||
/* Frees driver. */
|
||||
void (*free)(void *data);
|
||||
|
||||
/* Human-readable identifier. */
|
||||
const char *ident;
|
||||
|
||||
void (*set_rotation)(void *data, unsigned rotation);
|
||||
void (*viewport_info)(void *data, struct rarch_viewport *vp);
|
||||
|
||||
/* Reads out in BGR byte order (24bpp). */
|
||||
bool (*read_viewport)(void *data, uint8_t *buffer);
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
void (*overlay_interface)(void *data, const video_overlay_interface_t **iface);
|
||||
#endif
|
||||
void (*poke_interface)(void *data, const video_poke_interface_t **iface);
|
||||
unsigned (*wrap_type_to_enum)(enum gfx_wrap_type type);
|
||||
} video_driver_t;
|
||||
|
||||
enum rarch_display_type
|
||||
{
|
||||
/* Non-bindable types like consoles, KMS, VideoCore, etc. */
|
||||
RARCH_DISPLAY_NONE = 0,
|
||||
/* video_display => Display*, video_window => Window */
|
||||
RARCH_DISPLAY_X11,
|
||||
/* video_display => N/A, video_window => HWND */
|
||||
RARCH_DISPLAY_WIN32,
|
||||
RARCH_DISPLAY_OSX
|
||||
};
|
||||
|
||||
/* Flags for init_drivers/uninit_drivers */
|
||||
enum
|
||||
{
|
||||
@ -781,39 +600,6 @@ bool driver_update_system_av_info(const struct retro_system_av_info *info);
|
||||
|
||||
extern driver_t driver;
|
||||
|
||||
/* Backends */
|
||||
extern video_driver_t video_gl;
|
||||
extern video_driver_t video_psp1;
|
||||
extern video_driver_t video_vita;
|
||||
extern video_driver_t video_d3d;
|
||||
extern video_driver_t video_gx;
|
||||
extern video_driver_t video_xenon360;
|
||||
extern video_driver_t video_xvideo;
|
||||
extern video_driver_t video_xdk_d3d;
|
||||
extern video_driver_t video_sdl;
|
||||
extern video_driver_t video_sdl2;
|
||||
extern video_driver_t video_vg;
|
||||
extern video_driver_t video_omap;
|
||||
extern video_driver_t video_exynos;
|
||||
extern video_driver_t video_null;
|
||||
|
||||
extern input_driver_t input_android;
|
||||
extern input_driver_t input_sdl;
|
||||
extern input_driver_t input_dinput;
|
||||
extern input_driver_t input_x;
|
||||
extern input_driver_t input_wayland;
|
||||
extern input_driver_t input_ps3;
|
||||
extern input_driver_t input_psp;
|
||||
extern input_driver_t input_xenon360;
|
||||
extern input_driver_t input_gx;
|
||||
extern input_driver_t input_xinput;
|
||||
extern input_driver_t input_linuxraw;
|
||||
extern input_driver_t input_udev;
|
||||
extern input_driver_t input_apple;
|
||||
extern input_driver_t input_qnx;
|
||||
extern input_driver_t input_rwebinput;
|
||||
extern input_driver_t input_null;
|
||||
|
||||
/**
|
||||
* config_get_input_driver_options:
|
||||
*
|
||||
|
@ -496,6 +496,7 @@ AUDIO
|
||||
/*============================================================
|
||||
DRIVERS
|
||||
============================================================ */
|
||||
#include "../video_driver.c"
|
||||
#include "../audio/audio_driver.c"
|
||||
#include "../driver.c"
|
||||
|
||||
|
167
video_driver.c
Normal file
167
video_driver.c
Normal file
@ -0,0 +1,167 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2015 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <string/string_list.h>
|
||||
#include "video_driver.h"
|
||||
#include "general.h"
|
||||
|
||||
static const video_driver_t *video_drivers[] = {
|
||||
#ifdef HAVE_OPENGL
|
||||
&video_gl,
|
||||
#endif
|
||||
#ifdef XENON
|
||||
&video_xenon360,
|
||||
#endif
|
||||
#if defined(_XBOX) && (defined(HAVE_D3D8) || defined(HAVE_D3D9)) || defined(HAVE_WIN32_D3D9)
|
||||
&video_d3d,
|
||||
#endif
|
||||
#ifdef SN_TARGET_PSP2
|
||||
&video_vita,
|
||||
#endif
|
||||
#ifdef PSP
|
||||
&video_psp1,
|
||||
#endif
|
||||
#ifdef HAVE_SDL
|
||||
&video_sdl,
|
||||
#endif
|
||||
#ifdef HAVE_SDL2
|
||||
&video_sdl2,
|
||||
#endif
|
||||
#ifdef HAVE_XVIDEO
|
||||
&video_xvideo,
|
||||
#endif
|
||||
#ifdef GEKKO
|
||||
&video_gx,
|
||||
#endif
|
||||
#ifdef HAVE_VG
|
||||
&video_vg,
|
||||
#endif
|
||||
#ifdef HAVE_OMAP
|
||||
&video_omap,
|
||||
#endif
|
||||
#ifdef HAVE_EXYNOS
|
||||
&video_exynos,
|
||||
#endif
|
||||
&video_null,
|
||||
NULL,
|
||||
};
|
||||
|
||||
/**
|
||||
* video_driver_find_handle:
|
||||
* @index : index of driver to get handle to.
|
||||
*
|
||||
* Returns: handle to video driver at index. Can be NULL
|
||||
* if nothing found.
|
||||
**/
|
||||
const void *video_driver_find_handle(int index)
|
||||
{
|
||||
const void *drv = video_drivers[index];
|
||||
if (!drv)
|
||||
return NULL;
|
||||
return drv;
|
||||
}
|
||||
|
||||
/**
|
||||
* video_driver_find_ident:
|
||||
* @index : index of driver to get handle to.
|
||||
*
|
||||
* Returns: Human-readable identifier of video driver at index. Can be NULL
|
||||
* if nothing found.
|
||||
**/
|
||||
const char *video_driver_find_ident(int index)
|
||||
{
|
||||
const video_driver_t *drv = video_drivers[index];
|
||||
if (!drv)
|
||||
return NULL;
|
||||
return drv->ident;
|
||||
}
|
||||
|
||||
/**
|
||||
* config_get_video_driver_options:
|
||||
*
|
||||
* Get an enumerated list of all video driver names, separated by '|'.
|
||||
*
|
||||
* Returns: string listing of all video driver names, separated by '|'.
|
||||
**/
|
||||
const char* config_get_video_driver_options(void)
|
||||
{
|
||||
union string_list_elem_attr attr;
|
||||
unsigned i;
|
||||
char *options = NULL;
|
||||
int options_len = 0;
|
||||
struct string_list *options_l = string_list_new();
|
||||
|
||||
attr.i = 0;
|
||||
|
||||
for (i = 0; video_driver_find_handle(i); i++)
|
||||
{
|
||||
const char *opt = video_driver_find_ident(i);
|
||||
options_len += strlen(opt) + 1;
|
||||
string_list_append(options_l, opt, attr);
|
||||
}
|
||||
|
||||
options = (char*)calloc(options_len, sizeof(char));
|
||||
|
||||
string_list_join_concat(options, options_len, options_l, "|");
|
||||
|
||||
string_list_free(options_l);
|
||||
options_l = NULL;
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
void find_video_driver(void)
|
||||
{
|
||||
int i;
|
||||
#if defined(HAVE_OPENGL) && defined(HAVE_FBO)
|
||||
if (g_extern.system.hw_render_callback.context_type)
|
||||
{
|
||||
RARCH_LOG("Using HW render, OpenGL driver forced.\n");
|
||||
driver.video = &video_gl;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (driver.frontend_ctx &&
|
||||
driver.frontend_ctx->get_video_driver)
|
||||
{
|
||||
driver.video = driver.frontend_ctx->get_video_driver();
|
||||
|
||||
if (driver.video)
|
||||
return;
|
||||
RARCH_WARN("Frontend supports get_video_driver() but did not specify one.\n");
|
||||
}
|
||||
|
||||
i = find_driver_index("video_driver", g_settings.video.driver);
|
||||
if (i >= 0)
|
||||
driver.video = video_driver_find_handle(i);
|
||||
else
|
||||
{
|
||||
unsigned d;
|
||||
RARCH_ERR("Couldn't find any video driver named \"%s\"\n",
|
||||
g_settings.video.driver);
|
||||
RARCH_LOG_OUTPUT("Available video drivers are:\n");
|
||||
for (d = 0; video_driver_find_handle(d); d++)
|
||||
RARCH_LOG_OUTPUT("\t%s\n", video_driver_find_ident(d));
|
||||
RARCH_WARN("Going to default to first video driver...\n");
|
||||
|
||||
driver.video = video_driver_find_handle(0);
|
||||
|
||||
if (!driver.video)
|
||||
rarch_fail(1, "find_video_driver()");
|
||||
}
|
||||
}
|
281
video_driver.h
Normal file
281
video_driver.h
Normal file
@ -0,0 +1,281 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2015 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __VIDEO_DRIVER__H
|
||||
#define __VIDEO_DRIVER__H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <boolean.h>
|
||||
#include "libretro.h"
|
||||
|
||||
#include "input/input_context.h"
|
||||
#include "gfx/shader/shader_parse.h"
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
#include "input/overlay.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct retro_keybind
|
||||
{
|
||||
bool valid;
|
||||
unsigned id;
|
||||
const char *desc;
|
||||
enum retro_key key;
|
||||
|
||||
uint64_t joykey;
|
||||
/* Default key binding value - for resetting bind to default */
|
||||
uint64_t def_joykey;
|
||||
|
||||
uint32_t joyaxis;
|
||||
uint32_t def_joyaxis;
|
||||
|
||||
/* Used by input_{push,pop}_analog_dpad(). */
|
||||
uint32_t orig_joyaxis;
|
||||
|
||||
char joykey_label[256];
|
||||
char joyaxis_label[256];
|
||||
};
|
||||
|
||||
typedef struct input_driver
|
||||
{
|
||||
void *(*init)(void);
|
||||
void (*poll)(void *data);
|
||||
int16_t (*input_state)(void *data,
|
||||
const struct retro_keybind **retro_keybinds,
|
||||
unsigned port, unsigned device, unsigned index, unsigned id);
|
||||
bool (*key_pressed)(void *data, int key);
|
||||
void (*free)(void *data);
|
||||
bool (*set_sensor_state)(void *data, unsigned port,
|
||||
enum retro_sensor_action action, unsigned rate);
|
||||
float (*get_sensor_input)(void *data, unsigned port, unsigned id);
|
||||
uint64_t (*get_capabilities)(void *data);
|
||||
const char *ident;
|
||||
|
||||
void (*grab_mouse)(void *data, bool state);
|
||||
bool (*set_rumble)(void *data, unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t state);
|
||||
const rarch_joypad_driver_t *(*get_joypad_driver)(void *data);
|
||||
} input_driver_t;
|
||||
|
||||
extern input_driver_t input_android;
|
||||
extern input_driver_t input_sdl;
|
||||
extern input_driver_t input_dinput;
|
||||
extern input_driver_t input_x;
|
||||
extern input_driver_t input_wayland;
|
||||
extern input_driver_t input_ps3;
|
||||
extern input_driver_t input_psp;
|
||||
extern input_driver_t input_xenon360;
|
||||
extern input_driver_t input_gx;
|
||||
extern input_driver_t input_xinput;
|
||||
extern input_driver_t input_linuxraw;
|
||||
extern input_driver_t input_udev;
|
||||
extern input_driver_t input_apple;
|
||||
extern input_driver_t input_qnx;
|
||||
extern input_driver_t input_rwebinput;
|
||||
extern input_driver_t input_null;
|
||||
|
||||
struct rarch_viewport;
|
||||
|
||||
typedef struct video_info
|
||||
{
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
bool fullscreen;
|
||||
bool vsync;
|
||||
bool force_aspect;
|
||||
#ifdef GEKKO
|
||||
/* TODO - we can't really have driver system-specific
|
||||
* variables in here. There should be some
|
||||
* kind of publicly accessible driver implementation
|
||||
* video struct for specific things like this.
|
||||
*/
|
||||
unsigned viwidth;
|
||||
#endif
|
||||
bool vfilter;
|
||||
bool smooth;
|
||||
/* Maximum input size: RARCH_SCALE_BASE * input_scale */
|
||||
unsigned input_scale;
|
||||
/* Use 32bit RGBA rather than native XBGR1555. */
|
||||
bool rgb32;
|
||||
} video_info_t;
|
||||
|
||||
struct font_params
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float scale;
|
||||
/* Drop shadow color multiplier. */
|
||||
float drop_mod;
|
||||
/* Drop shadow offset.
|
||||
* If both are 0, no drop shadow will be rendered. */
|
||||
int drop_x, drop_y;
|
||||
/* ABGR. Use the macros. */
|
||||
uint32_t color;
|
||||
bool full_screen;
|
||||
};
|
||||
|
||||
|
||||
#define FONT_COLOR_RGBA(r, g, b, a) (((r) << 0) | ((g) << 8) | ((b) << 16) | ((a) << 24))
|
||||
#define FONT_COLOR_GET_RED(col) (((col) >> 0) & 0xff)
|
||||
#define FONT_COLOR_GET_GREEN(col) (((col) >> 8) & 0xff)
|
||||
#define FONT_COLOR_GET_BLUE(col) (((col) >> 16) & 0xff)
|
||||
#define FONT_COLOR_GET_ALPHA(col) (((col) >> 24) & 0xff)
|
||||
|
||||
/* Optionally implemented interface to poke more
|
||||
* deeply into video driver. */
|
||||
|
||||
typedef struct video_poke_interface
|
||||
{
|
||||
void (*set_filtering)(void *data, unsigned index, bool smooth);
|
||||
#ifdef HAVE_FBO
|
||||
uintptr_t (*get_current_framebuffer)(void *data);
|
||||
retro_proc_address_t (*get_proc_address)(void *data, const char *sym);
|
||||
#endif
|
||||
void (*set_aspect_ratio)(void *data, unsigned aspectratio_index);
|
||||
void (*apply_state_changes)(void *data);
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
/* Update texture. */
|
||||
void (*set_texture_frame)(void *data, const void *frame, bool rgb32,
|
||||
unsigned width, unsigned height, float alpha);
|
||||
|
||||
/* Enable or disable rendering. */
|
||||
void (*set_texture_enable)(void *data, bool enable, bool full_screen);
|
||||
#endif
|
||||
void (*set_osd_msg)(void *data, const char *msg,
|
||||
const struct font_params *params, void *font);
|
||||
|
||||
void (*show_mouse)(void *data, bool state);
|
||||
void (*grab_mouse_toggle)(void *data);
|
||||
|
||||
struct gfx_shader *(*get_current_shader)(void *data);
|
||||
} video_poke_interface_t;
|
||||
|
||||
typedef struct video_driver
|
||||
{
|
||||
/* Should the video driver act as an input driver as well?
|
||||
* The video initialization might preinitialize an input driver
|
||||
* to override the settings in case the video driver relies on
|
||||
* input driver for event handling. */
|
||||
void *(*init)(const video_info_t *video, const input_driver_t **input,
|
||||
void **input_data);
|
||||
|
||||
/* msg is for showing a message on the screen along with the video frame. */
|
||||
bool (*frame)(void *data, const void *frame, unsigned width,
|
||||
unsigned height, unsigned pitch, const char *msg);
|
||||
|
||||
/* Should we care about syncing to vblank? Fast forwarding. */
|
||||
void (*set_nonblock_state)(void *data, bool toggle);
|
||||
|
||||
/* Is the window still active? */
|
||||
bool (*alive)(void *data);
|
||||
|
||||
/* Does the window have focus? */
|
||||
bool (*focus)(void *data);
|
||||
|
||||
/* Does the graphics conext support windowed mode? */
|
||||
bool (*has_windowed)(void *data);
|
||||
|
||||
/* Sets shader. Might not be implemented. Will be moved to
|
||||
* poke_interface later. */
|
||||
bool (*set_shader)(void *data, enum rarch_shader_type type,
|
||||
const char *path);
|
||||
|
||||
/* Frees driver. */
|
||||
void (*free)(void *data);
|
||||
|
||||
/* Human-readable identifier. */
|
||||
const char *ident;
|
||||
|
||||
void (*set_rotation)(void *data, unsigned rotation);
|
||||
void (*viewport_info)(void *data, struct rarch_viewport *vp);
|
||||
|
||||
/* Reads out in BGR byte order (24bpp). */
|
||||
bool (*read_viewport)(void *data, uint8_t *buffer);
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
void (*overlay_interface)(void *data, const video_overlay_interface_t **iface);
|
||||
#endif
|
||||
void (*poke_interface)(void *data, const video_poke_interface_t **iface);
|
||||
unsigned (*wrap_type_to_enum)(enum gfx_wrap_type type);
|
||||
} video_driver_t;
|
||||
|
||||
enum rarch_display_type
|
||||
{
|
||||
/* Non-bindable types like consoles, KMS, VideoCore, etc. */
|
||||
RARCH_DISPLAY_NONE = 0,
|
||||
/* video_display => Display*, video_window => Window */
|
||||
RARCH_DISPLAY_X11,
|
||||
/* video_display => N/A, video_window => HWND */
|
||||
RARCH_DISPLAY_WIN32,
|
||||
RARCH_DISPLAY_OSX
|
||||
};
|
||||
|
||||
extern video_driver_t video_gl;
|
||||
extern video_driver_t video_psp1;
|
||||
extern video_driver_t video_vita;
|
||||
extern video_driver_t video_d3d;
|
||||
extern video_driver_t video_gx;
|
||||
extern video_driver_t video_xenon360;
|
||||
extern video_driver_t video_xvideo;
|
||||
extern video_driver_t video_xdk_d3d;
|
||||
extern video_driver_t video_sdl;
|
||||
extern video_driver_t video_sdl2;
|
||||
extern video_driver_t video_vg;
|
||||
extern video_driver_t video_omap;
|
||||
extern video_driver_t video_exynos;
|
||||
extern video_driver_t video_null;
|
||||
|
||||
/**
|
||||
* video_driver_find_handle:
|
||||
* @index : index of driver to get handle to.
|
||||
*
|
||||
* Returns: handle to video driver at index. Can be NULL
|
||||
* if nothing found.
|
||||
**/
|
||||
const void *video_driver_find_handle(int index);
|
||||
|
||||
/**
|
||||
* video_driver_find_ident:
|
||||
* @index : index of driver to get handle to.
|
||||
*
|
||||
* Returns: Human-readable identifier of video driver at index. Can be NULL
|
||||
* if nothing found.
|
||||
**/
|
||||
const char *video_driver_find_ident(int index);
|
||||
|
||||
/**
|
||||
* config_get_video_driver_options:
|
||||
*
|
||||
* Get an enumerated list of all video driver names, separated by '|'.
|
||||
*
|
||||
* Returns: string listing of all video driver names, separated by '|'.
|
||||
**/
|
||||
const char* config_get_video_driver_options(void);
|
||||
|
||||
void find_video_driver(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user