From 74f2b4b2aef0d5313179c5d566942a442a119a43 Mon Sep 17 00:00:00 2001
From: Marcus Meissner <marcus@jet.franken.de>
Date: Fri, 19 Jan 2001 21:09:07 +0000
Subject: [PATCH] Added configure check for old linux/input.h.

---
 configure                         | 99 ++++++++++++++++++++++---------
 configure.in                      | 19 ++++++
 dlls/dinput/joystick/linuxinput.c |  6 ++
 include/acconfig.h                |  3 +
 include/config.h.in               |  3 +
 5 files changed, 101 insertions(+), 29 deletions(-)

diff --git a/configure b/configure
index 7ed320b78f8..2a1f0c31b40 100755
--- a/configure
+++ b/configure
@@ -6199,14 +6199,55 @@ EOF
 
 
 
+echo $ac_n "checking "whether linux/input.h is for real"""... $ac_c" 1>&6
+echo "configure:6204: checking "whether linux/input.h is for real"" >&5
+if eval "test \"`echo '$''{'wine_cv_linux_input_h'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 6209 "configure"
+#include "confdefs.h"
+
+	    #include <linux/input.h>
+	 
+int main() {
+
+	    int foo = EVIOCGBIT(EV_ABS,42);
+	    int bar = BTN_PINKIE;
+	    int fortytwo = 42;
+	
+; return 0; }
+EOF
+if { (eval echo configure:6222: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  wine_cv_linux_input_h=yes
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  wine_cv_linux_input_h=no
+fi
+rm -f conftest*
+    
+fi
+
+echo "$ac_t""$wine_cv_linux_input_h" 1>&6
+    if test "$wine_cv_linux_input_h" = "yes"
+    then
+        cat >> confdefs.h <<\EOF
+#define HAVE_CORRECT_LINUXINPUT_H 1
+EOF
+
+    fi
+
    
 echo $ac_n "checking "whether we can use re-entrant gethostbyname_r Linux style"""... $ac_c" 1>&6
-echo "configure:6205: checking "whether we can use re-entrant gethostbyname_r Linux style"" >&5
+echo "configure:6246: checking "whether we can use re-entrant gethostbyname_r Linux style"" >&5
 if eval "test \"`echo '$''{'wine_cv_linux_gethostbyname_r_6'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6210 "configure"
+#line 6251 "configure"
 #include "confdefs.h"
 
 #include <netdb.h>
@@ -6227,7 +6268,7 @@ int main() {
     
 ; return 0; }
 EOF
