Contents

physicalValue(fromTypeTruncatingIfNeeded:as:)

The logical value of the data, shifted and scaled by the Hidelement’s physical minimum, physical maximum and exponent.

Declaration

func physicalValue<IntegerType, FloatingType>(fromTypeTruncatingIfNeeded: IntegerType.Type, as: FloatingType.Type) -> FloatingType? where IntegerType : FixedWidthInteger, FloatingType : BinaryFloatingPoint

Parameters

  • fromTypeTruncatingIfNeeded:

    The type to cast the underlying bytes to before bounding, shifting and scaling; truncating or extending the bytes as necessary.

  • as:

    The type to cast the calculated floating point result to before returning.

Return Value

The calculated value cast as the requested type, or nil if out of bounds.

Discussion

The logicalValue(asTypeTruncatingIfNeeded:) is first retrieved with the specified type. If the logical value is undefined, such as when the raw value is out of bounds, the physical value is also undefined.

More information and example calculations for physical values can be found in the HID specification: See the HID specification for more details: https://www.usb.org/hid.

See Also

Get element data and values