ferretro/ferretro_components/src/provided/stdlib/camera.rs

67 lines
1.5 KiB
Rust

use std::os::raw::c_uint;
use crate::base::RetroComponent;
use crate::prelude::RetroCallbacks;
#[derive(Default)]
pub struct CameraInfoComponent {
initialized: bool,
started: bool,
width: c_uint,
height: c_uint,
cap_raw_fb: bool,
cap_gl_tex: bool,
}
impl CameraInfoComponent {
pub fn dimensions(&self) -> Option<(c_uint, c_uint)> {
if self.initialized {
Some((self.width, self.height))
} else {
None
}
}
pub fn raw_fb(&self) -> Option<bool> {
if self.initialized {
Some(self.cap_raw_fb)
} else {
None
}
}
pub fn gl_tex(&self) -> Option<bool> {
if self.initialized {
Some(self.cap_gl_tex)
} else {
None
}
}
pub fn started(&self) -> bool {
self.started
}
}
impl RetroComponent for CameraInfoComponent {}
impl RetroCallbacks for CameraInfoComponent {
fn get_camera_interface(&mut self, width: c_uint, height: c_uint, cap_raw_fb: bool, cap_gl_tex: bool) -> Option<bool> {
self.initialized = true;
self.width = width;
self.height = height;
self.cap_raw_fb = cap_raw_fb;
self.cap_gl_tex = cap_gl_tex;
Some(true)
}
fn camera_start(&mut self) -> Option<bool> {
self.started = true;
Some(true)
}
fn camera_stop(&mut self) -> Option<()> {
self.started = false;
Some(())
}
}