
fn video_refresh(&mut self, data: &[u8], width: c_uint, height: c_uint, pitch: c_uint); fn video_refresh_dupe(&mut self, width: c_uint, height: c_uint, pitch: c_uint); fn video_refresh_hw(&mut self, width: c_uint, height: c_uint); fn audio_sample(&mut self, left: i16, right: i16); fn audio_sample_batch(&mut self, stereo_pcm: &[i16]) -> usize; have been replaced with fn video_refresh(&mut self, frame: &VideoFrame); fn audio_samples(&mut self, stereo_pcm: &[i16]) -> usize; where VideoFrame is pub enum VideoFrame<'a> { XRGB1555 { data: &'a [u16], width: c_uint, height: c_uint, pitch_u16: usize }, RGB565 { data: &'a [u16], width: c_uint, height: c_uint, pitch_u16: usize }, XRGB8888 { data: &'a [u32], width: c_uint, height: c_uint, pitch_u32: usize }, Duplicate { width: c_uint, height: c_uint, pitch_u8: usize, }, HardwareRender { width: c_uint, height: c_uint, }, } use `pub fn VideoFrame::data_pitch_as_bytes(&self) -> Option<(&'a [u8], usize)>` for things that need to access the framebuffer data as a byte array rather than a pixel array.
103 lines
4.3 KiB
Rust
103 lines
4.3 KiB
Rust
use std::cell::RefCell;
|
|
use std::os::raw::c_uint;
|
|
use std::rc::Rc;
|
|
use std::path::PathBuf;
|
|
|
|
use crate::prelude::*;
|
|
use crate::retro::ffi::*;
|
|
|
|
impl<T: RetroCallbacks> RetroCallbacks for Rc<RefCell<T>> {
|
|
fn video_refresh(&mut self, frame: &VideoFrame) {
|
|
RefCell::borrow_mut(self).video_refresh(frame)
|
|
}
|
|
fn audio_samples(&mut self, stereo_pcm: &[i16]) -> usize {
|
|
RefCell::borrow_mut(self).audio_samples(stereo_pcm)
|
|
}
|
|
fn input_poll(&mut self) {
|
|
RefCell::borrow_mut(self).input_poll()
|
|
}
|
|
fn input_state(&mut self, port: u32, device: InputDeviceId, index: InputIndex) -> i16 {
|
|
RefCell::borrow_mut(self).input_state(port, device, index)
|
|
}
|
|
fn set_rotation(&mut self, rotation: EnvRotation) -> Option<bool> {
|
|
RefCell::borrow_mut(self).set_rotation(rotation)
|
|
}
|
|
fn get_overscan(&mut self) -> Option<bool> {
|
|
RefCell::borrow_mut(self).get_overscan()
|
|
}
|
|
fn set_message(&mut self, message: &Message) -> Option<bool> {
|
|
RefCell::borrow_mut(self).set_message(message)
|
|
}
|
|
fn shutdown(&mut self) -> Option<bool> {
|
|
RefCell::borrow_mut(self).shutdown()
|
|
}
|
|
fn set_performance_level(&mut self, level: c_uint) -> Option<bool> {
|
|
RefCell::borrow_mut(self).set_performance_level(level)
|
|
}
|
|
fn get_system_directory(&mut self) -> Option<PathBuf> {
|
|
RefCell::borrow_mut(self).get_system_directory()
|
|
}
|
|
fn set_pixel_format(&mut self, format: PixelFormat) -> Option<bool> {
|
|
RefCell::borrow_mut(self).set_pixel_format(format)
|
|
}
|
|
fn set_input_descriptors(&mut self, input_descriptors: &Vec<InputDescriptor2>) -> Option<bool> {
|
|
RefCell::borrow_mut(self).set_input_descriptors(input_descriptors)
|
|
}
|
|
fn set_hw_render(&mut self, hw_render_callback: &HwRenderCallback) -> Option<bool> {
|
|
RefCell::borrow_mut(self).set_hw_render(hw_render_callback)
|
|
}
|
|
fn get_variable(&mut self, key: &str) -> Option<String> {
|
|
RefCell::borrow_mut(self).get_variable(key)
|
|
}
|
|
fn set_variables(&mut self, variables: &Vec<Variable2>) -> Option<bool> {
|
|
RefCell::borrow_mut(self).set_variables(variables)
|
|
}
|
|
fn get_variable_update(&mut self) -> Option<bool> {
|
|
RefCell::borrow_mut(self).get_variable_update()
|
|
}
|
|
fn set_support_no_game(&mut self, supports_no_game: bool) -> Option<bool> {
|
|
RefCell::borrow_mut(self).set_support_no_game(supports_no_game)
|
|
}
|
|
fn get_libretro_path(&mut self) -> Option<PathBuf> {
|
|
RefCell::borrow_mut(self).get_libretro_path()
|
|
}
|
|
fn get_input_device_capabilities(&mut self) -> Option<u64> {
|
|
RefCell::borrow_mut(self).get_input_device_capabilities()
|
|
}
|
|
fn get_core_assets_directory(&mut self) -> Option<PathBuf> {
|
|
RefCell::borrow_mut(self).get_core_assets_directory()
|
|
}
|
|
fn get_save_directory(&mut self) -> Option<PathBuf> {
|
|
RefCell::borrow_mut(self).get_save_directory()
|
|
}
|
|
fn set_system_av_info(&mut self, system_av_info: &SystemAvInfo) -> Option<bool> {
|
|
RefCell::borrow_mut(self).set_system_av_info(system_av_info)
|
|
}
|
|
fn set_subsystem_info(&mut self, subsystem_info: &Vec<SubsystemInfo2>) -> Option<bool> {
|
|
RefCell::borrow_mut(self).set_subsystem_info(subsystem_info)
|
|
}
|
|
fn set_controller_info(&mut self, controller_info: &Vec<ControllerDescription2>) -> Option<bool> {
|
|
RefCell::borrow_mut(self).set_controller_info(controller_info)
|
|
}
|
|
fn set_memory_maps(&mut self, memory_map: &MemoryMap) -> Option<bool> {
|
|
RefCell::borrow_mut(self).set_memory_maps(memory_map)
|
|
}
|
|
fn set_geometry(&mut self, game_geometry: &GameGeometry) -> Option<bool> {
|
|
RefCell::borrow_mut(self).set_geometry(game_geometry)
|
|
}
|
|
fn get_username(&mut self) -> Option<String> {
|
|
RefCell::borrow_mut(self).get_username()
|
|
}
|
|
fn get_language(&mut self) -> Option<Language> {
|
|
RefCell::borrow_mut(self).get_language()
|
|
}
|
|
fn hw_get_current_framebuffer(&mut self) -> Option<usize> {
|
|
RefCell::borrow_mut(self).hw_get_current_framebuffer()
|
|
}
|
|
fn hw_get_proc_address(&mut self, sym: &str) -> Option<*const ()> {
|
|
RefCell::borrow_mut(self).hw_get_proc_address(sym)
|
|
}
|
|
// TODO: the rest, dynamically.
|
|
// can we proc macro it?
|
|
// 's~^\( *\)fn \(.*\)(&mut self\(, \)\?\([^)]*\))\(.*\){$~\1fn \2(\&mut self\3\4)\5{\n\1 RefCell::borrow_mut(self).\2(\4)~'
|
|
}
|