The way that "pulse mode" works is that rather than directly controlling the throttle each individual movement of a joystick out of the center position (or press of a button) impart's a certain amount of dV or rotational velocity.
The stock dragonfly has this functionality and I am trying to adapt it to my own addon.
I've copy/pasted portions of the dragonfly's code into my Lunar Lander and even have the pulse control mode kind off working. The problem is that I have no idea how the function actually works so I can debug it.
I need someone who's code-fu is stronger to help explain what is going on.
here is the pertinent code as it appears in my clbkpoststep
It works too, the problem is that as soon as I try to put it in a boolean or switch function (so the orbinaut can turn pulse mode on/off) all hell breaks loose.
My thruster settings either become stuck or the just start firing off randomly.
I need some help to figure out what's going on.
The stock dragonfly has this functionality and I am trying to adapt it to my own addon.
I've copy/pasted portions of the dragonfly's code into my Lunar Lander and even have the pulse control mode kind off working. The problem is that I have no idea how the function actually works so I can debug it.
I need someone who's code-fu is stronger to help explain what is going on.
here is the pertinent code as it appears in my clbkpoststep
Code:
// pulse control (copied from stock Dragonfly's thruster controls)
double tlevel; // thruster setting
double tlevel_r; // reciprical of 'tlevel'
static int lin_x,lin_y,lin_z;
static int rot_x,rot_y,rot_z;
if ((tlevel = GetManualControlLevel(THGROUP_ATT_PITCHUP, MANCTRL_ANYDEVICE, MANCTRL_ROTMODE)) && (!rot_x++)) SetThrusterGroupLevel(th_rot_pup, tlevel*dlevel);
if ((tlevel_r = GetManualControlLevel(THGROUP_ATT_PITCHDOWN, MANCTRL_ANYDEVICE, MANCTRL_ROTMODE)) && (!rot_x++)) SetThrusterGroupLevel(th_rot_pdown, tlevel_r*dlevel);
if (tlevel + tlevel_r==0) rot_x=0;
...repeats for each axis in turn
It works too, the problem is that as soon as I try to put it in a boolean or switch function (so the orbinaut can turn pulse mode on/off) all hell breaks loose.
My thruster settings either become stuck or the just start firing off randomly.
I need some help to figure out what's going on.