Split into two crates in one workspace: ferretro_core & ferretro_components

This commit is contained in:
Vivian Lim 2021-08-18 14:32:55 -07:00
parent d156c04a04
commit 5d2692262c
23 changed files with 109 additions and 59 deletions

27
.gitignore vendored
View File

@ -1,13 +1,34 @@
# build artifacts
/target
**/*.rs.bk
/.idea
/Cargo.lock
# editors
/.idea
/.vscode
# cores
*.so
*.dll
*.dylib
*.mp4
*.ogv
# roms
*.gb
*.bin
*.sfc
*.z64
# save states
*.state*
# media
*.mp4
*.ogv
*.flv
*.flac
# scratch data
/scratch
# desktop.ini.mac
.DS_Store

View File

@ -1,28 +1,5 @@
[package]
name = "ferretro"
version = "0.1.0"
authors = ["lifning <lifning+git@pm.me>", "viv <vvnl+git@protonmail.com>", "iliana <iliana@buttslol.net>"]
edition = "2018"
[build-dependencies]
cc = "^1"
[dependencies]
libretro-sys = "0.1"
libloading = "0.5"
num_enum = "0.4"
ffmpeg-next = { version = "4.3.8", optional = true }
sdl2 = { version = "0.32", optional = true }
crossbeam-channel = { version = "0.4", optional = true }
[dev-dependencies]
# example: sdl2_emulator
sdl2 = "0.32"
crossbeam-channel = "0.4"
structopt = "0.3"
# example: ffmpeg_recorder
ffmpeg-next = "4.3.8"
[features]
ffmpeg_comp = ["ffmpeg-next"]
sdl2_comp = ["sdl2", "crossbeam-channel"]
[workspace]
members = [
"ferretro_core",
"ferretro_components",
]

View File

@ -0,0 +1,24 @@
[package]
name = "ferretro_components"
version = "0.1.0"
authors = ["lifning <lifning+git@pm.me>", "viv <vvnl+git@protonmail.com>", "iliana <iliana@buttslol.net>"]
edition = "2018"
[build-dependencies]
cc = "^1"
[dependencies]
ferretro_core = { path = "../ferretro_core"}
libloading = "0.5"
num_enum = "0.4"
ffmpeg-next = { version = "4.3.8", optional = true }
sdl2 = { version = "0.32", optional = true }
crossbeam-channel = { version = "0.4", optional = true }
[dev-dependencies]
crossbeam-channel = "0.4"
structopt = "0.3"
[features]
ffmpeg_comp = ["ffmpeg-next"]
sdl2_comp = ["sdl2", "crossbeam-channel"]

View File

@ -1,20 +1,20 @@
extern crate crossbeam_channel;
extern crate ferretro;
extern crate ferretro_components;
extern crate ffmpeg_next as ffmpeg;
extern crate sdl2;
use std::path::PathBuf;
use structopt::StructOpt;
use ferretro::prelude::*;
use ferretro_components::prelude::*;
use ferretro::components::provided::{
use ferretro_components::provided::{
ffmpeg::FfmpegComponent,
sdl2::Sdl2Component,
stdlib::{PathBufComponent, StderrLogComponent},
};
use ferretro::components::ControlFlow;
use ferretro::components::provided::stdlib::StderrSysInfoLogComponent;
use ferretro_components::base::ControlFlow;
use ferretro_components::provided::stdlib::StderrSysInfoLogComponent;
#[derive(StructOpt)]
struct Opt {

View File

@ -1,7 +1,5 @@
pub mod provided;
use crate::prelude::*;
use crate::retro::ffi::*;
use ferretro_core::retro::ffi::*;
use std::os::raw::c_uint;
use std::path::{PathBuf, Path};
use std::pin::Pin;
@ -48,7 +46,7 @@ impl RetroComponentBase {
// TODO: constructor & wrapper that uses a statically linked libretro?
pub fn new(core_path: impl AsRef<Path>) -> Pin<Box<Self>> {
let lib = libloading::Library::new(core_path.as_ref()).unwrap();
let raw_retro = crate::retro::loading::LibretroApi::from_library(lib).unwrap();
let raw_retro = ferretro_core::retro::loading::LibretroApi::from_library(lib).unwrap();
let retro = LibretroWrapper::from(raw_retro);
let emu = RetroComponentBase {
@ -69,7 +67,7 @@ impl RetroComponentBase {
};
let mut pin_emu = Box::pin(emu);
crate::retro::wrapper::set_handler(pin_emu.as_mut());
ferretro_core::retro::wrapper::set_handler(pin_emu.as_mut());
pin_emu.retro.init();
pin_emu
}
@ -495,6 +493,6 @@ impl RetroCallbacks for RetroComponentBase {
impl Drop for RetroComponentBase {
fn drop(&mut self) {
crate::retro::wrapper::unset_handler();
ferretro_core::retro::wrapper::unset_handler();
}
}

View File

@ -0,0 +1,10 @@
pub mod provided;
pub mod base;
pub mod prelude {
pub use crate::base::{RetroComponent, RetroComponentBase};
pub use ferretro_core::retro::constants::*;
pub use ferretro_core::retro::wrapped_types::*;
pub use ferretro_core::retro::wrapper::{RetroCallbacks, LibretroWrapper, LibretroWrapperAccess};
pub use ferretro_core::retro::ffi::{PixelFormat, GameGeometry, SystemAvInfo, SystemInfo};
}

View File

@ -8,7 +8,7 @@ use crate::prelude::*;
use ffmpeg::{ChannelLayout, Packet, filter, format, frame, media};
use ffmpeg::util::rational::Rational;
use crate::components::ControlFlow;
use crate::base::ControlFlow;
enum EncoderToWriteFrom {
Video,

View File

@ -4,7 +4,7 @@ use std::path::Path;
use std::time::{Duration, Instant};
use crate::prelude::*;
use crate::components::ControlFlow;
use crate::base::ControlFlow;
use sdl2::audio::{AudioCallback, AudioFormat, AudioSpec, AudioSpecDesired, AudioDevice};
use sdl2::controller::{GameController, Button, Axis};

View File

@ -32,7 +32,7 @@ pub struct StderrLogComponent {
impl RetroComponent for StderrLogComponent {}
impl RetroCallbacks for StderrLogComponent {
fn log_print(&mut self, level: crate::retro::ffi::LogLevel, msg: &str) {
fn log_print(&mut self, level: ferretro_core::retro::ffi::LogLevel, msg: &str) {
eprint!("{}[{:?}] {}", self.prefix, level, msg);
}
}

22
ferretro_core/Cargo.toml Normal file
View File

@ -0,0 +1,22 @@
[package]
name = "ferretro_core"
version = "0.1.0"
authors = ["lifning <lifning+git@pm.me>", "viv <vvnl+git@protonmail.com>", "iliana <iliana@buttslol.net>"]
edition = "2018"
[build-dependencies]
cc = "^1"
[dependencies]
libretro-sys = "0.1"
libloading = "0.5"
num_enum = "0.4"
crossbeam-channel = { version = "0.4", optional = true }
[dev-dependencies]
# example: sdl2_emulator
sdl2 = "0.32"
crossbeam-channel = "0.4"
structopt = "0.3"
# example: ffmpeg_recorder
ffmpeg-next = "4.3.8"

View File

@ -1,4 +1,4 @@
extern crate ferretro;
extern crate ferretro_core;
extern crate ffmpeg_next as ffmpeg;
use std::collections::VecDeque;
@ -8,11 +8,11 @@ use std::pin::Pin;
use structopt::StructOpt;
use ferretro::retro;
use ferretro::retro::ffi::{PixelFormat, GameGeometry, SystemAvInfo, SystemInfo};
use ferretro::retro::wrapper::{LibretroWrapper, RetroCallbacks};
use ferretro_core::retro;
use ferretro_core::retro::ffi::{PixelFormat, GameGeometry, SystemAvInfo, SystemInfo};
use ferretro_core::retro::wrapper::{LibretroWrapper, RetroCallbacks};
use ferretro::retro::wrapped_types::{Variable2};
use ferretro_core::retro::wrapped_types::{Variable2};
use ffmpeg::{ChannelLayout, Packet, codec, filter, format, frame, media};
use ffmpeg::util::rational::Rational;
@ -504,7 +504,7 @@ impl retro::wrapper::RetroCallbacks for MyEmulator {
fn get_variable(&mut self, key: &str) -> Option<String> {
match key {
"beetle_saturn_analog_stick_deadzone" => Some("15%".to_string()),
"parallel-n64-gfxplugin" => Some("angrylion".to_string()),
//"parallel-n64-gfxplugin" => Some("angrylion".to_string()),
"parallel-n64-astick-deadzone" => Some("15%".to_string()),
_ => None,
}

View File

@ -1,12 +1,12 @@
extern crate crossbeam_channel;
extern crate ferretro;
extern crate ferretro_core;
extern crate sdl2;
use ferretro::retro;
use ferretro::retro::ffi::{GameGeometry, SystemInfo, SystemAvInfo};
use ferretro::retro::constants::{InputIndex, JoypadButton, AnalogAxis, DeviceType};
use ferretro::retro::wrapped_types::{ControllerDescription2, InputDescriptor2, InputDeviceId, SubsystemInfo2, Variable2};
use ferretro::retro::wrapper::LibretroWrapper;
use ferretro_core::retro;
use ferretro_core::retro::ffi::{GameGeometry, SystemInfo, SystemAvInfo};
use ferretro_core::retro::constants::{InputIndex, JoypadButton, AnalogAxis, DeviceType};
use ferretro_core::retro::wrapped_types::{ControllerDescription2, InputDescriptor2, InputDeviceId, SubsystemInfo2, Variable2};
use ferretro_core::retro::wrapper::LibretroWrapper;
use std::ffi::CStr;
use std::io::Read;

View File

@ -1,11 +1,9 @@
extern crate libloading;
pub mod retro;
pub mod components;
pub mod prelude {
pub use crate::retro::constants::*;
pub use crate::components::{RetroComponent, RetroComponentBase};
pub use crate::retro::wrapped_types::*;
pub use crate::retro::wrapper::{RetroCallbacks, LibretroWrapper, LibretroWrapperAccess};
pub use crate::retro::ffi::{PixelFormat, GameGeometry, SystemAvInfo, SystemInfo};