diff options
author | CNLohr <charles@cnlohr.com> | 2018-03-04 22:47:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-04 22:47:08 -0500 |
commit | 1a686a660c750499d3e1c4b46e3c506748147a08 (patch) | |
tree | 3c0b9d6da586ac0d20edf7ba75fb44851a08375d /src | |
parent | e4b3a18a2665e0241bde7ce2a510de6313369311 (diff) | |
parent | 48e32da8ec20f8f4df934e2de8ebe4385b483c51 (diff) | |
download | libsurvive-1a686a660c750499d3e1c4b46e3c506748147a08.tar.gz libsurvive-1a686a660c750499d3e1c4b46e3c506748147a08.tar.bz2 |
Merge pull request #101 from jdavidberger/unsigned_fix
Fixed inadvertent change to signedness of acceldata type
Diffstat (limited to 'src')
-rw-r--r-- | src/ootx_decoder.c | 4 | ||||
-rwxr-xr-x | src/survive_vive.c | 13 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/ootx_decoder.c b/src/ootx_decoder.c index ad55f5b..b7327d5 100644 --- a/src/ootx_decoder.c +++ b/src/ootx_decoder.c @@ -183,12 +183,12 @@ union iFloat { }; -struct __attribute__((__packed__)) unaligned_16_t { +struct __attribute__((__packed__)) unaligned_u16_t { uint16_t v; }; float _half_to_float(uint8_t* data) { - uint16_t x = ((struct unaligned_16_t*)data)->v; + uint16_t x = ((struct unaligned_u16_t*)data)->v; union iFloat fnum; fnum.f = 0; diff --git a/src/survive_vive.c b/src/survive_vive.c index 5be2d03..cb05efc 100755 --- a/src/survive_vive.c +++ b/src/survive_vive.c @@ -903,15 +903,20 @@ int survive_get_config( char ** config, SurviveViveData * sv, int devno, int ifa #define POP1 (*(readdata++)) - struct __attribute__((__packed__)) unaligned_16_t { - uint16_t v; + int16_t v; }; struct __attribute__((__packed__)) unaligned_32_t { + int32_t v; +}; +struct __attribute__((__packed__)) unaligned_u16_t { + uint16_t v; +}; +struct __attribute__((__packed__)) unaligned_u32_t { uint32_t v; }; -#define POP2 ((((( struct unaligned_16_t*)((readdata+=2)-2))))->v) -#define POP4 ((((( struct unaligned_32_t*)((readdata+=4)-4))))->v) +#define POP2 ((((( struct unaligned_u16_t*)((readdata+=2)-2))))->v) +#define POP4 ((((( struct unaligned_u32_t*)((readdata+=4)-4))))->v) void calibrate_acc(SurviveObject* so, FLT* agm) { if (so->acc_bias != NULL) { |