fasteddy516 / CircuitPython_JoystickXL

Turn a CircuitPython device into a joystick controller with lots of inputs.
MIT License
18 stars 7 forks source link

Axis invert functionality not fully implemented #17

Closed kmatthews123 closed 7 months ago

kmatthews123 commented 10 months ago

I'm trying to add several axis, one of those is a joystick and it seems as though one of the axis is reversed. I would like to simply invert the axis but when I try and pass something like the below,

''' joystick.add_input( Axis(board.A3, invert=True) ) '''

it seems to break the code and it refuses to work, I can add axis without any additional flags. I tried using the HOTAS example as a template and add the declarations as variables as described in the example but this also seems to break things. I have tried several different things but following the documentation has lead me to no joy. Any assistance is appreciated.

fasteddy516 commented 10 months ago

Well that's embarrassing - I had a quick look at the code, and it looks like I never actually finished the 'invert' implementation. 😧 I'll try to get that fixed as soon as I can, but it will likely be a couple of days before I get to it.

In the meantime, I don't immediately see that attempting to use it it should actually prevent the code from running, just that it isn't taken into account when reading axis values. Can you describe what you mean by the code "breaks"? (i.e., does it raise an exception, cause unexpected behaviour, etc.)

kmatthews123 commented 10 months ago

I think that, in trying to get it working, I was confused by the API call-out. From what I understand now, setting up the joystick axis (or buttons or hats) should look something like Joystick.addinput( Axis(board.A0, deadband=(some int) invert=True), Ext. )

I tried a bunch of other stuff to get it working like adding a virtual axis and inverting an analog input value, then using the joystick.axis[Axis.Z].source_value = int (joystick.axis[Axis.X].source_value × -1)

This example was pulled from your discussion thread from December of 2021 on multiple inputs having one output.

The failure mode for these things being wrong were basically just the hardware not being recognized by my computer as a joystick. I think there were bootout.txt error logs but I don't have them at this point.

I did get things working on my end by using a different joystick with a y axis that wasn't inverted by default. Just a different piece of hardware but it would be nice to have the option to use my original joystick as it is nicer.

Also thank you for this project. If there's any way I can help or contribute Id be happy to help. I should have a pretty fun project show and tell to share in few weeks.