diff --git a/Cargo.toml b/Cargo.toml index a8b6ac3..3ca3b16 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,3 +10,4 @@ failure = "^0.1" libloading = "^0.5" num_enum = "^0.4" structopt = "^0.3" + diff --git a/src/main.rs b/src/bin/example.rs similarity index 70% rename from src/main.rs rename to src/bin/example.rs index 7e2b6ff..2e410a6 100644 --- a/src/main.rs +++ b/src/bin/example.rs @@ -1,21 +1,14 @@ -extern crate failure; -extern crate libloading; - -#[allow(non_camel_case_types, non_upper_case_globals, non_snake_case, dead_code)] -mod libretro_ffi; -mod libretro_loading; -mod libretro_convert; -mod libretro_wrapper; +extern crate rustro; use std::ffi::CStr; use std::path::PathBuf; use structopt::StructOpt; -use crate::libretro_convert::Handler; +use rustro::retro; struct Foo; -impl Handler for Foo { +impl retro::convert::Handler for Foo { fn video_refresh(&mut self, data: &[u8], width: u32, height: u32, pitch: u32) { println!("video_refresh {}x{}", width, height); } @@ -35,8 +28,8 @@ struct Opt { fn main() -> failure::Fallible<()> { let opt: Opt = Opt::from_args(); let lib = libloading::Library::new(&opt.core)?; - let retro = libretro_loading::LibretroApi::from_library(&lib)?; - let wrapper = libretro_wrapper::LibretroWrapper::from(retro); + let retro = retro::loading::LibretroApi::from_library(&lib)?; + let wrapper = retro::wrapper::LibretroWrapper::from(retro); let mut foo = Foo{}; wrapper.register_handler(&mut foo); println!("api version: {}", wrapper.as_ref().api_version()); diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..e71bd1b --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,4 @@ +extern crate failure; +extern crate libloading; + +pub mod retro; diff --git a/src/libretro_convert.rs b/src/retro/convert.rs similarity index 99% rename from src/libretro_convert.rs rename to src/retro/convert.rs index 1c8e6ed..13144f0 100644 --- a/src/libretro_convert.rs +++ b/src/retro/convert.rs @@ -4,7 +4,7 @@ use std::path::PathBuf; use num_enum::{TryFromPrimitive, IntoPrimitive}; -use crate::libretro_ffi::*; +use super::ffi::*; // NB: commented-out stuff is from newer versions of libretro.h not yet represented in libretro-sys diff --git a/src/libretro_ffi.rs b/src/retro/ffi.rs similarity index 100% rename from src/libretro_ffi.rs rename to src/retro/ffi.rs diff --git a/src/libretro_loading.rs b/src/retro/loading.rs similarity index 99% rename from src/libretro_loading.rs rename to src/retro/loading.rs index 793e8b7..f75f60c 100644 --- a/src/libretro_loading.rs +++ b/src/retro/loading.rs @@ -5,8 +5,8 @@ use std::path::Path; use failure::Fallible; use libloading; -use crate::libretro_ffi::*; -use crate::libretro_convert::*; +use super::ffi::*; +use super::convert::*; pub struct LibretroApi<'a> { lib: &'a libloading::Library, // for tying our lifetime to its own diff --git a/src/retro/mod.rs b/src/retro/mod.rs new file mode 100644 index 0000000..5234288 --- /dev/null +++ b/src/retro/mod.rs @@ -0,0 +1,5 @@ +pub mod convert; +#[allow(non_camel_case_types, non_upper_case_globals, non_snake_case, dead_code)] +pub mod ffi; +pub mod loading; +pub mod wrapper; diff --git a/src/libretro_wrapper.rs b/src/retro/wrapper.rs similarity index 99% rename from src/libretro_wrapper.rs rename to src/retro/wrapper.rs index b47d72e..5afec64 100644 --- a/src/libretro_wrapper.rs +++ b/src/retro/wrapper.rs @@ -9,8 +9,8 @@ use std::path::Path; use libretro_sys::{Message, PixelFormat, SystemAvInfo, GameGeometry}; use num_enum::{IntoPrimitive, TryFromPrimitive}; -use crate::libretro_convert::*; -use crate::libretro_loading::*; +use super::convert::*; +use super::loading::*; static mut CB_SINGLETON: StaticCallbacks = StaticCallbacks { handler: None,