NaN Wrote:A more sophisticated approach might be to hook your code as a JOYSTICK to EVENTSYSTEM_SDL. And add your input polling code to void EVENTSYSTEM_SDL:
rocessEvents().
I followed your approach: I've extended the JOYSTICK and added an extra fake axis mapped to the marker tracker. Furthermore, inside the PrecessEvents method, I had a loop over all joypads for updating the fake axis. It looks like it's working (both my setAxis and getAxis methods get called, as well as the one of the original JOYSTICK, which means that I don't lose the original joypad functionallities

). The problem is that, when in the control-editing window I try to add a new control, the fake axis never gets recognized. That means, the if below return always false
Code:
for (int i = 0; i < eventsystem.GetNumAxes(j) && !have_a_control_input; i++)
{
//std::cout << "joy " << j << " axis " << i << ": " << eventsystem.GetJoyAxis(j, i) << endl;
assert(j < (int)controlgrab_joystick_state.size());
assert(i < controlgrab_joystick_state[j].GetNumAxes());
if (eventsystem.GetJoyAxis(j, i) - controlgrab_joystick_state[j].GetAxis(i) > 0.4 && !have_a_control_input)
{
have_a_control_input = true;
carcontrols_local.second.AddInputJoyAxis(controlgrab_input, controlgrab_analog,
controlgrab_only_one, j, i, "positive", error_output);
}
if (eventsystem.GetJoyAxis(j, i) - controlgrab_joystick_state[j].GetAxis(i) < -0.4 && !have_a_control_input)
{
have_a_control_input = true;
carcontrols_local.second.AddInputJoyAxis(controlgrab_input, controlgrab_analog,
controlgrab_only_one, j, i, "negative", error_output);
}
}
}
Which is the meaning of this subtraction?
Code:
eventsystem.GetJoyAxis(j, i) - controlgrab_joystick_state[j].GetAxis(i)
Why replicating the vector of joysticks? I'm missing something here ...