Closed RandieBarsteward closed 4 years ago
This page (https://whitemagic.github.io/JoystickGremlin/user_plugins/) provides some explanation, however, certain aspects are out of date so I'll highlight the important bits you need for the response curve parts.
Gremlin has support for two response curve types, cubic spines and cubic bezier splines. The former are easier to configure as they just need a few coordinates. The latter is more complex because in addition to coordinates it also has controls which shape the whole curve.
import gremlin
from vjoy.vjoy import AxisName
default_curve = gremlin.spline.CubicSpline(
[(-1.0, -1.0), (0.0, 0.0), (1.0, 1.0)]
)
precision_curve = gremlin.spline.CubicSpline(
[(-1.0, -0.5), (0.0, 0.0), (1.0, 0.5)]
)
@device_decorator.axis(1)
def pitch(event, vjoy):
vjoy[1].axis(AxisName.X).value = default_curve (event.value)
This should be a basic example which defines two curves and then uses one of them in the callback on the device. I omitted the creation of the device decorator or setting a particular curve as the active one. To know what values to put into the constructors of both CubicSpline
and CubicBezierSpline
you can just look at the values stored in the profile XML file and use them in the same order as a list of coordinates in the constructors. Applying the curve to a value is always done via the ()
operator on the object instance.
@WhiteMagic I hadn't considered getting the curve info from the XML. That will make things really easy to test and adjust.
Thanks for the reply and all your work on Joystick Gremlin, it's an amazing project!
Could anyone provide an explanation for how I could implement response curves within Python modules?
I would like to have multiple curves (such as an S curve) which I can swap out within the modules. I can't find any relevant documentation and examples in other people's projects/modules don't really explain how the curves work.