Disable control transfer debugging

This commit is contained in:
Marc Riera 2023-05-05 00:18:24 +02:00
parent 46543c3f36
commit 70852cf2a7
2 changed files with 10 additions and 11 deletions

View file

@ -22,7 +22,6 @@ mod zkns001;
const FFS_MOUNT: &str = "/tmp/ffs";
const ENDPOINT0: &str = "/tmp/ffs/ep0";
const ENDPOINT1: &str = "/tmp/ffs/ep1";
const ENDPOINT3: &str = "/tmp/ffs/ep3";
const ANDROID_GADGET: &str = "/sys/class/android_usb/android0";
#[derive(PartialEq, Debug, Clone, Copy)]
@ -140,7 +139,7 @@ pub fn set_state(state: &mut ControllerState, model: &ControllerModel) {
}
pub fn handle_ctrl_transfer(model: ControllerModel, data: &[u8]) {
println!("CTRL REQ: {:?}", data);
//println!("CTRL REQ: {:?}", data);
if data[1] == 6 && data[3] == 34 {
// Get HID report descriptor
let report: Option<&[u8]>;
@ -165,11 +164,11 @@ pub fn handle_ctrl_transfer(model: ControllerModel, data: &[u8]) {
}
}
else if data[1] == 9 {
if let Ok(mut ep0) = File::open(&ENDPOINT0) {
let mut buffer = [0; 8];
ep0.read(&mut buffer).unwrap();
println!("CTRL DAT: {:?}", buffer);
}
// if let Ok(mut ep0) = File::open(&ENDPOINT0) {
// let mut buffer = [0; 8];
// ep0.read(&mut buffer).ok();
// println!("CTRL DAT: {:?}", buffer);
// }
}
}
@ -223,7 +222,7 @@ fn init_gadget(model: &ControllerModel, (device, descriptors, strings): (&Device
fs::write(gadget.join(Path::new("iManufacturer")), &device.i_manufacturer.to_string()).ok();
fs::write(gadget.join(Path::new("iProduct")), &device.i_product.to_string()).ok();
fs::write(gadget.join(Path::new("iSerial")), &device.i_serial_number.to_string()).ok();
fs::write(gadget.join(Path::new("functions")), "ffs").ok();
fs::write(gadget.join(Path::new("functions")), "ffs,rndis").ok();
fs::write(gadget.join(Path::new("f_ffs/aliases")), "ffs").ok();
fs::write(gadget.join(Path::new("enable")), "1").ok();
}

View file

@ -1,7 +1,7 @@
use std::fs::File;
use std::io::{Write};
use crate::controller::physical::ControllerState;
use crate::controller::emulated::{DeviceDescriptor, ENDPOINT3};
use crate::controller::emulated::{DeviceDescriptor, ENDPOINT1};
pub const DESCRIPTORS: [u8; 76] = [0x01, 0x00, 0x00, 0x00, 0x4C, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x09, 0x04, 0x00, 0x00, 0x03, 0xFF, 0x00, 0x00, 0x00,
@ -11,7 +11,7 @@ pub const DESCRIPTORS: [u8; 76] = [0x01, 0x00, 0x00, 0x00, 0x4C, 0x00, 0x00, 0x0
0x09, 0x04, 0x00, 0x00, 0x03, 0xFF, 0x00, 0x00, 0x00,
0x07, 0x05, 0x82, 0x02, 0x20, 0x00, 0x00,
0x07, 0x05, 0x02, 0x02, 0x20, 0x00, 0x00,
0x07, 0x05, 0x81, 0x03, 0x08, 0x00, 0x01,];
0x07, 0x05, 0x81, 0x03, 0x08, 0x00, 0x01];
pub const STRINGS: [u8; 16] = [0x02, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
pub const DEVICE_DESCRIPTOR: DeviceDescriptor = DeviceDescriptor{b_device_class: 0x02, b_device_sub_class: 0x0, id_vendor: 0x067B, id_product: 0x2303, bcd_device: 0x0102, i_manufacturer: "TAITO", i_product: "Densha de Go! Plug & Play (Master Controller II mode)", i_serial_number: "VOK-00106"};
@ -37,7 +37,7 @@ pub fn update_gadget(state: &mut ControllerState) {
let button_c = if state.button_c {BUTTON_C[1]} else {BUTTON_C[0]};
let button_s = if state.button_d {BUTTON_S[1]} else {BUTTON_S[0]};
if let Ok(mut file) = File::create(ENDPOINT3) {
if let Ok(mut file) = File::create(ENDPOINT1) {
file.write(handle.as_bytes()).ok();
file.write(&[0xD]).ok();
file.write(button_a.as_bytes()).ok();