Trying to get input from g29 steering wheel

I have been working on getting input from my g29 steering wheel in Rust using the sdl2 library, and have made it recognize the wheel, and register button events, but can't seem to get axis information :confused:

I have tried using example code from the rust-sdl2 github page with minor tweaks: rust-sdl2/ at master 路 Rust-SDL2/rust-sdl2 路 GitHub

I am almost completely new to rust, so assume I don't have a clue how any of this stuff works, because that is probably acurate.

Thanks for any help in advance :slight_smile:

Here is the code I am currently working with:

extern crate sdl2;

fn main() -> Result<(), String> {
    let sdl_context = sdl2::init()?;
    let joystick_subsystem = sdl_context.joystick()?;

    let available = joystick_subsystem
        .map_err(|e| format!("can't enumerate joysticks: {}", e))?;

    println!("{} joysticks available", available);

    // Iterate over all available joysticks and stop once we manage to open one.
    let mut joystick = (0..available)
        .find_map(|id| match {
            Ok(c) => {
                println!("Success: opened \"{}\"",;
            Err(e) => {
                println!("failed: {:?}", e);
        .expect("Couldn't open any joystick");

    // Print the joystick's power level
        "\"{}\" power level: {:?}",,
        joystick.power_level().map_err(|e| e.to_string())?
    println!("Number of axes: {:?}", joystick.num_axes());

    for event in sdl_context.event_pump()?.wait_iter() {
        use sdl2::event::Event;

        match event {
            Event::JoyAxisMotion {
                value: val,
            } => {
                // Axis motion is an absolute value in the range
                // [-32768, 32767]. Let's simulate a very rough dead
                // zone to ignore spurious events.
                let dead_zone = 10_000;
                if val > dead_zone || val < -dead_zone {
                    println!("Axis {} moved to {}", axis_idx, val);
            Event::JoyButtonDown { button_idx, .. } => {
                println!("Button {} down", button_idx);
            Event::JoyButtonUp { button_idx, .. } => {
                println!("Button {} up", button_idx);
            Event::JoyHatMotion { hat_idx, state, .. } => {
                println!("Hat {} moved to {:?}", hat_idx, state)
            Event::Quit { .. } => break,
            _ => (),


event::Event impl's Debug, so you could try replacing

_ => (),


a = println!("{a:?}"),

Then run the code and move the wheel, and if it prints anything different that might be where the axis information is. You could also comment out the dead zone, just in case.

I tried both replacing the code as you suggested, and removing the dead zone, but there is still no axis data coming through.
Could there be anything else I can try?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.