| 1 | |
| 2 | // Copyright (c) 2003-2019 Xsens Technologies B.V. or subsidiaries worldwide. |
| 3 | // All rights reserved. |
| 4 | // |
| 5 | // Redistribution and use in source and binary forms, with or without modification, |
| 6 | // are permitted provided that the following conditions are met: |
| 7 | // |
| 8 | // 1. Redistributions of source code must retain the above copyright notice, |
| 9 | // this list of conditions, and the following disclaimer. |
| 10 | // |
| 11 | // 2. Redistributions in binary form must reproduce the above copyright notice, |
| 12 | // this list of conditions, and the following disclaimer in the documentation |
| 13 | // and/or other materials provided with the distribution. |
| 14 | // |
| 15 | // 3. Neither the names of the copyright holders nor the names of their contributors |
| 16 | // may be used to endorse or promote products derived from this software without |
| 17 | // specific prior written permission. |
| 18 | // |
| 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
| 20 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 21 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
| 22 | // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 | // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
| 24 | // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 25 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR |
| 26 | // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 27 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS |
| 28 | // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES |
| 29 | // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE |
| 30 | // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES. |
| 31 | // |
| 32 | |
| 33 | #ifndef XSGLOVESNAPSHOT_H |
| 34 | #define XSGLOVESNAPSHOT_H |
| 35 | |
| 36 | #include "xstypesconfig.h" |
| 37 | #include "xsdeviceid.h" |
| 38 | |
| 39 | struct XsGloveSnapshot; |
| 40 | |
| 41 | #ifdef __cplusplus |
| 42 | extern "C" { |
| 43 | #endif |
| 44 | #ifndef __cplusplus |
| 45 | #define XSGLOVESNAPSHOT_INITIALIZER {0, 0, 0, 0, \ |
| 46 | XSFINGERSNAPSHOT_INITIALIZER, XSFINGERSNAPSHOT_INITIALIZER, XSFINGERSNAPSHOT_INITIALIZER, XSFINGERSNAPSHOT_INITIALIZER, XSFINGERSNAPSHOT_INITIALIZER, XSFINGERSNAPSHOT_INITIALIZER, \ |
| 47 | XSFINGERSNAPSHOT_INITIALIZER, XSFINGERSNAPSHOT_INITIALIZER, XSFINGERSNAPSHOT_INITIALIZER, XSFINGERSNAPSHOT_INITIALIZER, XSFINGERSNAPSHOT_INITIALIZER, XSFINGERSNAPSHOT_INITIALIZER} |
| 48 | #define XSFINGERSNAPSHOT_INITIALIZER {0,0,0, 0,0,0, 0,0,0, 0, 0, 0} |
| 49 | #endif |
| 50 | |
| 51 | #ifdef __cplusplus |
| 52 | } // extern "C" |
| 53 | #endif |
| 54 | |
| 55 | #ifdef _MSC_VER |
| 56 | #pragma pack(push, 1) |
| 57 | #ifndef PACK_POST |
| 58 | #define PACK_POST |
| 59 | #endif |
| 60 | #else |
| 61 | #ifndef PACK_POST |
| 62 | #define PACK_POST __attribute__((__packed__)) |
| 63 | #endif |
| 64 | #endif |
| 65 | |
| 66 | #include <math.h> /* pow */ |
| 67 | |
| 68 | /*! \brief int24 |
| 69 | */ |
| 70 | struct int24_t { |
| 71 | uint8_t m_vals[3]; /*!< \brief The data*/ |
| 72 | |
| 73 | #ifdef __cplusplus |
| 74 | //! \brief convert int24 to double |
| 75 | inline double toDouble() const |
| 76 | { |
| 77 | if (m_vals[2] & 0x80) |
| 78 | return ((double)(int32_t)(((uint32_t)0xff000000) | (((uint32_t)m_vals[2]) << 16) | (((uint32_t)m_vals[1]) << 8) | ((uint32_t)m_vals[0]))); |
| 79 | else |
| 80 | return (double)((((uint32_t)m_vals[2]) << 16) | (((uint32_t)m_vals[1]) << 8) | (uint32_t)m_vals[0]); |
| 81 | } |
| 82 | |
| 83 | #endif |
| 84 | #ifdef SWIG |
| 85 | }; |
| 86 | #else |
| 87 | } PACK_POST; |
| 88 | #endif |
| 89 | typedef struct int24_t int24_t; |
| 90 | |
| 91 | /*! \brief A container for Finger Snapshot data |
| 92 | */ |
| 93 | struct XsFingerSnapshot { |
| 94 | int24_t m_iQ[3]; /*!< \brief The integrated orientation */ |
| 95 | int32_t m_iV[3]; /*!< \brief The integrated velocity */ |
| 96 | int16_t m_mag[3]; /*!< \brief The magnetic field */ |
| 97 | uint16_t m_flags; /*!< \brief The flags */ |
| 98 | uint8_t m_ccacc; /*!< \brief The acceleration cliping */ |
| 99 | uint8_t m_ccgyr; /*!< \brief The gyroscope clipping */ |
| 100 | #ifdef SWIG |
| 101 | }; |
| 102 | #else |
| 103 | } PACK_POST; |
| 104 | #endif |
| 105 | typedef struct XsFingerSnapshot XsFingerSnapshot; |
| 106 | |
| 107 | /*! \brief A container for Glove Snapshot data |
| 108 | */ |
| 109 | struct XsGloveSnapshot |
| 110 | { |
| 111 | uint16_t m_snapshotCounter; /*!< \brief The snapshot counter */ |
| 112 | uint16_t m_validSampleFlags; /*!< \brief The valid sample flags */ |
| 113 | uint16_t m_timestamp; /*!< \brief The timestamp */ |
| 114 | uint8_t m_carpusOffset; /*!< \brief The carpus offset */ |
| 115 | XsFingerSnapshot m_fingers[12]; /*!< \brief The 12 fingers */ |
| 116 | #if 0 // def __cplusplus |
| 117 | /*! \brief Returns true if all fields of this and \a other are exactly identical */ |
| 118 | inline bool operator == (const XsGloveSnapshot& other) const |
| 119 | { |
| 120 | return true; |
| 121 | } |
| 122 | #endif |
| 123 | #ifdef SWIG |
| 124 | }; |
| 125 | #else |
| 126 | } PACK_POST; |
| 127 | #endif |
| 128 | typedef struct XsGloveSnapshot XsGloveSnapshot; |
| 129 | |
| 130 | #ifdef _MSC_VER |
| 131 | #pragma pack(pop) |
| 132 | #endif |
| 133 | |
| 134 | #endif |