diff --git a/include/psmove.h b/include/psmove.h index 88aaba49..58daa627 100644 --- a/include/psmove.h +++ b/include/psmove.h @@ -238,14 +238,9 @@ typedef struct _PSMove_3AxisTransform PSMove_3AxisTransform; /*! Library version number */ enum PSMove_Version { - /** - * Version format: AA.BB.CC = 0xAABBCC - * - * Examples: - * 3.0.1 = 0x030001 - * 4.2.11 = 0x04020B - **/ - PSMOVE_CURRENT_VERSION = 0x030001, /*!< Current version, see psmove_init() */ + PSMOVE_CURRENT_VERSION = (PSMOVEAPI_VERSION_MAJOR << 16) | + (PSMOVEAPI_VERSION_MINOR << 8) | + (PSMOVEAPI_VERSION_PATCH << 0) }; /** diff --git a/include/psmove_config.h.in b/include/psmove_config.h.in index bfc16bcb..84e78586 100644 --- a/include/psmove_config.h.in +++ b/include/psmove_config.h.in @@ -33,3 +33,8 @@ #cmakedefine PSMOVE_BUILD_TRACKER #cmakedefine PSMOVE_USE_PSEYE + +/* Version information */ +#define PSMOVEAPI_VERSION_MAJOR @PSMOVEAPI_VERSION_MAJOR@ +#define PSMOVEAPI_VERSION_MINOR @PSMOVEAPI_VERSION_MINOR@ +#define PSMOVEAPI_VERSION_PATCH @PSMOVEAPI_VERSION_PATCH@ diff --git a/src/psmove.c b/src/psmove.c index 61453786..659fdea7 100644 --- a/src/psmove.c +++ b/src/psmove.c @@ -289,14 +289,13 @@ psmove_get_half_frame(PSMove *move, enum PSMove_Sensor sensor, enum PSMove_Bool psmove_init(enum PSMove_Version version) { - /** - * You could do initialization here. Be sure to always check - * if initialization has already been carried out, as this - * might be called multiple times, even after succeeding once. - **/ + // Compile-time version of the library is PSMOVE_CURRENT_VERSION + // Compile-time version of the user code is the value of "version" - /* For now, assume future versions will be backwards-compatible */ - if (version >= PSMOVE_CURRENT_VERSION) { + // The requested version must be equal or less than the version implemented, + // but it's okay if the requested version is less than the implemented version, + // as we (try to) be backwards compatible with older API users + if (version <= PSMOVE_CURRENT_VERSION) { return PSMove_True; } else { return PSMove_False;