Struct LoadGameContext

Source
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>

Source

pub(crate) fn new( environment_callback: &'a retro_environment_t, interfaces: Arc<RwLock<InterfaceList>>, ) -> Self

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn enable_location_interface(&mut self) -> Result<(), Box<dyn Error>>

Source

pub fn enable_rumble_interface(&mut self) -> Result<(), Box<dyn Error>>

Source

pub fn enable_perf_interface(&mut self) -> Result<(), Box<dyn Error>>

Source

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

Source

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.

Source

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.

Source

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<'_>

Source

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<'_>

Source

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<'_>

Source

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<'_>

Source

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<'_>

Source

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<'_>

Source

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<'_>

Source

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<'_>

Source

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<'_>

Source

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<'_>

Source

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.

    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);

Trait Implementations§

Source§

impl<'a> From<&LoadGameContext<'a>> for GenericContext<'a>

Source§

fn from(other: &LoadGameContext<'a>) -> GenericContext<'a>

Converts to this type from the input type.
Source§

impl<'a> From<&LoadGameSpecialContext<'a>> for LoadGameContext<'a>

Source§

fn from(other: &LoadGameSpecialContext<'a>) -> LoadGameContext<'a>

Converts to this type from the input type.
Source§

impl<'a> From<&mut LoadGameContext<'a>> for GenericContext<'a>

Source§

fn from(other: &mut LoadGameContext<'a>) -> GenericContext<'a>

Converts to this type from the input type.
Source§

impl<'a> From<&mut LoadGameSpecialContext<'a>> for LoadGameContext<'a>

Source§

fn from(other: &mut LoadGameSpecialContext<'a>) -> LoadGameContext<'a>

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for LoadGameContext<'a>

§

impl<'a> RefUnwindSafe for LoadGameContext<'a>

§

impl<'a> !Send for LoadGameContext<'a>

§

impl<'a> !Sync for LoadGameContext<'a>

§

impl<'a> Unpin for LoadGameContext<'a>

§

impl<'a> UnwindSafe for LoadGameContext<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.