Struct GenericContext

Source
pub struct GenericContext<'a> {
    pub(crate) environment_callback: &'a retro_environment_t,
    pub(crate) interfaces: Arc<RwLock<InterfaceList>>,
}
Expand description

Exposes environment callbacks that are safe to call in every context.

Fields§

§environment_callback: &'a retro_environment_t§interfaces: Arc<RwLock<InterfaceList>>

Implementations§

Source§

impl<'a> GenericContext<'a>

Source

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

Source

pub unsafe fn environment_callback(&self) -> &'a retro_environment_t

Source

pub unsafe fn interfaces(&self) -> Arc<RwLock<InterfaceList>>

Source

pub fn enable_keyboard_callback(&self) -> bool

Enables the Core::on_keyboard_event callback.

Source

pub fn enable_audio_callback(&self) -> bool

Source

pub fn enable_disk_control_interface(&self) -> bool

Source

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

Source

pub fn enable_audio_buffer_status_callback(&self) -> bool

Source

pub unsafe fn set_led_state(&self, led: i32, state: i32)

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 set_rumble_state( &self, port: u32, effect: retro_rumble_effect, strength: u16, ) -> bool

Source

pub fn start_perf_counter( &mut self, name: &'static str, ) -> Result<(), Box<dyn Error>>

Source

pub fn stop_perf_counter( &mut self, name: &'static str, ) -> Result<(), Box<dyn Error>>

Source

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

Source

pub fn perf_get_time_usec(&self) -> i64

Source

pub fn perf_get_counter(&self) -> u64

Source

pub fn get_cpu_features(&self) -> CpuFeatures

Source

pub fn location_service_start(&self)

Source

pub fn location_service_stop(&self)

Source

pub fn location_service_get_position(&self) -> Option<Position>

Source

pub fn location_service_set_interval( &self, interval_ms: u32, interval_distance: u32, )

Source

pub fn midi_input_enabled(&self) -> bool

Source

pub fn midi_output_enabled(&self) -> bool

Source

pub fn midi_read_next(&self) -> Option<u8>

Source

pub fn midi_write_byte(&self, value: u8, delta_time: u32) -> bool

Source

pub fn midi_flush(&self) -> bool

Source

pub unsafe fn vfs_get_path( &self, handle: &mut retro_vfs_file_handle, ) -> Option<CString>

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 vfs_open( &self, path: &str, mode: VfsFileOpenFlags, hints: VfsFileOpenHints, ) -> Result<retro_vfs_file_handle, 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 vfs_close( &self, handle: retro_vfs_file_handle, ) -> 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 vfs_size( &self, handle: &mut retro_vfs_file_handle, ) -> Result<u64, 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 vfs_truncate( &self, handle: &mut retro_vfs_file_handle, length: i64, ) -> 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 vfs_tell( &self, handle: &mut retro_vfs_file_handle, ) -> Result<u64, 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 vfs_seek( &self, handle: &mut retro_vfs_file_handle, offset: i64, seek_position: VfsSeekPosition, ) -> Result<u64, 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 vfs_read( &self, handle: &mut retro_vfs_file_handle, length: usize, ) -> Result<Vec<u8>, 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 vfs_write( &self, handle: &mut retro_vfs_file_handle, buffer: &mut [u8], ) -> Result<u64, 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 vfs_flush( &self, handle: &mut retro_vfs_file_handle, ) -> 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 vfs_remove(&self, path: &str) -> 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 vfs_rename( &self, old_path: &str, new_path: &str, ) -> 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 vfs_stat( &self, path: &str, ) -> Result<(VfsStat, u64), 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 vfs_mkdir(&self, dir: &str) -> 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 vfs_opendir( &self, dir: &str, include_hidden: bool, ) -> Result<retro_vfs_dir_handle, 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 vfs_readdir( &self, handle: &mut retro_vfs_dir_handle, ) -> 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 vfs_dirent_get_name( &self, handle: &mut retro_vfs_dir_handle, ) -> Result<CString, 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 vfs_dirent_is_dir( &self, handle: &mut retro_vfs_dir_handle, ) -> Result<bool, 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 vfs_closedir( &self, handle: retro_vfs_dir_handle, ) -> 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§

impl GenericContext<'_>

Source

pub fn set_rotation(&self, rotation: Rotation) -> bool

Sets screen rotation of graphics.

Source§

impl GenericContext<'_>

Source

pub fn get_overscan(&self) -> bool

👎Deprecated: This function is considered deprecated in favor of using core options to manage overscan in a more nuanced, core-specific way

Boolean value whether or not the implementation should use overscan, or crop away overscan.

Source§

impl GenericContext<'_>

Source

pub fn can_dupe(&self) -> bool

Boolean value whether or not frontend supports frame duping, passing NULL to video frame callback.

Source§

impl GenericContext<'_>

Source

pub fn set_message(&self, message: &str, frames: u32) -> bool

Sets a message to be displayed in implementation-specific manner for a certain amount of ‘frames’. Should not be used for trivial messages, which should simply be logged via RETRO_ENVIRONMENT_GET_LOG_INTERFACE (or as a fallback, stderr).

Source§

impl GenericContext<'_>

Source

pub fn shutdown(&self)

Requests the frontend to shutdown. Should only be used if game has a specific way to shutdown the game from a menu item or similar.

Source§

impl GenericContext<'_>

Source

pub fn get_system_directory<'a>(&self) -> Option<&'a Path>

Returns the “system” directory of the frontend. This directory can be used to store system specific content such as BIOSes, configuration data, etc. The returned value can be NULL. If so, no such directory is defined, and it’s up to the implementation to find a suitable directory.

NOTE: Some cores used this folder also for “save” data such as memory cards, etc, for lack of a better place to put it. This is now discouraged, and if possible, cores should try to use the new get_save_directory().

Source§

impl GenericContext<'_>

Source

pub fn set_input_descriptors( &self, descriptors: &[retro_input_descriptor], ) -> bool

Sets an array of retro_input_descriptors. It is up to the frontend to present this in a usable way. The array is terminated by retro_input_descriptor::description being set to NULL. This function can be called at any time, but it is recommended to call it as early as possible.

Source§

impl GenericContext<'_>

Source

pub fn set_keyboard_callback(&self, data: retro_keyboard_callback) -> bool

Sets a callback function used to notify core about keyboard events.

Source§

impl GenericContext<'_>

Source

pub fn set_disk_control_interface( &self, data: retro_disk_control_callback, ) -> bool

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

Source§

impl GenericContext<'_>

Source

pub fn get_variable<'a>(&self, key: &'a str) -> Option<&'a str>

Interface to acquire user-defined information from environment that cannot feasibly be supported in a multi-system way.

The key should be set to a key which has already been set by set_variables or set_core_options.

Returns None if the variable could not be found.

Source§

impl GenericContext<'_>

Source

pub fn get_variable_update(&self) -> bool

Result is set to true if some variables are updated by frontend since last call to get_variable.

Source§

impl GenericContext<'_>

Source

pub fn get_libretro_path<'a>(&self) -> Option<&'a Path>

Retrieves the absolute path from where this libretro implementation was loaded. None 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.

Source§

impl GenericContext<'_>

Source

pub fn set_audio_callback(&self, data: retro_audio_callback) -> bool

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.

Source§

impl GenericContext<'_>

Source

pub unsafe fn get_sensor_interface(&self) -> Option<retro_sensor_interface>

Unstable 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.

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

Source

pub fn get_log_callback( &self, ) -> Result<Option<retro_log_callback>, Box<dyn Error>>

Gets an interface for logging. This is useful for logging in a cross-platform way as certain platforms cannot 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.

Source§

impl GenericContext<'_>

Source

pub fn get_perf_interface(&self) -> Option<retro_perf_callback>

Gets an interface for performance counters. This is useful for performance logging in a cross-platform way and for detecting architecture-specific features, such as SIMD support.

Source§

impl GenericContext<'_>

Source

pub fn get_location_callback(&self) -> Option<retro_location_callback>

Gets access to the location interface. The purpose of this interface is to be able to retrieve location-based information from the host device, such as current latitude / longitude.

Source§

impl GenericContext<'_>

Source

pub fn get_core_assets_directory<'a>(&self) -> Option<&'a Path>

Returns the “core assets” directory of the frontend. This directory can be used to store specific assets that the core relies upon, such as art assets, input data, etc etc. The returned value can be None. If so, no such directory is defined, and it’s up to the implementation to find a suitable directory.

Source§

impl GenericContext<'_>

Source

pub fn get_save_directory<'a>(&self) -> Option<&'a Path>

Returns the “save” directory of the frontend, unless there is no save directory available. The save directory should be used to store SRAM, memory cards, high scores, etc, if the libretro core cannot use the regular memory interface (Core::get_memory_data).

If the frontend cannot designate a save directory, it will return None to indicate that the core should attempt to operate without a save directory set.

NOTE: early libretro cores used the system directory for save files. Cores that need to be backwards-compatible can still check get_system_directory.

Source§

impl GenericContext<'_>

Source

pub fn set_controller_info(&self, data: &[retro_controller_info]) -> bool

This environment call lets a libretro core tell the frontend which controller subclasses are recognized in calls to Core::on_set_controller_port_device.

Some emulators such as Super Nintendo support multiple lightgun types which must be specifically selected from. It is therefore sometimes necessary for a frontend to be able to tell the core about a special kind of input device which is not specifcally provided by the Libretro API.

In order for a frontend to understand the workings of those devices, they must be defined as a specialized subclass of the generic device types already defined in the libretro API.

The core must pass an array of const struct retro_controller_info which is terminated with a blanked out struct. Each element of the retro_controller_info struct corresponds to the ascending port index that is passed to Core::on_set_controller_port_device when that function is called to indicate to the core that the frontend has changed the active device subclass. SEE ALSO: Core::on_set_controller_port_device

The ascending input port indexes provided by the core in the struct are generally presented by frontends as ascending User # or Player #, such as Player 1, Player 2, Player 3, etc. Which device subclasses are supported can vary per input port.

The first inner element of each entry in the retro_controller_info array is a retro_controller_description struct that specifies the names and codes of all device subclasses that are available for the corresponding User or Player, beginning with the generic Libretro device that the subclasses are derived from. The second inner element of each entry is the total number of subclasses that are listed in the retro_controller_description.

NOTE: Even if special device types are set in the libretro core, libretro should only poll input based on the base input device types.

Source§

impl GenericContext<'_>

Source

pub fn get_username<'a>(&self) -> Option<&'a str>

Returns the specified username of the frontend, if specified by the user. This username can be used as a nickname for a core that has online facilities or any other mode where personalization of the user is desirable. The returned value can be None. If this environment callback is used by a core that requires a valid username, a default username should be specified by the core.

Source§

impl GenericContext<'_>

Source

pub fn get_language(&self) -> Option<retro_language>

Returns the language of the frontend, if specified by the user. It can be used by the core for localization purposes.

Source§

impl GenericContext<'_>

Source

pub unsafe fn get_current_software_framebuffer( &self, data: retro_framebuffer, ) -> Option<retro_framebuffer>

Unstable Returns a preallocated framebuffer which the core can use for rendering the frame into when not using set_hw_render. The framebuffer returned from this call must not be used after the current call to Core::on_run returns.

The goal of this call is to allow zero-copy behavior where a core can render directly into video memory, avoiding extra bandwidth cost by copying memory from core to video memory.

If this call succeeds and the core renders into it, the framebuffer pointer and pitch can be passed to RunContext::draw_framebuffer. If the buffer from get_current_software_framebuffer is to be used, the core must pass the exact same pointer as returned by get_current_software_framebuffer; i.e. passing a pointer which is offset from the buffer is undefined. The width, height and pitch parameters must also match exactly to the values obtained from get_current_software_framebuffer.

It is possible for a frontend to return a different pixel format than the one used in set_pixel_format. This can happen if the frontend needs to perform conversion.

It is still valid for a core to render to a different buffer even if get_current_software_framebuffer succeeds.

A frontend must make sure that the pointer obtained from this function is writeable (and readable).

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

Source

pub unsafe fn get_hw_render_interface( &self, ) -> Option<retro_hw_render_interface>

Unstable Returns an API specific rendering interface for accessing API specific data. Not all HW rendering APIs support or need this. The contents of the returned pointer is specific to the rendering API being used. See the various headers like libretro_vulkan.h, etc.

get_hw_render_interface cannot be called before retro_hw_context_reset_callback has been called.

Similarly, after retro_hw_context_destroyed_callback returns, the contents of the HW_RENDER_INTERFACE are invalidated.

TODO: Set a status flag in retro_hw_context_reset_callback and retro_hw_context_destroyed_callback to force the mentioned call restrictions.

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

Source

pub unsafe fn get_hw_render_interface_vulkan( &self, ) -> Option<retro_hw_render_interface_vulkan>

Unstable See get_hw_render_interface.

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

Source

pub unsafe fn set_hw_shared_context(&self) -> bool

Unstable The frontend will try to use a ‘shared’ hardware context (mostly applicable to OpenGL) when a hardware context is being set up.

Returns true if the frontend supports shared hardware contexts and false if the frontend does not support shared hardware contexts.

This will do nothing on its own until SET_HW_RENDER environment callbacks are being used.

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

Source

pub unsafe fn get_led_interface(&self) -> Option<retro_led_interface>

Unstable Gets an interface which is used by a libretro core to set state of LEDs.

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

Source

pub unsafe fn get_audio_video_enable(&self) -> AudioVideoEnable

Unstable Tells the core if the frontend wants audio or video. If disabled, the frontend will discard the audio or video, so the core may decide to skip generating a frame or generating audio. This is mainly used for increasing performance.

See AudioVideoEnable for descriptions of the flags.

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

Source

pub unsafe fn get_midi_interface(&self) -> Option<retro_midi_interface>

Unstable Returns a MIDI interface that can be used for raw data I/O.

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

Source

pub unsafe fn get_fastforwarding(&self) -> bool

Unstable Boolean value that indicates whether or not the frontend is in fastforwarding mode.

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

Source

pub unsafe fn get_target_refresh_rate(&self) -> Option<f32>

Unstable Float value that lets us know what target refresh rate is curently in use by the frontend.

The core can use the returned value to set an ideal refresh rate/framerate.

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

Source

pub unsafe fn get_input_bitmasks(&self) -> bool

Unstable Boolean value that indicates whether or not the frontend supports input bitmasks being returned by retro_input_state_t. The advantage of this is that retro_input_state_t has to be only called once to grab all button states instead of multiple times.

If it returns true, you can pass RETRO_DEVICE_ID_JOYPAD_MASK as id to retro_input_state_t (make sure device is set to RETRO_DEVICE_JOYPAD). It will return a bitmask of all the digital buttons.

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

Source

pub fn get_core_options_version(&self) -> u32

The returned value is the API version number of the core options interface supported by the frontend. If the underlying callback failed, API version is assumed to be 0.

In legacy code, core options are set by passing an array of retro_variable structs to set_variables. This may be still be done regardless of the core options interface version.

If version is >= 1 however, core options may instead be set by passing an array of retro_core_option_definition structs to set_core_options, or a 2D array of retro_core_option_definition structs to RETRO_ENVIRONMENT_SET_CORE_OPTIONS_INTL. This allows the core to additionally set option sublabel information and/or provide localisation support.

If version is >= 2, core options may instead be set by passing a retro_core_options_v2 struct to set_core_options_v2, or an array of retro_core_options_v2 structs to set_core_options_v2_intl. This allows the core to additionally set optional core option category information for frontends with core option category support.

Source§

impl GenericContext<'_>

Source

pub fn set_core_options_display( &self, options: retro_core_option_display, ) -> bool

Allows an implementation to signal the environment to show or hide a variable when displaying core options. This is considered a suggestion. The frontend is free to ignore this callback, and its implementation not considered mandatory.

‘data’ points to a retro_core_option_display struct

retro_core_option_display::key is a variable identifier which has already been set by set_variables / set_core_options.

retro_core_option_display::visible is a boolean, specifying whether variable should be displayed

Note that all core option variables will be set visible by default when calling set_variables / set_core_options.

Source§

impl GenericContext<'_>

Source

pub fn get_preferred_hw_render(&self) -> u32

Allows an implementation to ask frontend preferred hardware context to use. Core should use this information to deal with what specific context to request with SET_HW_RENDER.

‘data’ points to an unsigned variable

Source§

impl GenericContext<'_>

Source

pub fn get_disk_control_interface_version(&self) -> u32

Unsigned value is the API version number of the disk control interface supported by the frontend. If callback return false, API version is assumed to be 0.

In legacy code, the disk control interface is defined by passing a struct of type [retro_disk_control_callback] to [set_disk_control_interface`]. This may be still be done regardless of the disk control interface version.

If version is >= 1 however, the disk control interface may instead be defined by passing a struct of type retro_disk_control_ext_callback to set_disk_control_ext_interface. This allows the core to provide additional information about disk images to the frontend and/or enables extra disk control functionality by the frontend.

Source§

impl GenericContext<'_>

Source

pub fn set_disk_control_ext_interface( &self, data: retro_disk_control_ext_callback, ) -> bool

Sets an interface which frontend can use to eject and insert disk images, and also obtain information about individual disk image files registered by the core. This is used for games which consist of multiple images and must be manually swapped out by the user (e.g. PSX, floppy disk based systems).

Source§

impl GenericContext<'_>

Source

pub fn get_message_interface_version(&self) -> u32

The returned value is the API version number of the message interface supported by the frontend. If the underlying callback failed, API version is assumed to be 0.

In legacy code, messages may be displayed in an implementation-specific manner by passing a struct of type retro_message to set_message. This may be still be done regardless of the message interface version.

If version is >= 1 however, messages may instead be displayed by calling set_message_ext. This allows the core to specify message logging level, priority and destination (OSD, logging interface or both).

Source§

impl GenericContext<'_>

Source

pub fn set_message_ext( &self, message: &str, duration: u32, priority: u32, level: retro_log_level, target: retro_message_target, type_: retro_message_type, progress: MessageProgress, ) -> bool

Sets a message to be displayed in an implementation-specific manner for a certain duration of milliseconds. Additionally allows the core to specify message logging level, priority and destination (OSD, logging interface or both). Should not be used for trivial messages, which should simply be logged via RETRO_ENVIRONMENT_GET_LOG_INTERFACE (or as a fallback, stderr).

Source§

impl GenericContext<'_>

Source

pub fn get_input_max_users(&self) -> (u32, bool)

The first returned value is the number of active input devices provided by the frontend. This may change between frames, but will remain constant for the duration of each frame.

If the second return value is true, a core does not need to poll any input device with an index greater than or equal to the number of active devices.

If the second return value is false, the number of active input devices is unknown. In this case, all input devices should be considered active.

Source§

impl GenericContext<'_>

Source

pub fn set_audio_buffer_status_callback( &self, data: retro_audio_buffer_status_callback, ) -> bool

Lets the core know the occupancy level of the frontend audio buffer. Can be used by a core to attempt frame skipping in order to avoid buffer under-runs. A core may pass NULL to disable buffer status reporting in the frontend.

Source§

impl GenericContext<'_>

Source

pub fn supports_fastforwarding_override(&self) -> bool

Checks whether the frontend supports the set_fastforwarding_override interface.

Source§

impl GenericContext<'_>

Source

pub fn set_fastforwarding_override( &self, value: retro_fastforwarding_override, ) -> bool

Used by a libretro core to override the current fastforwarding mode of the frontend.

Source§

impl GenericContext<'_>

Source

pub fn set_variable(&self, value: retro_variable) -> bool

Allows an implementation to notify the frontend that a core option value has changed.

retro_variable::key and retro_variable::value must match strings that have been set previously via one of the following:

After changing a core option value via this callback, get_variable_update will return true.

If data is NULL, no changes will be registered and the callback will return true; an implementation may therefore pass NULL in order to test whether the callback is supported.

Source§

impl GenericContext<'_>

Source

pub unsafe fn get_throttle_state(&self) -> Option<retro_throttle_state>

Unstable Allows an implementation to get details on the actual rate the frontend is attempting to call Core::on_run.

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

Source

pub unsafe fn get_savestate_context(&self) -> Option<retro_savestate_context>

Unstable Tells the core about the context the frontend is asking for savestate.

§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.

Trait Implementations§

Source§

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

Source§

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

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.
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 GenericContext<'a>

Source§

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

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.
Source§

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

Source§

fn from(other: &mut InitContext<'a>) -> GenericContext<'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 GenericContext<'a>

Source§

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

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for GenericContext<'a>

§

impl<'a> RefUnwindSafe for GenericContext<'a>

§

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

§

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

§

impl<'a> Unpin for GenericContext<'a>

§

impl<'a> UnwindSafe for GenericContext<'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.