fsVarsRegisterVarsStatusUpdateHandler

The fsVarsRegisterVarsStatusUpdateHandler function can be used to register a handler which will be called when the states of variables are updated. The function will be called when LVar are reset or when LVar, OVar and ZVar are removed.

 

Syntax
FsVarError fsVarsRegisterVarsStatusUpdateHandler(
    FsVarsStatusUpdateHandler handler,
    void* pUserParam,
    bool bUseObjIdSpecialValue
);

 

Parameters
Parameters Description
handler The pointer to the function that will be called when the variable state is updated.
pUserParam A pointer to the user defined parameter returned when the handler is called.
bUseObjIdSpecialValue

When set to true, the value of the object ID given by the handler is transformed to use special values (FS_OBJECT_ID_USER_AIRCRAFT for the user aircraft for example) instead of the actual object ID.

Default: true

 

Return Values

The function returns FsVarError, where 0 means there is no error (in which case the handler will be called each time the simulation needs to notify a change in the variables).

 

The handler

Syntax:

typedef void (*FsVarsStatusUpdateHandler)(
    FsVarTypeFlags varsUpdated,
    FsVarUpdateOp operation,
    FsObjectId objectId,
    void* pUserParam
);

Parameters:

Parameters Description
varsUpdated This flag contains all the variable types affected by the operation .
operation Enum describing the operation affecting the variables.
objectId ID of the object affected by the operation, when relevent (if not FS_OBJECT_ID_NONE is sent). If the handler has been registered with the boolean bUseObjectIdSpecialValue set to true, the ID is transformed to correspond to the special value of the object (for example the ID of the user aircraft will be FS_OBJECT_ID_USER_AIRCRAFT)
pUserParam Pointer given when the handler was registered and given back when the handler is called.
Example
void handler(FsVarsTypeFlags varsUpdated, FsVarUpdateOp op, FsObjectId objId, void* pUserParam)
{
    // Process variables status update
}
extern "C" MSFS_CALLBACK void module_init()
{
    FsVarError err = fsVarsRegisterVarsStatusUpdateHandler(handler, pUserData, true);
    if (err != FS_VAR_ERROR_NONE)
    {
        // Error
    }
}