1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
From: Joel Ray Holveck <joelh@piquan.org>
Date: Tue, 13 Oct 2020 13:57:27 +0200
Subject: hid-bigendian
===================================================================
---
src/Input/FGHIDEventInput.cxx | 4 ++++
1 file changed, 4 insertions(+)
--- a/src/Input/FGHIDEventInput.cxx
+++ b/src/Input/FGHIDEventInput.cxx
@@ -27,6 +27,8 @@
#include <cassert>
#include <algorithm>
+#include <endian.h>
+
#include <hidapi/hidapi.h>
#include <hidapi/hidparse.h>
@@ -865,6 +867,8 @@
uint32_t v = 0;
// this goes from byte alignment to word alignment safely
memcpy((void*) &v, bytes + wholeBytesToSkip, bytesToCopy);
+ // the memcpy arranges v in little-endian order, so swap if needed
+ v = le32toh(v);
// shift down so lowest bit is aligned
v = v >> offsetInByte;
|