pub struct LoadGameContext<'a> {
pub(crate) environment_callback: &'a retro_environment_t,
pub(crate) interfaces: Arc<RwLock<InterfaceList>>,
}
Expand description
Functions that are safe to be called in Core::on_load_game
.
For a description of the callbacks see CoreWrapper
.
Fields§
§environment_callback: &'a retro_environment_t
§interfaces: Arc<RwLock<InterfaceList>>
Implementations§
Source§impl<'a> LoadGameContext<'a>
impl<'a> LoadGameContext<'a>
pub(crate) fn new( environment_callback: &'a retro_environment_t, interfaces: Arc<RwLock<InterfaceList>>, ) -> Self
Sourcepub fn enable_frame_time_callback(&self, reference: i64)
pub fn enable_frame_time_callback(&self, reference: i64)
The 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.
Sourcepub unsafe fn enable_camera_interface(
&mut self,
caps: u64,
width: u32,
height: u32,
) -> Result<(), Box<dyn Error>>
pub unsafe fn enable_camera_interface( &mut self, caps: u64, width: u32, height: u32, ) -> Result<(), Box<dyn Error>>
Unstable
§This feature is unstable and guarded by the unstable-env-commands
feature flag.
Please be advised that this feature might change without further notice and no guarantees about its stability can be made.
Sourcepub unsafe fn enable_sensor_interface(&mut self) -> Result<(), Box<dyn Error>>
pub unsafe fn enable_sensor_interface(&mut self) -> Result<(), Box<dyn Error>>
Unstable
§This feature is unstable and guarded by the unstable-env-commands
feature flag.
Please be advised that this feature might change without further notice and no guarantees about its stability can be made.
Sourcepub unsafe fn enable_led_interface(&mut self) -> Result<(), Box<dyn Error>>
pub unsafe fn enable_led_interface(&mut self) -> Result<(), Box<dyn Error>>
Unstable
§This feature is unstable and guarded by the unstable-env-commands
feature flag.
Please be advised that this feature might change without further notice and no guarantees about its stability can be made.
Sourcepub unsafe fn enable_midi_interface(&mut self) -> Result<(), Box<dyn Error>>
pub unsafe fn enable_midi_interface(&mut self) -> Result<(), Box<dyn Error>>
Unstable
§This feature is unstable and guarded by the unstable-env-commands
feature flag.
Please be advised that this feature might change without further notice and no guarantees about its stability can be made.
pub fn enable_location_interface(&mut self) -> Result<(), Box<dyn Error>>
pub fn enable_rumble_interface(&mut self) -> Result<(), Box<dyn Error>>
pub fn enable_perf_interface(&mut self) -> Result<(), Box<dyn Error>>
pub unsafe fn enable_hw_render( &mut self, context_type: retro_hw_context_type, bottom_left_origin: bool, version_major: u32, version_minor: u32, debug_context: bool, ) -> bool
Sourcepub unsafe fn set_hw_render_context_negotiation_interface_data<T: HwRenderContextNegotiationInterface + 'static>(
&mut self,
interface: T,
) -> bool
pub unsafe fn set_hw_render_context_negotiation_interface_data<T: HwRenderContextNegotiationInterface + 'static>( &mut self, interface: T, ) -> bool
Unstable
§This feature is unstable and guarded by the unstable-env-commands
feature flag.
Please be advised that this feature might change without further notice and no guarantees about its stability can be made.
Sourcepub unsafe fn enable_hw_render_negotiation_interface(
&mut self,
interface_type: retro_hw_render_context_negotiation_interface_type,
interface_version: u32,
) -> bool
pub unsafe fn enable_hw_render_negotiation_interface( &mut self, interface_type: retro_hw_render_context_negotiation_interface_type, interface_version: u32, ) -> bool
Unstable
§This feature is unstable and guarded by the unstable-env-commands
feature flag.
Please be advised that this feature might change without further notice and no guarantees about its stability can be made.
Sourcepub unsafe fn enable_hw_render_negotiation_interface_vulkan(
&mut self,
get_application_info: retro_vulkan_get_application_info_t,
create_device: retro_vulkan_create_device_t,
destroy_device: retro_vulkan_destroy_device_t,
) -> bool
pub unsafe fn enable_hw_render_negotiation_interface_vulkan( &mut self, get_application_info: retro_vulkan_get_application_info_t, create_device: retro_vulkan_create_device_t, destroy_device: retro_vulkan_destroy_device_t, ) -> bool
Unstable
§This feature is unstable and guarded by the unstable-env-commands
feature flag.
Please be advised that this feature might change without further notice and no guarantees about its stability can be made.
Source§impl LoadGameContext<'_>
impl LoadGameContext<'_>
Sourcepub fn set_performance_level(&self, level: u8) -> bool
pub fn set_performance_level(&self, level: u8) -> bool
Gives a hint to the frontend how demanding this implementation is on a system. E.g. reporting a level of 2 means this implementation should run decently on all frontends of level 2 and up.
It can be used by the frontend to potentially warn about too demanding implementations.
The levels are “floating”.
This function can be called on a per-game basis, as certain games an implementation can play might be particularly demanding.
Source§impl LoadGameContext<'_>
impl LoadGameContext<'_>
Sourcepub fn set_pixel_format<F: Into<retro_pixel_format>>(&self, format: F) -> bool
pub fn set_pixel_format<F: Into<retro_pixel_format>>(&self, format: F) -> bool
Sets the internal pixel format used by the implementation.
The default pixel format is retro_pixel_format::RETRO_PIXEL_FORMAT_0RGB1555
.
This pixel format however, is deprecated (see enum retro_pixel_format
).
If the call returns false
, the frontend does not support this pixel
format.
Source§impl LoadGameContext<'_>
impl LoadGameContext<'_>
Sourcepub fn set_hw_render(&self, data: retro_hw_render_callback) -> bool
pub fn set_hw_render(&self, data: retro_hw_render_callback) -> bool
Sets an interface to let a libretro core render with hardware acceleration.
If successful, libretro cores will be able to render to a
frontend-provided framebuffer.
The size of this framebuffer will be at least as large as
max_width/max_height provided in Core::on_get_av_info
.
If HW rendering is used, call either
RunContext::draw_hardware_frame
or RunContext::dupe_frame
.
Source§impl LoadGameContext<'_>
impl LoadGameContext<'_>
Sourcepub fn set_frame_time_callback(&self, data: retro_frame_time_callback) -> bool
pub fn set_frame_time_callback(&self, data: retro_frame_time_callback) -> bool
Lets the core know how much time has passed since last
invocation of Core::on_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 retro_frame_time_callback
.
Source§impl LoadGameContext<'_>
impl LoadGameContext<'_>
Sourcepub fn get_rumble_interface(&self) -> Option<retro_rumble_interface>
pub fn get_rumble_interface(&self) -> Option<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.
Should be called from either Core::on_init
or Core::on_load_game
.
Should not be called from Core::on_set_environment
.
Returns false if rumble functionality is unavailable.
Source§impl LoadGameContext<'_>
impl LoadGameContext<'_>
Sourcepub unsafe fn get_camera_interface(
&self,
data: retro_camera_callback,
) -> Option<retro_camera_callback>
pub unsafe fn get_camera_interface( &self, data: retro_camera_callback, ) -> Option<retro_camera_callback>
Unstable
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 Core::on_run
.
get_camera_interface
should be called in Core::on_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
§This feature is unstable and guarded by the unstable-env-commands
feature flag.
Please be advised that this feature might change without further notice and no guarantees about its stability can be made.
Source§impl LoadGameContext<'_>
impl LoadGameContext<'_>
Sourcepub unsafe fn set_memory_maps(&self, data: retro_memory_map) -> bool
pub unsafe fn set_memory_maps(&self, data: retro_memory_map) -> bool
Unstable This environment call lets a libretro core tell the frontend about the memory maps this core emulates. This can be used to implement, for example, cheats in a core-agnostic way.
Should only be used by emulators; it doesn’t make much sense for anything else. It is recommended to expose all relevant pointers through retro_get_memory_* as well.
Can be called from Core::on_init
and Core::on_load_game
.
§This feature is unstable and guarded by the unstable-env-commands
feature flag.
Please be advised that this feature might change without further notice and no guarantees about its stability can be made.
Source§impl LoadGameContext<'_>
impl LoadGameContext<'_>
Sourcepub unsafe fn set_hw_render_context_negotiation_interface(
&self,
interface: &retro_hw_render_context_negotiation_interface,
) -> bool
pub unsafe fn set_hw_render_context_negotiation_interface( &self, interface: &retro_hw_render_context_negotiation_interface, ) -> bool
Unstable
Sets an interface which lets the libretro core negotiate with frontend how a context is created.
The semantics of this interface depends on which API is used in set_hw_render
earlier.
This interface will be used when the frontend is trying to create a HW rendering context,
so it will be used after set_hw_render
, but before the context_reset callback.
§This feature is unstable and guarded by the unstable-env-commands
feature flag.
Please be advised that this feature might change without further notice and no guarantees about its stability can be made.
Source§impl LoadGameContext<'_>
impl LoadGameContext<'_>
Sourcepub fn set_serialization_quirks(&self, quirks: SerializationQuirks) -> bool
pub fn set_serialization_quirks(&self, quirks: SerializationQuirks) -> bool
Sets quirk flags associated with serialization. The frontend will zero any flags it doesn’t recognize or support.
Should be set in either Core::on_init
or Core::on_load_game
, but not both.
Source§impl LoadGameContext<'_>
impl LoadGameContext<'_>
Sourcepub fn get_game_info_ext(&self) -> Option<retro_game_info_ext>
pub fn get_game_info_ext(&self) -> Option<retro_game_info_ext>
Allows an implementation to fetch extended game
information, providing additional content path
and memory buffer status details.
This function may only be called inside
Core::on_load_game
or Core::on_load_game_special
.
If callback returns false
, extended game information
is unsupported by the frontend. In this case, only
regular retro_game_info
will be available.
get_game_info_ext
is guaranteed
to return true if set_content_info_override
returns true
.
‘data’ points to an array of [retro_game_info_ext structs
].
For struct member descriptions, see the definition of
struct retro_game_info_ext
.
- If function is called inside
Core::on_load_game
, theretro_game_info_ext
array is guaranteed to have a size of 1 - i.e. the returned pointer may be used to access directly the members of the firstretro_game_info_ext
struct, for example:
struct retro_game_info_ext *game_info_ext;
if (environ_cb(RETRO_ENVIRONMENT_GET_GAME_INFO_EXT, &game_info_ext))
printf("Content Directory: %s\n", game_info_ext->dir);
- If the function is called inside
Core::on_load_game_special
, theretro_game_info_ext
array is guaranteed to have a size equal to thenum_info
argument passed toCore::on_load_game_special