فهرست منبع

added missing hidapi stuff for os/2 with libusb

Ozkan Sezer 3 سال پیش
والد
کامیت
f14c7bb443
5فایلهای تغییر یافته به همراه34 افزوده شده و 0 حذف شده
  1. 9 0
      Makefile.os2
  2. 7 0
      configure
  3. 7 0
      configure.ac
  4. 6 0
      include/SDL_config_os2.h
  5. 5 0
      src/hidapi/SDL_hidapi.c

+ 9 - 0
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
 

+ 7 - 0
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"

+ 7 - 0
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"

+ 6 - 0
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 */

+ 5 - 0
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)