mirror of
https://github.com/marcriera/ddgo-pnp-controller.git
synced 2025-04-18 09:39:28 +02:00
Disable control transfer debugging
This commit is contained in:
parent
46543c3f36
commit
70852cf2a7
2 changed files with 10 additions and 11 deletions
|
@ -22,7 +22,6 @@ mod zkns001;
|
||||||
const FFS_MOUNT: &str = "/tmp/ffs";
|
const FFS_MOUNT: &str = "/tmp/ffs";
|
||||||
const ENDPOINT0: &str = "/tmp/ffs/ep0";
|
const ENDPOINT0: &str = "/tmp/ffs/ep0";
|
||||||
const ENDPOINT1: &str = "/tmp/ffs/ep1";
|
const ENDPOINT1: &str = "/tmp/ffs/ep1";
|
||||||
const ENDPOINT3: &str = "/tmp/ffs/ep3";
|
|
||||||
const ANDROID_GADGET: &str = "/sys/class/android_usb/android0";
|
const ANDROID_GADGET: &str = "/sys/class/android_usb/android0";
|
||||||
|
|
||||||
#[derive(PartialEq, Debug, Clone, Copy)]
|
#[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]) {
|
pub fn handle_ctrl_transfer(model: ControllerModel, data: &[u8]) {
|
||||||
println!("CTRL REQ: {:?}", data);
|
//println!("CTRL REQ: {:?}", data);
|
||||||
if data[1] == 6 && data[3] == 34 {
|
if data[1] == 6 && data[3] == 34 {
|
||||||
// Get HID report descriptor
|
// Get HID report descriptor
|
||||||
let report: Option<&[u8]>;
|
let report: Option<&[u8]>;
|
||||||
|
@ -165,11 +164,11 @@ pub fn handle_ctrl_transfer(model: ControllerModel, data: &[u8]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if data[1] == 9 {
|
else if data[1] == 9 {
|
||||||
if let Ok(mut ep0) = File::open(&ENDPOINT0) {
|
// if let Ok(mut ep0) = File::open(&ENDPOINT0) {
|
||||||
let mut buffer = [0; 8];
|
// let mut buffer = [0; 8];
|
||||||
ep0.read(&mut buffer).unwrap();
|
// ep0.read(&mut buffer).ok();
|
||||||
println!("CTRL DAT: {:?}", buffer);
|
// 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("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("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("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("f_ffs/aliases")), "ffs").ok();
|
||||||
fs::write(gadget.join(Path::new("enable")), "1").ok();
|
fs::write(gadget.join(Path::new("enable")), "1").ok();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Write};
|
use std::io::{Write};
|
||||||
use crate::controller::physical::ControllerState;
|
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,
|
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,
|
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,
|
0x09, 0x04, 0x00, 0x00, 0x03, 0xFF, 0x00, 0x00, 0x00,
|
||||||
0x07, 0x05, 0x82, 0x02, 0x20, 0x00, 0x00,
|
0x07, 0x05, 0x82, 0x02, 0x20, 0x00, 0x00,
|
||||||
0x07, 0x05, 0x02, 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 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"};
|
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_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]};
|
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(handle.as_bytes()).ok();
|
||||||
file.write(&[0xD]).ok();
|
file.write(&[0xD]).ok();
|
||||||
file.write(button_a.as_bytes()).ok();
|
file.write(button_a.as_bytes()).ok();
|
||||||
|
|
Loading…
Add table
Reference in a new issue