Implemented DirectInput Joystick support (tested with WC:Prophecy).

This commit is contained in:
Marcus Meissner 1999-08-04 15:07:56 +00:00 committed by Alexandre Julliard
parent 5910c68101
commit 028e9a1720
6 changed files with 600 additions and 62 deletions

142
configure vendored
View File

@ -4479,6 +4479,7 @@ for ac_hdr in \
float.h \
libio.h \
linux/cdrom.h \
linux/joystick.h \
linux/ucdrom.h \
ncurses.h \
net/if.h \
@ -4508,17 +4509,17 @@ for ac_hdr in \
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:4512: checking for $ac_hdr" >&5
echo "configure:4513: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 4517 "configure"
#line 4518 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:4522: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:4523: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@ -4545,12 +4546,12 @@ fi
done
echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6
echo "configure:4549: checking whether stat file-mode macros are broken" >&5
echo "configure:4550: checking whether stat file-mode macros are broken" >&5
if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 4554 "configure"
#line 4555 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
@ -4603,12 +4604,12 @@ fi
echo $ac_n "checking for working const""... $ac_c" 1>&6
echo "configure:4607: checking for working const" >&5
echo "configure:4608: checking for working const" >&5
if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 4612 "configure"
#line 4613 "configure"
#include "confdefs.h"
int main() {
@ -4657,7 +4658,7 @@ ccp = (char const *const *) p;
; return 0; }
EOF
if { (eval echo configure:4661: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:4662: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_const=yes
else
@ -4678,21 +4679,21 @@ EOF
fi
echo $ac_n "checking for inline""... $ac_c" 1>&6
echo "configure:4682: checking for inline" >&5
echo "configure:4683: checking for inline" >&5
if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_c_inline=no
for ac_kw in inline __inline__ __inline; do
cat > conftest.$ac_ext <<EOF
#line 4689 "configure"
#line 4690 "configure"
#include "confdefs.h"
int main() {
} $ac_kw foo() {
; return 0; }
EOF
if { (eval echo configure:4696: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:4697: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_inline=$ac_kw; break
else
@ -4718,12 +4719,12 @@ EOF
esac
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
echo "configure:4722: checking for ANSI C header files" >&5
echo "configure:4723: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 4727 "configure"
#line 4728 "configure"
#include "confdefs.h"
#include <stdlib.h>
#include <stdarg.h>
@ -4731,7 +4732,7 @@ else
#include <float.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:4735: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:4736: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@ -4748,7 +4749,7 @@ rm -f conftest*
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
#line 4752 "configure"
#line 4753 "configure"
#include "confdefs.h"
#include <string.h>
EOF
@ -4766,7 +4767,7 @@ fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF
#line 4770 "configure"
#line 4771 "configure"
#include "confdefs.h"
#include <stdlib.h>
EOF
@ -4787,7 +4788,7 @@ if test "$cross_compiling" = yes; then
:
else
cat > conftest.$ac_ext <<EOF
#line 4791 "configure"
#line 4792 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@ -4798,7 +4799,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }
EOF
if { (eval echo configure:4802: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
if { (eval echo configure:4803: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
:
else
@ -4822,12 +4823,12 @@ EOF
fi
echo $ac_n "checking for size_t""... $ac_c" 1>&6
echo "configure:4826: checking for size_t" >&5
echo "configure:4827: checking for size_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 4831 "configure"
#line 4832 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@ -4855,7 +4856,7 @@ EOF
fi
echo $ac_n "checking size of long long""... $ac_c" 1>&6
echo "configure:4859: checking size of long long" >&5
echo "configure:4860: checking size of long long" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -4863,7 +4864,7 @@ else
ac_cv_sizeof_long_long=0
else
cat > conftest.$ac_ext <<EOF
#line 4867 "configure"
#line 4868 "configure"
#include "confdefs.h"
#include <stdio.h>
main()
@ -4874,7 +4875,7 @@ main()
exit(0);
}
EOF
if { (eval echo configure:4878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
if { (eval echo configure:4879: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_long_long=`cat conftestval`
else
@ -4894,16 +4895,59 @@ EOF
if test "$ac_cv_header_sys_vfs_h" = "yes"
if test "$ac_cv_header_linux_joystick_h" = "yes"
then
echo $ac_n "checking "whether sys/vfs.h defines statfs"""... $ac_c" 1>&6
echo "configure:4902: checking "whether sys/vfs.h defines statfs"" >&5
if eval "test \"`echo '$''{'wine_cv_sys_vfs_has_statfs'+set}'`\" = set"; then
echo $ac_n "checking "whether linux/joystick.h uses the Linux 2.2+ API"""... $ac_c" 1>&6
echo "configure:4902: 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 4907 "configure"
#include "confdefs.h"
#include <sys/ioctl.h>
#include <linux/joystick.h>
struct js_event blub;
int main() {
/*empty*/
; return 0; }
EOF
if { (eval echo configure:4919: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
wine_cv_linux_joystick_22_api=yes
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
wine_cv_linux_joystick_22_api=no
fi
rm -f conftest*
fi
echo "$ac_t""$wine_cv_linux_joystick_22_api" 1>&6
if test "$wine_cv_linux_joystick_22_api"
then
cat >> confdefs.h <<\EOF
#define HAVE_LINUX_22_JOYSTICK_API 1
EOF
fi
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:4946: 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 4951 "configure"
#include "confdefs.h"
#include <sys/types.h>
@ -4920,7 +4964,7 @@ int main() {
; return 0; }
EOF
if { (eval echo configure:4924: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:4968: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
wine_cv_sys_vfs_has_statfs=yes
else
@ -4947,12 +4991,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:4951: checking "whether sys/statfs.h defines statfs"" >&5
echo "configure:4995: 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 4956 "configure"
#line 5000 "configure"
#include "confdefs.h"
#include <sys/types.h>
@ -4967,7 +5011,7 @@ int main() {
; return 0; }
EOF
if { (eval echo configure:4971: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:5015: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
wine_cv_sys_statfs_has_statfs=yes
else
@ -4994,12 +5038,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:4998: checking "whether sys/mount.h defines statfs"" >&5
echo "configure:5042: 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 5003 "configure"
#line 5047 "configure"
#include "confdefs.h"
#include <sys/types.h>
@ -5014,7 +5058,7 @@ int main() {
; return 0; }
EOF
if { (eval echo configure:5018: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:5062: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
wine_cv_sys_mount_has_statfs=yes
else
@ -5040,7 +5084,7 @@ fi
echo $ac_n "checking "for statfs.f_bfree"""... $ac_c" 1>&6
echo "configure:5044: checking "for statfs.f_bfree"" >&5
echo "configure:5088: 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
@ -5049,7 +5093,7 @@ else
wine_cv_statfs_bfree=no
else
cat > conftest.$ac_ext <<EOF
#line 5053 "configure"
#line 5097 "configure"
#include "confdefs.h"
#include <sys/types.h>
@ -5076,7 +5120,7 @@ int main() {
; return 0; }
EOF
if { (eval echo configure:5080: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:5124: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
wine_cv_statfs_bfree=yes
else
@ -5100,7 +5144,7 @@ EOF
fi
echo $ac_n "checking "for statfs.f_bavail"""... $ac_c" 1>&6
echo "configure:5104: checking "for statfs.f_bavail"" >&5
echo "configure:5148: 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
@ -5109,7 +5153,7 @@ else
wine_cv_statfs_bavail=no
else
cat > conftest.$ac_ext <<EOF
#line 5113 "configure"
#line 5157 "configure"
#include "confdefs.h"
#include <sys/types.h>
@ -5136,7 +5180,7 @@ int main() {
; return 0; }
EOF
if { (eval echo configure:5140: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:5184: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
wine_cv_statfs_bavail=yes
else
@ -5161,7 +5205,7 @@ fi
echo $ac_n "checking "for working sigaltstack"""... $ac_c" 1>&6
echo "configure:5165: checking "for working sigaltstack"" >&5
echo "configure:5209: checking "for working sigaltstack"" >&5
if eval "test \"`echo '$''{'ac_cv_c_working_sigaltstack'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -5170,7 +5214,7 @@ else
else
cat > conftest.$ac_ext <<EOF
#line 5174 "configure"
#line 5218 "configure"
#include "confdefs.h"
#include <stdio.h>
@ -5208,7 +5252,7 @@ else
}
EOF
if { (eval echo configure:5212: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
if { (eval echo configure:5256: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_c_working_sigaltstack="yes"
else
@ -5235,12 +5279,12 @@ fi
echo $ac_n "checking "for msg_accrights in struct msghdr"""... $ac_c" 1>&6
echo "configure:5239: checking "for msg_accrights in struct msghdr"" >&5
echo "configure:5283: 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 5244 "configure"
#line 5288 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/socket.h>
@ -5248,7 +5292,7 @@ int main() {
struct msghdr hdr; hdr.msg_accrights=0
; return 0; }
EOF
if { (eval echo configure:5252: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:5296: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_msg_accrights="yes"
else
@ -5271,12 +5315,12 @@ fi
echo $ac_n "checking "whether we need to define __i386__"""... $ac_c" 1>&6
echo "configure:5275: checking "whether we need to define __i386__"" >&5
echo "configure:5319: 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 5280 "configure"
#line 5324 "configure"
#include "confdefs.h"
#if (defined(i386) || defined(__i386)) && !defined(__i386__)
yes

View File

@ -506,6 +506,7 @@ AC_CHECK_HEADERS(\
float.h \
libio.h \
linux/cdrom.h \
linux/joystick.h \
linux/ucdrom.h \
ncurses.h \
net/if.h \
@ -541,6 +542,27 @@ AC_C_INLINE()
AC_TYPE_SIZE_T()
AC_CHECK_SIZEOF(long long,0)
if test "$ac_cv_header_linux_joystick_h" = "yes"
then
AC_CACHE_CHECK("whether linux/joystick.h uses the Linux 2.2+ API",
wine_cv_linux_joystick_22_api,
AC_TRY_COMPILE([
#include <sys/ioctl.h>
#include <linux/joystick.h>
struct js_event blub;
],/*empty*/,
wine_cv_linux_joystick_22_api=yes,
wine_cv_linux_joystick_22_api=no,
wine_cv_linux_joystick_22_api=no
)
)
if test "$wine_cv_linux_joystick_22_api"
then
AC_DEFINE(HAVE_LINUX_22_JOYSTICK_API)
fi
fi
dnl **** statfs checks ****
if test "$ac_cv_header_sys_vfs_h" = "yes"

View File

@ -95,3 +95,6 @@
/* Define if the system has dynamic link library support with the dl* API */
#undef HAVE_DL_API
/* Define if <linux/joystick.h> defines the Linux 2.2 joystick API */
#undef HAVE_LINUX_22_JOYSTICK_API

View File

@ -124,6 +124,9 @@
/* Define if the system has dynamic link library support with the dl* API */
#undef HAVE_DL_API
/* Define if <linux/joystick.h> defines the Linux 2.2 joystick API */
#undef HAVE_LINUX_22_JOYSTICK_API
/* The number of bytes in a long long. */
#undef SIZEOF_LONG_LONG
@ -226,6 +229,9 @@
/* Define if you have the <linux/cdrom.h> header file. */
#undef HAVE_LINUX_CDROM_H
/* Define if you have the <linux/joystick.h> header file. */
#undef HAVE_LINUX_JOYSTICK_H
/* Define if you have the <linux/ucdrom.h> header file. */
#undef HAVE_LINUX_UCDROM_H

View File

@ -457,9 +457,9 @@ typedef const DIPROPRANGE *LPCDIPROPRANGE;
typedef struct DIPROPCAL {
DIPROPHEADER diph;
LONG lMin;
LONG lCenter;
LONG lMax;
LONG lMin;
LONG lCenter;
LONG lMax;
} DIPROPCAL, *LPDIPROPCAL;
typedef const DIPROPCAL *LPCDIPROPCAL;
@ -635,14 +635,103 @@ typedef BOOL (CALLBACK * LPDIENUMEFFECTSCALLBACKA)(LPCDIEFFECTINFOA, LPVOID);
typedef BOOL (CALLBACK * LPDIENUMEFFECTSCALLBACKW)(LPCDIEFFECTINFOW, LPVOID);
typedef struct DIEFFESCAPE {
DWORD dwSize;
DWORD dwCommand;
LPVOID lpvInBuffer;
DWORD cbInBuffer;
LPVOID lpvOutBuffer;
DWORD cbOutBuffer;
DWORD dwSize;
DWORD dwCommand;
LPVOID lpvInBuffer;
DWORD cbInBuffer;
LPVOID lpvOutBuffer;
DWORD cbOutBuffer;
} DIEFFESCAPE, *LPDIEFFESCAPE;
typedef struct DIJOYSTATE {
LONG lX;
LONG lY;
LONG lZ;
LONG lRx;
LONG lRy;
LONG lRz;
LONG rglSlider[2];
DWORD rgdwPOV[4];
BYTE rgbButtons[32];
} DIJOYSTATE, *LPDIJOYSTATE;
typedef struct DIJOYSTATE2 {
LONG lX;
LONG lY;
LONG lZ;
LONG lRx;
LONG lRy;
LONG lRz;
LONG rglSlider[2];
DWORD rgdwPOV[4];
BYTE rgbButtons[128];
LONG lVX; /* 'v' as in velocity */
LONG lVY;
LONG lVZ;
LONG lVRx;
LONG lVRy;
LONG lVRz;
LONG rglVSlider[2];
LONG lAX; /* 'a' as in acceleration */
LONG lAY;
LONG lAZ;
LONG lARx;
LONG lARy;
LONG lARz;
LONG rglASlider[2];
LONG lFX; /* 'f' as in force */
LONG lFY;
LONG lFZ;
LONG lFRx; /* 'fr' as in rotational force aka torque */
LONG lFRy;
LONG lFRz;
LONG rglFSlider[2];
} DIJOYSTATE2, *LPDIJOYSTATE2;
#define DIJOFS_X FIELD_OFFSET(DIJOYSTATE, lX)
#define DIJOFS_Y FIELD_OFFSET(DIJOYSTATE, lY)
#define DIJOFS_Z FIELD_OFFSET(DIJOYSTATE, lZ)
#define DIJOFS_RX FIELD_OFFSET(DIJOYSTATE, lRx)
#define DIJOFS_RY FIELD_OFFSET(DIJOYSTATE, lRy)
#define DIJOFS_RZ FIELD_OFFSET(DIJOYSTATE, lRz)
#define DIJOFS_SLIDER(n) (FIELD_OFFSET(DIJOYSTATE, rglSlider) + \
(n) * sizeof(LONG))
#define DIJOFS_POV(n) (FIELD_OFFSET(DIJOYSTATE, rgdwPOV) + \
(n) * sizeof(DWORD))
#define DIJOFS_BUTTON(n) (FIELD_OFFSET(DIJOYSTATE, rgbButtons) + (n))
#define DIJOFS_BUTTON0 DIJOFS_BUTTON(0)
#define DIJOFS_BUTTON1 DIJOFS_BUTTON(1)
#define DIJOFS_BUTTON2 DIJOFS_BUTTON(2)
#define DIJOFS_BUTTON3 DIJOFS_BUTTON(3)
#define DIJOFS_BUTTON4 DIJOFS_BUTTON(4)
#define DIJOFS_BUTTON5 DIJOFS_BUTTON(5)
#define DIJOFS_BUTTON6 DIJOFS_BUTTON(6)
#define DIJOFS_BUTTON7 DIJOFS_BUTTON(7)
#define DIJOFS_BUTTON8 DIJOFS_BUTTON(8)
#define DIJOFS_BUTTON9 DIJOFS_BUTTON(9)
#define DIJOFS_BUTTON10 DIJOFS_BUTTON(10)
#define DIJOFS_BUTTON11 DIJOFS_BUTTON(11)
#define DIJOFS_BUTTON12 DIJOFS_BUTTON(12)
#define DIJOFS_BUTTON13 DIJOFS_BUTTON(13)
#define DIJOFS_BUTTON14 DIJOFS_BUTTON(14)
#define DIJOFS_BUTTON15 DIJOFS_BUTTON(15)
#define DIJOFS_BUTTON16 DIJOFS_BUTTON(16)
#define DIJOFS_BUTTON17 DIJOFS_BUTTON(17)
#define DIJOFS_BUTTON18 DIJOFS_BUTTON(18)
#define DIJOFS_BUTTON19 DIJOFS_BUTTON(19)
#define DIJOFS_BUTTON20 DIJOFS_BUTTON(20)
#define DIJOFS_BUTTON21 DIJOFS_BUTTON(21)
#define DIJOFS_BUTTON22 DIJOFS_BUTTON(22)
#define DIJOFS_BUTTON23 DIJOFS_BUTTON(23)
#define DIJOFS_BUTTON24 DIJOFS_BUTTON(24)
#define DIJOFS_BUTTON25 DIJOFS_BUTTON(25)
#define DIJOFS_BUTTON26 DIJOFS_BUTTON(26)
#define DIJOFS_BUTTON27 DIJOFS_BUTTON(27)
#define DIJOFS_BUTTON28 DIJOFS_BUTTON(28)
#define DIJOFS_BUTTON29 DIJOFS_BUTTON(29)
#define DIJOFS_BUTTON30 DIJOFS_BUTTON(30)
#define DIJOFS_BUTTON31 DIJOFS_BUTTON(31)
/*****************************************************************************
* IDirectInputEffect interface
*/

View File

@ -24,9 +24,17 @@
#include <unistd.h>
#include <assert.h>
#ifdef HAVE_SYS_SIGNAL_H
#include <sys/signal.h>
# include <sys/signal.h>
#endif
#include <sys/time.h>
#include <sys/fcntl.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <sys/errno.h>
#ifdef HAVE_LINUX_JOYSTICK_H
# include <linux/joystick.h>
# define JOYDEV "/dev/js0"
#endif
#include "wine/obj_base.h"
#include "debugtools.h"
#include "dinput.h"
@ -41,6 +49,7 @@
DEFAULT_DEBUG_CHANNEL(dinput)
extern BYTE InputKeyStateTable[256];
extern int min_keycode, max_keycode;
extern WORD keyc2vkey[256];
@ -71,6 +80,27 @@ struct SysKeyboardAImpl
BYTE keystate[256];
};
#ifdef HAVE_LINUX_22_JOYSTICK_API
typedef struct JoystickAImpl JoystickAImpl;
static ICOM_VTABLE(IDirectInputDevice2A) JoystickAvt;
struct JoystickAImpl
{
/* IDirectInputDevice2AImpl */
ICOM_VTABLE(IDirectInputDevice2A)* lpvtbl;
DWORD ref;
GUID guid;
/* joystick private */
int joyfd;
LPDIDATAFORMAT df;
HANDLE hEvent;
LONG lMin,lMax,deadzone;
LPDIDEVICEOBJECTDATA data_queue;
int queue_pos, queue_len;
DIJOYSTATE js;
};
#endif
struct SysMouseAImpl
{
/* IDirectInputDevice2AImpl */
@ -101,6 +131,14 @@ static int evsequence=0;
When enumerating each device supporting DInput, they have two UIDs :
- the 'windows' UID
- a vendor UID */
#ifdef HAVE_LINUX_22_JOYSTICK_API
static GUID DInput_Wine_Joystick_GUID = { /* 9e573ed9-7734-11d2-8d4a-23903fb6bdf7 */
0x9e573ed9,
0x7734,
0x11d2,
{0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
};
#endif
static GUID DInput_Wine_Mouse_GUID = { /* 9e573ed8-7734-11d2-8d4a-23903fb6bdf7 */
0x9e573ed8,
0x7734,
@ -198,8 +236,29 @@ static HRESULT WINAPI IDirectInputAImpl_EnumDevices(
ret = lpCallback(&devInstance, pvRef);
TRACE("Mouse registered\n");
if (ret == DIENUM_STOP)
return 0;
}
if ((dwDevType == 0) || (dwDevType == DIDEVTYPE_JOYSTICK)) {
/* check whether we have a joystick */
#ifdef HAVE_LINUX_22_JOYSTICK_API
if ((access(JOYDEV,O_RDONLY)!=-1) || (errno!=ENODEV)) {
/* Return joystick */
devInstance.guidInstance = GUID_Joystick;
devInstance.guidProduct = DInput_Wine_Joystick_GUID;
/* we only support traditional joysticks for now */
devInstance.dwDevType = DIDEVTYPE_JOYSTICK | DIDEVTYPEJOYSTICK_TRADITIONAL;
strcpy(devInstance.tszInstanceName, "Joystick");
/* ioctl JSIOCGNAME(len) */
strcpy(devInstance.tszProductName, "Wine Joystick");
ret = lpCallback(&devInstance,pvRef);
TRACE("Joystick registered\n");
if (ret == DIENUM_STOP)
return 0;
}
#endif
}
/* Should also do joystick enumerations.... */
return 0;
}
@ -251,6 +310,19 @@ static HRESULT WINAPI IDirectInputAImpl_CreateDevice(
*pdev=(IDirectInputDeviceA*)newDevice;
return DI_OK;
}
#ifdef HAVE_LINUX_22_JOYSTICK_API
if ((!memcmp(&GUID_Joystick,rguid,sizeof(GUID_Joystick))) ||
(!memcmp(&DInput_Wine_Joystick_GUID,rguid,sizeof(GUID_Joystick)))) {
JoystickAImpl* newDevice;
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickAImpl));
newDevice->ref = 1;
newDevice->lpvtbl = &JoystickAvt;
newDevice->joyfd = -1;
memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
*pdev=(IDirectInputDeviceA*)newDevice;
return DI_OK;
}
#endif
return E_FAIL;
}
@ -898,7 +970,7 @@ static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE2A iface)
point.y = This->win_centerY;
MapWindowPoints(This->win, HWND_DESKTOP, &point, 1);
DISPLAY_MoveCursor(point.x, point.y);
This->acquired = 1;
}
return 0;
@ -1103,7 +1175,275 @@ static HRESULT WINAPI SysMouseAImpl_SetEventNotification(LPDIRECTINPUTDEVICE2A i
return DI_OK;
}
#ifdef HAVE_LINUX_22_JOYSTICK_API
/******************************************************************************
* Joystick
*/
static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE2A iface)
{
ICOM_THIS(JoystickAImpl,iface);
This->ref--;
if (This->ref)
return This->ref;
HeapFree(GetProcessHeap(),0,This);
return 0;
}
/******************************************************************************
* SetDataFormat : the application can choose the format of the data
* the device driver sends back with GetDeviceState.
*/
static HRESULT WINAPI JoystickAImpl_SetDataFormat(
LPDIRECTINPUTDEVICE2A iface,LPCDIDATAFORMAT df
)
{
ICOM_THIS(JoystickAImpl,iface);
int i;
TRACE("(this=%p,%p)\n",This,df);
TRACE("(df.dwSize=%ld)\n",df->dwSize);
TRACE("(df.dwObjsize=%ld)\n",df->dwObjSize);
TRACE("(df.dwFlags=0x%08lx)\n",df->dwFlags);
TRACE("(df.dwDataSize=%ld)\n",df->dwDataSize);
TRACE("(df.dwNumObjs=%ld)\n",df->dwNumObjs);
for (i=0;i<df->dwNumObjs;i++) {
char xbuf[50];
if (df->rgodf[i].pguid)
WINE_StringFromCLSID(df->rgodf[i].pguid,xbuf);
else
strcpy(xbuf,"<no guid>");
TRACE("df.rgodf[%d].guid %s (%p)\n",i,xbuf, df->rgodf[i].pguid);
TRACE("df.rgodf[%d].dwOfs %ld\n",i,df->rgodf[i].dwOfs);
TRACE("dwType 0x%02x,dwInstance %d\n",DIDFT_GETTYPE(df->rgodf[i].dwType),DIDFT_GETINSTANCE(df->rgodf[i].dwType));
TRACE("df.rgodf[%d].dwFlags 0x%08lx\n",i,df->rgodf[i].dwFlags);
}
This->df = HeapAlloc(GetProcessHeap(),0,df->dwSize+(df->dwNumObjs*df->dwObjSize));
memcpy(This->df,df,df->dwSize+(df->dwNumObjs*df->dwObjSize));
return 0;
}
/******************************************************************************
* Acquire : gets exclusive control of the joystick
*/
static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE2A iface)
{
ICOM_THIS(JoystickAImpl,iface);
TRACE("(this=%p)\n",This);
if (This->joyfd!=-1)
return 0;
This->joyfd=open(JOYDEV,O_RDONLY);
if (This->joyfd==-1)
return DIERR_NOTFOUND;
return 0;
}
/******************************************************************************
* Unacquire : frees the joystick
*/
static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE2A iface)
{
ICOM_THIS(JoystickAImpl,iface);
TRACE("(this=%p)\n",This);
if (This->joyfd!=-1) {
close(This->joyfd);
This->joyfd = -1;
}
return 0;
}
#define map_axis(val) ((val+32768)*(This->lMax-This->lMin)/65536+This->lMin)
static void joy_polldev(JoystickAImpl *This) {
struct timeval tv;
fd_set readfds;
struct js_event jse;
if (This->joyfd==-1)
return;
while (1) {
memset(&tv,0,sizeof(tv));
FD_ZERO(&readfds);FD_SET(This->joyfd,&readfds);
if (1>select(This->joyfd+1,&readfds,NULL,NULL,&tv))
return;
/* we have one event, so we can read */
if (sizeof(jse)!=read(This->joyfd,&jse,sizeof(jse))) {
return;
}
TRACE("js_event: type 0x%x, number %d, value %d\n",jse.type,jse.number,jse.value);
if (jse.type & JS_EVENT_BUTTON) {
GEN_EVENT(DIJOFS_BUTTON(jse.number),jse.value?0x80:0x00,jse.time,evsequence++);
This->js.rgbButtons[jse.number] = jse.value?0x80:0x00;
}
if (jse.type & JS_EVENT_AXIS) {
switch (jse.number) {
case 0:
GEN_EVENT(jse.number*4,jse.value,jse.time,evsequence++);
This->js.lX = map_axis(jse.value);
break;
case 1:
GEN_EVENT(jse.number*4,jse.value,jse.time,evsequence++);
This->js.lY = map_axis(jse.value);
break;
case 2:
GEN_EVENT(jse.number*4,jse.value,jse.time,evsequence++);
This->js.lZ = map_axis(jse.value);
break;
default:
FIXME("more then 3 axes (%d) not handled!\n",jse.number);
break;
}
}
}
}
/******************************************************************************
* GetDeviceState : returns the "state" of the joystick.
*
*/
static HRESULT WINAPI JoystickAImpl_GetDeviceState(
LPDIRECTINPUTDEVICE2A iface,DWORD len,LPVOID ptr
) {
ICOM_THIS(JoystickAImpl,iface);
joy_polldev(This);
TRACE("(this=%p,0x%08lx,%p)\n",This,len,ptr);
if (len != sizeof(DIJOYSTATE)) {
FIXME("len %ld is not sizeof(DIJOYSTATE), unsupported format.\n",len);
}
memcpy(ptr,&(This->js),len);
This->queue_pos = 0;
return 0;
}
/******************************************************************************
* GetDeviceState : gets buffered input data.
*/
static HRESULT WINAPI JoystickAImpl_GetDeviceData(LPDIRECTINPUTDEVICE2A iface,
DWORD dodsize,
LPDIDEVICEOBJECTDATA dod,
LPDWORD entries,
DWORD flags
) {
ICOM_THIS(JoystickAImpl,iface);
FIXME("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx),STUB!\n",This,dodsize,*entries,flags);
joy_polldev(This);
if (flags & DIGDD_PEEK)
FIXME("DIGDD_PEEK\n");
if (dod == NULL) {
} else {
}
return 0;
}
/******************************************************************************
* SetProperty : change input device properties
*/
static HRESULT WINAPI JoystickAImpl_SetProperty(LPDIRECTINPUTDEVICE2A iface,
REFGUID rguid,
LPCDIPROPHEADER ph)
{
ICOM_THIS(JoystickAImpl,iface);
char xbuf[50];
if (HIWORD(rguid))
WINE_StringFromCLSID(rguid,xbuf);
else
sprintf(xbuf,"<special guid %ld>",(DWORD)rguid);
FIXME("(this=%p,%s,%p)\n",This,xbuf,ph);
FIXME("ph.dwSize = %ld, ph.dwHeaderSize =%ld, ph.dwObj = %ld, ph.dwHow= %ld\n",ph->dwSize, ph->dwHeaderSize,ph->dwObj,ph->dwHow);
if (!HIWORD(rguid)) {
switch ((DWORD)rguid) {
case (DWORD) DIPROP_BUFFERSIZE: {
LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
FIXME("buffersize = %ld\n",pd->dwData);
break;
}
case (DWORD)DIPROP_RANGE: {
LPCDIPROPRANGE pr = (LPCDIPROPRANGE)ph;
FIXME("proprange(%ld,%ld)\n",pr->lMin,pr->lMax);
This->lMin = pr->lMin;
This->lMax = pr->lMax;
break;
}
case (DWORD)DIPROP_DEADZONE: {
LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
FIXME("deadzone(%ld)\n",pd->dwData);
This->deadzone = pd->dwData;
break;
}
default:
FIXME("Unknown type %ld (%s)\n",(DWORD)rguid,xbuf);
break;
}
}
return 0;
}
/******************************************************************************
* SetEventNotification : specifies event to be sent on state change
*/
static HRESULT WINAPI JoystickAImpl_SetEventNotification(
LPDIRECTINPUTDEVICE2A iface, HANDLE hnd
) {
ICOM_THIS(JoystickAImpl,iface);
TRACE("(this=%p,0x%08lx)\n",This,(DWORD)hnd);
This->hEvent = hnd;
return DI_OK;
}
static HRESULT WINAPI JoystickAImpl_GetCapabilities(
LPDIRECTINPUTDEVICE2A iface,
LPDIDEVCAPS lpDIDevCaps)
{
ICOM_THIS(JoystickAImpl,iface);
BYTE axes,buttons;
int xfd = This->joyfd;
TRACE("%p->(%p)\n",iface,lpDIDevCaps);
if (xfd==-1)
xfd = open(JOYDEV,O_RDONLY);
lpDIDevCaps->dwFlags = DIDC_ATTACHED;
lpDIDevCaps->dwDevType = DIDEVTYPE_JOYSTICK;
#ifdef JSIOCGAXES
if (-1==ioctl(xfd,JSIOCGAXES,&axes))
axes = 2;
lpDIDevCaps->dwAxes = axes;
#endif
#ifdef JSIOCGBUTTONS
if (-1==ioctl(xfd,JSIOCGAXES,&buttons))
buttons = 2;
lpDIDevCaps->dwButtons = buttons;
#endif
if (xfd!=This->joyfd)
close(xfd);
return DI_OK;
}
static HRESULT WINAPI JoystickAImpl_Poll(LPDIRECTINPUTDEVICE2A iface) {
ICOM_THIS(JoystickAImpl,iface);
TRACE("(),stub!\n");
joy_polldev(This);
return DI_OK;
}
#endif
/****************************************************************************/
/****************************************************************************/
static ICOM_VTABLE(IDirectInputDevice2A) SysKeyboardAvt =
{
@ -1168,3 +1508,37 @@ static ICOM_VTABLE(IDirectInputDevice2A) SysMouseAvt =
IDirectInputDevice2AImpl_Poll,
IDirectInputDevice2AImpl_SendDeviceData,
};
#ifdef HAVE_LINUX_22_JOYSTICK_API
static ICOM_VTABLE(IDirectInputDevice2A) JoystickAvt =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
IDirectInputDevice2AImpl_QueryInterface,
IDirectInputDevice2AImpl_AddRef,
JoystickAImpl_Release,
JoystickAImpl_GetCapabilities,
IDirectInputDevice2AImpl_EnumObjects,
IDirectInputDevice2AImpl_GetProperty,
JoystickAImpl_SetProperty,
JoystickAImpl_Acquire,
JoystickAImpl_Unacquire,
JoystickAImpl_GetDeviceState,
JoystickAImpl_GetDeviceData,
JoystickAImpl_SetDataFormat,
JoystickAImpl_SetEventNotification,
IDirectInputDevice2AImpl_SetCooperativeLevel,
IDirectInputDevice2AImpl_GetObjectInfo,
IDirectInputDevice2AImpl_GetDeviceInfo,
IDirectInputDevice2AImpl_RunControlPanel,
IDirectInputDevice2AImpl_Initialize,
IDirectInputDevice2AImpl_CreateEffect,
IDirectInputDevice2AImpl_EnumEffects,
IDirectInputDevice2AImpl_GetEffectInfo,
IDirectInputDevice2AImpl_GetForceFeedbackState,
IDirectInputDevice2AImpl_SendForceFeedbackCommand,
IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
IDirectInputDevice2AImpl_Escape,
JoystickAImpl_Poll,
IDirectInputDevice2AImpl_SendDeviceData,
};
#endif