andrewfenn@gmail.com: [4/4] xinput: Added XInputGetCapabilities function with test case

11 views
Skip to first unread message

Patchwatcher

unread,
Oct 31, 2008, 7:14:47 PM10/31/08
to wine-patch...@googlegroups.com
From: "Andrew Fenn" <andre...@gmail.com>
Subject: [4/4] xinput: Added XInputGetCapabilities function with test case
Date: Fri, 31 Oct 2008 18:11:49 +0000

From 85411fc9d473dbf21efa64b50aa71a7dabea3411 Mon Sep 17 00:00:00 2001
From: Andrew Fenn <andre...@gmail.com>
Date: Fri, 31 Oct 2008 17:52:14 +0000
Subject: xinput: Added XInputGetCapabilities function with test case

---
dlls/xinput1_3/tests/xinput.c | 27 +++++++++++++++++++++++++++
dlls/xinput1_3/xinput1_3.spec | 2 +-
dlls/xinput1_3/xinput1_3_main.c | 12 ++++++++++++
3 files changed, 40 insertions(+), 1 deletions(-)

diff --git a/dlls/xinput1_3/tests/xinput.c b/dlls/xinput1_3/tests/xinput.c
index c969bc6..340d68d 100644
--- a/dlls/xinput1_3/tests/xinput.c
+++ b/dlls/xinput1_3/tests/xinput.c
@@ -24,6 +24,7 @@
#include "wine/test.h"

static DWORD (WINAPI *XInputGetState)(DWORD, XINPUT_STATE*)=NULL;
+static DWORD (WINAPI *XInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*)=NULL;

static void test_get_state(void)
{
@@ -64,6 +65,30 @@ static void test_get_state(void)
ok(result == ERROR_BAD_ARGUMENTS, "XInputGetState returned (%d)\n", result);
}

+static void test_get_capabilities(void)
+{
+ XINPUT_CAPABILITIES capabilities;
+ DWORD controllerNum;
+ DWORD result;
+
+ for(controllerNum=0; controllerNum < XUSER_MAX_COUNT; controllerNum++)
+ {
+ ZeroMemory(&capabilities, sizeof(XINPUT_CAPABILITIES));
+
+ result = XInputGetCapabilities(controllerNum, XINPUT_FLAG_GAMEPAD, &capabilities);
+ ok(result == ERROR_SUCCESS || result == ERROR_DEVICE_NOT_CONNECTED, "XInputGetCapabilities failed with (%d)\n", result);
+
+ if (ERROR_DEVICE_NOT_CONNECTED == result)
+ {
+ skip("Controller %d is not connected\n", controllerNum);
+ }
+ }
+
+ ZeroMemory(&capabilities, sizeof(XINPUT_CAPABILITIES));
+ result = XInputGetCapabilities(XUSER_MAX_COUNT+1, XINPUT_FLAG_GAMEPAD, &capabilities);
+ ok(result == ERROR_BAD_ARGUMENTS, "XInputGetCapabilities returned (%d)\n", result);
+}
+
START_TEST(xinput)
{
HMODULE hXinput;
@@ -72,7 +97,9 @@ START_TEST(xinput)
if (hXinput)
{
XInputGetState = (void*)GetProcAddress(hXinput, "XInputGetState");
+ XInputGetCapabilities = (void*)GetProcAddress(hXinput, "XInputGetCapabilities");
test_get_state();
+ test_get_capabilities();
}
else
{
diff --git a/dlls/xinput1_3/xinput1_3.spec b/dlls/xinput1_3/xinput1_3.spec
index 8fb6353..92d45e9 100644
--- a/dlls/xinput1_3/xinput1_3.spec
+++ b/dlls/xinput1_3/xinput1_3.spec
@@ -2,6 +2,6 @@
@ stub XInputSetState #(long ptr)
@ stdcall XInputGetState(long ptr)
@ stub XInputGetKeystroke #(long long ptr)
-@ stub XInputGetCapabilities #(long long ptr)
+@ stdcall 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
index b12b67f..ae48134 100644
--- a/dlls/xinput1_3/xinput1_3_main.c
+++ b/dlls/xinput1_3/xinput1_3_main.c
@@ -57,3 +57,15 @@ DWORD WINAPI XInputGetState(DWORD dwUserIndex, XINPUT_STATE* pState)
}
return ERROR_BAD_ARGUMENTS;
}
+
+DWORD WINAPI XInputGetCapabilities(DWORD dwUserIndex, DWORD dwFlags, XINPUT_CAPABILITIES* pCapabilities)
+{
+ FIXME("(%d %d 0x%08x)\n", dwUserIndex, dwFlags, pCapabilities);
+
+ if (dwUserIndex < XUSER_MAX_COUNT)
+ {
+ return ERROR_DEVICE_NOT_CONNECTED;
+ /* If controller exists then return ERROR_SUCCESS */
+ }
+ return ERROR_BAD_ARGUMENTS;
+}
--
1.5.4.3

Reply all
Reply to author
Forward
0 new messages