pub struct RunContext<'a> {Show 13 fields
pub(crate) environment_callback: &'a retro_environment_t,
pub(crate) interfaces: Arc<RwLock<InterfaceList>>,
pub(crate) audio_sample_batch_callback: &'a retro_audio_sample_batch_t,
pub(crate) audio_sample_callback: &'a retro_audio_sample_t,
pub(crate) input_poll_callback: &'a retro_input_poll_t,
pub(crate) input_state_callback: &'a retro_input_state_t,
pub(crate) video_refresh_callback: &'a retro_video_refresh_t,
pub(crate) can_dupe: bool,
pub(crate) had_frame: &'a mut bool,
pub(crate) last_width: &'a mut u32,
pub(crate) last_height: &'a mut u32,
pub(crate) last_pitch: &'a mut usize,
pub(crate) supports_bitmasks: bool,
}
Expand description
Functions that are safe to be called in Core::on_run
.
For a description of the callbacks see CoreWrapper
.
Fields§
§environment_callback: &'a retro_environment_t
§interfaces: Arc<RwLock<InterfaceList>>
§audio_sample_batch_callback: &'a retro_audio_sample_batch_t
§audio_sample_callback: &'a retro_audio_sample_t
§input_poll_callback: &'a retro_input_poll_t
§input_state_callback: &'a retro_input_state_t
§video_refresh_callback: &'a retro_video_refresh_t
§can_dupe: bool
§had_frame: &'a mut bool
§last_width: &'a mut u32
§last_height: &'a mut u32
§last_pitch: &'a mut usize
§supports_bitmasks: bool
Implementations§
Source§impl RunContext<'_>
impl RunContext<'_>
pub fn can_dupe(&self) -> bool
Sourcepub fn poll_input(&self)
pub fn poll_input(&self)
Polls for input if RunContext::input_poll_callback
has been set
Sourcepub fn get_input_state(
&self,
port: u32,
device: u32,
index: u32,
id: u32,
) -> i16
pub fn get_input_state( &self, port: u32, device: u32, index: u32, id: u32, ) -> i16
Gets the input state for the given player and device if RunContext::input_state_callback
has been set
Sourcepub fn get_joypad_state(&self, port: u32, index: u32) -> JoypadState
pub fn get_joypad_state(&self, port: u32, index: u32) -> JoypadState
Queries the libretro frontend for the state of each joypad button by making an environment call for every button separately.
See also Self::get_joypad_bitmask
.
Sourcepub unsafe fn get_joypad_bitmask(&self, port: u32, index: u32) -> JoypadState
pub unsafe fn get_joypad_bitmask(&self, port: u32, index: u32) -> JoypadState
Unstable Queries the frontend for the joypad state with the more efficient, but currently experimental, joypad bitmask feature. Only a single call into the frontend gets made.
§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 get_current_framebuffer(
&self,
width: u32,
height: u32,
access_flags: MemoryAccess,
format: PixelFormat,
) -> Result<Framebuffer<'_>, Box<dyn Error>>
pub unsafe fn get_current_framebuffer( &self, width: u32, height: u32, access_flags: MemoryAccess, format: PixelFormat, ) -> Result<Framebuffer<'_>, 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 get_current_framebuffer_or_fallback(
&self,
width: u32,
height: u32,
access_flags: MemoryAccess,
format: PixelFormat,
) -> Framebuffer<'_>
pub unsafe fn get_current_framebuffer_or_fallback( &self, width: u32, height: u32, access_flags: MemoryAccess, format: PixelFormat, ) -> Framebuffer<'_>
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 fn draw_frame(&mut self, data: &[u8], width: u32, height: u32, pitch: usize)
pub fn draw_frame(&mut self, data: &[u8], width: u32, height: u32, pitch: usize)
Draws a new frame if RunContext::video_refresh_callback
has been set
Sourcepub fn dupe_frame(&self)
pub fn dupe_frame(&self)
Duplicates the previous frame
pub fn draw_framebuffer(&mut self, framebuffer: retro_framebuffer)
pub fn draw_hardware_frame(&mut self, width: u32, height: u32, pitch: usize)
Sourcepub unsafe fn camera_start(&self)
pub unsafe fn camera_start(&self)
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 camera_stop(&self)
pub unsafe fn camera_stop(&self)
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 RunContext<'_>
impl RunContext<'_>
Sourcepub fn get_input_device_capabilities(&self) -> RetroDevice
pub fn get_input_device_capabilities(&self) -> RetroDevice
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: RetroDevice::JOYPAD | RetroDevice::ANALOG
.
Source§impl RunContext<'_>
impl RunContext<'_>
Sourcepub fn set_system_av_info(&self, av_info: retro_system_av_info) -> bool
pub fn set_system_av_info(&self, av_info: retro_system_av_info) -> bool
Sets a new av_info structure.
This should only be used if the core is completely altering the internal resolutions, aspect ratios, timings, sampling rate, etc. Calling this can require a full reinitialization of video/audio drivers in the frontend,
so it is important to call it very sparingly, and usually only with
the users explicit consent.
An eventual driver reinitialize will happen so that video and
audio callbacks
happening after this call within the same Core::on_run
call will
target the newly initialized driver.
This callback makes it possible to support configurable resolutions in games, which can be useful to avoid setting the “worst case” in max_width/max_height.
HIGHLY RECOMMENDED
Do not call this callback every time
resolution changes in an emulator core if it’s
expected to be a temporary change, for the reasons of possible
driver reinitialization.
This call is not a free pass for not trying to provide
correct values in Core::on_get_av_info
. If you need to change
things like aspect ratio or nominal width/height,
use set_game_geometry
, which is a softer variant
of set_system_av_info
.
If this returns false
, the frontend does not acknowledge a
changed retro_system_av_info
struct.
Source§impl RunContext<'_>
impl RunContext<'_>
Sourcepub fn set_game_geometry(&self, geometry: retro_game_geometry) -> bool
pub fn set_game_geometry(&self, geometry: retro_game_geometry) -> bool
Sets a new game_geometry structure.
This environment call is similar to set_system_av_info
for changing
video parameters, but provides a guarantee that drivers will not be
reinitialized.
The purpose of this call is to allow a core to alter nominal width/heights as well as aspect ratios on-the-fly, which can be useful for some emulators to change in run-time.
max_width/max_height arguments are ignored and cannot be changed
with this call as this could potentially require a reinitialization or a
non-constant time operation.
If max_width/max_height are to be changed, set_system_av_info
is required.
A frontend must guarantee that this environment call completes in constant time.
Source§impl RunContext<'_>
impl RunContext<'_>
Sourcepub fn set_minimum_audio_latency(&self, latency: u32) -> bool
pub fn set_minimum_audio_latency(&self, latency: u32) -> bool
Sets minimum frontend audio latency in milliseconds. Resultant audio latency may be larger than set value, or smaller if a hardware limit is encountered. A frontend is expected to honour requests up to 512 ms.
- If value is less than current frontend audio latency, callback has no effect
- If value is zero, default frontend audio latency is set
May be used by a core to increase audio latency and
therefore decrease the probability of buffer under-runs
(crackling) when performing ‘intensive’ operations.
A core utilising RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK
to implement audio-buffer-based frame skipping may achieve
optimal results by setting the audio latency to a ‘high’
(typically 6x or 8x) integer multiple of the expected
frame time.
Calling this can require a full reinitialization of audio
drivers in the frontend, so it is important to call it very
sparingly, and usually only with the users explicit consent.
An eventual driver reinitialize will happen so that audio
callbacks happening after this call within the same Core::on_run
call will target the newly initialized driver.