From: Matthew Tran 0e4ef622@gmail.com
--- dlls/dinput/tests/hid.c | 84 ++++++++++++++++++++++++++++++++--------- include/hidusage.h | 1 + 2 files changed, 68 insertions(+), 17 deletions(-)
diff --git a/dlls/dinput/tests/hid.c b/dlls/dinput/tests/hid.c index 88565283735..345aede2c73 100644 --- a/dlls/dinput/tests/hid.c +++ b/dlls/dinput/tests/hid.c @@ -1286,7 +1286,10 @@ static void test_hidp_set_output( HANDLE file, int report_id, ULONG report_len, .code = IOCTL_HID_SET_OUTPUT_REPORT, .report_id = report_id, .report_len = report_len - (report_id ? 0 : 1), - .report_buf = {report_id,0,0xcd,0xcd,0xcd}, + .report_buf = { + report_id,0,0,0,0,0,0,0,0,0,0,0,0xcd,0xcd,0xcd,0xcd, + 0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd, + }, .ret_length = 3, .ret_status = STATUS_SUCCESS, }, @@ -1299,9 +1302,7 @@ static void test_hidp_set_output( HANDLE file, int report_id, ULONG report_len,
memset( report, 0xcd, sizeof(report) ); status = HidP_InitializeReportForID( HidP_Output, report_id, preparsed, report, report_len ); - ok( status == HIDP_STATUS_REPORT_DOES_NOT_EXIST, "HidP_InitializeReportForID returned %#lx\n", status ); - memset( report, 0, report_len ); - report[0] = report_id; + ok( status == HIDP_STATUS_SUCCESS, "HidP_InitializeReportForID returned %#lx\n", status );
SetLastError( 0xdeadbeef ); ret = HidD_SetOutputReport( file, report, 0 ); @@ -1322,7 +1323,7 @@ static void test_hidp_set_output( HANDLE file, int report_id, ULONG report_len, .code = IOCTL_HID_SET_OUTPUT_REPORT, .broken = TRUE, .report_len = report_len - 1, - .report_buf = {0x5a,0x5a}, + .report_buf = {0x5a,0x5a,0x5a,0x5a,0x5a,0x5a,0x5a,0x5a,0x5a,0x5a,0x5a,0x5a}, .ret_length = 3, .ret_status = STATUS_SUCCESS, }; @@ -1372,7 +1373,9 @@ static void test_write_file( HANDLE file, int report_id, ULONG report_len ) .code = IOCTL_HID_WRITE_REPORT, .report_id = report_id, .report_len = report_len - (report_id ? 0 : 1), - .report_buf = {report_id ? report_id : 0xcd,0xcd,0xcd,0xcd,0xcd}, + .report_buf = { + report_id ? report_id : 0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd, + 0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd}, .ret_length = 3, .ret_status = STATUS_SUCCESS, }; @@ -1558,8 +1561,8 @@ static void test_hidp( HANDLE file, HANDLE async_file, int report_id, BOOL polle .LinkUsage = HID_USAGE_GENERIC_JOYSTICK, .LinkUsagePage = HID_USAGE_PAGE_GENERIC, .CollectionType = 1, - .NumberOfChildren = 7, - .FirstChild = 9, + .NumberOfChildren = 8, + .FirstChild = 10, }, { .LinkUsage = HID_USAGE_GENERIC_JOYSTICK, @@ -1591,6 +1594,7 @@ static void test_hidp( HANDLE file, HANDLE async_file, int report_id, BOOL polle char buffer[200], report[200]; DWORD collection_count; DWORD waveform_list; + DWORD generic_output_list; HIDP_DATA data[64]; USAGE usages[16]; ULONG off, value; @@ -1701,8 +1705,6 @@ static void test_hidp( HANDLE file, HANDLE async_file, int report_id, BOOL polle ok( count == 0, "HidP_GetSpecificButtonCaps returned count %d, expected %d\n", count, 0 );
count = ARRAY_SIZE(value_caps); - status = HidP_GetValueCaps( HidP_Output, value_caps, &count, preparsed_data ); - ok( status == HIDP_STATUS_USAGE_NOT_FOUND, "HidP_GetValueCaps returned %#lx\n", status ); status = HidP_GetValueCaps( HidP_Feature + 1, value_caps, &count, preparsed_data ); ok( status == HIDP_STATUS_INVALID_REPORT_TYPE, "HidP_GetValueCaps returned %#lx\n", status ); count = 0; @@ -1726,8 +1728,6 @@ static void test_hidp( HANDLE file, HANDLE async_file, int report_id, BOOL polle }
count = ARRAY_SIZE(value_caps) - 4; - status = HidP_GetSpecificValueCaps( HidP_Output, 0, 0, 0, value_caps, &count, preparsed_data ); - ok( status == HIDP_STATUS_USAGE_NOT_FOUND, "HidP_GetSpecificValueCaps returned %#lx\n", status ); status = HidP_GetSpecificValueCaps( HidP_Feature + 1, 0, 0, 0, value_caps, &count, preparsed_data ); ok( status == HIDP_STATUS_INVALID_REPORT_TYPE, "HidP_GetSpecificValueCaps returned %#lx\n", status ); count = 0; @@ -2036,7 +2036,7 @@ static void test_hidp( HANDLE file, HANDLE async_file, int report_id, BOOL polle value = HidP_MaxDataListLength( HidP_Input, preparsed_data ); ok( value == 58, "HidP_MaxDataListLength(HidP_Input) returned %ld, expected %d\n", value, 58 ); value = HidP_MaxDataListLength( HidP_Output, preparsed_data ); - ok( value == 0, "HidP_MaxDataListLength(HidP_Output) returned %ld, expected %d\n", value, 0 ); + ok( value == 10, "HidP_MaxDataListLength(HidP_Output) returned %ld, expected %d\n", value, 10 ); value = HidP_MaxDataListLength( HidP_Feature, preparsed_data ); ok( value == 14, "HidP_MaxDataListLength(HidP_Feature) returned %ld, expected %d\n", value, 14 );
@@ -2271,6 +2271,38 @@ static void test_hidp( HANDLE file, HANDLE async_file, int report_id, BOOL polle ok( status == HIDP_STATUS_SUCCESS, "HidP_GetUsageValue returned %#lx\n", status ); ok( value == 0xfffffd0b, "got value %#lx, expected %#x\n", value, 0xfffffd0b );
+ memset( report, 0xcd, sizeof(report) ); + status = HidP_InitializeReportForID( HidP_Output, report_id, preparsed_data, report, + caps.OutputReportByteLength ); + ok( status == HIDP_STATUS_SUCCESS, "HidP_InitializeReportForID returned %#lx\n", status ); + + memset( buffer, 0xcd, sizeof(buffer) ); + memset( buffer, 0, caps.OutputReportByteLength ); + buffer[0] = report_id; + ok( !memcmp( buffer, report, sizeof(buffer) ), "unexpected report data\n" ); + + for (i = 0; i < caps.NumberLinkCollectionNodes; ++i) + { + if (collections[i].LinkUsagePage != HID_USAGE_PAGE_GENERIC) continue; + if (collections[i].LinkUsage == HID_USAGE_GENERIC_UNDEFINED) break; + } + ok( i < caps.NumberLinkCollectionNodes, + "HID_USAGE_GENERIC_UNDEFINED collection not found\n" ); + generic_output_list = i; + + for (i = 0; i < 10; ++i) + { + status = HidP_SetUsageValue( HidP_Output, HID_USAGE_PAGE_ORDINAL, generic_output_list, i + 1, + i, preparsed_data, report, caps.OutputReportByteLength ); + ok( status == HIDP_STATUS_SUCCESS, "HidP_SetUsageValue returned %#lx\n", status ); + + if (report_id) + buffer[i + 2] = i; + else + buffer[i + 3] = i; + } + ok( !memcmp( buffer, report, sizeof(buffer) ), "unexpected report data\n" ); + test_hidp_get_input( file, report_id, caps.InputReportByteLength, preparsed_data ); test_hidp_get_feature( file, report_id, caps.FeatureReportByteLength, preparsed_data ); test_hidp_set_feature( file, report_id, caps.FeatureReportByteLength, preparsed_data ); @@ -2883,7 +2915,7 @@ static void test_hid_driver( DWORD report_id, DWORD polled ) USAGE_PAGE(1, HID_USAGE_PAGE_LED), USAGE(1, HID_USAGE_LED_GREEN), COLLECTION(1, Report), - REPORT_ID_OR_USAGE_PAGE(1, report_id, 0), + REPORT_ID_OR_USAGE_PAGE(1, report_id, 1), USAGE_PAGE(1, HID_USAGE_PAGE_LED), REPORT_COUNT(1, 8), REPORT_SIZE(1, 1), @@ -2893,12 +2925,28 @@ static void test_hid_driver( DWORD report_id, DWORD polled ) USAGE_PAGE(1, HID_USAGE_PAGE_LED), USAGE(1, HID_USAGE_LED_RED), COLLECTION(1, Report), - REPORT_ID_OR_USAGE_PAGE(1, report_id, 1), + REPORT_ID_OR_USAGE_PAGE(1, report_id, 0), USAGE_PAGE(1, HID_USAGE_PAGE_LED), REPORT_COUNT(1, 8), REPORT_SIZE(1, 1), OUTPUT(1, Cnst|Var|Abs), END_COLLECTION, + + USAGE_PAGE(1, HID_USAGE_PAGE_GENERIC), + USAGE(1, HID_USAGE_GENERIC_UNDEFINED), + COLLECTION(1, Report), + REPORT_ID_OR_USAGE_PAGE(1, report_id, 0), + REPORT_COUNT(1, 10), + REPORT_SIZE(1, 8), + LOGICAL_MINIMUM(2, 0), + LOGICAL_MAXIMUM(2, 255), + USAGE_PAGE(1, HID_USAGE_PAGE_ORDINAL), + STRING_MINIMUM(1, 6), + STRING_MAXIMUM(1, 16), + USAGE_MINIMUM(1, 1), /* Instance 1 */ + USAGE_MAXIMUM(1, 10), /* Instance 31 */ + OUTPUT(1, Data|Var|Abs), + END_COLLECTION, END_COLLECTION, }; #undef REPORT_ID_OR_USAGE_PAGE @@ -2910,12 +2958,14 @@ static void test_hid_driver( DWORD report_id, DWORD polled ) .Usage = HID_USAGE_GENERIC_JOYSTICK, .UsagePage = HID_USAGE_PAGE_GENERIC, .InputReportByteLength = report_id ? 32 : 33, - .OutputReportByteLength = report_id ? 2 : 3, + .OutputReportByteLength = report_id ? 12 : 13, .FeatureReportByteLength = report_id ? 21 : 22, - .NumberLinkCollectionNodes = 10, + .NumberLinkCollectionNodes = 11, .NumberInputButtonCaps = 17, .NumberInputValueCaps = 7, .NumberInputDataIndices = 47, + .NumberOutputValueCaps = 1, + .NumberOutputDataIndices = 10, .NumberFeatureButtonCaps = 1, .NumberFeatureValueCaps = 6, .NumberFeatureDataIndices = 8, diff --git a/include/hidusage.h b/include/hidusage.h index 2ea3784d626..955ad348fb2 100644 --- a/include/hidusage.h +++ b/include/hidusage.h @@ -39,6 +39,7 @@ typedef USHORT USAGE, *PUSAGE; #define HID_USAGE_DIGITIZER_TIP_SWITCH ((USAGE) 0x42) #define HID_USAGE_DIGITIZER_BARREL_SWITCH ((USAGE) 0x44)
+#define HID_USAGE_GENERIC_UNDEFINED ((USAGE) 0x00) #define HID_USAGE_GENERIC_POINTER ((USAGE) 0x01) #define HID_USAGE_GENERIC_MOUSE ((USAGE) 0x02) #define HID_USAGE_GENERIC_JOYSTICK ((USAGE) 0x04)