mirror of
https://github.com/transistorfet/moa.git
synced 2024-11-25 15:33:08 +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"
|
edition = "2018"
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [".", "frontends/moa-console", "frontends/moa-minifb"]
|
members = [".", "frontends/moa-common", "frontends/moa-console", "frontends/moa-minifb"]
|
||||||
default-members = ["frontends/moa-console"]
|
default-members = ["frontends/moa-console"]
|
||||||
|
|
||||||
[features]
|
|
||||||
default = ["tty"]
|
|
||||||
tty = ["nix"]
|
|
||||||
|
|
||||||
[dependencies]
|
[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::sync::mpsc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::os::unix::io::AsRawFd;
|
|
||||||
|
|
||||||
use nix::fcntl::OFlag;
|
use nix::fcntl::OFlag;
|
||||||
use nix::pty::{self, PtyMaster};
|
use nix::pty::{self, PtyMaster};
|
||||||
use nix::fcntl::{fcntl, FcntlArg};
|
use nix::fcntl::{fcntl, FcntlArg};
|
||||||
|
|
||||||
use crate::error::Error;
|
use moa::error::Error;
|
||||||
use crate::host::traits::Tty;
|
use moa::host::traits::Tty;
|
||||||
|
|
||||||
|
|
||||||
pub struct SimplePty {
|
pub struct SimplePty {
|
@ -5,5 +5,6 @@ edition = "2018"
|
|||||||
default-run = "moa-computie"
|
default-run = "moa-computie"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
moa = { path = "../../", features = ["tty"] }
|
moa = { path = "../../" }
|
||||||
|
moa-common = { path = "../moa-common", features = ["tty"] }
|
||||||
|
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
|
|
||||||
use moa::error::Error;
|
use moa::error::Error;
|
||||||
use moa::host::traits::{Host, WindowUpdater};
|
use moa::host::traits::{Host, Tty, WindowUpdater};
|
||||||
|
|
||||||
pub struct ConsoleFrontend;
|
pub struct ConsoleFrontend;
|
||||||
|
|
||||||
impl Host for 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> {
|
fn add_window(&mut self, updater: Box<dyn WindowUpdater>) -> Result<(), Error> {
|
||||||
println!("console: add_window() is not supported from the console; ignoring request...");
|
println!("console: add_window() is not supported from the console; ignoring request...");
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -6,10 +6,21 @@ use crate::host::keys::Key;
|
|||||||
use crate::host::controllers::{ControllerDevice, ControllerEvent};
|
use crate::host::controllers::{ControllerDevice, ControllerEvent};
|
||||||
|
|
||||||
pub trait Host {
|
pub trait Host {
|
||||||
//fn create_pty(&self) -> Result<Box<dyn Tty>, Error>;
|
fn create_pty(&self) -> Result<Box<dyn Tty>, Error> {
|
||||||
fn add_window(&mut self, updater: Box<dyn WindowUpdater>) -> Result<(), Error>;
|
Err(Error::new("This frontend doesn't support PTYs"))
|
||||||
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 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 {
|
pub trait Tty {
|
||||||
|
@ -9,7 +9,6 @@ use crate::peripherals::ata::AtaDevice;
|
|||||||
use crate::peripherals::mc68681::MC68681;
|
use crate::peripherals::mc68681::MC68681;
|
||||||
|
|
||||||
use crate::host::traits::Host;
|
use crate::host::traits::Host;
|
||||||
use crate::host::tty::SimplePty;
|
|
||||||
|
|
||||||
|
|
||||||
pub fn build_computie<H: Host>(host: &H) -> Result<System, Error> {
|
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))?;
|
system.add_addressable_device(0x00600000, wrap_transmutable(ata))?;
|
||||||
|
|
||||||
let mut serial = MC68681::new();
|
let mut serial = MC68681::new();
|
||||||
launch_terminal_emulator(serial.port_a.connect(Box::new(SimplePty::open()?))?);
|
launch_terminal_emulator(serial.port_a.connect(host.create_pty()?)?);
|
||||||
launch_slip_connection(serial.port_b.connect(Box::new(SimplePty::open()?))?);
|
launch_slip_connection(serial.port_b.connect(host.create_pty()?)?);
|
||||||
system.add_addressable_device(0x00700000, wrap_transmutable(serial))?;
|
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))?;
|
system.add_addressable_device(0x00600000, wrap_transmutable(ata))?;
|
||||||
|
|
||||||
let mut serial = MC68681::new();
|
let mut serial = MC68681::new();
|
||||||
launch_terminal_emulator(serial.port_a.connect(Box::new(SimplePty::open()?))?);
|
launch_terminal_emulator(serial.port_a.connect(host.create_pty()?)?);
|
||||||
//launch_slip_connection(serial.port_b.connect(Box::new(SimplePty::open()?))?);
|
//launch_slip_connection(serial.port_b.connect(host.create_pty()?)?);
|
||||||
system.add_addressable_device(0x00700000, wrap_transmutable(serial))?;
|
system.add_addressable_device(0x00700000, wrap_transmutable(serial))?;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user