quick and dirty logging of variable queries

This commit is contained in:
lif 2019-11-17 01:42:29 -08:00
parent a591037d19
commit b3156a4b04
2 changed files with 13 additions and 8 deletions

View File

@ -270,6 +270,11 @@ impl retro::wrapper::Handler for MyEmulator {
Some(std::env::temp_dir())
}
fn get_variable(&mut self, key: &str) -> Option<String> {
eprintln!("ignored: get_variable({})", key);
None
}
fn set_system_av_info(&mut self, av_info: SystemAvInfo) -> bool {
self.set_geometry(av_info.geometry.clone());
self.av_info = av_info;

View File

@ -50,8 +50,8 @@ pub trait Handler: Unpin + 'static {
fn set_pixel_format(&mut self, format: PixelFormat) -> bool { false }
fn set_input_descriptors(&mut self, input_descriptors: &[InputDescriptor]) -> bool { false }
fn set_hw_render(&mut self, hw_render_callback: HwRenderCallback) -> bool { false }
fn get_variable(&mut self) -> Option<EnvVariable> { None }
fn set_variables(&mut self, variables: &[EnvVariable]) -> bool { false }
fn get_variable(&mut self, key: &str) -> Option<String> { None }
fn set_variables(&mut self, variables: &[Variable]) -> bool { false }
fn get_variable_update(&mut self) -> Option<bool> { None }
fn set_support_no_game(&mut self, supports_no_game: bool) -> bool { false }
fn get_libretro_path(&mut self) -> Option<PathBuf> { None }
@ -123,12 +123,12 @@ impl StaticCallbacks {
// TODO EnvCmd::SetDiskControlInterface => {},
// TODO EnvCmd::SetHwRender => {},
EnvCmd::GetVariable => {
// TODO: actually implement
let v = Self::from_void::<Variable>(data)?;
eprintln!(
"Unsupported env cmd: GetVariable ({})",
unsafe { CStr::from_ptr(v.key) }.to_string_lossy());
false
let mut var = Self::from_void::<Variable>(data)?;
let value = handler
.get_variable(unsafe { CStr::from_ptr(var.key) }.to_str().ok()?)?;
// leaks memory.
var.value = CString::new(value).ok()?.into_raw();
true
},
// TODO EnvCmd::SetVariables => {},
EnvCmd::GetVariableUpdate => Self::clone_into_void(data, &handler.get_variable_update()?)?,