mirror of
https://github.com/transistorfet/moa.git
synced 2024-11-24 23:32:46 +00:00
Moved tty to frontends/moa-common to remove the dependency on nix
This commit is contained in:
parent
d274186388
commit
427c79b7b4
@ -4,13 +4,8 @@ version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
[workspace]
|
||||
members = [".", "frontends/moa-console", "frontends/moa-minifb"]
|
||||
members = [".", "frontends/moa-common", "frontends/moa-console", "frontends/moa-minifb"]
|
||||
default-members = ["frontends/moa-console"]
|
||||
|
||||
[features]
|
||||
default = ["tty"]
|
||||
tty = ["nix"]
|
||||
|
||||
[dependencies]
|
||||
nix = { version = "0.23", optional = true }
|
||||
|
||||
|
12
frontends/moa-common/Cargo.toml
Normal file
12
frontends/moa-common/Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "moa-common"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
[features]
|
||||
tty = ["nix"]
|
||||
|
||||
[dependencies]
|
||||
moa = { path = "../../" }
|
||||
nix = { version = "0.23", optional = true }
|
||||
|
3
frontends/moa-common/src/lib.rs
Normal file
3
frontends/moa-common/src/lib.rs
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
pub mod tty;
|
||||
|
@ -3,14 +3,13 @@ use std::thread;
|
||||
use std::sync::mpsc;
|
||||
use std::time::Duration;
|
||||
use std::io::{Read, Write};
|
||||
use std::os::unix::io::AsRawFd;
|
||||
|
||||
use nix::fcntl::OFlag;
|
||||
use nix::pty::{self, PtyMaster};
|
||||
use nix::fcntl::{fcntl, FcntlArg};
|
||||
|
||||
use crate::error::Error;
|
||||
use crate::host::traits::Tty;
|
||||
use moa::error::Error;
|
||||
use moa::host::traits::Tty;
|
||||
|
||||
|
||||
pub struct SimplePty {
|
@ -5,5 +5,6 @@ edition = "2018"
|
||||
default-run = "moa-computie"
|
||||
|
||||
[dependencies]
|
||||
moa = { path = "../../", features = ["tty"] }
|
||||
moa = { path = "../../" }
|
||||
moa-common = { path = "../moa-common", features = ["tty"] }
|
||||
|
||||
|
@ -1,10 +1,15 @@
|
||||
|
||||
use moa::error::Error;
|
||||
use moa::host::traits::{Host, WindowUpdater};
|
||||
use moa::host::traits::{Host, Tty, WindowUpdater};
|
||||
|
||||
pub struct ConsoleFrontend;
|
||||
|
||||
impl Host for ConsoleFrontend {
|
||||
fn create_pty(&self) -> Result<Box<dyn Tty>, Error> {
|
||||
use moa_common::tty::SimplePty;
|
||||
Ok(Box::new(SimplePty::open()?))
|
||||
}
|
||||
|
||||
fn add_window(&mut self, updater: Box<dyn WindowUpdater>) -> Result<(), Error> {
|
||||
println!("console: add_window() is not supported from the console; ignoring request...");
|
||||
Ok(())
|
||||
|
@ -6,10 +6,21 @@ use crate::host::keys::Key;
|
||||
use crate::host::controllers::{ControllerDevice, ControllerEvent};
|
||||
|
||||
pub trait Host {
|
||||
//fn create_pty(&self) -> Result<Box<dyn Tty>, Error>;
|
||||
fn add_window(&mut self, updater: Box<dyn WindowUpdater>) -> Result<(), Error>;
|
||||
fn register_controller(&mut self, _device: ControllerDevice, _input: Box<dyn ControllerUpdater>) -> Result<(), Error> { Err(Error::new("Not supported")) }
|
||||
fn register_keyboard(&mut self, _input: Box<dyn KeyboardUpdater>) -> Result<(), Error> { Err(Error::new("Not supported")) }
|
||||
fn create_pty(&self) -> Result<Box<dyn Tty>, Error> {
|
||||
Err(Error::new("This frontend doesn't support PTYs"))
|
||||
}
|
||||
|
||||
fn add_window(&mut self, updater: Box<dyn WindowUpdater>) -> Result<(), Error> {
|
||||
Err(Error::new("This frontend doesn't support windows"))
|
||||
}
|
||||
|
||||
fn register_controller(&mut self, _device: ControllerDevice, _input: Box<dyn ControllerUpdater>) -> Result<(), Error> {
|
||||
Err(Error::new("This frontend doesn't support game controllers"))
|
||||
}
|
||||
|
||||
fn register_keyboard(&mut self, _input: Box<dyn KeyboardUpdater>) -> Result<(), Error> {
|
||||
Err(Error::new("This frontend doesn't support the keyboard"))
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Tty {
|
||||
|
@ -9,7 +9,6 @@ use crate::peripherals::ata::AtaDevice;
|
||||
use crate::peripherals::mc68681::MC68681;
|
||||
|
||||
use crate::host::traits::Host;
|
||||
use crate::host::tty::SimplePty;
|
||||
|
||||
|
||||
pub fn build_computie<H: Host>(host: &H) -> Result<System, Error> {
|
||||
@ -27,8 +26,8 @@ pub fn build_computie<H: Host>(host: &H) -> Result<System, Error> {
|
||||
system.add_addressable_device(0x00600000, wrap_transmutable(ata))?;
|
||||
|
||||
let mut serial = MC68681::new();
|
||||
launch_terminal_emulator(serial.port_a.connect(Box::new(SimplePty::open()?))?);
|
||||
launch_slip_connection(serial.port_b.connect(Box::new(SimplePty::open()?))?);
|
||||
launch_terminal_emulator(serial.port_a.connect(host.create_pty()?)?);
|
||||
launch_slip_connection(serial.port_b.connect(host.create_pty()?)?);
|
||||
system.add_addressable_device(0x00700000, wrap_transmutable(serial))?;
|
||||
|
||||
|
||||
@ -65,8 +64,8 @@ pub fn build_computie_k30<H: Host>(host: &H) -> Result<System, Error> {
|
||||
system.add_addressable_device(0x00600000, wrap_transmutable(ata))?;
|
||||
|
||||
let mut serial = MC68681::new();
|
||||
launch_terminal_emulator(serial.port_a.connect(Box::new(SimplePty::open()?))?);
|
||||
//launch_slip_connection(serial.port_b.connect(Box::new(SimplePty::open()?))?);
|
||||
launch_terminal_emulator(serial.port_a.connect(host.create_pty()?)?);
|
||||
//launch_slip_connection(serial.port_b.connect(host.create_pty()?)?);
|
||||
system.add_addressable_device(0x00700000, wrap_transmutable(serial))?;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user