The API provides a function signed char getDirection();
, that returns 1 for "forward", 0 for "motionless", -1 for "backward."
And of course, as explained in these questions, a simple comparison:
if(getDirection() == -1) { ... }
fails. Okay, I understand why it fails. But I just can't find how to make it work! I tried casting the left side to (int)
, the right side to (signed char)
, still nada...
edit:
signed char a = getDirection();
printf("%d\n",(int) a);
printf("%d\n",(int) getDirection());
Results:
-1
255
edit2: per request:
const signed char getDirection(uchar d)
{
if(d >= config.directional_inputs.channelCount) return -2;
return shm->input_state.directional_inputs[d].direction;
}