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

[webhid] Add missing report item bitfield attributes

The Device Class Definition for HID defines a bitfield that
accompanies each Main item in the HID report descriptor. The
bitfield is a 32-bit value that defines 9 attributes. Three
of these attributes were already exposed in the HID report
item dictionary (isAbsolute, isArray, hasNull), this CL adds
the remaining six.

Bug: 1156954
Change-Id: Ic0d7d069010bdc0c75369fbc1fb85586d5caeefa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2605585Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Matt Reynolds <mattreynolds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841339}
parent 7e75dffe
......@@ -504,8 +504,14 @@ HIDReportItem* HIDDevice::ToHIDReportItem(
HIDReportItem* result = HIDReportItem::Create();
result->setIsAbsolute(!report_item.is_relative);
result->setIsArray(!report_item.is_variable);
result->setIsBufferedBytes(report_item.is_buffered_bytes);
result->setIsConstant(report_item.is_constant);
result->setIsLinear(!report_item.is_non_linear);
result->setIsRange(report_item.is_range);
result->setIsVolatile(report_item.is_volatile);
result->setHasNull(report_item.has_null_position);
result->setHasPreferredState(!report_item.no_preferred_state);
result->setWrap(report_item.wrap);
result->setReportSize(report_item.report_size);
result->setReportCount(report_item.report_count);
result->setUnitExponent(
......
......@@ -40,13 +40,39 @@ dictionary HIDReportItem {
// all inputs simultaneously.
boolean isArray;
// True if the item emits a fixed-size stream of bytes, or false if the item
// is a bit field.
boolean isBufferedBytes;
// True if the item is a read-only constant value, or false if the item is a
// report field with modifiable device data.
boolean isConstant;
// True if there is a linear relationship between the measured value and the
// raw data from the device, or false if the data has been processed and no
// longer represents a linear relationship.
boolean isLinear;
// True if the usages for this item are defined by |usageMinimum| and
// |usageMaximum| or false if the usages are defined by |usages|.
boolean isRange;
// True if the item is a feature or output field that can change without
// host interaction, or false if the field should not change without host
// interaction.
boolean isVolatile;
// True if the item uses an out-of-bounds value when there is no input.
boolean hasNull;
// True if the item has a preferred state to which it will return when the
// user is not physically interacting with the control.
boolean hasPreferredState;
// True if the data rolls over when reaching either the extreme high or low
// value.
boolean wrap;
// An ordered list of 32-bit usage values associated with this item. Unused
// if |isRange| is true. If |reportCount| is two or more, usages are
// assigned from the list until the list is exhausted.
......
......@@ -117,8 +117,14 @@ hid_test(async (t, fake) => {
const i = r.items[0];
assert_true(i.isAbsolute, 'reportItem.isAbsolute');
assert_false(i.isArray, 'reportItem.isArray');
assert_false(i.isBufferedBytes, 'reportItem.isBufferedBytes');
assert_false(i.isConstant, 'reportItem.isConstant');
assert_true(i.isLinear, 'reportItem.isLinear');
assert_false(i.isRange, 'reportItem.isRange');
assert_false(i.isVolatile, 'reportItem.isVolatile');
assert_false(i.hasNull, 'reportItem.hasNull');
assert_true(i.hasPreferredState, 'reportItem.hasPreferredState');
assert_false(i.wrap, 'reportItem.wrap');
assert_equals(i.usages.length, 1, 'reportItem.usages.length');
assert_equals(i.usages[0], 0x00090001, 'reportItem.usages[0]');
assert_equals(i.usageMinimum, 0, 'reportItem.usageMinimum');
......
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