only stdout for output to std
parent
d2e4a4de28
commit
ee34b47bd8
|
|
@ -39,24 +39,24 @@ pub fn build_input_stream_device_gilrs(cfg: &Stream) -> Result<InputStreamDevice
|
|||
|
||||
let mut gilrs = Gilrs::new().unwrap();
|
||||
|
||||
println!("printing gamepads");
|
||||
eprintln!("printing gamepads");
|
||||
for (_id, gamepad) in gilrs.gamepads() {
|
||||
println!("{} is {:?}", gamepad.name(), gamepad.power_info());
|
||||
eprintln!("{} is {:?}", gamepad.name(), gamepad.power_info());
|
||||
}
|
||||
|
||||
println!("printing gamepads events");
|
||||
eprintln!("printing gamepads events");
|
||||
loop {
|
||||
// println!("reading gamepads events");
|
||||
// eprintln!("reading gamepads events");
|
||||
// Examine new events
|
||||
while let Some(Event { id, event, time }) = gilrs.next_event() {
|
||||
println!("{:?} New event from {}: {:?}", time, id, event);
|
||||
eprintln!("{:?} New event from {}: {:?}", time, id, event);
|
||||
let active_gamepad = Some(id);
|
||||
|
||||
println!("inspecting event");
|
||||
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) {
|
||||
println!("Button South is pressed (XBox - A, PS - X)");
|
||||
eprintln!("Button South is pressed (XBox - A, PS - X)");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -74,7 +74,7 @@ pub fn build_input_stream_device_hidapi(cfg: &Stream) -> Result<InputStreamDevic
|
|||
match HidApi::new() {
|
||||
Ok(api) => {
|
||||
for device in api.devices() {
|
||||
println!("{:#?}", device);
|
||||
eprintln!("{:#?}", device);
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
|
|
@ -94,7 +94,7 @@ pub fn build_input_stream_device_rusb(cfg: &Stream) -> Result<InputStreamDevice,
|
|||
|
||||
for device in ctx.devices().unwrap().iter() {
|
||||
let device_desc = device.device_descriptor().unwrap();
|
||||
println!("Bus {:03} Device {:03} ID {:04x}:{:04x}",
|
||||
eprintln!("Bus {:03} Device {:03} ID {:04x}:{:04x}",
|
||||
device.bus_number(),
|
||||
device.address(),
|
||||
device_desc.vendor_id(),
|
||||
|
|
@ -116,7 +116,7 @@ pub struct InputStreamUDP {
|
|||
|
||||
pub fn build_input_stream_udp(cfg: &Stream) -> Result<InputStreamUDP, String> {
|
||||
let udp_cfg = cfg.engine.udp.as_ref().unwrap();
|
||||
println!("$ echo -n 'hello world' | nc -4u -w0 localhost {}", &udp_cfg.port.to_string());
|
||||
eprintln!("$ echo -n 'hello world' | nc -4u -w0 localhost {}", &udp_cfg.port.to_string());
|
||||
return Ok(InputStreamUDP{
|
||||
last_socket: None,
|
||||
port: udp_cfg.port,
|
||||
|
|
@ -133,7 +133,7 @@ impl InputStream for InputStreamUDP {
|
|||
let mut buf = [0; 128];
|
||||
let result = self.last_socket.as_ref().unwrap().recv_from(&mut buf);
|
||||
if result.is_err() {
|
||||
println!("InputStreamUDP: failed to recv: {:?}", result.err());
|
||||
eprintln!("InputStreamUDP: failed to recv: {:?}", result.err());
|
||||
self.last_socket = None;
|
||||
return Vec::<char>::new();
|
||||
}
|
||||
|
|
@ -297,13 +297,13 @@ impl OutputStream for OutputStreamUDP {
|
|||
if self.last_socket.is_none() {
|
||||
let result = std::net::UdpSocket::bind("127.0.0.1:".to_string() + &(self.port+10).to_string());
|
||||
if result.is_err() {
|
||||
println!("OutputStreamUDP: failed to bind to 127.0.0.1:{}: {:?}", &(self.port+10).to_string(), result.err());
|
||||
eprintln!("OutputStreamUDP: failed to bind to 127.0.0.1:{}: {:?}", &(self.port+10).to_string(), result.err());
|
||||
return;
|
||||
}
|
||||
self.last_socket = Some(result.unwrap());
|
||||
let result = self.last_socket.as_ref().unwrap().connect(self.host.to_string() + ":" + &self.port.to_string());
|
||||
if result.is_err() {
|
||||
println!("OutputStreamUDP: failed to connect to {}:{}: {:?}", self.host.to_string(), self.port.to_string(), result.err());
|
||||
eprintln!("OutputStreamUDP: failed to connect to {}:{}: {:?}", self.host.to_string(), self.port.to_string(), result.err());
|
||||
self.last_socket = None;
|
||||
return;
|
||||
}
|
||||
|
|
@ -311,7 +311,7 @@ impl OutputStream for OutputStreamUDP {
|
|||
|
||||
let result = self.last_socket.as_ref().unwrap().send(&v.iter().cloned().collect::<String>().as_bytes());
|
||||
if result.is_err() {
|
||||
println!("OutputStreamUDP: failed to send: {:?}", result.err());
|
||||
eprintln!("OutputStreamUDP: failed to send: {:?}", result.err());
|
||||
self.last_socket = None;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue