2 * The Wine project - Xinput Joystick Library
3 * Copyright 2008 Andrew Fenn
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "wine/test.h"
26 static DWORD (WINAPI *pXInputGetState)(DWORD, XINPUT_STATE*);
27 static DWORD (WINAPI *pXInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*);
29 static void test_get_state(void)
32 XINPUT_STATE controllerState;
36 for(controllerNum=0; controllerNum < XUSER_MAX_COUNT; controllerNum++)
38 ZeroMemory(&controllerState, sizeof(XINPUT_STATE));
40 result = pXInputGetState(controllerNum, &controllerState);
41 ok(result == ERROR_SUCCESS || result == ERROR_DEVICE_NOT_CONNECTED, "XInputGetState failed with (%d)\n", result);
43 if (ERROR_DEVICE_NOT_CONNECTED == result)
45 skip("Controller %d is not connected\n", controllerNum);
49 trace("-- Results for controller %d --\n", controllerNum);
50 trace("XInputGetState: %d\n", result);
51 trace("State->dwPacketNumber: %d\n", controllerState.dwPacketNumber);
52 trace("Gamepad Variables --\n");
53 trace("Gamepad.wButtons: %#x\n", controllerState.Gamepad.wButtons);
54 trace("Gamepad.bLeftTrigger: 0x%08x\n", controllerState.Gamepad.bLeftTrigger);
55 trace("Gamepad.bRightTrigger: 0x%08x\n", controllerState.Gamepad.bRightTrigger);
56 trace("Gamepad.sThumbLX: %d\n", controllerState.Gamepad.sThumbLX);
57 trace("Gamepad.sThumbLY: %d\n", controllerState.Gamepad.sThumbLY);
58 trace("Gamepad.sThumbRX: %d\n", controllerState.Gamepad.sThumbRX);
59 trace("Gamepad.sThumbRY: %d\n", controllerState.Gamepad.sThumbRY);
63 ZeroMemory(&controllerState, sizeof(XINPUT_STATE));
64 result = pXInputGetState(XUSER_MAX_COUNT+1, &controllerState);
65 ok(result == ERROR_BAD_ARGUMENTS, "XInputGetState returned (%d)\n", result);
68 static void test_get_capabilities(void)
70 XINPUT_CAPABILITIES capabilities;
74 for(controllerNum=0; controllerNum < XUSER_MAX_COUNT; controllerNum++)
76 ZeroMemory(&capabilities, sizeof(XINPUT_CAPABILITIES));
78 result = pXInputGetCapabilities(controllerNum, XINPUT_FLAG_GAMEPAD, &capabilities);
79 ok(result == ERROR_SUCCESS || result == ERROR_DEVICE_NOT_CONNECTED, "XInputGetCapabilities failed with (%d)\n", result);
81 if (ERROR_DEVICE_NOT_CONNECTED == result)
83 skip("Controller %d is not connected\n", controllerNum);
87 ZeroMemory(&capabilities, sizeof(XINPUT_CAPABILITIES));
88 result = pXInputGetCapabilities(XUSER_MAX_COUNT+1, XINPUT_FLAG_GAMEPAD, &capabilities);
89 ok(result == ERROR_BAD_ARGUMENTS, "XInputGetCapabilities returned (%d)\n", result);
95 hXinput = LoadLibraryA( "xinput1_3.dll" );
99 pXInputGetState = (void*)GetProcAddress(hXinput, "XInputGetState");
100 pXInputGetCapabilities = (void*)GetProcAddress(hXinput, "XInputGetCapabilities");
102 test_get_capabilities();
106 skip("Could not load xinput1_3.dll\n");