// <nested-name> ::= N [<CV-qualifiers>] <prefix> <unqualified-name> E
//               ::= N [<CV-qualifiers>] <template-prefix> <template-args> E
static bool ParseNestedName(State *state) {
  State copy = *state;
  if (ParseChar(state, 'N') &&
      EnterNestedName(state) &&
      Optional(ParseCVQualifiers(state)) &&
      ParsePrefix(state) &&
      LeaveNestedName(state, copy.nest_level) &&
      ParseChar(state, 'E')) {
    return true;
  }
  *state = copy;
  return false;
}
// This part is tricky.  If we literally translate them to code, we'll
// end up infinite loop.  Hence we merge them to avoid the case.
//
// <prefix> ::= <prefix> <unqualified-name>
//          ::= <template-prefix> <template-args>
//          ::= <template-param>
//          ::= <substitution>
//          ::= # empty
// <template-prefix> ::= <prefix> <(template) unqualified-name>
//                   ::= <template-param>
//                   ::= <substitution>
static bool ParsePrefix(State *state) {
  bool has_something = false;
  while (true) {
    MaybeAppendSeparator(state);
    if (ParseTemplateParam(state) ||
        ParseSubstitution(state) ||
        ParseUnscopedName(state)) {
      has_something = true;
      MaybeIncreaseNestLevel(state);
      continue;
    }
    MaybeCancelLastSeparator(state);
    if (has_something && ParseTemplateArgs(state)) {
      return ParsePrefix(state);
    } else {
      break;
    }
  }
  return true;
}
예제 #3
0
void Config::ReadPadMapping(Controller* pController, const std::string& section, SWIP* pSWIP)
{
    Mapping* pMapping = &pController->m_mapping;

    // Guide button
    pSWIP->Get(section, "GuideButton", &pMapping->guide, -1);

    // Fire buttons
    for (u32 i = 0; i < _countof(pMapping->Button); ++i)
    {
        s8 button;
        pSWIP->Get(section, buttonNames[i], &button);
        pMapping->Button[i] = button - 1;
    }

    // D-PAD
    pSWIP->Get(section, "D-pad POV", &pMapping->DpadPOV);
    if (pMapping->DpadPOV >= 0)
    {
        for (u32 i = 0; i < _countof(pMapping->pov); ++i)
        {
            // D-PAD directions
            s16 val = 0;
            pSWIP->Get(section, povNames[i], &val, -1);
            if (val > 0 && val < 128)
            {
                pMapping->pov[i] = val - 1;
                pMapping->PovIsButton = true;
            }
            else if (val > -1)
            {
                pMapping->pov[i] = val;
                pMapping->PovIsButton = false;
            }
        }
    }

    for (u32 i = 0; i < _countof(pMapping->Axis); ++i)
    {
        // Axes
        std::string axis;
        if (pSWIP->Get(section, axisNames[i], &axis))
            ParsePrefix(axis, &pMapping->Axis[i].analogType, &pMapping->Axis[i].id);

        // DeadZones
        pSWIP->Get(section, axisDZNames[i], &pMapping->Axis[i].axisdeadzone);

        // Anti DeadZones
        pSWIP->Get(section, axisADZNames[i], &pMapping->Axis[i].antideadzone);

        // Linearity
        pSWIP->Get(section, axisLNames[i], &pMapping->Axis[i].axislinear);

        // Axis to DPAD options
        pSWIP->Get(section, "AxisToDPad", &pMapping->Axis[i].axistodpad);
        pSWIP->Get(section, "AxisToDPadDeadZone", &pMapping->Axis[i].a2ddeadzone);
        pSWIP->Get(section, "AxisToDPadOffset", &pMapping->Axis[i].a2doffset);

        // Axis to button mappings
        s8 ret;
        pSWIP->Get(section, axisBNames[i * 2], &ret);
        if (ret > 0)
        {
            pMapping->Axis[i].hasDigital = true;
            pMapping->Axis[i].positiveButtonID = ret - 1;
        }
        pSWIP->Get(section, axisBNames[i * 2 + 1], &ret);
        if (ret > 0)
        {
            pMapping->Axis[i].hasDigital = true;
            pMapping->Axis[i].negativeButtonID = ret - 1;
        }
    }

    // Triggers
    for (u32 i = 0; i < _countof(pMapping->Trigger); ++i)
    {
        std::string trigger;
        if (pSWIP->Get(section, triggerNames[i], &trigger))
            ParsePrefix(trigger, &pMapping->Trigger[i].type, &pMapping->Trigger[i].id);

        pSWIP->Get(section, triggerDZNames[i], &pMapping->Trigger[i].triggerdz);

        // SeDoG mod
        pSWIP->Get(section, triggerBNames[i], &pMapping->Trigger[i].but);
    }
}