use std::sync::Arc;
use bolt::{BOLT_VPID_PAIRS, BoltReceiver};
use thiserror::Error;
use crate::{channel::HidppChannel, protocol::v10::Hidpp10Error};
pub mod bolt;
pub const RECEIVER_DEVICE_INDEX: u8 = 0xff;
#[derive(Clone)]
#[non_exhaustive]
pub enum Receiver {
Bolt(BoltReceiver),
}
pub fn detect(chan: Arc<HidppChannel>) -> Option<Receiver> {
if BOLT_VPID_PAIRS.contains(&(chan.vendor_id, chan.product_id)) {
if let Ok(bolt) = BoltReceiver::new(chan) {
return Some(Receiver::Bolt(bolt));
}
return None;
}
None
}
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum ReceiverError {
#[error("no (supported) receiver could be found")]
UnknownReceiver,
#[error("a HID++1.0 error occurred")]
Protocol(#[from] Hidpp10Error),
}