Debian Codegraph @

debian/patches/hid-bigendian.patch

raw
1 From: Joel Ray Holveck <[email protected]>
2 Date: Tue, 13 Oct 2020 13:57:27 +0200
3 Subject: hid-bigendian
4
5 ===================================================================
6 ---
7 src/Input/FGHIDEventInput.cxx | 4 ++++
8 1 file changed, 4 insertions(+)
9
10 diff --git a/src/Input/FGHIDEventInput.cxx b/src/Input/FGHIDEventInput.cxx
11 index bf42b4f..663f352 100644
12 --- a/src/Input/FGHIDEventInput.cxx
13 +++ b/src/Input/FGHIDEventInput.cxx
14 @@ -14,6 +14,8 @@
15 #include <unordered_set>
16 #include <string>
17
18 +#include <endian.h>
19 +
20 #include <Main/fg_props.hxx>
21 #include <hidapi/hidapi.h>
22 #include <hidapi/hidparse.h>
23 @@ -717,6 +719,8 @@ int extractBits(uint8_t* bytes, size_t lengthInBytes, size_t bitOffset, size_t b
24 uint32_t v = 0;
25 // this goes from byte alignment to word alignment safely
26 memcpy((void*)&v, bytes + wholeBytesToSkip, bytesToCopy);
27 + // the memcpy arranges v in little-endian order, so swap if needed
28 + v = le32toh(v);
29
30 // shift down so lowest bit is aligned
31 v = v >> offsetInByte;