-
Notifications
You must be signed in to change notification settings - Fork 298
/
hidapi-20160919.patchset
223 lines (197 loc) · 5.87 KB
/
hidapi-20160919.patchset
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
From 0e6ebfe2cee9ea675ebc175fb95830cc1ecf5ef8 Mon Sep 17 00:00:00 2001
From: CodeforEvolution <themysterymail555@gmail.com>
Date: Mon, 26 Dec 2016 16:59:41 +0000
Subject: Changes to Build System for Haiku
diff --git a/Makefile.am b/Makefile.am
index 196c991..48e522d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -31,6 +31,10 @@ if OS_KFREEBSD
SUBDIRS += libusb
endif
+if OS_HAIKU
+SUBDIRS += libusb
+endif
+
if OS_WINDOWS
SUBDIRS += windows
endif
diff --git a/configure.ac b/configure.ac
index c6747f9..dd5249a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -107,6 +107,18 @@ case $host in
AC_CHECK_LIB([usb], [libusb_init], [LIBS_LIBUSB_PRIVATE="${LIBS_LIBUSB_PRIVATE} -lusb"], [hidapi_lib_error libusb])
echo libs_priv: $LIBS_LIBUSB_PRIVATE
;;
+*-*-haiku)
+ AC_MSG_RESULT([ (Haiku back-end)])
+ AC_DEFINE(OS_HAIKU, 1, [Haiku implementation])
+ AC_SUBST(OS_HAIKU)
+ backend="libusb"
+ os="haiku"
+ threads="pthreads"
+
+ PKG_CHECK_MODULES([libusb], [libusb-1.0 >= 1.0.9], true, [hidapi_lib_error libusb-1.0])
+ LIBS_LIBUSB_PRIVATE+=" $libusb_LIBS"
+ CFLAGS_LIBUSB+=" $libusb_CFLAGS"
+ ;;
*-mingw*)
AC_MSG_RESULT([ (Windows back-end, using MinGW)])
backend="windows"
@@ -213,6 +225,7 @@ AM_CONDITIONAL(OS_LINUX, test "x$os" = xlinux)
AM_CONDITIONAL(OS_DARWIN, test "x$os" = xdarwin)
AM_CONDITIONAL(OS_FREEBSD, test "x$os" = xfreebsd)
AM_CONDITIONAL(OS_KFREEBSD, test "x$os" = xkfreebsd)
+AM_CONDITIONAL(OS_HAIKU, test "x$os" = xhaiku)
AM_CONDITIONAL(OS_WINDOWS, test "x$os" = xwindows)
AC_CONFIG_HEADERS([config.h])
diff --git a/libusb/Makefile-manual b/libusb/Makefile-manual
index c0fe868..0acf707 100644
--- a/libusb/Makefile-manual
+++ b/libusb/Makefile-manual
@@ -10,6 +10,10 @@ ifeq ($(OS), FreeBSD)
FILE=Makefile.freebsd
endif
+ifeq ($(OS), Haiku)
+ FILE=Makefile.haiku
+endif
+
ifeq ($(FILE), )
all:
$(error Your platform ${OS} is not supported by hidapi/libusb at this time.)
diff --git a/libusb/Makefile.am b/libusb/Makefile.am
index 13c9d35..1da06bc 100644
--- a/libusb/Makefile.am
+++ b/libusb/Makefile.am
@@ -21,6 +21,13 @@ libhidapi_la_LDFLAGS = $(LTLDFLAGS)
libhidapi_la_LIBADD = $(LIBS_LIBUSB)
endif
+if OS_HAIKU
+lib_LTLIBRARIES = libhidapi.la
+libhidapi_la_SOURCES = hid.c
+libhidapi_la_LDFLAGS = $(LTLDFLAGS)
+libhidapi_la_LIBADD = $(LIBS_LIBUSB)
+endif
+
hdrdir = $(includedir)/hidapi
hdr_HEADERS = $(top_srcdir)/hidapi/hidapi.h
diff --git a/libusb/Makefile.haiku b/libusb/Makefile.haiku
new file mode 100644
index 0000000..6ddd172
--- /dev/null
+++ b/libusb/Makefile.haiku
@@ -0,0 +1,46 @@
+###########################################
+# Simple Makefile for HIDAPI test program
+#
+# Alan Ott
+# Signal 11 Software
+# 2010-06-01
+###########################################
+
+all: hidtest libs
+
+libs: libhidapi.so
+
+CC ?= cc
+CFLAGS ?= -Wall -g -fPIC
+
+CXX ?= c++
+CXXFLAGS ?= -Wall -g
+
+COBJS = hid.o
+CPPOBJS = ../hidtest/hidtest.o
+OBJS = $(COBJS) $(CPPOBJS)
+INCLUDES = -I../hidapi -I$(shell finddir B_SYSTEM_HEADERS_DIRECTORY)
+LDFLAGS = -L$(shell finddir B_SYSTEM_LIB_DIRECTORY)
+LIBS = -lusb-1.0
+
+
+# Console Test Program
+hidtest: $(OBJS)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ $(LIBS)
+
+# Shared Libs
+libhidapi.so: $(COBJS)
+ $(CC) $(LDFLAGS) -shared -Wl,-soname,$@.0 $^ -o $@ $(LIBS)
+
+# Objects
+$(COBJS): %.o: %.c
+ $(CC) $(CFLAGS) -c $(INCLUDES) $< -o $@
+
+$(CPPOBJS): %.o: %.cpp
+ $(CXX) $(CXXFLAGS) -c $(INCLUDES) $< -o $@
+
+
+clean:
+ rm -f $(OBJS) hidtest libhidapi.so ../hidtest/hidtest.o
+
+.PHONY: clean libs
--
2.2.2
From 106ec32de206ec49fb0441e55690d7ff3cd24b9c Mon Sep 17 00:00:00 2001
From: CodeforEvolution <themysterymail555@gmail.com>
Date: Mon, 26 Dec 2016 17:14:58 +0000
Subject: Changes in source for no iconv/pthread barriers
diff --git a/libusb/hid.c b/libusb/hid.c
index 3c6d877..c6ad012 100644
--- a/libusb/hid.c
+++ b/libusb/hid.c
@@ -45,15 +45,15 @@
/* GNU / LibUSB */
#include <libusb.h>
-#ifndef __ANDROID__
+#if !defined(__ANDROID__) || !defined(__HAIKU__)
#include <iconv.h>
#endif
#include "hidapi.h"
-#ifdef __ANDROID__
+#if defined(__ANDROID__) || defined(__HAIKU__)
-/* Barrier implementation because Android/Bionic don't have pthread_barrier.
+/* Barrier implementation because Android/Bionic/Haiku don't have pthread_barrier.
This implementation came from Brent Priddy and was posted on
StackOverflow. It is used with his permission. */
typedef int pthread_barrierattr_t;
@@ -390,7 +390,7 @@ static wchar_t *get_usb_string(libusb_device_handle *dev, uint8_t idx)
int len;
wchar_t *str = NULL;
-#ifndef __ANDROID__ /* we don't use iconv on Android */
+#if !defined(__ANDROID__) || !defined(__HAIKU__) /* we don't use iconv on Android/Haiku */
wchar_t wbuf[256];
/* iconv variables */
iconv_t ic;
@@ -420,7 +420,7 @@ static wchar_t *get_usb_string(libusb_device_handle *dev, uint8_t idx)
if (len < 0)
return NULL;
-#ifdef __ANDROID__
+#if defined(__ANDROID__) || defined(__HAIKU__)
/* Bionic does not have iconv support nor wcsdup() function, so it
has to be done manually. The following code will only work for
--
2.2.2
From 3de18a772eebbddd93e0fa356d6c738b0718f011 Mon Sep 17 00:00:00 2001
From: CodeforEvolution <themysterymail555@gmail.com>
Date: Mon, 26 Dec 2016 18:09:26 +0000
Subject: Fix Change in Source
diff --git a/libusb/hid.c b/libusb/hid.c
index c6ad012..f11d4d5 100644
--- a/libusb/hid.c
+++ b/libusb/hid.c
@@ -45,7 +45,7 @@
/* GNU / LibUSB */
#include <libusb.h>
-#if !defined(__ANDROID__) || !defined(__HAIKU__)
+#if !defined(__ANDROID__) && !defined(__HAIKU__)
#include <iconv.h>
#endif
@@ -390,7 +390,7 @@ static wchar_t *get_usb_string(libusb_device_handle *dev, uint8_t idx)
int len;
wchar_t *str = NULL;
-#if !defined(__ANDROID__) || !defined(__HAIKU__) /* we don't use iconv on Android/Haiku */
+#if !defined(__ANDROID__) && !defined(__HAIKU__) /* we don't use iconv on Android/Haiku */
wchar_t wbuf[256];
/* iconv variables */
iconv_t ic;
--
2.2.2