File: hid-bigendian.patch

package info (click to toggle)
flightgear 1%3A2020.3.19%2Bdfsg-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 51,168 kB
  • sloc: cpp: 245,588; ansic: 181,318; sh: 13,686; perl: 4,475; python: 3,139; xml: 899; asm: 642; makefile: 347; java: 314
file content (29 lines) | stat: -rw-r--r-- 802 bytes parent folder | download | duplicates (2)
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;