drop unimplemented streams and dependencies for build time

This commit is contained in:
bel
2023-03-24 23:55:30 -06:00
parent 451a1c43a3
commit 14df9125ef
3 changed files with 3 additions and 340 deletions

View File

@@ -1,8 +1,5 @@
use crate::config::Stream;
use hidapi::HidApi;
use rusb::UsbContext;
use gilrs::{Gilrs, Button, Event};
use serde_json::json;
use handlebars::Handlebars;
use std::time::{SystemTime, UNIX_EPOCH};
@@ -20,7 +17,6 @@ pub fn build_input_stream(cfg: &Stream) -> Box<dyn InputStream> {
return Box::new(build_input_stream_kafka(&cfg).unwrap());
},
"udp" => return Box::new(build_input_stream_udp(&cfg).unwrap()),
"device" => return Box::new(build_input_stream_device(&cfg).unwrap()),
_ => {},
};
assert!(false);
@@ -30,78 +26,9 @@ pub fn build_input_stream(cfg: &Stream) -> Box<dyn InputStream> {
pub struct InputStreamDevice {
}
pub fn build_input_stream_device(cfg: &Stream) -> Result<InputStreamDevice, String> {
return build_input_stream_device_gilrs(cfg)
}
pub fn build_input_stream_device_gilrs(cfg: &Stream) -> Result<InputStreamDevice, String> {
let _device_cfg = cfg.engine.device.as_ref().unwrap();
let mut gilrs = Gilrs::new().unwrap();
eprintln!("printing gamepads");
for (_id, gamepad) in gilrs.gamepads() {
eprintln!("{} is {:?}", gamepad.name(), gamepad.power_info());
}
eprintln!("printing gamepads events");
loop {
// eprintln!("reading gamepads events");
// Examine new events
while let Some(Event { id, event, time }) = gilrs.next_event() {
eprintln!("{:?} New event from {}: {:?}", time, id, event);
let active_gamepad = Some(id);
eprintln!("inspecting event");
// You can also use cached gamepad state
if let Some(gamepad) = active_gamepad.map(|id| gilrs.gamepad(id)) {
if gamepad.is_pressed(Button::South) {
eprintln!("Button South is pressed (XBox - A, PS - X)");
}
}
break;
}
std::thread::sleep(std::time::Duration::from_millis(15));
break;
}
return Err("do what".to_string());
}
pub fn build_input_stream_device_hidapi(cfg: &Stream) -> Result<InputStreamDevice, String> {
let _device_cfg = cfg.engine.device.as_ref().unwrap();
match HidApi::new() {
Ok(api) => {
for device in api.devices() {
eprintln!("{:#?}", device);
}
},
Err(e) => {
eprintln!("Error: {}", e);
},
};
return Err("do what".to_string());
}
pub fn build_input_stream_device_rusb(cfg: &Stream) -> Result<InputStreamDevice, String> {
let _device_cfg = cfg.engine.device.as_ref().unwrap();
assert!(rusb::has_capability());
let ctx = rusb::Context::new().unwrap();
assert!(ctx.devices().unwrap().len() > 0);
for device in ctx.devices().unwrap().iter() {
let device_desc = device.device_descriptor().unwrap();
eprintln!("Bus {:03} Device {:03} ID {:04x}:{:04x}",
device.bus_number(),
device.address(),
device_desc.vendor_id(),
device_desc.product_id());
}
return Err("do what".to_string());
}
//pub fn build_input_stream_device_gilrs(cfg: &Stream) -> Result<InputStreamDevice, String> {
//pub fn build_input_stream_device_hidapi(cfg: &Stream) -> Result<InputStreamDevice, String> {
//pub fn build_input_stream_device_rusb(cfg: &Stream) -> Result<InputStreamDevice, String> {
impl InputStream for InputStreamDevice {
fn get(&mut self) -> Vec<char> {