Trait rust_libretro::Core
source · [−]pub trait Core {
Show 23 methods
fn get_info(&self) -> SystemInfo;
fn on_get_av_info(
&mut self,
_ctx: &mut GetAvInfoContext<'_>
) -> retro_system_av_info;
fn on_set_environment(
&mut self,
_initial: bool,
_ctx: &mut SetEnvironmentContext<'_>
) { ... }
fn on_init(&mut self, _ctx: &mut InitContext<'_>) { ... }
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,
_data: *mut c_void,
_size: size_t,
_ctx: &mut SerializeContext<'_>
) -> bool { ... }
fn on_unserialize(
&mut self,
_data: *const c_void,
_size: size_t,
_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: *const c_char,
_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 get_frame_time_reference(&self) -> retro_usec_t { ... }
fn on_write_audio(&mut self, _ctx: &mut AudioContext<'_>) { ... }
}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.
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_init(&mut self, _ctx: &mut InitContext<'_>)
fn on_init(&mut self, _ctx: &mut InitContext<'_>)
Called when the libretro API has been initialized.
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
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,
_data: *mut c_void,
_size: size_t,
_ctx: &mut SerializeContext<'_>
) -> bool
fn on_serialize(
&mut self,
_data: *mut c_void,
_size: size_t,
_ctx: &mut SerializeContext<'_>
) -> bool
Serializes internal state. If failed, or size is lower than
Core::get_serialize_size, it should return false, [`true’] otherwise.
TODO
fn on_unserialize(
&mut self,
_data: *const c_void,
_size: size_t,
_ctx: &mut UnserializeContext<'_>
) -> bool
fn on_unserialize(
&mut self,
_data: *const c_void,
_size: size_t,
_ctx: &mut UnserializeContext<'_>
) -> bool
Deserializes internal state. TODO
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
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<'_>)
TODO
fn on_cheat_set(
&mut self,
_index: c_uint,
_enabled: bool,
_code: *const c_char,
_ctx: &mut CheatSetContext<'_>
)
fn on_cheat_set(
&mut self,
_index: c_uint,
_enabled: bool,
_code: *const c_char,
_ctx: &mut CheatSetContext<'_>
)
TODO
fn on_get_region(&mut self, _ctx: &mut GetRegionContext<'_>) -> c_uint
fn on_get_region(&mut self, _ctx: &mut GetRegionContext<'_>) -> c_uint
Gets the region of the game. TODO
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
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
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.
fn on_keyboard_event(
&mut self,
_down: bool,
_keycode: retro_key,
_character: u32,
_key_modifiers: retro_mod
)
fn get_frame_time_reference(&self) -> retro_usec_t
fn get_frame_time_reference(&self) -> retro_usec_t
Needed for the frame time callback and calculated as 1000000 / FPS.
Gets called right after Core::on_load_game or Core::on_load_game_special.
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