-if { (eval echo configure:6231: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6272: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_linux_gethostbyname_r_6=yes
 else
@@ -6253,12 +6294,12 @@ EOF
 if test "$ac_cv_header_linux_joystick_h" = "yes"
 then
    echo $ac_n "checking "whether linux/joystick.h uses the Linux 2.2+ API"""... $ac_c" 1>&6
-echo "configure:6257: checking "whether linux/joystick.h uses the Linux 2.2+ API"" >&5
+echo "configure:6298: checking "whether linux/joystick.h uses the Linux 2.2+ API"" >&5
 if eval "test \"`echo '$''{'wine_cv_linux_joystick_22_api'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6262 "configure"
+#line 6303 "configure"
 #include "confdefs.h"
 
 	#include <sys/ioctl.h>
@@ -6273,7 +6314,7 @@ int main() {
 /*empty*/
 ; return 0; }
 EOF
-if { (eval echo configure:6277: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6318: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_linux_joystick_22_api=yes
 else
@@ -6300,12 +6341,12 @@ fi
 if test "$ac_cv_header_sys_vfs_h" = "yes"
 then
     echo $ac_n "checking "whether sys/vfs.h defines statfs"""... $ac_c" 1>&6
-echo "configure:6304: checking "whether sys/vfs.h defines statfs"" >&5
+echo "configure:6345: checking "whether sys/vfs.h defines statfs"" >&5
 if eval "test \"`echo '$''{'wine_cv_sys_vfs_has_statfs'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6309 "configure"
+#line 6350 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -6322,7 +6363,7 @@ int main() {
 	
 ; return 0; }
 EOF
-if { (eval echo configure:6326: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6367: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_sys_vfs_has_statfs=yes
 else
@@ -6349,12 +6390,12 @@ fi
 if test "$ac_cv_header_sys_statfs_h" = "yes"
 then
     echo $ac_n "checking "whether sys/statfs.h defines statfs"""... $ac_c" 1>&6
-echo "configure:6353: checking "whether sys/statfs.h defines statfs"" >&5
+echo "configure:6394: checking "whether sys/statfs.h defines statfs"" >&5
 if eval "test \"`echo '$''{'wine_cv_sys_statfs_has_statfs'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6358 "configure"
+#line 6399 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -6369,7 +6410,7 @@ int main() {
 	
 ; return 0; }
 EOF
-if { (eval echo configure:6373: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6414: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_sys_statfs_has_statfs=yes
 else
@@ -6396,12 +6437,12 @@ fi
 if test "$ac_cv_header_sys_mount_h" = "yes"
 then
     echo $ac_n "checking "whether sys/mount.h defines statfs"""... $ac_c" 1>&6
-echo "configure:6400: checking "whether sys/mount.h defines statfs"" >&5
+echo "configure:6441: checking "whether sys/mount.h defines statfs"" >&5
 if eval "test \"`echo '$''{'wine_cv_sys_mount_has_statfs'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6405 "configure"
+#line 6446 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -6416,7 +6457,7 @@ int main() {
 	
 ; return 0; }
 EOF
-if { (eval echo configure:6420: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6461: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_sys_mount_has_statfs=yes
 else
@@ -6442,7 +6483,7 @@ fi
 
 
 echo $ac_n "checking "for statfs.f_bfree"""... $ac_c" 1>&6
-echo "configure:6446: checking "for statfs.f_bfree"" >&5
+echo "configure:6487: checking "for statfs.f_bfree"" >&5
 if eval "test \"`echo '$''{'wine_cv_statfs_bfree'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6451,7 +6492,7 @@ else
         wine_cv_statfs_bfree=no
     else
     	cat > conftest.$ac_ext <<EOF
-#line 6455 "configure"
+#line 6496 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -6478,7 +6519,7 @@ int main() {
 	
 ; return 0; }
 EOF
-if { (eval echo configure:6482: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6523: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_statfs_bfree=yes
 else
@@ -6502,7 +6543,7 @@ EOF
 fi
 
 echo $ac_n "checking "for statfs.f_bavail"""... $ac_c" 1>&6
-echo "configure:6506: checking "for statfs.f_bavail"" >&5
+echo "configure:6547: checking "for statfs.f_bavail"" >&5
 if eval "test \"`echo '$''{'wine_cv_statfs_bavail'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -6511,7 +6552,7 @@ else
         wine_cv_statfs_bavail=no
     else
     	cat > conftest.$ac_ext <<EOF
-#line 6515 "configure"
+#line 6556 "configure"
 #include "confdefs.h"
 
 	#include <sys/types.h>
@@ -6538,7 +6579,7 @@ int main() {
 	
 ; return 0; }
 EOF
-if { (eval echo configure:6542: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6583: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   wine_cv_statfs_bavail=yes
 else
@@ -6563,12 +6604,12 @@ fi
 
 
 echo $ac_n "checking "for msg_accrights in struct msghdr"""... $ac_c" 1>&6
-echo "configure:6567: checking "for msg_accrights in struct msghdr"" >&5
+echo "configure:6608: checking "for msg_accrights in struct msghdr"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_msg_accrights'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6572 "configure"
+#line 6613 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -6576,7 +6617,7 @@ int main() {
 struct msghdr hdr; hdr.msg_accrights=0
 ; return 0; }
 EOF
-if { (eval echo configure:6580: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6621: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_msg_accrights="yes"
 else
@@ -6599,12 +6640,12 @@ fi
 
 
 echo $ac_n "checking "for sun_len in struct sockaddr_un"""... $ac_c" 1>&6
-echo "configure:6603: checking "for sun_len in struct sockaddr_un"" >&5
+echo "configure:6644: checking "for sun_len in struct sockaddr_un"" >&5
 if eval "test \"`echo '$''{'ac_cv_c_sun_len'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6608 "configure"
+#line 6649 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -6613,7 +6654,7 @@ int main() {
 static struct sockaddr_un addr; addr.sun_len = 1
 ; return 0; }
 EOF
-if { (eval echo configure:6617: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:6658: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_sun_len="yes"
 else
@@ -6636,12 +6677,12 @@ fi
 
 
 echo $ac_n "checking "whether we need to define __i386__"""... $ac_c" 1>&6
-echo "configure:6640: checking "whether we need to define __i386__"" >&5
+echo "configure:6681: checking "whether we need to define __i386__"" >&5
 if eval "test \"`echo '$''{'ac_cv_cpp_def_i386'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 6645 "configure"
+#line 6686 "configure"
 #include "confdefs.h"
 #if (defined(i386) || defined(__i386)) && !defined(__i386__)
 yes
diff --git a/configure.in b/configure.in
index 14b465f448f..f39afbb9421 100644
--- a/configure.in
+++ b/configure.in
@@ -838,6 +838,25 @@ AC_C_INLINE()
 AC_TYPE_SIZE_T()
 AC_CHECK_SIZEOF(long long,0)
 
+AC_CACHE_CHECK("whether linux/input.h is for real",
+	wine_cv_linux_input_h,
+	AC_TRY_COMPILE([
+	    #include <linux/input.h>
+	] , [
+	    int foo = EVIOCGBIT(EV_ABS,42);
+	    int bar = BTN_PINKIE;
+	    int fortytwo = 42;
+	],
+	wine_cv_linux_input_h=yes,
+	wine_cv_linux_input_h=no,
+	no
+	)
+    )
+    if test "$wine_cv_linux_input_h" = "yes"
+    then
+        AC_DEFINE(HAVE_CORRECT_LINUXINPUT_H)
+    fi
+
    
 AC_CACHE_CHECK("whether we can use re-entrant gethostbyname_r Linux style",
    	wine_cv_linux_gethostbyname_r_6,
diff --git a/dlls/dinput/joystick/linuxinput.c b/dlls/dinput/joystick/linuxinput.c
index 2094572aa3d..a93d70b1ec0 100644
--- a/dlls/dinput/joystick/linuxinput.c
+++ b/dlls/dinput/joystick/linuxinput.c
@@ -21,10 +21,14 @@
 #ifdef HAVE_SYS_ERRNO_H
 # include <sys/errno.h>
 #endif
+
+#ifdef HAVE_CORRECT_LINUXINPUT_H
+
 #ifdef HAVE_LINUX_INPUT_H
 # include <linux/input.h>
 #endif
 
+
 #define EVDEVPREFIX	"/dev/input/event"
 
 #include "debugtools.h"
@@ -883,3 +887,5 @@ static ICOM_VTABLE(IDirectInputDevice7A) Joystick7Avt =
 #undef XCAST
 
 #endif  /* HAVE_LINUX_INPUT_H */
+
+#endif
diff --git a/include/acconfig.h b/include/acconfig.h
index d895b4545a0..0ca86fb9124 100644
--- a/include/acconfig.h
+++ b/include/acconfig.h
@@ -116,3 +116,6 @@
 
 /* Define if Linux-style gethostbyname_r and gethostbyaddr_r are available */
 #undef HAVE_LINUX_GETHOSTBYNAME_R_6
+
+/* Define if we have linux/input.h AND it contains the INPUT event API */
+#undef HAVE_CORRECT_LINUXINPUT_H
diff --git a/include/config.h.in b/include/config.h.in
index d24fb8a70c3..e5f91b84d02 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -148,6 +148,9 @@
 /* Define if Linux-style gethostbyname_r and gethostbyaddr_r are available */
 #undef HAVE_LINUX_GETHOSTBYNAME_R_6
 
+/* Define if we have linux/input.h AND it contains the INPUT event API */
+#undef HAVE_CORRECT_LINUXINPUT_H
+
 /* The number of bytes in a long long.  */
 #undef SIZEOF_LONG_LONG
 
-- 
GitLab