pub struct G29 { /* private fields */ }Expand description
G29 Establishes a connection to the Logitech G29 Racing Wheel and provides methods to interact with it.
§Example
use lib_g29{G29, Options, Led};
use std::time::Duration;
use std::thread::sleep;
let options = Options {
..Default::default()
};
let g29 = G29::connect(options);
g29.set_leds(Led::All);
sleep(Duration::from_secs(5));
g29.disconnect();Implementations§
Source§impl G29
impl G29
Sourcepub fn set_auto_center_force(&mut self, strength: u8, turning_multiplier: u8)
pub fn set_auto_center_force(&mut self, strength: u8, turning_multiplier: u8)
Set auto-center force.
§Arguments
strength- The strength of the auto-center force (0x00 to 0x0f)turning_multiplier- The rate the effect strength rises as the wheel turns (0x00 to 0xff)
§Example
use lib_g29{G29, Options};
let options = Options {
..Default::default()
};
let mut g29 = G29::connect(options);
g29.set_auto_center_force(0x0f, 0xff);
loop {}Sourcepub fn set_leds(&self, leds: Led)
pub fn set_leds(&self, leds: Led)
Set the LED lights on the G29.
§Arguments
leds- The LED lights to set
§Example
use lib_g29{G29, Options, Led};
use std::time::Duration;
use std::thread::sleep;
let options = Options {
..Default::default()
};
let g29 = G29::connect(options);
loop {
g29.set_leds(Led::All);
sleep(Duration::from_secs(1));
g29.set_leds(Led::Red | Led::GreenOne);
sleep(Duration::from_secs(1));
}Sourcepub fn force_friction(&self, left: u8, right: u8)
pub fn force_friction(&self, left: u8, right: u8)
Set the force feedback on the G29.
§Arguments
left- The strength of the left motor (0x00 to 0x07)right- The strength of the right motor (0x00 to 0x07)
§Example
use lib_g29{G29, Options};
let options = Options {
..Default::default()
};
let mut g29 = G29::connect(options);
g29.force_friction(0x07, 0x07);
loop {}Sourcepub fn steering_fine(&self) -> u8
pub fn steering_fine(&self) -> u8
Get the fine steering value. 255 is fully right, 0 is fully left
Sourcepub fn dpad(&self) -> DpadPosition
pub fn dpad(&self) -> DpadPosition
Get the Dpad position.
§Example
if g29.dpad() == DpadPosition::Top {
println!("Dpad is at the top");
}Returns true if the x button is pressed.
Returns true if the square button is pressed.
Returns true if the circle button is pressed.
Returns true if the triangle button is pressed.
Sourcepub fn right_shifter(&self) -> bool
pub fn right_shifter(&self) -> bool
returns true if the right shifter is pressed.
Sourcepub fn left_shifter(&self) -> bool
pub fn left_shifter(&self) -> bool
Returns true if the left shifter is pressed.
Returns true if the r2 button is pressed.
Returns true if the l2 button is pressed.
Returns true if the share button is pressed.
Returns true if the option button is pressed.
Returns true if the r3 button is pressed.
Returns true if the l3 button is pressed.
Sourcepub fn gear_selector(&self) -> GearSelector
pub fn gear_selector(&self) -> GearSelector
Get the gear selector position.
§Example
if g29.gear_selector() == GearSelector::First {
println!("Gear is in first");
}Returns true if the plus button is pressed.
Returns true if the minus button is pressed.
Sourcepub fn spinner_right(&self) -> bool
pub fn spinner_right(&self) -> bool
Returns true if the spinner is rotating clockwise.
Sourcepub fn spinner_left(&self) -> bool
pub fn spinner_left(&self) -> bool
Returns true if the spinner is rotating counter-clockwise.
Returns true if the spinner button is pressed.
Returns true if the playstation button is pressed.
Sourcepub fn clutch(&self) -> u8
pub fn clutch(&self) -> u8
Returns the value of the clutch pedal. 255 is depressed, 0 is fully pressed
Sourcepub fn shifter_pressed(&self) -> bool
pub fn shifter_pressed(&self) -> bool
Returns true if the shifter is pressed.
Sourcepub fn disconnect(&mut self)
pub fn disconnect(&mut self)
Disconnect from the G29.
§Example
use lib_g29{G29, Options};
use std::time::Duration;
use std::thread::sleep;
let options = Options {
..Default::default()
};
let mut g29 = G29::connect(options);
sleep(Duration::from_secs(5));
g29.disconnect();pub fn connected(&self) -> bool
Sourcepub fn register_event_handler(
&self,
event: Event,
handler: HandlerFn,
) -> Option<EventHandler>
pub fn register_event_handler( &self, event: Event, handler: HandlerFn, ) -> Option<EventHandler>
Register an event handler for a specific event.
§Arguments
event- The event to register the handler forhandler- The handler function
§Example
use lib_g29{G29, Options, Event, EventHandler};
use std::time::Duration;
use std::thread::sleep;
let options = Options {
..Default::default()
};
let g29 = G29::connect(options);
let handler: EventHandler = g29.register_event_handler(Event::Steering, |g29| {
println!("Steering: {}", g29.steering());
});
sleep(Duration::from_secs(5));
g29.unregister_event_handler(handler);
g29.disconnect();Sourcepub fn unregister_event_handler(&mut self, event_handler: EventHandler)
pub fn unregister_event_handler(&mut self, event_handler: EventHandler)
Unregister an event handler for a specific event.
§Arguments
event_handler- The event handler to unregister
§Example
use lib_g29{G29, Options, Event, EventHandler};
use std::time::Duration;
use std::thread::sleep;
let options = Options {
..Default::default()
};
let g29 = G29::connect(options);
let handler: EventHandler = g29.register_event_handler(Event::Steering, |g29| {
println!("Steering: {}", g29.steering());
});
sleep(Duration::from_secs(5));
g29.unregister_event_handler(handler);
g29.disconnect();Trait Implementations§
Auto Trait Implementations§
impl Freeze for G29
impl RefUnwindSafe for G29
impl Send for G29
impl Sync for G29
impl Unpin for G29
impl UnwindSafe for G29
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more