WhiteMagic / JoystickGremlin

A tool for configuring and managing joystick devices.
http://whitemagic.github.io/JoystickGremlin/
GNU General Public License v3.0
313 stars 46 forks source link

How do I set a button to invert an axis? #504

Closed Pomax closed 20 hours ago

Pomax commented 1 year ago

I might not be good enough at google, but I can't for the life of me figure out how to add a rule that says "if button X gets pressed, invert whatever values axis Y generates, centered around value Z".

WhiteMagic commented 1 year ago

The behaviour you describe with your phrasing is not possible with the UI. You cannot read the state of other inputs and apply transformations to them based on another unrelated input's event. What you can do is have two different response curves that will apply when the joystick axis moves, and depending on whether the button is pressed one or the other response curve is used. To do that you'd need two response curves on the desired axis and have two conditions on them to set which one is active when the button is pressed and which one when the button is released.

Pomax commented 1 year ago

Is there a way to make the button press swap the curves, instead of needing to hold it?

The reason I need this is that some third party aircraft in MSFS2020 use trim buttons, but forget that even if the plane doesn't "model" one, there is always a trim axis as well, and don't make sure it's set to the correct behaviour, so you move your trim lever and instead of going up, you plow into the ground.

So I'm looking for a way to swap the output of the trim axis from [0,max] to [max,0], with a button press, rather than a press-and-hold.

WhiteMagic commented 1 year ago

Two possible options for this are:

  1. Using separate modes that inherit from the base one and have different curves associated with them.
  2. Abusing a vJoy button as an auxiliary state variable that is then used in the trim axis as a condition to select one or the other response curve.

Based on your description I suspect that the second option is more desirable. You should be able to use a chain container with macros that first press a vJoy button and the second chain container (triggered upon the next time you press the button) releases the vJoy button. On the axis you want to use for trim you would then add two response curves. The two curves would each have a condition checking the state of the particular vJoy button and one is active when said button is pressed, while the other one would be active when the button is released.