feat: custom PTP implementation

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-10-15 23:35:35 +01:00
parent 943f22c074
commit 1f26a91dcd
17 changed files with 743 additions and 173 deletions

View File

@@ -1,27 +1,4 @@
use anyhow::bail;
use clap::Args;
#[derive(Debug, Clone)]
pub enum SimulationSelector {
Slot(u8),
Name(String),
}
impl std::str::FromStr for SimulationSelector {
type Err = anyhow::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
if let Ok(slot) = s.parse::<u8>() {
return Ok(Self::Slot(slot));
}
if s.is_empty() {
bail!("Simulation name cannot be empty")
}
Ok(Self::Name(s.to_string()))
}
}
#[derive(Args, Debug)]
pub struct FilmSimulationOptions {}

View File

@@ -4,7 +4,7 @@ use clap::Subcommand;
use serde::Serialize;
use crate::{
camera::{Camera, UsbMode},
camera::{Camera, ptp::enums::UsbMode},
usb,
};
@@ -112,10 +112,10 @@ fn handle_info(json: bool, device_id: Option<&str>) -> anyhow::Result<()> {
let repr = CameraRepr {
device: (&camera).into(),
manufacturer: info.Manufacturer.clone(),
model: info.Model.clone(),
device_version: info.DeviceVersion.clone(),
serial_number: info.SerialNumber,
manufacturer: info.manufacturer.clone(),
model: info.model.clone(),
device_version: info.device_version.clone(),
serial_number: info.serial_number,
mode,
battery,
};

View File

@@ -5,7 +5,7 @@ pub mod device;
pub mod render;
pub mod simulation;
use clap::{Parser, Subcommand};
use clap::{ArgAction, Parser, Subcommand};
use backup::BackupCmd;
use device::DeviceCmd;
@@ -23,13 +23,9 @@ pub struct Cli {
#[arg(long, short = 'j', global = true)]
pub json: bool,
/// Only log warnings and errors
#[arg(long, short = 'q', global = true, conflicts_with = "verbose")]
pub quiet: bool,
/// Log extra debugging information
#[arg(long, short = 'v', global = true, conflicts_with = "quiet")]
pub verbose: bool,
/// Log extra debugging information (multiple instances increase verbosity)
#[arg(long, short = 'v', action = ArgAction::Count, global = true)]
pub verbose: u8,
/// Manually specify target device
#[arg(long, short = 'd', global = true)]

View File

@@ -2,7 +2,7 @@ use std::path::PathBuf;
use super::common::{
file::{Input, Output},
film::{FilmSimulationOptions, SimulationSelector},
film::FilmSimulationOptions,
};
use clap::Args;
@@ -10,7 +10,7 @@ use clap::Args;
pub struct RenderCmd {
/// Simulation number or name
#[arg(long, conflicts_with = "simulation_file")]
simulation: Option<SimulationSelector>,
simulation: Option<u8>,
/// Path to exported simulation
#[arg(long, conflicts_with = "simulation")]

View File

@@ -1,6 +1,6 @@
use super::common::{
file::{Input, Output},
film::{FilmSimulationOptions, SimulationSelector},
film::FilmSimulationOptions,
};
use clap::Subcommand;
@@ -14,14 +14,14 @@ pub enum SimulationCmd {
#[command(alias = "g")]
Get {
/// Simulation number or name
simulation: SimulationSelector,
simulation: u8,
},
/// Set simulation parameters
#[command(alias = "s")]
Set {
/// Simulation number or name
simulation: SimulationSelector,
simulation: u8,
#[command(flatten)]
film_simulation_options: FilmSimulationOptions,
@@ -31,7 +31,7 @@ pub enum SimulationCmd {
#[command(alias = "e")]
Export {
/// Simulation number or name
simulation: SimulationSelector,
simulation: u8,
/// Output file (use '-' to write to stdout)
output_file: Output,