Gamepad modifiers - what should be possible?

In the GDC tool there is a bit of code that infers what modifiers to apply to a gamepad mapping:

if (dmMath::Abs(delta) > 1.5f)
    driver.m_Triggers[i].m_Modifiers[dmInputDDF::GAMEPAD_MODIFIER_SCALE] = true;
else if (gamepad_type == dmInputDDF::GAMEPAD_TYPE_AXIS)
    driver.m_Triggers[i].m_Modifiers[dmInputDDF::GAMEPAD_MODIFIER_CLAMP] = true;
if (delta < 0.0f)
    driver.m_Triggers[i].m_Modifiers[dmInputDDF::GAMEPAD_MODIFIER_NEGATE] = true;

if (gamepad_type == dmInputDDF::GAMEPAD_TYPE_HAT) {
    driver.m_Triggers[i].m_HatMask = (uint32_t)value;
}

The spacing and lack of braces makes it a bit tricky to grok quickly, but essentially it looks like SCALE and CLAMP should be mutually exclusive, while NEGATE can be applied in any case.

However, there are instances in default.gamepads that are somewhat confusing:

> cat default.gamepads | grep CLAMP | grep SCALE | wc -l
16

There are 16 instances that specify both SCALE and CLAMP. Does such a combination actually make any sense? Is it valid, or are those maps just unclear and would end up being interpreted as one or the other?

> cat default.gamepads | grep CLAMP | grep BUTTON | wc -l
10

There are 10 instances of CLAMP being applied to a BUTTON - is this valid? Does it make sense?

I’m writing a GUI-based gamepad mapper tool that reads from the RAW data, so just want to make sure I get it right, since I can’t easily test it with every controller.

Here are the rules I think should be the case, please correct if these aren’t right:

  • CLAMP, SCALE, and NEGATE are only relevant for AXIS inputs
  • CLAMP and SCALE are mutually exclusive and required for an AXIS input - that is, one or the other should always be present for AXIS inputs.

Yeah, I’m not sure how the original code was tested, to detect the scale.
Looking at the GDC-tool, the flags are mutually exclusive, but looking at the runtime (input.cpp), they are not.
I don’t have enough info to tell what the source data actually is expected, but assuming most users use the GDC tool, I think it should be fine to write the gui tool using the same (mutually exclusive) approach.
It should be easy enough to change afterwards anyways.

1 Like