From 457a22deac90ba47a785d09cf4c6d53991287794 Mon Sep 17 00:00:00 2001
From: Andrew Fenn <andrewfenn@gmail.com>
Date: Mon, 10 Nov 2008 16:22:35 +0000
Subject: [PATCH] xinput1_3: Initial implementation.

---
 .gitignore                      |  1 +
 configure                       |  9 +++++++
 configure.ac                    |  1 +
 dlls/Makefile.in                | 19 +++++++++++---
 dlls/xinput1_3/Makefile.in      | 16 ++++++++++++
 dlls/xinput1_3/version.rc       | 27 ++++++++++++++++++++
 dlls/xinput1_3/xinput1_3.spec   |  7 +++++
 dlls/xinput1_3/xinput1_3_main.c | 45 +++++++++++++++++++++++++++++++++
 8 files changed, 122 insertions(+), 3 deletions(-)
 create mode 100644 dlls/xinput1_3/Makefile.in
 create mode 100644 dlls/xinput1_3/version.rc
 create mode 100644 dlls/xinput1_3/xinput1_3.spec
 create mode 100644 dlls/xinput1_3/xinput1_3_main.c

diff --git a/.gitignore b/.gitignore
index 1caea1bc939..afd7219b40d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -48,6 +48,7 @@ dlls/keyboard.drv16
 dlls/krnl386.exe16
 dlls/libd3dx9.def
 dlls/libwinspool.def
+dlls/libxinput.def
 dlls/lzexpand.dll16
 dlls/mmsystem.dll16
 dlls/mouse.drv16
diff --git a/configure b/configure
index 6918414fc0f..632b942dc7e 100755
--- a/configure
+++ b/configure
@@ -26833,6 +26833,14 @@ ALL_MAKEFILE_DEPENDS="$ALL_MAKEFILE_DEPENDS
 dlls/wtsapi32/Makefile: dlls/wtsapi32/Makefile.in dlls/Makedll.rules"
 ac_config_files="$ac_config_files dlls/wtsapi32/Makefile"
 
+ALL_MAKEFILES="$ALL_MAKEFILES \\
+	dlls/xinput1_3/Makefile"
+test "x$enable_xinput1_3" != xno && ALL_DLL_DIRS="$ALL_DLL_DIRS \\
+	xinput1_3"
+ALL_MAKEFILE_DEPENDS="$ALL_MAKEFILE_DEPENDS
+dlls/xinput1_3/Makefile: dlls/xinput1_3/Makefile.in dlls/Makedll.rules"
+ac_config_files="$ac_config_files dlls/xinput1_3/Makefile"
+
 ALL_MAKEFILES="$ALL_MAKEFILES \\
 	documentation/Makefile"
 test "x$enable_documentation" != xno && ALL_TOP_DIRS="$ALL_TOP_DIRS \\
@@ -28365,6 +28373,7 @@ do
     "dlls/ws2_32/tests/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/ws2_32/tests/Makefile" ;;
     "dlls/wsock32/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/wsock32/Makefile" ;;
     "dlls/wtsapi32/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/wtsapi32/Makefile" ;;
+    "dlls/xinput1_3/Makefile") CONFIG_FILES="$CONFIG_FILES dlls/xinput1_3/Makefile" ;;
     "documentation/Makefile") CONFIG_FILES="$CONFIG_FILES documentation/Makefile" ;;
     "fonts/Makefile") CONFIG_FILES="$CONFIG_FILES fonts/Makefile" ;;
     "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;;
