Formatting
This commit is contained in:
@@ -149,19 +149,19 @@ pub fn gc_event_system(
|
||||
send_axis!(GamepadAxis::LeftStickY, now.left_stick.1);
|
||||
}
|
||||
if prev.right_stick != now.right_stick {
|
||||
send_axis!(
|
||||
GamepadAxis::RightStickX,
|
||||
now.right_stick.0
|
||||
);
|
||||
send_axis!(
|
||||
GamepadAxis::RightStickY,
|
||||
now.right_stick.1
|
||||
);
|
||||
send_axis!(GamepadAxis::RightStickX, now.right_stick.0);
|
||||
send_axis!(GamepadAxis::RightStickY, now.right_stick.1);
|
||||
}
|
||||
if prev.triggers != now.triggers {
|
||||
// The analog triggers are represented as button-axis values, as we have no GamepadAxis to use.
|
||||
send_button!(GamepadButton::LeftTrigger2, unsigned_axis_float(now.triggers.0));
|
||||
send_button!(GamepadButton::RightTrigger2, unsigned_axis_float(now.triggers.1));
|
||||
send_button!(
|
||||
GamepadButton::LeftTrigger2,
|
||||
unsigned_axis_float(now.triggers.0)
|
||||
);
|
||||
send_button!(
|
||||
GamepadButton::RightTrigger2,
|
||||
unsigned_axis_float(now.triggers.1)
|
||||
);
|
||||
}
|
||||
|
||||
macro_rules! digital {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
pub mod bridge;
|
||||
pub mod poll;
|
||||
|
||||
pub use bridge::{GcPort, GcPorts, GC_PORT_COUNT};
|
||||
pub use bridge::{GC_PORT_COUNT, GcPort, GcPorts};
|
||||
pub use poll::{GcAdapterSnapshot, GcPortState};
|
||||
|
||||
use bevy::input::gamepad::{gamepad_connection_system, gamepad_event_processing_system};
|
||||
use bevy::input::InputSystems;
|
||||
use bevy::input::gamepad::{gamepad_connection_system, gamepad_event_processing_system};
|
||||
use bevy::prelude::*;
|
||||
|
||||
#[derive(Default)]
|
||||
|
||||
@@ -98,12 +98,9 @@ pub fn spawn_poll_thread() -> Result<GcAdapterSnapshot, gc_adapter_neo::UsbError
|
||||
.name("gc-adapter-poll".into())
|
||||
.spawn(move || {
|
||||
// Flush whatever the adapter had buffered before we started
|
||||
if let Err(payload) =
|
||||
panic::catch_unwind(AssertUnwindSafe(|| adapter.refresh_inputs()))
|
||||
if let Err(payload) = panic::catch_unwind(AssertUnwindSafe(|| adapter.refresh_inputs()))
|
||||
{
|
||||
error!(
|
||||
"GameCube Controller Adapter USB refresh panicked on startup: {payload:?}"
|
||||
);
|
||||
error!("GameCube Controller Adapter USB refresh panicked on startup: {payload:?}");
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
@@ -112,8 +109,7 @@ pub fn spawn_poll_thread() -> Result<GcAdapterSnapshot, gc_adapter_neo::UsbError
|
||||
let mut rate_window_count: u32 = 0;
|
||||
|
||||
while !thread_shutdown.load(Ordering::Relaxed) {
|
||||
let result =
|
||||
panic::catch_unwind(AssertUnwindSafe(|| adapter.read_controllers()));
|
||||
let result = panic::catch_unwind(AssertUnwindSafe(|| adapter.read_controllers()));
|
||||
|
||||
let controllers = match result {
|
||||
Ok(Ok(controllers)) => controllers,
|
||||
@@ -142,7 +138,8 @@ pub fn spawn_poll_thread() -> Result<GcAdapterSnapshot, gc_adapter_neo::UsbError
|
||||
|
||||
let mut states = [GcPortState::default(); 4];
|
||||
for i in 0..4 {
|
||||
states[i] = GcPortState::make_port_state(&controllers[i], adapter.calibration(i));
|
||||
states[i] =
|
||||
GcPortState::make_port_state(&controllers[i], adapter.calibration(i));
|
||||
}
|
||||
*thread_ports.lock().unwrap_or_else(|e| e.into_inner()) = states;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user