xinput: Added XInputGetCapabilities function with test case.

This commit is contained in:
Andrew Fenn 2008-11-10 16:33:15 +00:00 committed by Alexandre Julliard
parent 29789a8ef4
commit 611ebb53e3
3 changed files with 40 additions and 1 deletions

View File

@ -24,6 +24,7 @@
#include "wine/test.h" #include "wine/test.h"
static DWORD (WINAPI *pXInputGetState)(DWORD, XINPUT_STATE*); static DWORD (WINAPI *pXInputGetState)(DWORD, XINPUT_STATE*);
static DWORD (WINAPI *pXInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*);
static void test_get_state(void) 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); 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 = pXInputGetCapabilities(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 = pXInputGetCapabilities(XUSER_MAX_COUNT+1, XINPUT_FLAG_GAMEPAD, &capabilities);
ok(result == ERROR_BAD_ARGUMENTS, "XInputGetCapabilities returned (%d)\n", result);
}
START_TEST(xinput) START_TEST(xinput)
{ {
HMODULE hXinput; HMODULE hXinput;
@ -72,7 +97,9 @@ START_TEST(xinput)
if (hXinput) if (hXinput)
{ {
pXInputGetState = (void*)GetProcAddress(hXinput, "XInputGetState"); pXInputGetState = (void*)GetProcAddress(hXinput, "XInputGetState");
pXInputGetCapabilities = (void*)GetProcAddress(hXinput, "XInputGetCapabilities");
test_get_state(); test_get_state();
test_get_capabilities();
} }
else else
{ {

View File

@ -2,6 +2,6 @@
@ stub XInputSetState #(long ptr) @ stub XInputSetState #(long ptr)
@ stdcall XInputGetState(long ptr) @ stdcall XInputGetState(long ptr)
@ stub XInputGetKeystroke #(long long ptr) @ stub XInputGetKeystroke #(long long ptr)
@ stub XInputGetCapabilities #(long long ptr) @ stdcall XInputGetCapabilities(long long ptr)
@ stub XInputGetDSoundAudioDeviceGuids #(long ptr ptr) @ stub XInputGetDSoundAudioDeviceGuids #(long ptr ptr)
@ stub XInputGetBatteryInformation @ stub XInputGetBatteryInformation

View File

@ -57,3 +57,15 @@ DWORD WINAPI XInputGetState(DWORD dwUserIndex, XINPUT_STATE* pState)
} }
return ERROR_BAD_ARGUMENTS; return ERROR_BAD_ARGUMENTS;
} }
DWORD WINAPI XInputGetCapabilities(DWORD dwUserIndex, DWORD dwFlags, XINPUT_CAPABILITIES* pCapabilities)
{
FIXME("(%d %d %p)\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;
}