Commit f8c0228d authored by Aric Stewart's avatar Aric Stewart Committed by Alexandre Julliard

winebus.sys: Add SDL gamepad and joystick driver.

parent a110f87b
......@@ -658,6 +658,8 @@ CUPS_LIBS
CUPS_CFLAGS
CAPI20_LIBS
CAPI20_CFLAGS
SDL2_LIBS
SDL2_CFLAGS
UDEV_LIBS
UDEV_CFLAGS
OSS4_CFLAGS
......@@ -859,6 +861,7 @@ with_pulse
with_sane
with_tiff
with_udev
with_sdl
with_v4l
with_xcomposite
with_xcursor
......@@ -1733,6 +1736,8 @@ GSTREAMER_CFLAGS
GSTREAMER_LIBS
UDEV_CFLAGS
UDEV_LIBS
SDL2_CFLAGS
SDL2_LIBS
CAPI20_CFLAGS
CAPI20_LIBS
CUPS_CFLAGS
......@@ -2430,6 +2435,7 @@ Optional Packages:
--without-sane do not use SANE (scanner support)
--without-tiff do not use TIFF
--without-udev do not use udev (plug and play support)
--without-sdl do not use SDL
--without-v4l do not use v4l1 (v4l support)
--without-xcomposite do not use the Xcomposite extension
--without-xcursor do not use the Xcursor extension
......@@ -2500,6 +2506,8 @@ Some influential environment variables:
gstreamer-audio-1.0, overriding pkg-config
UDEV_CFLAGS C compiler flags for libudev, overriding pkg-config
UDEV_LIBS Linker flags for libudev, overriding pkg-config
SDL2_CFLAGS C compiler flags for sdl2, overriding pkg-config
SDL2_LIBS Linker flags for sdl2, overriding pkg-config
CAPI20_CFLAGS
C compiler flags for capi20, overriding pkg-config
CAPI20_LIBS Linker flags for capi20, overriding pkg-config
......@@ -3737,6 +3745,12 @@ if test "${with_udev+set}" = set; then :
fi
# Check whether --with-sdl was given.
if test "${with_sdl+set}" = set; then :
withval=$with_sdl;
fi
# Check whether --with-v4l was given.
if test "${with_v4l+set}" = set; then :
withval=$with_v4l;
......@@ -13328,6 +13342,104 @@ esac
fi
if test "x$with_sdl" != "xno"
then
if ${SDL2_CFLAGS:+false} :; then :
if ${PKG_CONFIG+:} false; then :
SDL2_CFLAGS=`$PKG_CONFIG --cflags sdl2 2>/dev/null`
fi
fi
if ${SDL2_LIBS:+false} :; then :
if ${PKG_CONFIG+:} false; then :
SDL2_LIBS=`$PKG_CONFIG --libs sdl2 2>/dev/null`
fi
fi
SDL2_LIBS=${SDL2_LIBS:-"-lSDL2"}
$as_echo "$as_me:${as_lineno-$LINENO}: sdl2 cflags: $SDL2_CFLAGS" >&5
$as_echo "$as_me:${as_lineno-$LINENO}: sdl2 libs: $SDL2_LIBS" >&5
ac_save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $SDL2_CFLAGS"
for ac_header in SDL2/SDL.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "SDL2/SDL.h" "ac_cv_header_SDL2_SDL_h" "$ac_includes_default"
if test "x$ac_cv_header_SDL2_SDL_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SDL2_SDL_H 1
_ACEOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -lSDL2" >&5
$as_echo_n "checking for -lSDL2... " >&6; }
if ${ac_cv_lib_soname_SDL2+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_soname_save_LIBS=$LIBS
LIBS="-lSDL2 $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char SDL_Init ();
int
main ()
{
return SDL_Init ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
case "$LIBEXT" in
dll) ac_cv_lib_soname_SDL2=`$ac_cv_path_LDD conftest.exe | grep "SDL2" | sed -e "s/dll.*/dll/"';2,$d'` ;;
dylib) ac_cv_lib_soname_SDL2=`$OTOOL -L conftest$ac_exeext | grep "libSDL2-2.0*\\.[0-9A-Za-z.]*dylib" | sed -e "s/^.*\/\(libSDL2-2.0*\.[0-9A-Za-z.]*dylib\).*$/\1/"';2,$d'` ;;
*) ac_cv_lib_soname_SDL2=`$READELF -d conftest$ac_exeext | grep "NEEDED.*libSDL2-2.0*\\.$LIBEXT" | sed -e "s/^.*\\[\\(libSDL2-2.0*\\.$LIBEXT[^ ]*\\)\\].*$/\1/"';2,$d'`
if ${ac_cv_lib_soname_SDL2:+false} :; then :
ac_cv_lib_soname_SDL2=`$LDD conftest$ac_exeext | grep "libSDL2-2.0*\\.$LIBEXT" | sed -e "s/^.*\(libSDL2-2.0*\.$LIBEXT[^ ]*\).*$/\1/"';2,$d'`
fi ;;
esac
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_soname_save_LIBS
fi
if ${ac_cv_lib_soname_SDL2:+false} :; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
$as_echo "not found" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_soname_SDL2" >&5
$as_echo "$ac_cv_lib_soname_SDL2" >&6; }
cat >>confdefs.h <<_ACEOF
#define SONAME_LIBSDL2 "$ac_cv_lib_soname_SDL2"
_ACEOF
fi
fi
done
CPPFLAGS=$ac_save_CPPFLAGS
test -z "$SDL2_CFLAGS" || SDL2_CFLAGS=`echo " $SDL2_CFLAGS" | sed 's/ -I\([^/]\)/ -I\$(top_builddir)\/\1/g'`
test -z "$SDL2_LIBS" || SDL2_LIBS=`echo " $SDL2_LIBS" | sed 's/ -L\([^/]\)/ -L\$(top_builddir)\/\1/g'`
fi
if test "x$SDL_LIBS" = "x"; then :
case "x$with_sdl" in
x) as_fn_append wine_notices "|libSDL2 ${notice_platform}development files not found, SDL2 won't be supported." ;;
xno) ;;
*) as_fn_error $? "libSDL2 ${notice_platform}development files not found, SDL2 won't be supported.
This is an error since --with-sdl was requested." "$LINENO" 5 ;;
esac
fi
if test "x$with_capi" != "xno"
then
if ${CAPI20_CFLAGS:+false} :; then :
......@@ -18169,6 +18281,8 @@ ALSA_LIBS = $ALSA_LIBS
OSS4_CFLAGS = $OSS4_CFLAGS
UDEV_CFLAGS = $UDEV_CFLAGS
UDEV_LIBS = $UDEV_LIBS
SDL2_CFLAGS = $SDL2_CFLAGS
SDL2_LIBS = $SDL2_LIBS
CAPI20_CFLAGS = $CAPI20_CFLAGS
CAPI20_LIBS = $CAPI20_LIBS
CUPS_CFLAGS = $CUPS_CFLAGS
......
......@@ -79,6 +79,7 @@ AC_ARG_WITH(pulse, AS_HELP_STRING([--without-pulse],[do not use PulseAudio s
AC_ARG_WITH(sane, AS_HELP_STRING([--without-sane],[do not use SANE (scanner support)]))
AC_ARG_WITH(tiff, AS_HELP_STRING([--without-tiff],[do not use TIFF]))
AC_ARG_WITH(udev, AS_HELP_STRING([--without-udev],[do not use udev (plug and play support)]))
AC_ARG_WITH(sdl, AS_HELP_STRING([--without-sdl],[do not use SDL]))
AC_ARG_WITH(v4l, AS_HELP_STRING([--without-v4l],[do not use v4l1 (v4l support)]))
AC_ARG_WITH(xcomposite,AS_HELP_STRING([--without-xcomposite],[do not use the Xcomposite extension]),
[if test "x$withval" = "xno"; then ac_cv_header_X11_extensions_Xcomposite_h=no; fi])
......@@ -1592,6 +1593,16 @@ fi
WINE_NOTICE_WITH(udev,[test "x$UDEV_LIBS" = "x"],
[libudev ${notice_platform}development files not found, plug and play won't be supported.])
dnl **** Check for libSDL2 ****
if test "x$with_sdl" != "xno"
then
WINE_PACKAGE_FLAGS(SDL2,[sdl2],[-lSDL2],,,
[AC_CHECK_HEADERS([SDL2/SDL.h],
[WINE_CHECK_SONAME(SDL2,SDL_Init,,,,[[libSDL2-2.0*]])])])
fi
WINE_NOTICE_WITH(sdl,[test "x$SDL_LIBS" = "x"],
[libSDL2 ${notice_platform}development files not found, SDL2 won't be supported.])
dnl **** Check for capi4linux ****
if test "x$with_capi" != "xno"
then
......
MODULE = winebus.sys
IMPORTS = ntoskrnl setupapi
EXTRALIBS = $(IOKIT_LIBS) $(UDEV_LIBS)
EXTRAINCL = $(UDEV_CFLAGS)
EXTRAINCL = $(UDEV_CFLAGS) $(SDL2_CFLAGS)
EXTRADLLFLAGS = -Wb,--subsystem,native
C_SRCS = \
bus_iohid.c \
bus_sdl.c \
bus_udev.c \
main.c
......@@ -21,6 +21,7 @@ typedef int(*enum_func)(DEVICE_OBJECT *device, void *context);
/* Busses */
NTSTATUS WINAPI udev_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_path) DECLSPEC_HIDDEN;
NTSTATUS WINAPI iohid_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_path) DECLSPEC_HIDDEN;
NTSTATUS WINAPI sdl_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_path) DECLSPEC_HIDDEN;
/* Native device function table */
typedef struct
......
/*
* Plug and Play support for hid devices found through SDL2
*
* Copyright 2017 CodeWeavers, Aric Stewart
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdlib.h>
#define NONAMELESSUNION
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "winternl.h"
#include "ddk/wdm.h"
#include "wine/debug.h"
#include "bus.h"
WINE_DEFAULT_DEBUG_CHANNEL(plugplay);
#ifdef SONAME_LIBSDL2
NTSTATUS WINAPI sdl_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_path)
{
FIXME("STUB: (%p, %s)\n", driver, debugstr_w(registry_path->Buffer));
return STATUS_UNSUCCESSFUL;
}
#else
NTSTATUS WINAPI sdl_driver_init(DRIVER_OBJECT *driver, UNICODE_STRING *registry_path)
{
WARN("compiled without SDL support\n");
return STATUS_NOT_IMPLEMENTED;
}
#endif /* SONAME_LIBSDL2 */
......@@ -17,7 +17,7 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdarg.h>
#define NONAMELESSUNION
......@@ -708,9 +708,18 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
static UNICODE_STRING udev = {sizeof(udevW) - sizeof(WCHAR), sizeof(udevW), (WCHAR *)udevW};
static const WCHAR iohidW[] = {'\\','D','r','i','v','e','r','\\','I','O','H','I','D',0};
static UNICODE_STRING iohid = {sizeof(iohidW) - sizeof(WCHAR), sizeof(iohidW), (WCHAR *)iohidW};
static const WCHAR sdlW[] = {'\\','D','r','i','v','e','r','\\','S','D','L','J','O','Y',0};
static UNICODE_STRING sdl = {sizeof(sdlW) - sizeof(WCHAR), sizeof(sdlW), (WCHAR *)sdlW};
static const WCHAR SDL_enabledW[] = {'E','n','a','b','l','e',' ','S','D','L',0};
static const UNICODE_STRING SDL_enabled = {sizeof(SDL_enabledW) - sizeof(WCHAR), sizeof(SDL_enabledW), (WCHAR*)SDL_enabledW};
TRACE( "(%p, %s)\n", driver, debugstr_w(path->Buffer) );
if (check_bus_option(path, &SDL_enabled, 1))
{
if (IoCreateDriver(&sdl, sdl_driver_init) == STATUS_SUCCESS)
return STATUS_SUCCESS;
}
IoCreateDriver(&udev, udev_driver_init);
IoCreateDriver(&iohid, iohid_driver_init);
......
......@@ -840,6 +840,9 @@
/* Define to 1 if you have the <scsi/sg.h> header file. */
#undef HAVE_SCSI_SG_H
/* Define to 1 if you have the <SDL2/SDL.h> header file. */
#undef HAVE_SDL2_SDL_H
/* Define to 1 if you have the <Security/Security.h> header file. */
#undef HAVE_SECURITY_SECURITY_H
......@@ -1515,6 +1518,9 @@
/* Define to the soname of the libsane library. */
#undef SONAME_LIBSANE
/* Define to the soname of the libSDL2 library. */
#undef SONAME_LIBSDL2
/* Define to the soname of the libtiff library. */
#undef SONAME_LIBTIFF
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment