added missing hidapi stuff for os/2 with libusb
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
diff --git a/Makefile.os2 b/Makefile.os2
index 856bec8..6af282d 100644
--- a/Makefile.os2
+++ b/Makefile.os2
@@ -4,6 +4,11 @@
# If you have GNU libiconv installed (iconv2.dll), you
# can compile against it by specifying LIBICONV=1, e.g.:
# wmake -f Makefile.os2 LIBICONV=1
+#
+# If you have libusb-1.0 installed (usb100.dll, libusb.h), you
+# can compile hidapi joystick support against it (experimental)
+# by specifying HIDAPI=1, e.g.:
+# wmake -f Makefile.os2 HIDAPI=1
LIBNAME = SDL2
VERSION = 2.0.20
@@ -42,6 +47,10 @@ LIBS+= $(ICONVLIB)
!else
LIBS+= libuls.lib libconv.lib
!endif
+# hidapi (libusb):
+!ifeq HIDAPI 1
+CFLAGS_DLL+= -DHAVE_LIBUSB_H=1
+!endif
# building SDL itself (for DECLSPEC):
CFLAGS_DLL+= -DBUILD_SDL
diff --git a/configure b/configure
index 0da00de..a02b8f9 100755
--- a/configure
+++ b/configure
@@ -25403,6 +25403,9 @@ fi
enable_hidapi_libusb=yes
require_hidapi_libusb=yes
;;
+ *-*-os2* )
+ enable_hidapi_libusb=yes
+ ;;
esac
hidapi_support=yes
@@ -25513,6 +25516,9 @@ $as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic li
*-*-cygwin* | *-*-mingw* )
libusb_lib="libusb-1.0.dll"
;;
+ *-*-os2* )
+ libusb_lib="usb100.dll"
+ ;;
esac
if test x$libusb_lib = x; then
libusb_lib=`find_lib "libusb-1.0.so.*" "" | sed 's/.*\/\(.*\)/\1/; q'`
@@ -26720,6 +26726,7 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
CheckDummyVideo
CheckDiskAudio
CheckDummyAudio
+ CheckHIDAPI
# Set up the core platform files
SOURCES="$SOURCES $srcdir/src/core/os2/*.c"
diff --git a/configure.ac b/configure.ac
index 689f546..3c1c6c8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3489,6 +3489,9 @@ CheckHIDAPI()
enable_hidapi_libusb=yes
require_hidapi_libusb=yes
;;
+ *-*-os2* )
+ enable_hidapi_libusb=yes
+ ;;
esac
hidapi_support=yes
@@ -3521,6 +3524,9 @@ CheckHIDAPI()
*-*-cygwin* | *-*-mingw* )
libusb_lib="libusb-1.0.dll"
;;
+ *-*-os2* )
+ libusb_lib="usb100.dll"
+ ;;
esac
if test x$libusb_lib = x; then
libusb_lib=[`find_lib "libusb-1.0.so.*" "" | sed 's/.*\/\(.*\)/\1/; q'`]
@@ -4429,6 +4435,7 @@ case "$host" in
CheckDummyVideo
CheckDiskAudio
CheckDummyAudio
+ CheckHIDAPI
# Set up the core platform files
SOURCES="$SOURCES $srcdir/src/core/os2/*.c"
diff --git a/include/SDL_config_os2.h b/include/SDL_config_os2.h
index 7c2342d..1728bd7 100644
--- a/include/SDL_config_os2.h
+++ b/include/SDL_config_os2.h
@@ -38,8 +38,14 @@
#define SDL_VIDEO_DRIVER_DUMMY 1
#define SDL_VIDEO_DRIVER_OS2 1
#define SDL_JOYSTICK_OS2 1
+#ifndef HAVE_LIBUSB_H /* see Makefile */
#define SDL_HIDAPI_DISABLED 1
/*#undef SDL_JOYSTICK_HIDAPI */
+#else
+#define SDL_JOYSTICK_HIDAPI 1
+/* dynamically loaded libusb-1.0 dll: */
+#define SDL_LIBUSB_DYNAMIC "usb100.dll"
+#endif
/*#undef SDL_JOYSTICK_VIRTUAL */
/* Enable OpenGL support */
diff --git a/src/hidapi/SDL_hidapi.c b/src/hidapi/SDL_hidapi.c
index 2ddce67..aacff63 100644
--- a/src/hidapi/SDL_hidapi.c
+++ b/src/hidapi/SDL_hidapi.c
@@ -1036,8 +1036,13 @@ int SDL_hid_init(void)
libusb_ctx.libhandle = SDL_LoadObject(SDL_LIBUSB_DYNAMIC);
if (libusb_ctx.libhandle != NULL) {
SDL_bool loaded = SDL_TRUE;
+ #ifdef __OS2__
+ #define LOAD_LIBUSB_SYMBOL(func) \
+ if (!(libusb_ctx.func = SDL_LoadFunction(libusb_ctx.libhandle,"_libusb_" #func))) {loaded = SDL_FALSE;}
+ #else
#define LOAD_LIBUSB_SYMBOL(func) \
if (!(libusb_ctx.func = SDL_LoadFunction(libusb_ctx.libhandle, "libusb_" #func))) {loaded = SDL_FALSE;}
+ #endif
LOAD_LIBUSB_SYMBOL(init)
LOAD_LIBUSB_SYMBOL(exit)
LOAD_LIBUSB_SYMBOL(get_device_list)