diff --git a/configure.ac b/configure.ac
index e83ee37ab04..663df149add 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2094,6 +2094,7 @@ WINE_CONFIG_MAKEFILE([dlls/ws2_32/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL
 WINE_CONFIG_MAKEFILE([dlls/ws2_32/tests/Makefile],[dlls/Maketest.rules],[dlls],[ALL_TEST_DIRS])
 WINE_CONFIG_MAKEFILE([dlls/wsock32/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
 WINE_CONFIG_MAKEFILE([dlls/wtsapi32/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
+WINE_CONFIG_MAKEFILE([dlls/xinput1_3/Makefile],[dlls/Makedll.rules],[dlls],[ALL_DLL_DIRS])
 WINE_CONFIG_MAKEFILE([documentation/Makefile],[Make.rules],[],[ALL_TOP_DIRS])
 WINE_CONFIG_MAKEFILE([fonts/Makefile],[Make.rules],[],[ALL_TOP_DIRS])
 WINE_CONFIG_MAKEFILE([include/Makefile],[Make.rules],[],[ALL_TOP_DIRS])
diff --git a/dlls/Makefile.in b/dlls/Makefile.in
index 69d30b9f367..56e0506cd7c 100644
--- a/dlls/Makefile.in
+++ b/dlls/Makefile.in
@@ -165,7 +165,8 @@ STATIC_IMPLIBEXT = $(IMPLIBEXT:def=def.a)
 
 IMPORT_SYMLINKS = \
 	libd3dx9.$(IMPLIBEXT) \
-	libwinspool.$(IMPLIBEXT)
+	libwinspool.$(IMPLIBEXT) \
+	libxinput.$(IMPLIBEXT)
 
 IMPORT_LIBS = \
 	$(IMPORT_SYMLINKS) \
@@ -311,11 +312,13 @@ IMPORT_LIBS = \
 	wow32/libwow32.$(IMPLIBEXT) \
 	ws2_32/libws2_32.$(IMPLIBEXT) \
 	wsock32/libwsock32.$(IMPLIBEXT) \
-	wtsapi32/libwtsapi32.$(IMPLIBEXT)
+	wtsapi32/libwtsapi32.$(IMPLIBEXT) \
+	xinput1_3/libxinput.$(IMPLIBEXT)
 
 CROSS_IMPLIBS = \
 	libd3dx9.a \
 	libwinspool.a \
+	libxinput.a \
 	activeds/libactiveds.a \
 	advapi32/libadvapi32.a \
 	advpack/libadvpack.a \
@@ -449,7 +452,8 @@ CROSS_IMPLIBS = \
 	wow32/libwow32.a \
 	ws2_32/libws2_32.a \
 	wsock32/libwsock32.a \
-	wtsapi32/libwtsapi32.a
+	wtsapi32/libwtsapi32.a \
+	xinput1_3/libxinput.a
 
 $(TESTSUBDIRS:%=%/__crosstest__): $(CROSS_IMPLIBS)
 
@@ -865,6 +869,9 @@ wsock32/libwsock32.def wsock32/libwsock32.a: wsock32/wsock32.spec $(WINEBUILD)
 wtsapi32/libwtsapi32.def wtsapi32/libwtsapi32.a: wtsapi32/wtsapi32.spec $(WINEBUILD)
 	@cd wtsapi32 && $(MAKE) `basename $@`
 
+xinput1_3/libxinput.def xinput1_3/libxinput.a: xinput1_3/xinput1_3.spec $(WINEBUILD)
+	@cd xinput1_3 && $(MAKE) `basename $@`
+
 libd3dx9.a: d3dx9_36/libd3dx9.a
 	$(RM) $@ && $(LN_S) d3dx9_36/libd3dx9.a $@
 
@@ -877,6 +884,12 @@ libwinspool.a: winspool.drv/libwinspool.a
 libwinspool.def: winspool.drv/libwinspool.def
 	$(RM) $@ && $(LN_S) winspool.drv/libwinspool.def $@
 
+libxinput.a: xinput1_3/libxinput.a
+	$(RM) $@ && $(LN_S) xinput1_3/libxinput.a $@
+
+libxinput.def: xinput1_3/libxinput.def
+	$(RM) $@ && $(LN_S) xinput1_3/libxinput.def $@
+
 $(BUILDSUBDIRS): $(IMPORT_LIBS)
 $(INSTALLSUBDIRS:%=%/__install__) $(INSTALLSUBDIRS:%=%/__install-lib__): $(IMPORT_LIBS)
 
diff --git a/dlls/xinput1_3/Makefile.in b/dlls/xinput1_3/Makefile.in
new file mode 100644
index 00000000000..7e8f5715743
--- /dev/null
+++ b/dlls/xinput1_3/Makefile.in
@@ -0,0 +1,16 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = xinput1_3.dll
+IMPORTLIB = xinput
+IMPORTS   = kernel32
+
+C_SRCS = \
+	xinput1_3_main.c
+
+RC_SRCS = version.rc
+
+@MAKE_DLL_RULES@
+
+@DEPENDENCIES@  # everything below this line is overwritten by make depend
diff --git a/dlls/xinput1_3/version.rc b/dlls/xinput1_3/version.rc
new file mode 100644
index 00000000000..191b1425313
--- /dev/null
+++ b/dlls/xinput1_3/version.rc
@@ -0,0 +1,27 @@
+/*
+ * The Wine project - Xinput Joystick Library
+ * Copyright 2008 Andrew Fenn
+ *
+ * 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
+ */
+
+#define WINE_FILEDESCRIPTION_STR "Wine Common Controller API"
+#define WINE_FILENAME_STR "xinput1_3.dll"
+#define WINE_FILEVERSION 9,15,779,0000
+#define WINE_FILEVERSION_STR "9.15.779.0000"
+#define WINE_PRODUCTVERSION 9,15,779,0000
+#define WINE_PRODUCTVERSION_STR "9.15"
+
+#include "wine/wine_common_ver.rc"
diff --git a/dlls/xinput1_3/xinput1_3.spec b/dlls/xinput1_3/xinput1_3.spec
new file mode 100644
index 00000000000..5caaa37b9d9
--- /dev/null
+++ b/dlls/xinput1_3/xinput1_3.spec
@@ -0,0 +1,7 @@
+@ stub XInputEnable #(long)
+@ stub XInputSetState #(long ptr)
+@ stub XInputGetState #(long ptr)
+@ stub XInputGetKeystroke #(long long ptr)
+@ stub XInputGetCapabilities #(long long ptr)
+@ stub XInputGetDSoundAudioDeviceGuids #(long ptr ptr)
+@ stub XInputGetBatteryInformation
diff --git a/dlls/xinput1_3/xinput1_3_main.c b/dlls/xinput1_3/xinput1_3_main.c
new file mode 100644
index 00000000000..6198b3b4bf4
--- /dev/null
+++ b/dlls/xinput1_3/xinput1_3_main.c
@@ -0,0 +1,45 @@
+/*
+ * The Wine project - Xinput Joystick Library
+ * Copyright 2008 Andrew Fenn
+ *
+ * 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 <assert.h>
+#include <stdarg.h>
+#include <string.h>
+
+#include "wine/debug.h"
+#include "windef.h"
+#include "winbase.h"
+#include "winerror.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(xinput);
+
+BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved)
+{
+    switch(reason)
+    {
+    case DLL_WINE_PREATTACH:
+        return FALSE; /* prefer native version */
+    case DLL_PROCESS_ATTACH:
+        DisableThreadLibraryCalls(inst);
+        break;
+    case DLL_PROCESS_DETACH:
+        break;
+    }
+    return TRUE;
+}
-- 
GitLab