AsRef < Deref
This commit is contained in:
parent
3157fbdac1
commit
bdb746c861
2 changed files with 8 additions and 7 deletions
|
@ -51,13 +51,13 @@ impl MyEmulator {
|
||||||
let raw_retro = retro::loading::LibretroApi::from_library(lib).unwrap();
|
let raw_retro = retro::loading::LibretroApi::from_library(lib).unwrap();
|
||||||
let retro = retro::wrapper::LibretroWrapper::from(raw_retro);
|
let retro = retro::wrapper::LibretroWrapper::from(raw_retro);
|
||||||
|
|
||||||
let sys_info = retro.as_ref().get_system_info();
|
let sys_info = retro.get_system_info();
|
||||||
let title = format!(
|
let title = format!(
|
||||||
"{} - rust libretro",
|
"{} - rust libretro",
|
||||||
unsafe { CStr::from_ptr(sys_info.library_name) }.to_string_lossy()
|
unsafe { CStr::from_ptr(sys_info.library_name) }.to_string_lossy()
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut av_info = retro.as_ref().get_system_av_info();
|
let mut av_info = retro.get_system_av_info();
|
||||||
let pixel_format = sdl2::pixels::PixelFormatEnum::ABGR1555;
|
let pixel_format = sdl2::pixels::PixelFormatEnum::ABGR1555;
|
||||||
|
|
||||||
// HACK: some cores don't report this 'til we get an environ call to set_system_av_info...
|
// HACK: some cores don't report this 'til we get an environ call to set_system_av_info...
|
||||||
|
@ -130,7 +130,7 @@ impl MyEmulator {
|
||||||
};
|
};
|
||||||
let mut pin_emu = Box::pin(emu);
|
let mut pin_emu = Box::pin(emu);
|
||||||
retro::wrapper::set_handler(pin_emu.as_mut());
|
retro::wrapper::set_handler(pin_emu.as_mut());
|
||||||
pin_emu.retro.as_ref().init();
|
pin_emu.retro.init();
|
||||||
pin_emu
|
pin_emu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ impl MyEmulator {
|
||||||
}
|
}
|
||||||
|
|
||||||
// The rest of the game loop goes here...
|
// The rest of the game loop goes here...
|
||||||
self.retro.as_ref().run();
|
self.retro.run();
|
||||||
self.canvas.present();
|
self.canvas.present();
|
||||||
|
|
||||||
Duration::from_secs_f64(1.0 / self.av_info.timing.fps)
|
Duration::from_secs_f64(1.0 / self.av_info.timing.fps)
|
||||||
|
@ -173,7 +173,6 @@ impl MyEmulator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.retro
|
self.retro
|
||||||
.as_ref()
|
|
||||||
.load_game(Some(path), data, None)
|
.load_game(Some(path), data, None)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ use core::ffi::c_void;
|
||||||
use core::slice::from_raw_parts;
|
use core::slice::from_raw_parts;
|
||||||
|
|
||||||
use std::ffi::{CString, CStr};
|
use std::ffi::{CString, CStr};
|
||||||
|
use std::ops::Deref;
|
||||||
use std::os::raw::{c_uint, c_char};
|
use std::os::raw::{c_uint, c_char};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
|
@ -226,8 +227,9 @@ impl From<LibretroApi> for LibretroWrapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRef<LibretroApi> for LibretroWrapper {
|
impl Deref for LibretroWrapper {
|
||||||
fn as_ref(&self) -> &LibretroApi {
|
type Target = LibretroApi;
|
||||||
|
fn deref(&self) -> &LibretroApi {
|
||||||
&self.api
|
&self.api
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue