Trait rust_libretro::core::Core
source · [−]pub trait Core: CoreOptions {
Show 23 methods
fn get_info(&self) -> SystemInfo;
fn on_get_av_info(
&mut self,
_ctx: &mut GetAvInfoContext<'_>
) -> retro_system_av_info;
fn on_init(&mut self, _ctx: &mut InitContext<'_>);
fn on_set_environment(
&mut self,
_initial: bool,
_ctx: &mut SetEnvironmentContext<'_>
) { ... }
fn on_deinit(&mut self, _ctx: &mut DeinitContext<'_>) { ... }
fn on_set_controller_port_device(&mut self, _port: c_uint, _device: c_uint) { ... }
fn on_reset(&mut self, _ctx: &mut ResetContext<'_>) { ... }
fn on_run(&mut self, _ctx: &mut RunContext<'_>, _delta_us: Option<i64>) { ... }
fn get_serialize_size(
&mut self,
_ctx: &mut GetSerializeSizeContext<'_>
) -> size_t { ... }
fn on_serialize(
&mut self,
_slice: &mut [u8],
_ctx: &mut SerializeContext<'_>
) -> bool { ... }
fn on_unserialize(
&mut self,
_slice: &mut [u8],
_ctx: &mut UnserializeContext<'_>
) -> bool { ... }
fn on_load_game(
&mut self,
_game: Option<retro_game_info>,
_ctx: &mut LoadGameContext<'_>
) -> bool { ... }
fn on_load_game_special(
&mut self,
_game_type: c_uint,
_info: *const retro_game_info,
_num_info: size_t,
_ctx: &mut LoadGameSpecialContext<'_>
) -> bool { ... }
fn on_unload_game(&mut self, _ctx: &mut UnloadGameContext<'_>) { ... }
fn on_cheat_reset(&mut self, _ctx: &mut CheatResetContext<'_>) { ... }
fn on_cheat_set(
&mut self,
_index: c_uint,
_enabled: bool,
_code: &CStr,
_ctx: &mut CheatSetContext<'_>
) { ... }
fn on_get_region(&mut self, _ctx: &mut GetRegionContext<'_>) -> c_uint { ... }
fn get_memory_data(
&mut self,
_id: c_uint,
_ctx: &mut GetMemoryDataContext<'_>
) -> *mut c_void { ... }
fn get_memory_size(
&mut self,
_id: c_uint,
_ctx: &mut GetMemorySizeContext<'_>
) -> size_t { ... }
fn on_options_changed(&mut self, _ctx: &mut OptionsChangedContext<'_>) { ... }
fn on_keyboard_event(
&mut self,
_down: bool,
_keycode: retro_key,
_character: u32,
_key_modifiers: retro_mod
) { ... }
fn on_write_audio(&mut self, _ctx: &mut AudioContext<'_>) { ... }
fn on_audio_set_state(&mut self, _enabled: bool) { ... }
}Expand description
This trait defines the basic functions that every libretro core must implement.
See also retro_core!().
Required methods
fn get_info(&self) -> SystemInfo
fn get_info(&self) -> SystemInfo
Returns static info about this core.
fn on_get_av_info(
&mut self,
_ctx: &mut GetAvInfoContext<'_>
) -> retro_system_av_info
fn on_get_av_info(
&mut self,
_ctx: &mut GetAvInfoContext<'_>
) -> retro_system_av_info
Called when the frontend needs information about the audio and video timings and the video geometry.
fn on_init(&mut self, _ctx: &mut InitContext<'_>)
fn on_init(&mut self, _ctx: &mut InitContext<'_>)
Called when the libretro API has been initialized.
Provided methods
fn on_set_environment(
&mut self,
_initial: bool,
_ctx: &mut SetEnvironmentContext<'_>
)
fn on_set_environment(
&mut self,
_initial: bool,
_ctx: &mut SetEnvironmentContext<'_>
)
Called when the frontend set a new environment callback.
Guaranteed to be called before Core::on_init.
fn on_deinit(&mut self, _ctx: &mut DeinitContext<'_>)
fn on_deinit(&mut self, _ctx: &mut DeinitContext<'_>)
Called when the libretro API gets destucted.
fn on_set_controller_port_device(&mut self, _port: c_uint, _device: c_uint)
fn on_set_controller_port_device(&mut self, _port: c_uint, _device: c_uint)
TODO: Documentation
fn on_reset(&mut self, _ctx: &mut ResetContext<'_>)
fn on_reset(&mut self, _ctx: &mut ResetContext<'_>)
Called when the frontend requests resetting the system.
fn on_run(&mut self, _ctx: &mut RunContext<'_>, _delta_us: Option<i64>)
fn on_run(&mut self, _ctx: &mut RunContext<'_>, _delta_us: Option<i64>)
Called once per frame
If a frame is not rendered for reasons where a game “dropped” a frame,
this still counts as a frame, and Core::on_run should explicitly dupe
a frame if environment::can_dupe returns true.
In this case, the video callback can take a NULL argument for data.
fn get_serialize_size(
&mut self,
_ctx: &mut GetSerializeSizeContext<'_>
) -> size_t
fn get_serialize_size(
&mut self,
_ctx: &mut GetSerializeSizeContext<'_>
) -> size_t
Returns the amount of data the implementation requires to serialize internal state (save states).
Between calls to Core::on_load_game and Core::on_unload_game, the
returned size is never allowed to be larger than a previous returned
value, to ensure that the frontend can allocate a save state buffer once.
fn on_serialize(
&mut self,
_slice: &mut [u8],
_ctx: &mut SerializeContext<'_>
) -> bool
fn on_serialize(
&mut self,
_slice: &mut [u8],
_ctx: &mut SerializeContext<'_>
) -> bool
Serializes internal state. If failed, or size is lower than
Core::get_serialize_size, it should return false, [`true’] otherwise.
fn on_unserialize(
&mut self,
_slice: &mut [u8],
_ctx: &mut UnserializeContext<'_>
) -> bool
fn on_unserialize(
&mut self,
_slice: &mut [u8],
_ctx: &mut UnserializeContext<'_>
) -> bool
Deserializes internal state.
TODO: Documentation
fn on_load_game(
&mut self,
_game: Option<retro_game_info>,
_ctx: &mut LoadGameContext<'_>
) -> bool
fn on_load_game(
&mut self,
_game: Option<retro_game_info>,
_ctx: &mut LoadGameContext<'_>
) -> bool
fn on_load_game_special(
&mut self,
_game_type: c_uint,
_info: *const retro_game_info,
_num_info: size_t,
_ctx: &mut LoadGameSpecialContext<'_>
) -> bool
fn on_load_game_special(
&mut self,
_game_type: c_uint,
_info: *const retro_game_info,
_num_info: size_t,
_ctx: &mut LoadGameSpecialContext<'_>
) -> bool
Loads a “special” kind of game. Should not be used, except in extreme cases.
TODO: Better documentation. What’s a “special” game?
fn on_unload_game(&mut self, _ctx: &mut UnloadGameContext<'_>)
fn on_unload_game(&mut self, _ctx: &mut UnloadGameContext<'_>)
Called when the currently loaded game should be unloaded.
Called before Core::on_deinit.
fn on_cheat_reset(&mut self, _ctx: &mut CheatResetContext<'_>)
fn on_cheat_reset(&mut self, _ctx: &mut CheatResetContext<'_>)
Instructs the core to remove all applied cheats.
fn on_cheat_set(
&mut self,
_index: c_uint,
_enabled: bool,
_code: &CStr,
_ctx: &mut CheatSetContext<'_>
)
fn on_cheat_set(
&mut self,
_index: c_uint,
_enabled: bool,
_code: &CStr,
_ctx: &mut CheatSetContext<'_>
)
TODO: Documentation
fn on_get_region(&mut self, _ctx: &mut GetRegionContext<'_>) -> c_uint
fn on_get_region(&mut self, _ctx: &mut GetRegionContext<'_>) -> c_uint
fn get_memory_data(
&mut self,
_id: c_uint,
_ctx: &mut GetMemoryDataContext<'_>
) -> *mut c_void
fn get_memory_data(
&mut self,
_id: c_uint,
_ctx: &mut GetMemoryDataContext<'_>
) -> *mut c_void
TODO: Documentation
fn get_memory_size(
&mut self,
_id: c_uint,
_ctx: &mut GetMemorySizeContext<'_>
) -> size_t
fn get_memory_size(
&mut self,
_id: c_uint,
_ctx: &mut GetMemorySizeContext<'_>
) -> size_t
TODO: Documentation
fn on_options_changed(&mut self, _ctx: &mut OptionsChangedContext<'_>)
fn on_options_changed(&mut self, _ctx: &mut OptionsChangedContext<'_>)
Gets called when the core options have been changed.
Options get checked before Core::on_load_game, Core::on_load_game_special and before each call of Core::on_run.
TODO: Documentation
fn on_write_audio(&mut self, _ctx: &mut AudioContext<'_>)
fn on_write_audio(&mut self, _ctx: &mut AudioContext<'_>)
Called when the frontend needs more audio frames
