Commit cb7da9e4 authored by Matt Reynolds's avatar Matt Reynolds Committed by Chromium LUCI CQ

[webhid] Add a collection type attribute

Each HID collection has an 8-bit value that defines the
collection type. This CL adds a type parameter to the collection
info exposed to javascript.

Bug: 1162143
Change-Id: I56370783aaa8bb811dc77c62ee9b0ce90d589046
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2605006Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841344}
parent 453592c8
......@@ -12,6 +12,9 @@ dictionary HIDCollectionInfo {
// The 16-bit usage value associated with this collection. Zero if not set.
unsigned short usage;
// The 8-bit collection type for this collection.
octet type;
// The subcollections of this collection, in the order they were encountered
// in the report descriptor.
sequence<HIDCollectionInfo> children;
......
......@@ -184,6 +184,7 @@ HIDCollectionInfo* ToHIDCollectionInfo(
HIDCollectionInfo* result = HIDCollectionInfo::Create();
result->setUsage(collection.usage->usage);
result->setUsagePage(collection.usage->usage_page);
result->setType(collection.collection_type);
HeapVector<Member<HIDReportInfo>> input_reports;
for (const auto& report : collection.input_reports)
......
......@@ -105,6 +105,7 @@ hid_test(async (t, fake) => {
const c = d.collections[0];
assert_equals(c.usagePage, PAGE_GENERIC_DESKTOP, 'collection.usagePage');
assert_equals(c.usage, GENERIC_DESKTOP_GAME_PAD, 'collection.usage');
assert_equals(c.type, HID_COLLECTION_TYPE_APPLICATION, 'collection.type');
assert_equals(c.children.length, 0, 'collection.children.length');
assert_equals(c.inputReports.length, 1, 'collection.inputReports.length');
assert_equals(c.outputReports.length, 0, 'collection.outputReports.length');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment