This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Start structures like in C++

How do I start the values ​​as in the example C++ code?

struct Gains{
    uint8_t totalGain         = FORCE_FEEDBACK_MAXGAIN;
   uint8_t constantGain      = FORCE_FEEDBACK_MAXGAIN;
   uint8_t rampGain          = FORCE_FEEDBACK_MAXGAIN;
   uint8_t squareGain        = FORCE_FEEDBACK_MAXGAIN;
   uint8_t sineGain          = FORCE_FEEDBACK_MAXGAIN;
   uint8_t triangleGain      = FORCE_FEEDBACK_MAXGAIN;
   uint8_t sawtoothdownGain  = FORCE_FEEDBACK_MAXGAIN;
   uint8_t sawtoothupGain    = FORCE_FEEDBACK_MAXGAIN;
   uint8_t springGain        = FORCE_FEEDBACK_MAXGAIN;
   uint8_t damperGain        = FORCE_FEEDBACK_MAXGAIN;
   uint8_t inertiaGain       = FORCE_FEEDBACK_MAXGAIN;
   uint8_t frictionGain      = FORCE_FEEDBACK_MAXGAIN;
   uint8_t customGain        = FORCE_FEEDBACK_MAXGAIN;
};

struct EffectParams{
    int32_t springMaxPosition = 0;
    int32_t springPosition = 0;

    int32_t damperMaxVelocity = 0;
    int32_t damperVelocity = 0;

    int32_t inertiaMaxAcceleration = 0;
    int32_t inertiaAcceleration = 0;

    int32_t frictionMaxPositionChange = 0;
    int32_t frictionPositionChange = 0;
};
   //force feedback gain
   struct Gains* m_gains;

   //force feedback effect params
   struct EffectParams* m_effect_params;

Parents Reply Children
  • How do I start values ​​in C?

    Like I said: you don't.  If you strongly believe you need that feature, you will have to write your code in C++.  It's ultimately as simple as that.

    Nor is it ever called "start".  The C++ feature you're trying to use is called a default value.  It's used by the constructor, for those members of the struct the user didn't supply their own initializer values, for .  C simply doesn't have that entire set of features.