From 48e32da8ec20f8f4df934e2de8ebe4385b483c51 Mon Sep 17 00:00:00 2001 From: Justin Berger Date: Sun, 4 Mar 2018 18:51:32 -0700 Subject: Fixed inadvertent change to signedness of acceldata --- src/ootx_decoder.c | 4 ++-- 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) { -- cgit v1.2.3