Author: akhaldi
Date: Thu Nov 17 23:29:18 2016
New Revision: 73310
URL:
http://svn.reactos.org/svn/reactos?rev=73310&view=rev
Log:
[XINPUT1_3_WINETEST] Sync with Wine Staging 1.9.23. CORE-12409
Modified:
trunk/rostests/winetests/xinput1_3/xinput.c
Modified: trunk/rostests/winetests/xinput1_3/xinput.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/xinput1_3/xinpu…
==============================================================================
--- trunk/rostests/winetests/xinput1_3/xinput.c [iso-8859-1] (original)
+++ trunk/rostests/winetests/xinput1_3/xinput.c [iso-8859-1] Thu Nov 17 23:29:18 2016
@@ -24,6 +24,7 @@
#include "wine/test.h"
static DWORD (WINAPI *pXInputGetState)(DWORD, XINPUT_STATE*);
+static DWORD (WINAPI *pXInputGetStateEx)(DWORD, XINPUT_STATE_EX*);
static DWORD (WINAPI *pXInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*);
static DWORD (WINAPI *pXInputSetState)(DWORD, XINPUT_VIBRATION*);
static void (WINAPI *pXInputEnable)(BOOL);
@@ -46,14 +47,14 @@
result = pXInputSetState(controllerNum, &vibrator);
ok(result == ERROR_SUCCESS || result == ERROR_DEVICE_NOT_CONNECTED,
"XInputSetState failed with (%d)\n", result);
- pXInputEnable(0);
+ if (pXInputEnable) pXInputEnable(0);
vibrator.wLeftMotorSpeed = 65535;
vibrator.wRightMotorSpeed = 65535;
result = pXInputSetState(controllerNum, &vibrator);
ok(result == ERROR_SUCCESS || result == ERROR_DEVICE_NOT_CONNECTED,
"XInputSetState failed with (%d)\n", result);
- pXInputEnable(1);
+ if (pXInputEnable) pXInputEnable(1);
}
result = pXInputSetState(XUSER_MAX_COUNT+1, &vibrator);
@@ -62,41 +63,63 @@
static void test_get_state(void)
{
-
- XINPUT_STATE controllerState;
- DWORD controllerNum;
- DWORD result;
-
- for(controllerNum=0; controllerNum < XUSER_MAX_COUNT; controllerNum++)
- {
- ZeroMemory(&controllerState, sizeof(XINPUT_STATE));
-
- result = pXInputGetState(controllerNum, &controllerState);
- ok(result == ERROR_SUCCESS || result == ERROR_DEVICE_NOT_CONNECTED,
"XInputGetState failed with (%d)\n", result);
-
- if (ERROR_DEVICE_NOT_CONNECTED == result)
- {
- skip("Controller %d is not connected\n", controllerNum);
- }
- else
- {
+ union
+ {
+ XINPUT_STATE state;
+ XINPUT_STATE_EX state_ex;
+ } xinput;
+ DWORD controllerNum, i;
+ DWORD result;
+
+ for (i = 0; i < (pXInputGetStateEx ? 2 : 1); i++)
+ {
+ for (controllerNum = 0; controllerNum < XUSER_MAX_COUNT; controllerNum++)
+ {
+ ZeroMemory(&xinput, sizeof(xinput));
+
+ if (i == 0)
+ result = pXInputGetState(controllerNum, &xinput.state);
+ else
+ result = pXInputGetStateEx(controllerNum, &xinput.state_ex);
+ ok(result == ERROR_SUCCESS || result == ERROR_DEVICE_NOT_CONNECTED,
+ "%s failed with (%d)\n", i == 0 ? "XInputGetState" :
"XInputGetStateEx", result);
+
+ if (ERROR_DEVICE_NOT_CONNECTED == result)
+ {
+ skip("Controller %d is not connected\n", controllerNum);
+ continue;
+ }
+
trace("-- Results for controller %d --\n", controllerNum);
- trace("XInputGetState: %d\n", result);
- trace("State->dwPacketNumber: %d\n",
controllerState.dwPacketNumber);
+ if (i == 0)
+ trace("XInputGetState: %d\n", result);
+ else
+ trace("XInputGetStateEx: %d\n", result);
+ trace("State->dwPacketNumber: %d\n",
xinput.state.dwPacketNumber);
trace("Gamepad Variables --\n");
- trace("Gamepad.wButtons: %#x\n",
controllerState.Gamepad.wButtons);
- trace("Gamepad.bLeftTrigger: 0x%08x\n",
controllerState.Gamepad.bLeftTrigger);
- trace("Gamepad.bRightTrigger: 0x%08x\n",
controllerState.Gamepad.bRightTrigger);
- trace("Gamepad.sThumbLX: %d\n", controllerState.Gamepad.sThumbLX);
- trace("Gamepad.sThumbLY: %d\n", controllerState.Gamepad.sThumbLY);
- trace("Gamepad.sThumbRX: %d\n", controllerState.Gamepad.sThumbRX);
- trace("Gamepad.sThumbRY: %d\n", controllerState.Gamepad.sThumbRY);
- }
- }
-
- ZeroMemory(&controllerState, sizeof(XINPUT_STATE));
- result = pXInputGetState(XUSER_MAX_COUNT+1, &controllerState);
+ trace("Gamepad.wButtons: %#x\n", xinput.state.Gamepad.wButtons);
+ trace("Gamepad.bLeftTrigger: 0x%08x\n",
xinput.state.Gamepad.bLeftTrigger);
+ trace("Gamepad.bRightTrigger: 0x%08x\n",
xinput.state.Gamepad.bRightTrigger);
+ trace("Gamepad.sThumbLX: %d\n", xinput.state.Gamepad.sThumbLX);
+ trace("Gamepad.sThumbLY: %d\n", xinput.state.Gamepad.sThumbLY);
+ trace("Gamepad.sThumbRX: %d\n", xinput.state.Gamepad.sThumbRX);
+ trace("Gamepad.sThumbRY: %d\n", xinput.state.Gamepad.sThumbRY);
+ }
+ }
+
+ result = pXInputGetState(XUSER_MAX_COUNT, &xinput.state);
ok(result == ERROR_BAD_ARGUMENTS, "XInputGetState returned (%d)\n",
result);
+
+ result = pXInputGetState(XUSER_MAX_COUNT+1, &xinput.state);
+ ok(result == ERROR_BAD_ARGUMENTS, "XInputGetState returned (%d)\n",
result);
+ if (pXInputGetStateEx)
+ {
+ result = pXInputGetStateEx(XUSER_MAX_COUNT, &xinput.state_ex);
+ ok(result == ERROR_BAD_ARGUMENTS, "XInputGetState returned (%d)\n",
result);
+
+ result = pXInputGetStateEx(XUSER_MAX_COUNT+1, &xinput.state_ex);
+ ok(result == ERROR_BAD_ARGUMENTS, "XInputGetState returned (%d)\n",
result);
+ }
}
static void test_get_keystroke(void)
@@ -110,7 +133,8 @@
ZeroMemory(&keystroke, sizeof(XINPUT_KEYSTROKE));
result = pXInputGetKeystroke(controllerNum, XINPUT_FLAG_GAMEPAD,
&keystroke);
- ok(result == ERROR_SUCCESS || result == ERROR_DEVICE_NOT_CONNECTED,
"XInputGetKeystroke failed with (%d)\n", result);
+ ok(result == ERROR_EMPTY || result == ERROR_SUCCESS || result ==
ERROR_DEVICE_NOT_CONNECTED,
+ "XInputGetKeystroke failed with (%d)\n", result);
if (ERROR_DEVICE_NOT_CONNECTED == result)
{
@@ -195,29 +219,70 @@
START_TEST(xinput)
{
+ struct
+ {
+ const char *name;
+ int version;
+ } libs[] = {
+ { "xinput1_1.dll", 1 },
+ { "xinput1_2.dll", 2 },
+ { "xinput1_3.dll", 3 },
+ { "xinput1_4.dll", 4 },
+ { "xinput9_1_0.dll", 0 } /* legacy for XP/Vista */
+ };
HMODULE hXinput;
- hXinput = LoadLibraryA( "xinput1_3.dll" );
-
- if (!hXinput)
- {
- win_skip("Could not load xinput1_3.dll\n");
- return;
- }
-
- pXInputEnable = (void*)GetProcAddress(hXinput, "XInputEnable");
- pXInputSetState = (void*)GetProcAddress(hXinput, "XInputSetState");
- pXInputGetState = (void*)GetProcAddress(hXinput, "XInputGetState");
- pXInputGetKeystroke = (void*)GetProcAddress(hXinput,
"XInputGetKeystroke");
- pXInputGetCapabilities = (void*)GetProcAddress(hXinput,
"XInputGetCapabilities");
- pXInputGetDSoundAudioDeviceGuids = (void*)GetProcAddress(hXinput,
"XInputGetDSoundAudioDeviceGuids");
- pXInputGetBatteryInformation = (void*)GetProcAddress(hXinput,
"XInputGetBatteryInformation");
-
- test_set_state();
- test_get_state();
- test_get_keystroke();
- test_get_capabilities();
- test_get_dsoundaudiodevice();
- test_get_batteryinformation();
-
- FreeLibrary(hXinput);
-}
+ void *pXInputGetStateEx_Ordinal;
+ int i;
+
+ for (i = 0; i < sizeof(libs) / sizeof(libs[0]); i++)
+ {
+ hXinput = LoadLibraryA( libs[i].name );
+
+ if (!hXinput)
+ {
+ win_skip("Could not load %s\n", libs[i].name);
+ continue;
+ }
+ trace("Testing %s\n", libs[i].name);
+
+ pXInputEnable = (void*)GetProcAddress(hXinput, "XInputEnable");
+ pXInputSetState = (void*)GetProcAddress(hXinput, "XInputSetState");
+ pXInputGetState = (void*)GetProcAddress(hXinput, "XInputGetState");
+ pXInputGetStateEx = (void*)GetProcAddress(hXinput, "XInputGetStateEx");
/* Win >= 8 */
+ pXInputGetStateEx_Ordinal = (void*)GetProcAddress(hXinput, (LPCSTR) 100);
+ pXInputGetKeystroke = (void*)GetProcAddress(hXinput,
"XInputGetKeystroke");
+ pXInputGetCapabilities = (void*)GetProcAddress(hXinput,
"XInputGetCapabilities");
+ pXInputGetDSoundAudioDeviceGuids = (void*)GetProcAddress(hXinput,
"XInputGetDSoundAudioDeviceGuids");
+ pXInputGetBatteryInformation = (void*)GetProcAddress(hXinput,
"XInputGetBatteryInformation");
+
+ /* XInputGetStateEx may not be present by name, use ordinal in this case */
+ if (!pXInputGetStateEx)
+ pXInputGetStateEx = pXInputGetStateEx_Ordinal;
+
+ test_set_state();
+ test_get_state();
+ test_get_capabilities();
+
+ if (libs[i].version != 4)
+ test_get_dsoundaudiodevice();
+ else
+ ok(!pXInputGetDSoundAudioDeviceGuids, "XInputGetDSoundAudioDeviceGuids
exists in %s\n", libs[i].name);
+
+ if (libs[i].version > 2)
+ {
+ test_get_keystroke();
+ test_get_batteryinformation();
+ ok(pXInputGetStateEx != NULL, "XInputGetStateEx not found in %s\n",
libs[i].name);
+ }
+ else
+ {
+ ok(!pXInputGetKeystroke, "XInputGetKeystroke exists in %s\n",
libs[i].name);
+ ok(!pXInputGetStateEx, "XInputGetStateEx exists in %s\n",
libs[i].name);
+ ok(!pXInputGetBatteryInformation, "XInputGetBatteryInformation exists in
%s\n", libs[i].name);
+ if (libs[i].version == 0)
+ ok(!pXInputEnable, "XInputEnable exists in %s\n",
libs[i].name);
+ }
+
+ FreeLibrary(hXinput);
+ }
+}