From 2a01cd732a7e7f7f21b932be3bb02b240673f09f Mon Sep 17 00:00:00 2001 From: Naxdy Date: Fri, 19 Apr 2024 17:14:20 +0200 Subject: [PATCH] feat(hid): distinguish "OG" from "PC" mode --- src/config.rs | 7 ++++++- src/gcc_hid.rs | 14 +++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/config.rs b/src/config.rs index 2200302..1f70d6d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -558,6 +558,9 @@ pub enum InputConsistencyMode { /// to something your opponent does. /// The name is not meant to imply that this is a hack that is super, but rather that this is super hacky. SuperHack = 2, + /// Transmit inputs every 1 ms, for use on PC or other devices that are not garbage. + /// This is not recommended for use on the Switch! + PC = 3, } #[derive(Debug, Clone, Format, PackedStruct)] @@ -1689,7 +1692,8 @@ async fn configuration_main_loop< // input consistency toggle 37 => { final_config.input_consistency_mode = match final_config.input_consistency_mode { - InputConsistencyMode::Original => InputConsistencyMode::ConsistencyHack, + InputConsistencyMode::Original => InputConsistencyMode::PC, + InputConsistencyMode::PC => InputConsistencyMode::ConsistencyHack, InputConsistencyMode::ConsistencyHack => InputConsistencyMode::SuperHack, InputConsistencyMode::SuperHack => InputConsistencyMode::Original, }; @@ -1713,6 +1717,7 @@ async fn configuration_main_loop< stick_y: (127_i8 + match final_config.input_consistency_mode { InputConsistencyMode::Original => -69, + InputConsistencyMode::PC => -42, InputConsistencyMode::ConsistencyHack => 42, InputConsistencyMode::SuperHack => 69, }) as u8, diff --git a/src/gcc_hid.rs b/src/gcc_hid.rs index fceee86..092d7d8 100644 --- a/src/gcc_hid.rs +++ b/src/gcc_hid.rs @@ -302,6 +302,7 @@ pub async fn usb_transfer_task(raw_serial: [u8; 8], driver: Driver<'static, USB> InputConsistencyMode::Original => "NaxGCC (OG Mode)", InputConsistencyMode::ConsistencyHack => "NaxGCC (Consistency Mode)", InputConsistencyMode::SuperHack => "NaxGCC (SuperHack Mode)", + InputConsistencyMode::PC => "NaxGCC (PC Mode)", }); usb_config.serial_number = Some(serial); usb_config.max_power = 200; @@ -338,7 +339,12 @@ pub async fn usb_transfer_task(raw_serial: [u8; 8], driver: Driver<'static, USB> let hid_config = embassy_usb::class::hid::Config { report_descriptor: GCC_REPORT_DESCRIPTOR, request_handler: Some(&request_handler), - poll_ms: 1, + poll_ms: match input_consistency_mode { + InputConsistencyMode::Original => 8, + InputConsistencyMode::ConsistencyHack + | InputConsistencyMode::SuperHack + | InputConsistencyMode::PC => 1, + }, max_packet_size_in: 37, max_packet_size_out: 5, }; @@ -378,7 +384,7 @@ pub async fn usb_transfer_task(raw_serial: [u8; 8], driver: Driver<'static, USB> // "Ticker at home", so we can use this for both consistency and SuperHack mode Timer::at(rate_limit_end_time).await; } - InputConsistencyMode::Original => {} + InputConsistencyMode::Original | InputConsistencyMode::PC => {} } match writer @@ -395,7 +401,9 @@ pub async fn usb_transfer_task(raw_serial: [u8; 8], driver: Driver<'static, USB> let polltime = currtime.duration_since(last_report_time); let micros = polltime.as_micros(); debug!("Report written in {}us", micros); - if input_consistency_mode != InputConsistencyMode::Original { + if input_consistency_mode != InputConsistencyMode::Original + && input_consistency_mode != InputConsistencyMode::PC + { while rate_limit_end_time < currtime { rate_limit_end_time += Duration::from_micros(8333); }