saulrh / composite-joystick

Use a Raspberry Pi in gadget mode to combine several josyticks into one
MIT License
18 stars 2 forks source link

Can only seem to get inputs from 1 joystick at a time out of 2 or 3 #1

Open elgatopanzon opened 1 year ago

elgatopanzon commented 1 year ago

The code you wrote is great, and this is a great project. However having some problems which I can't make heads or tails of... Only one of the configured joysticks ever passes input, the other 2 just don't pass anything. Axes are still, buttons don't work.

First of all I replaced the joystick IDs with mine as follows:

    let (js_idx, js_device, js_axes) =
        make_device("/dev/input/by-id/usb-Saitek_Saitek_Pro_Flight_Quadrant-event-joystick")
            .context("while opening joystick")?;

    let (sp_idx, sp_device, sp_axes) =
        make_device("/dev/input/by-id/usb-xin-mo.com_Xinmotek_Controller-event-joystick")
            .context("while opening spacemouse")?;

    let (th_idx, th_device, th_axes) =
        make_device("/dev/input/by-id/usb-SIMVERTEX_SIMVERTEX_TH13_SIMVERTEX-event-joystick")
            .context("while opening throttle")?;

The one which works is the middle one. The other 2 don't pass any inputs at all. The keys are configured correctly in the configuration.rs file, and when I configured them wrong it gave me an error when running that the event/button was not found for that device.

I tested a completely different configuration as well just to see if I was going crazy this time with 2x usb-Saitek_Saitek_Pro_Flight_Quadrant-event-joystick and using by-path to open each one directly on their port. For that configuration I removed all references of the th device and mappings, and gave each one the correct mappings in the config file. The 2nd one worked and passed it's inputs without issues including all axes, but the 1st one didn't.

Here is the mapping for that device's 3 axes:

    mux.configure_axis(
        OutputAxisId(EventCode::EV_ABS(EV_ABS::ABS_X)),
        AxisCombineFn::LargestMagnitude {
            inputs: vec![
                js_axes[&EventCode::EV_ABS(EV_ABS::ABS_X)],
            ],
        },
    );
    mux.configure_axis(
        OutputAxisId(EventCode::EV_ABS(EV_ABS::ABS_Y)),
        AxisCombineFn::LargestMagnitude {
            inputs: vec![
                js_axes[&EventCode::EV_ABS(EV_ABS::ABS_Y)],
            ],
        },
    );
    mux.configure_axis(
        OutputAxisId(EventCode::EV_ABS(EV_ABS::ABS_Z)),
        AxisCombineFn::LargestMagnitude {
            inputs: vec![
                js_axes[&EventCode::EV_ABS(EV_ABS::ABS_Z)],
            ],
        },
    );

I don't really know where to go from here to get it working.

eadanila commented 6 days ago

I came across this project and ran into the same issue as you. I traced it down to an off-by-one error in the assignment of the device index. Patched it and now it's working flawlessly for me! If you're still interested in using this, you can try my fix and see if it works for you.