mirror of
https://github.com/libretro/gambatte-libretro.git
synced 2024-11-23 07:49:48 +00:00
(Libretro) Go through new logger interface
This commit is contained in:
parent
5190180e49
commit
844de796ef
@ -9,6 +9,7 @@
|
||||
#include <sstream>
|
||||
#include <string.h>
|
||||
|
||||
static retro_log_printf_t log_cb;
|
||||
static retro_video_refresh_t video_cb;
|
||||
static retro_input_poll_t input_poll_cb;
|
||||
static retro_input_state_t input_state_cb;
|
||||
@ -66,6 +67,12 @@ void retro_get_system_av_info(struct retro_system_av_info *info)
|
||||
|
||||
void retro_init()
|
||||
{
|
||||
struct retro_log_callback log;
|
||||
|
||||
environ_cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log);
|
||||
if (log.log)
|
||||
log_cb = log.log;
|
||||
|
||||
// Using uint_least32_t in an audio interface expecting you to cast to short*? :( Weird stuff.
|
||||
assert(sizeof(gambatte::uint_least32_t) == sizeof(uint32_t));
|
||||
gb.setInputGetter(&gb_input);
|
||||
@ -196,7 +203,8 @@ static void check_palette(void)
|
||||
environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &system_directory_c);
|
||||
if (!system_directory_c)
|
||||
{
|
||||
fprintf(stderr, "[Gambatte]: no system directory defined, unable to look for custom palettes.\n");
|
||||
if (log_cb)
|
||||
log_cb(RETRO_LOG_WARN, "[Gambatte]: no system directory defined, unable to look for custom palettes.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -222,7 +230,10 @@ static void check_palette(void)
|
||||
if (!palette_file.is_open())
|
||||
return; // unable to find any custom palette file
|
||||
|
||||
// fprintf(stderr, "[Gambatte]: using custom palette %s.\n", custom_palette_path.c_str());
|
||||
#if 0
|
||||
if (log_cb)
|
||||
fprintf(RETRO_LOG_INFO, "[Gambatte]: using custom palette %s.\n", custom_palette_path.c_str());
|
||||
#endif
|
||||
unsigned line_count = 0;
|
||||
for (std::string line; getline(palette_file, line); ) // iterate over file lines
|
||||
{
|
||||
@ -239,7 +250,8 @@ static void check_palette(void)
|
||||
|
||||
if (line.find("=") == std::string::npos)
|
||||
{
|
||||
fprintf(stderr, "[Gambatte]: error in %s, line %d (color left as default).\n", custom_palette_path.c_str(), line_count);
|
||||
if (log_cb)
|
||||
log_cb(RETRO_LOG_ERROR, "[Gambatte]: error in %s, line %d (color left as default).\n", custom_palette_path.c_str(), line_count);
|
||||
continue; // current line does not contain a palette color definition, so go to next line
|
||||
}
|
||||
|
||||
@ -252,7 +264,9 @@ static void check_palette(void)
|
||||
ss >> rgb32;
|
||||
if (!ss)
|
||||
{
|
||||
fprintf(stderr, "[Gambatte]: unable to read palette color in %s, line %d (color left as default).\n", custom_palette_path.c_str(), line_count);
|
||||
if (log_cb)
|
||||
log_cb(RETRO_LOG_ERROR, "[Gambatte]: unable to read palette color in %s, line %d (color left as default).\n",
|
||||
custom_palette_path.c_str(), line_count);
|
||||
continue;
|
||||
}
|
||||
#ifdef VIDEO_RGB565
|
||||
@ -285,8 +299,8 @@ static void check_palette(void)
|
||||
gb.setDmgPaletteColor(2, 2, rgb32);
|
||||
else if (startswith(line, "Sprite%2023="))
|
||||
gb.setDmgPaletteColor(2, 3, rgb32);
|
||||
else
|
||||
fprintf(stderr, "[Gambatte]: error in %s, line %d (color left as default).\n", custom_palette_path.c_str(), line_count);
|
||||
else if (log_cb)
|
||||
log_cb(RETRO_LOG_ERROR, "[Gambatte]: error in %s, line %d (color left as default).\n", custom_palette_path.c_str(), line_count);
|
||||
} // endfor
|
||||
}
|
||||
|
||||
@ -344,7 +358,8 @@ bool retro_load_game(const struct retro_game_info *info)
|
||||
environ_cb(RETRO_ENVIRONMENT_GET_CAN_DUPE, &can_dupe);
|
||||
if (!can_dupe)
|
||||
{
|
||||
fprintf(stderr, "[Gambatte]: Cannot dupe frames!\n");
|
||||
if (log_cb)
|
||||
log_cb(RETRO_LOG_INFO, "[Gambatte]: Cannot dupe frames!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -352,14 +367,16 @@ bool retro_load_game(const struct retro_game_info *info)
|
||||
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565;
|
||||
if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt))
|
||||
{
|
||||
fprintf(stderr, "[Gambatte]: RGB565 is not supported.\n");
|
||||
if (log_cb)
|
||||
log_cb(RETRO_LOG_INFO, "[Gambatte]: RGB565 is not supported.\n");
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888;
|
||||
if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt))
|
||||
{
|
||||
fprintf(stderr, "[Gambatte]: XRGB8888 is not supported.\n");
|
||||
if (log_cb)
|
||||
log_cb(RETRO_LOG_INFO, "[Gambatte]: XRGB8888 is not supported.\n");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
@ -370,7 +387,8 @@ bool retro_load_game(const struct retro_game_info *info)
|
||||
rom_path = info->path ? info->path : "";
|
||||
strncpy(internal_game_name, (const char*)info->data + 0x134, sizeof(internal_game_name) - 1);
|
||||
|
||||
fprintf(stderr, "[Gambatte]: Got internal game name: %s.\n", internal_game_name);
|
||||
if (log_cb)
|
||||
log_cb(RETRO_LOG_INFO, "[Gambatte]: Got internal game name: %s.\n", internal_game_name);
|
||||
|
||||
check_variables();
|
||||
check_palette();
|
||||
|
280
libgambatte/libretro/libretro.h
Normal file → Executable file
280
libgambatte/libretro/libretro.h
Normal file → Executable file
@ -1,3 +1,25 @@
|
||||
/* Copyright (C) 2010-2013 The RetroArch team
|
||||
*
|
||||
* ---------------------------------------------------------------------------------------
|
||||
* The following license statement only applies to this libretro API header (libretro.h).
|
||||
* ---------------------------------------------------------------------------------------
|
||||
*
|
||||
* Permission is hereby granted, free of charge,
|
||||
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef LIBRETRO_H__
|
||||
#define LIBRETRO_H__
|
||||
|
||||
@ -72,6 +94,9 @@ extern "C" {
|
||||
// Eventually _PRESSED will return false for an index. No further presses are registered at this point.
|
||||
#define RETRO_DEVICE_POINTER 6
|
||||
|
||||
// FIXME: Document this.
|
||||
#define RETRO_DEVICE_SENSOR_ACCELEROMETER 7
|
||||
|
||||
// These device types are specializations of the base types above.
|
||||
// They should only be used in retro_set_controller_type() to inform libretro implementations
|
||||
// about use of a very specific device type.
|
||||
@ -128,6 +153,11 @@ extern "C" {
|
||||
#define RETRO_DEVICE_ID_POINTER_Y 1
|
||||
#define RETRO_DEVICE_ID_POINTER_PRESSED 2
|
||||
|
||||
// Id values for SENSOR types.
|
||||
#define RETRO_DEVICE_ID_SENSOR_ACCELEROMETER_X 0
|
||||
#define RETRO_DEVICE_ID_SENSOR_ACCELEROMETER_Y 1
|
||||
#define RETRO_DEVICE_ID_SENSOR_ACCELEROMETER_Z 2
|
||||
|
||||
// Returned from retro_get_region().
|
||||
#define RETRO_REGION_NTSC 0
|
||||
#define RETRO_REGION_PAL 1
|
||||
@ -335,6 +365,8 @@ enum retro_mod
|
||||
|
||||
// If set, this call is not part of the public libretro API yet. It can change or be removed at any time.
|
||||
#define RETRO_ENVIRONMENT_EXPERIMENTAL 0x10000
|
||||
// Environment callback to be used internally in frontend.
|
||||
#define RETRO_ENVIRONMENT_PRIVATE 0x20000
|
||||
|
||||
// Environment commands.
|
||||
#define RETRO_ENVIRONMENT_SET_ROTATION 1 // const unsigned * --
|
||||
@ -412,10 +444,8 @@ enum retro_mod
|
||||
// Sets an interface which frontend can use to eject and insert disk images.
|
||||
// This is used for games which consist of multiple images and must be manually
|
||||
// swapped out by the user (e.g. PSX).
|
||||
#define RETRO_ENVIRONMENT_SET_HW_RENDER (14 | RETRO_ENVIRONMENT_EXPERIMENTAL)
|
||||
#define RETRO_ENVIRONMENT_SET_HW_RENDER 14
|
||||
// struct retro_hw_render_callback * --
|
||||
// NOTE: This call is currently very experimental, and should not be considered part of the public API.
|
||||
// The interface could be changed or removed at any time.
|
||||
// Sets an interface to let a libretro core render with hardware acceleration.
|
||||
// Should be called in retro_load_game().
|
||||
// If successful, libretro cores will be able to render to a frontend-provided framebuffer.
|
||||
@ -423,7 +453,7 @@ enum retro_mod
|
||||
// If HW rendering is used, pass only RETRO_HW_FRAME_BUFFER_VALID or NULL to retro_video_refresh_t.
|
||||
#define RETRO_ENVIRONMENT_GET_VARIABLE 15
|
||||
// struct retro_variable * --
|
||||
// Interface to aquire user-defined information from environment
|
||||
// Interface to acquire user-defined information from environment
|
||||
// that cannot feasibly be supported in a multi-system way.
|
||||
// 'key' should be set to a key which has already been set by SET_VARIABLES.
|
||||
// 'data' will be set to a value or NULL.
|
||||
@ -452,12 +482,228 @@ enum retro_mod
|
||||
// Result is set to true if some variables are updated by
|
||||
// frontend since last call to RETRO_ENVIRONMENT_GET_VARIABLE.
|
||||
// Variables should be queried with GET_VARIABLE.
|
||||
//
|
||||
#define RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME 18
|
||||
// const bool * --
|
||||
// If true, the libretro implementation supports calls to retro_load_game() with NULL as argument.
|
||||
// Used by cores which can run without particular game data.
|
||||
// This should be called within retro_set_environment() only.
|
||||
//
|
||||
#define RETRO_ENVIRONMENT_GET_LIBRETRO_PATH 19
|
||||
// const char ** --
|
||||
// Retrieves the absolute path from where this libretro implementation was loaded.
|
||||
// NULL is returned if the libretro was loaded statically (i.e. linked statically to frontend), or if the path cannot be determined.
|
||||
// Mostly useful in cooperation with SET_SUPPORT_NO_GAME as assets can be loaded without ugly hacks.
|
||||
//
|
||||
//
|
||||
// Environment 20 was an obsolete version of SET_AUDIO_CALLBACK. It was not used by any known core at the time,
|
||||
// and was removed from the API.
|
||||
#define RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK 22
|
||||
// const struct retro_audio_callback * --
|
||||
// Sets an interface which is used to notify a libretro core about audio being available for writing.
|
||||
// The callback can be called from any thread, so a core using this must have a thread safe audio implementation.
|
||||
// It is intended for games where audio and video are completely asynchronous and audio can be generated on the fly.
|
||||
// This interface is not recommended for use with emulators which have highly synchronous audio.
|
||||
//
|
||||
// The callback only notifies about writability; the libretro core still has to call the normal audio callbacks
|
||||
// to write audio. The audio callbacks must be called from within the notification callback.
|
||||
// The amount of audio data to write is up to the implementation.
|
||||
// Generally, the audio callback will be called continously in a loop.
|
||||
//
|
||||
// Due to thread safety guarantees and lack of sync between audio and video, a frontend
|
||||
// can selectively disallow this interface based on internal configuration. A core using
|
||||
// this interface must also implement the "normal" audio interface.
|
||||
//
|
||||
// A libretro core using SET_AUDIO_CALLBACK should also make use of SET_FRAME_TIME_CALLBACK.
|
||||
#define RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK 21
|
||||
// const struct retro_frame_time_callback * --
|
||||
// Lets the core know how much time has passed since last invocation of retro_run().
|
||||
// The frontend can tamper with the timing to fake fast-forward, slow-motion, frame stepping, etc.
|
||||
// In this case the delta time will use the reference value in frame_time_callback..
|
||||
//
|
||||
#define RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE 23
|
||||
// struct retro_rumble_interface * --
|
||||
// Gets an interface which is used by a libretro core to set state of rumble motors in controllers.
|
||||
// A strong and weak motor is supported, and they can be controlled indepedently.
|
||||
//
|
||||
#define RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES 24
|
||||
// uint64_t * --
|
||||
// Gets a bitmask telling which device type are expected to be handled properly in a call to retro_input_state_t.
|
||||
// Devices which are not handled or recognized always return 0 in retro_input_state_t.
|
||||
// Example bitmask: caps = (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG).
|
||||
// Should only be called in retro_run().
|
||||
//
|
||||
#define RETRO_ENVIRONMENT_GET_SENSOR_INTERFACE (25 | RETRO_ENVIRONMENT_EXPERIMENTAL)
|
||||
// struct retro_sensor_interface * --
|
||||
// Gets access to the sensor interface.
|
||||
// The purpose of this interface is to allow
|
||||
// setting state related to sensors such as polling rate, enabling/disable it entirely, etc.
|
||||
// Reading sensor state is done via the normal input_state_callback API.
|
||||
//
|
||||
#define RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE (26 | RETRO_ENVIRONMENT_EXPERIMENTAL)
|
||||
// struct retro_camera_callback * --
|
||||
// Gets an interface to a video camera driver.
|
||||
// A libretro core can use this interface to get access to a video camera.
|
||||
// New video frames are delivered in a callback in same thread as retro_run().
|
||||
//
|
||||
// GET_CAMERA_INTERFACE should be called in retro_load_game().
|
||||
//
|
||||
// Depending on the camera implementation used, camera frames will be delivered as a raw framebuffer,
|
||||
// or as an OpenGL texture directly.
|
||||
//
|
||||
// The core has to tell the frontend here which types of buffers can be handled properly.
|
||||
// An OpenGL texture can only be handled when using a libretro GL core (SET_HW_RENDER).
|
||||
// It is recommended to use a libretro GL core when using camera interface.
|
||||
//
|
||||
// The camera is not started automatically. The retrieved start/stop functions must be used to explicitly
|
||||
// start and stop the camera driver.
|
||||
//
|
||||
#define RETRO_ENVIRONMENT_GET_LOG_INTERFACE 27
|
||||
// struct retro_log_callback * --
|
||||
// Gets an interface for logging. This is useful for logging in a cross-platform way
|
||||
// as certain platforms cannot use use stderr for logging. It also allows the frontend to
|
||||
// show logging information in a more suitable way.
|
||||
// If this interface is not used, libretro cores should log to stderr as desired.
|
||||
|
||||
enum retro_log_level
|
||||
{
|
||||
RETRO_LOG_DEBUG = 0,
|
||||
RETRO_LOG_INFO,
|
||||
RETRO_LOG_WARN,
|
||||
RETRO_LOG_ERROR,
|
||||
|
||||
RETRO_LOG_DUMMY = INT_MAX
|
||||
};
|
||||
|
||||
// Logging function. Takes log level argument as well.
|
||||
typedef void (*retro_log_printf_t)(enum retro_log_level level, const char *fmt, ...);
|
||||
|
||||
struct retro_log_callback
|
||||
{
|
||||
retro_log_printf_t log;
|
||||
};
|
||||
|
||||
// FIXME: Document the sensor API and work out behavior.
|
||||
// It will be marked as experimental until then.
|
||||
enum retro_sensor_action
|
||||
{
|
||||
RETRO_SENSOR_ACCELEROMETER_ENABLE = 0,
|
||||
RETRO_SENSOR_ACCELEROMETER_DISABLE,
|
||||
|
||||
RETRO_SENSOR_DUMMY = INT_MAX
|
||||
};
|
||||
|
||||
typedef bool (*retro_set_sensor_state_t)(unsigned port, enum retro_sensor_action action, unsigned rate);
|
||||
struct retro_sensor_interface
|
||||
{
|
||||
retro_set_sensor_state_t set_sensor_state;
|
||||
};
|
||||
////
|
||||
|
||||
enum retro_camera_buffer
|
||||
{
|
||||
RETRO_CAMERA_BUFFER_OPENGL_TEXTURE = 0,
|
||||
RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER,
|
||||
|
||||
RETRO_CAMERA_BUFFER_DUMMY = INT_MAX
|
||||
};
|
||||
|
||||
// Starts the camera driver. Can only be called in retro_run().
|
||||
typedef bool (*retro_camera_start_t)(void);
|
||||
// Stops the camera driver. Can only be called in retro_run().
|
||||
typedef void (*retro_camera_stop_t)(void);
|
||||
// Callback which signals when the camera driver is initialized and/or deinitialized.
|
||||
// retro_camera_start_t can be called in initialized callback.
|
||||
typedef void (*retro_camera_lifetime_status_t)(void);
|
||||
// A callback for raw framebuffer data. buffer points to an XRGB8888 buffer.
|
||||
// Width, height and pitch are similar to retro_video_refresh_t.
|
||||
// First pixel is top-left origin.
|
||||
typedef void (*retro_camera_frame_raw_framebuffer_t)(const uint32_t *buffer, unsigned width, unsigned height, size_t pitch);
|
||||
// A callback for when OpenGL textures are used.
|
||||
//
|
||||
// texture_id is a texture owned by camera driver.
|
||||
// Its state or content should be considered immutable, except for things like texture filtering and clamping.
|
||||
//
|
||||
// texture_target is the texture target for the GL texture.
|
||||
// These can include e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE, and possibly more depending on extensions.
|
||||
//
|
||||
// affine points to a packed 3x3 column-major matrix used to apply an affine transform to texture coordinates. (affine_matrix * vec3(coord_x, coord_y, 1.0))
|
||||
// After transform, normalized texture coord (0, 0) should be bottom-left and (1, 1) should be top-right (or (width, height) for RECTANGLE).
|
||||
//
|
||||
// GL-specific typedefs are avoided here to avoid relying on gl.h in the API definition.
|
||||
typedef void (*retro_camera_frame_opengl_texture_t)(unsigned texture_id, unsigned texture_target, const float *affine);
|
||||
struct retro_camera_callback
|
||||
{
|
||||
uint64_t caps; // Set by libretro core. Example bitmask: caps = (1 << RETRO_CAMERA_BUFFER_OPENGL_TEXTURE) | (1 << RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER).
|
||||
|
||||
unsigned width; // Desired resolution for camera. Is only used as a hint.
|
||||
unsigned height;
|
||||
retro_camera_start_t start; // Set by frontend.
|
||||
retro_camera_stop_t stop; // Set by frontend.
|
||||
|
||||
retro_camera_frame_raw_framebuffer_t frame_raw_framebuffer; // Set by libretro core if raw framebuffer callbacks will be used.
|
||||
retro_camera_frame_opengl_texture_t frame_opengl_texture; // Set by libretro core if OpenGL texture callbacks will be used.
|
||||
|
||||
// Set by libretro core. Called after camera driver is initialized and ready to be started.
|
||||
// Can be NULL, in which this callback is not called.
|
||||
retro_camera_lifetime_status_t initialized;
|
||||
|
||||
// Set by libretro core. Called right before camera driver is deinitialized.
|
||||
// Can be NULL, in which this callback is not called.
|
||||
retro_camera_lifetime_status_t deinitialized;
|
||||
};
|
||||
|
||||
enum retro_rumble_effect
|
||||
{
|
||||
RETRO_RUMBLE_STRONG = 0,
|
||||
RETRO_RUMBLE_WEAK = 1,
|
||||
|
||||
RETRO_RUMBLE_DUMMY = INT_MAX
|
||||
};
|
||||
|
||||
// Sets rumble state for joypad plugged in port 'port'. Rumble effects are controlled independently,
|
||||
// and setting e.g. strong rumble does not override weak rumble.
|
||||
// Strength has a range of [0, 0xffff].
|
||||
//
|
||||
// Returns true if rumble state request was honored. Calling this before first retro_run() is likely to return false.
|
||||
typedef bool (*retro_set_rumble_state_t)(unsigned port, enum retro_rumble_effect effect, uint16_t strength);
|
||||
struct retro_rumble_interface
|
||||
{
|
||||
retro_set_rumble_state_t set_rumble_state;
|
||||
};
|
||||
|
||||
// Notifies libretro that audio data should be written.
|
||||
typedef void (*retro_audio_callback_t)(void);
|
||||
|
||||
// True: Audio driver in frontend is active, and callback is expected to be called regularily.
|
||||
// False: Audio driver in frontend is paused or inactive. Audio callback will not be called until set_state has been called with true.
|
||||
// Initial state is false (inactive).
|
||||
typedef void (*retro_audio_set_state_callback_t)(bool enabled);
|
||||
struct retro_audio_callback
|
||||
{
|
||||
retro_audio_callback_t callback;
|
||||
retro_audio_set_state_callback_t set_state;
|
||||
};
|
||||
|
||||
// Notifies a libretro core of time spent since last invocation of retro_run() in microseconds.
|
||||
// It will be called right before retro_run() every frame.
|
||||
// The frontend can tamper with timing to support cases like fast-forward, slow-motion and framestepping.
|
||||
// In those scenarios the reference frame time value will be used.
|
||||
typedef int64_t retro_usec_t;
|
||||
typedef void (*retro_frame_time_callback_t)(retro_usec_t usec);
|
||||
struct retro_frame_time_callback
|
||||
{
|
||||
retro_frame_time_callback_t callback;
|
||||
retro_usec_t reference; // Represents the time of one frame. It is computed as 1000000 / fps, but the implementation will resolve the rounding to ensure that framestepping, etc is exact.
|
||||
};
|
||||
|
||||
// Pass this to retro_video_refresh_t if rendering to hardware.
|
||||
// Passing NULL to retro_video_refresh_t is still a frame dupe as normal.
|
||||
#define RETRO_HW_FRAME_BUFFER_VALID ((void*)-1)
|
||||
|
||||
// Invalidates the current HW context.
|
||||
// Any GL state is lost, and must not be deinitialized explicitly. If explicit deinitialization is desired by the libretro core,
|
||||
// it should implement context_destroy callback.
|
||||
// If called, all GPU resources must be reinitialized.
|
||||
// Usually called when frontend reinits video driver.
|
||||
// Also called first time video driver is initialized, allowing libretro core to init resources.
|
||||
@ -472,8 +718,10 @@ typedef retro_proc_address_t (*retro_hw_get_proc_address_t)(const char *sym);
|
||||
enum retro_hw_context_type
|
||||
{
|
||||
RETRO_HW_CONTEXT_NONE = 0,
|
||||
RETRO_HW_CONTEXT_OPENGL, // OpenGL 2.x. Latest version available before 3.x+.
|
||||
RETRO_HW_CONTEXT_OPENGL, // OpenGL 2.x. Latest version available before 3.x+. Driver can choose to use latest compatibility context.
|
||||
RETRO_HW_CONTEXT_OPENGLES2, // GLES 2.0
|
||||
RETRO_HW_CONTEXT_OPENGL_CORE, // Modern desktop core GL context. Use major/minor fields to set GL version.
|
||||
RETRO_HW_CONTEXT_OPENGLES3, // GLES 3.0
|
||||
|
||||
RETRO_HW_CONTEXT_DUMMY = INT_MAX
|
||||
};
|
||||
@ -481,10 +729,21 @@ enum retro_hw_context_type
|
||||
struct retro_hw_render_callback
|
||||
{
|
||||
enum retro_hw_context_type context_type; // Which API to use. Set by libretro core.
|
||||
retro_hw_context_reset_t context_reset; // Set by libretro core.
|
||||
retro_hw_context_reset_t context_reset; // Called when a context has been created or when it has been reset.
|
||||
retro_hw_get_current_framebuffer_t get_current_framebuffer; // Set by frontend.
|
||||
retro_hw_get_proc_address_t get_proc_address; // Set by frontend.
|
||||
bool depth; // Set if render buffers should have depth component attached.
|
||||
bool stencil; // Set if stencil buffers should be attached.
|
||||
// If depth and stencil are true, a packed 24/8 buffer will be added. Only attaching stencil is invalid and will be ignored.
|
||||
bool bottom_left_origin; // Use conventional bottom-left origin convention. Is false, standard libretro top-left origin semantics are used.
|
||||
unsigned version_major; // Major version number for core GL context.
|
||||
unsigned version_minor; // Minor version number for core GL context.
|
||||
|
||||
bool cache_context; // If this is true, the frontend will go very far to avoid resetting context in scenarios like toggling fullscreen, etc.
|
||||
// The reset callback might still be called in extreme situations such as if the context is lost beyond recovery.
|
||||
// For optimal stability, set this to false, and allow context to be reset at any time.
|
||||
retro_hw_context_reset_t context_destroy; // A callback to be called before the context is destroyed. Resources can be deinitialized at this step. This can be set to NULL, in which resources will just be destroyed without any notification.
|
||||
bool debug_context; // Creates a debug context.
|
||||
};
|
||||
|
||||
// Callback type passed in RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK. Called by the frontend in response to keyboard events.
|
||||
@ -492,11 +751,18 @@ struct retro_hw_render_callback
|
||||
// keycode is the RETROK value of the char.
|
||||
// character is the text character of the pressed key. (UTF-32).
|
||||
// key_modifiers is a set of RETROKMOD values or'ed together.
|
||||
//
|
||||
// The pressed/keycode state can be indepedent of the character.
|
||||
// It is also possible that multiple characters are generated from a single keypress.
|
||||
// Keycode events should be treated separately from character events.
|
||||
// However, when possible, the frontend should try to synchronize these.
|
||||
// If only a character is posted, keycode should be RETROK_UNKNOWN.
|
||||
// Similarily if only a keycode event is generated with no corresponding character, character should be 0.
|
||||
typedef void (*retro_keyboard_event_t)(bool down, unsigned keycode, uint32_t character, uint16_t key_modifiers);
|
||||
|
||||
struct retro_keyboard_callback
|
||||
{
|
||||
retro_keyboard_event_t callback;
|
||||
retro_keyboard_event_t callback;
|
||||
};
|
||||
|
||||
// Callbacks for RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE.
|
||||
|
Loading…
Reference in New Issue
Block a user