dinput/tests: Add more tests for simulation HID usages.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
2f41101b95
commit
21cdca2d8c
|
@ -2590,6 +2590,238 @@ static BOOL test_device_types( DWORD version )
|
|||
return success;
|
||||
}
|
||||
|
||||
static void test_driving_wheel_axes(void)
|
||||
{
|
||||
#include "psh_hid_macros.h"
|
||||
static const unsigned char report_desc[] =
|
||||
{
|
||||
USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC),
|
||||
USAGE(1, HID_USAGE_GENERIC_JOYSTICK),
|
||||
COLLECTION(1, Application),
|
||||
USAGE(1, HID_USAGE_GENERIC_JOYSTICK),
|
||||
COLLECTION(1, Report),
|
||||
REPORT_ID(1, 1),
|
||||
|
||||
USAGE_PAGE(1, HID_USAGE_PAGE_SIMULATION),
|
||||
USAGE(1, HID_USAGE_SIMULATION_RUDDER),
|
||||
USAGE(1, HID_USAGE_SIMULATION_THROTTLE),
|
||||
USAGE(1, HID_USAGE_SIMULATION_ACCELERATOR),
|
||||
USAGE(1, HID_USAGE_SIMULATION_BRAKE),
|
||||
USAGE(1, HID_USAGE_SIMULATION_CLUTCH),
|
||||
USAGE(1, HID_USAGE_SIMULATION_STEERING),
|
||||
LOGICAL_MINIMUM(1, 0),
|
||||
LOGICAL_MAXIMUM(1, 0x7f),
|
||||
PHYSICAL_MINIMUM(1, 0),
|
||||
PHYSICAL_MAXIMUM(1, 0x7f),
|
||||
REPORT_SIZE(1, 8),
|
||||
REPORT_COUNT(1, 6),
|
||||
INPUT(1, Data|Var|Abs),
|
||||
END_COLLECTION,
|
||||
END_COLLECTION,
|
||||
};
|
||||
#undef REPORT_ID_OR_USAGE_PAGE
|
||||
#include "pop_hid_macros.h"
|
||||
|
||||
static const HIDP_CAPS hid_caps =
|
||||
{
|
||||
.InputReportByteLength = 7,
|
||||
};
|
||||
const DIDEVCAPS expect_caps =
|
||||
{
|
||||
.dwSize = sizeof(DIDEVCAPS),
|
||||
.dwFlags = DIDC_ATTACHED | DIDC_EMULATED,
|
||||
.dwDevType = DIDEVTYPE_HID | (DI8DEVTYPEDRIVING_LIMITED << 8) | DI8DEVTYPE_DRIVING,
|
||||
.dwAxes = 6,
|
||||
};
|
||||
const DIDEVICEINSTANCEW expect_devinst =
|
||||
{
|
||||
.dwSize = sizeof(DIDEVICEINSTANCEW),
|
||||
.guidInstance = expect_guid_product,
|
||||
.guidProduct = expect_guid_product,
|
||||
.dwDevType = DIDEVTYPE_HID | (DI8DEVTYPEDRIVING_LIMITED << 8) | DI8DEVTYPE_DRIVING,
|
||||
.tszInstanceName = L"Wine test root driver",
|
||||
.tszProductName = L"Wine test root driver",
|
||||
.guidFFDriver = GUID_NULL,
|
||||
.wUsagePage = HID_USAGE_PAGE_GENERIC,
|
||||
.wUsage = HID_USAGE_GENERIC_JOYSTICK,
|
||||
};
|
||||
const DIDEVICEOBJECTINSTANCEW expect_objects[] =
|
||||
{
|
||||
{
|
||||
.dwSize = sizeof(DIDEVICEOBJECTINSTANCEW),
|
||||
.guidType = GUID_XAxis,
|
||||
.dwOfs = 0,
|
||||
.dwType = DIDFT_ABSAXIS|DIDFT_MAKEINSTANCE(0),
|
||||
.dwFlags = DIDOI_ASPECTPOSITION,
|
||||
.tszName = L"Steering",
|
||||
.wCollectionNumber = 1,
|
||||
.wUsagePage = HID_USAGE_PAGE_SIMULATION,
|
||||
.wUsage = HID_USAGE_SIMULATION_STEERING,
|
||||
.wReportId = 1,
|
||||
},
|
||||
{
|
||||
.dwSize = sizeof(DIDEVICEOBJECTINSTANCEW),
|
||||
.guidType = GUID_Unknown,
|
||||
.dwOfs = 0x4,
|
||||
.dwType = DIDFT_ABSAXIS|DIDFT_MAKEINSTANCE(6),
|
||||
.dwFlags = 0,
|
||||
.tszName = L"Clutch",
|
||||
.wCollectionNumber = 1,
|
||||
.wUsagePage = HID_USAGE_PAGE_SIMULATION,
|
||||
.wUsage = HID_USAGE_SIMULATION_CLUTCH,
|
||||
.wReportId = 1,
|
||||
},
|
||||
{
|
||||
.dwSize = sizeof(DIDEVICEOBJECTINSTANCEW),
|
||||
.guidType = GUID_RzAxis,
|
||||
.dwOfs = 0x8,
|
||||
.dwType = DIDFT_ABSAXIS|DIDFT_MAKEINSTANCE(5),
|
||||
.dwFlags = DIDOI_ASPECTPOSITION,
|
||||
.tszName = L"Brake",
|
||||
.wCollectionNumber = 1,
|
||||
.wUsagePage = HID_USAGE_PAGE_SIMULATION,
|
||||
.wUsage = HID_USAGE_SIMULATION_BRAKE,
|
||||
.wReportId = 1,
|
||||
},
|
||||
{
|
||||
.dwSize = sizeof(DIDEVICEOBJECTINSTANCEW),
|
||||
.guidType = GUID_YAxis,
|
||||
.dwOfs = 0xc,
|
||||
.dwType = DIDFT_ABSAXIS|DIDFT_MAKEINSTANCE(1),
|
||||
.dwFlags = DIDOI_ASPECTPOSITION,
|
||||
.tszName = L"Accelerator",
|
||||
.wCollectionNumber = 1,
|
||||
.wUsagePage = HID_USAGE_PAGE_SIMULATION,
|
||||
.wUsage = HID_USAGE_SIMULATION_ACCELERATOR,
|
||||
.wReportId = 1,
|
||||
},
|
||||
{
|
||||
.dwSize = sizeof(DIDEVICEOBJECTINSTANCEW),
|
||||
.guidType = GUID_Slider,
|
||||
.dwOfs = 0x10,
|
||||
.dwType = DIDFT_ABSAXIS|DIDFT_MAKEINSTANCE(2),
|
||||
.dwFlags = DIDOI_ASPECTPOSITION,
|
||||
.tszName = L"Throttle",
|
||||
.wCollectionNumber = 1,
|
||||
.wUsagePage = HID_USAGE_PAGE_SIMULATION,
|
||||
.wUsage = HID_USAGE_SIMULATION_THROTTLE,
|
||||
.wReportId = 1,
|
||||
},
|
||||
{
|
||||
.dwSize = sizeof(DIDEVICEOBJECTINSTANCEW),
|
||||
.guidType = GUID_RzAxis,
|
||||
.dwOfs = 0x14,
|
||||
.dwType = DIDFT_ABSAXIS|DIDFT_MAKEINSTANCE(7),
|
||||
.dwFlags = DIDOI_ASPECTPOSITION,
|
||||
.tszName = L"Rudder",
|
||||
.wCollectionNumber = 1,
|
||||
.wUsagePage = HID_USAGE_PAGE_SIMULATION,
|
||||
.wUsage = HID_USAGE_SIMULATION_RUDDER,
|
||||
.wReportId = 1,
|
||||
},
|
||||
{
|
||||
.dwSize = sizeof(DIDEVICEOBJECTINSTANCEW),
|
||||
.guidType = GUID_Unknown,
|
||||
.dwType = DIDFT_COLLECTION|DIDFT_NODATA|DIDFT_MAKEINSTANCE(0),
|
||||
.tszName = L"Collection 0 - Joystick",
|
||||
.wUsagePage = HID_USAGE_PAGE_GENERIC,
|
||||
.wUsage = HID_USAGE_GENERIC_JOYSTICK,
|
||||
},
|
||||
{
|
||||
.dwSize = sizeof(DIDEVICEOBJECTINSTANCEW),
|
||||
.guidType = GUID_Unknown,
|
||||
.dwType = DIDFT_COLLECTION|DIDFT_NODATA|DIDFT_MAKEINSTANCE(1),
|
||||
.tszName = L"Collection 1 - Joystick",
|
||||
.wUsagePage = HID_USAGE_PAGE_GENERIC,
|
||||
.wUsage = HID_USAGE_GENERIC_JOYSTICK,
|
||||
},
|
||||
};
|
||||
struct check_objects_todos object_todos[ARRAY_SIZE(expect_objects)] =
|
||||
{
|
||||
{.name = TRUE},
|
||||
{.name = TRUE},
|
||||
{.name = TRUE},
|
||||
{.name = TRUE},
|
||||
{.name = TRUE},
|
||||
};
|
||||
struct check_objects_params check_objects_params =
|
||||
{
|
||||
.version = DIRECTINPUT_VERSION,
|
||||
.expect_count = ARRAY_SIZE(expect_objects),
|
||||
.expect_objs = expect_objects,
|
||||
.todo_objs = object_todos,
|
||||
};
|
||||
|
||||
WCHAR cwd[MAX_PATH], tempdir[MAX_PATH];
|
||||
DIDEVICEINSTANCEW devinst = {0};
|
||||
IDirectInputDevice8W *device;
|
||||
DIDEVCAPS caps = {0};
|
||||
HRESULT hr;
|
||||
ULONG ref;
|
||||
|
||||
GetCurrentDirectoryW( ARRAY_SIZE(cwd), cwd );
|
||||
GetTempPathW( ARRAY_SIZE(tempdir), tempdir );
|
||||
SetCurrentDirectoryW( tempdir );
|
||||
|
||||
cleanup_registry_keys();
|
||||
if (!dinput_driver_start( report_desc, sizeof(report_desc), &hid_caps, NULL, 0 )) goto done;
|
||||
if (FAILED(hr = dinput_test_create_device( DIRECTINPUT_VERSION, &devinst, &device ))) goto done;
|
||||
|
||||
check_dinput_devices( DIRECTINPUT_VERSION, &devinst );
|
||||
|
||||
memset( &devinst, 0, sizeof(devinst) );
|
||||
devinst.dwSize = sizeof(DIDEVICEINSTANCEW);
|
||||
hr = IDirectInputDevice8_GetDeviceInfo( device, &devinst );
|
||||
ok( hr == DI_OK, "GetDeviceInfo returned %#lx\n", hr );
|
||||
check_member( devinst, expect_devinst, "%lu", dwSize );
|
||||
todo_wine
|
||||
check_member_guid( devinst, expect_devinst, guidInstance );
|
||||
check_member_guid( devinst, expect_devinst, guidProduct );
|
||||
todo_wine
|
||||
check_member( devinst, expect_devinst, "%#lx", dwDevType );
|
||||
todo_wine
|
||||
check_member_wstr( devinst, expect_devinst, tszInstanceName );
|
||||
todo_wine
|
||||
check_member_wstr( devinst, expect_devinst, tszProductName );
|
||||
check_member_guid( devinst, expect_devinst, guidFFDriver );
|
||||
check_member( devinst, expect_devinst, "%04x", wUsagePage );
|
||||
check_member( devinst, expect_devinst, "%04x", wUsage );
|
||||
|
||||
hr = IDirectInputDevice8_GetCapabilities( device, NULL );
|
||||
ok( hr == E_POINTER, "GetCapabilities returned %#lx\n", hr );
|
||||
hr = IDirectInputDevice8_GetCapabilities( device, &caps );
|
||||
ok( hr == DIERR_INVALIDPARAM, "GetCapabilities returned %#lx\n", hr );
|
||||
caps.dwSize = sizeof(DIDEVCAPS);
|
||||
hr = IDirectInputDevice8_GetCapabilities( device, &caps );
|
||||
ok( hr == DI_OK, "GetCapabilities returned %#lx\n", hr );
|
||||
check_member( caps, expect_caps, "%lu", dwSize );
|
||||
check_member( caps, expect_caps, "%#lx", dwFlags );
|
||||
todo_wine
|
||||
check_member( caps, expect_caps, "%#lx", dwDevType );
|
||||
check_member( caps, expect_caps, "%lu", dwAxes );
|
||||
check_member( caps, expect_caps, "%lu", dwButtons );
|
||||
check_member( caps, expect_caps, "%lu", dwPOVs );
|
||||
check_member( caps, expect_caps, "%lu", dwFFSamplePeriod );
|
||||
check_member( caps, expect_caps, "%lu", dwFFMinTimeResolution );
|
||||
check_member( caps, expect_caps, "%lu", dwFirmwareRevision );
|
||||
check_member( caps, expect_caps, "%lu", dwHardwareRevision );
|
||||
check_member( caps, expect_caps, "%lu", dwFFDriverVersion );
|
||||
|
||||
hr = IDirectInputDevice8_EnumObjects( device, check_objects, &check_objects_params, DIDFT_ALL );
|
||||
ok( hr == DI_OK, "EnumObjects returned %#lx\n", hr );
|
||||
ok( check_objects_params.index >= check_objects_params.expect_count, "missing %u objects\n",
|
||||
check_objects_params.expect_count - check_objects_params.index );
|
||||
|
||||
ref = IDirectInputDevice8_Release( device );
|
||||
ok( ref == 0, "Release returned %ld\n", ref );
|
||||
|
||||
done:
|
||||
pnp_driver_stop();
|
||||
cleanup_registry_keys();
|
||||
SetCurrentDirectoryW( cwd );
|
||||
winetest_pop_context();
|
||||
}
|
||||
|
||||
static BOOL test_winmm_joystick(void)
|
||||
{
|
||||
#include "psh_hid_macros.h"
|
||||
|
@ -2966,6 +3198,8 @@ START_TEST( joystick8 )
|
|||
test_simple_joystick( 0x500 );
|
||||
test_simple_joystick( 0x700 );
|
||||
test_simple_joystick( 0x800 );
|
||||
|
||||
test_driving_wheel_axes();
|
||||
}
|
||||
CoUninitialize();
|
||||
|
||||
|
|
Loading…
Reference in New Issue