<!--
{
  "availability" : [
    "macOS: 15.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreHID",
  "identifier" : "/documentation/CoreHID/HIDElement/Value",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Core HID"
    ],
    "preciseIdentifier" : "s:7CoreHID10HIDElementV5ValueV"
  },
  "title" : "HIDElement.Value"
}
-->

# HIDElement.Value

Data associated with a HID element.

```
struct Value
```

## Overview

Elements can have data associated with them. This data could be received as an update from the device to indicate user interaction, or could be provided to the device to alter functionality, such as turning on an LED. As the data for an element could be constantly changing, values should be seen as a snapshot of the element’s data at a specific time, and not valid at any other times.

Element values can be received by a [`HIDDeviceClient`](/documentation/CoreHID/HIDDeviceClient) using [`HIDDeviceClient.Notification.elementUpdates(values:)`](/documentation/CoreHID/HIDDeviceClient/Notification/elementUpdates(values:)) after the device issues an input report, or requested from the device by providing a [`HIDDeviceClient.RequestElementUpdate`](/documentation/CoreHID/HIDDeviceClient/RequestElementUpdate) to [`updateElements(_:timeout:)`](/documentation/CoreHID/HIDDeviceClient/updateElements(_:timeout:)). Element values can be sent to a device by providing a [`HIDDeviceClient.ProvideElementUpdate`](/documentation/CoreHID/HIDDeviceClient/ProvideElementUpdate) to [`updateElements(_:timeout:)`](/documentation/CoreHID/HIDDeviceClient/updateElements(_:timeout:)).

## Topics

### Create a HID element from a value

[`init(element: HIDElement, fromBytes: Data, timestamp: SuspendingClock.Instant)`](/documentation/CoreHID/HIDElement/Value/init(element:fromBytes:timestamp:))

Creates a value for an HID element.

[`init?<FloatingPointType>(element: HIDElement, fromPhysicalValue: FloatingPointType, timestamp: SuspendingClock.Instant)`](/documentation/CoreHID/HIDElement/Value/init(element:fromPhysicalValue:timestamp:))

Creates a HID element value from a physical value.

[`init?<IntegerType>(element: HIDElement, fromLogicalValueTruncatingIfNeeded: IntegerType, timestamp: SuspendingClock.Instant)`](/documentation/CoreHID/HIDElement/Value/init(element:fromLogicalValueTruncatingIfNeeded:timestamp:))

Creates a HID element value from a logical value.

[`init<IntegerType>(element: HIDElement, fromIntegerTruncatingIfNeeded: IntegerType, timestamp: SuspendingClock.Instant)`](/documentation/CoreHID/HIDElement/Value/init(element:fromIntegerTruncatingIfNeeded:timestamp:))

Creates an HID element value from an integer.

[`var element: HIDElement`](/documentation/CoreHID/HIDElement/Value/element)

The [`HIDElement`](/documentation/CoreHID/HIDElement) associated with this value.

### Get element data and values

[`var bytes: Data`](/documentation/CoreHID/HIDElement/Value/bytes)

The data as an array of bytes.

[`func integerValue<IntegerType>(asTypeTruncatingIfNeeded: IntegerType.Type) -> IntegerType`](/documentation/CoreHID/HIDElement/Value/integerValue(asTypeTruncatingIfNeeded:))

The raw value of the data cast as an integer type, with no transformations applied.

[`func logicalValue<IntegerType>(asTypeTruncatingIfNeeded: IntegerType.Type) -> IntegerType?`](/documentation/CoreHID/HIDElement/Value/logicalValue(asTypeTruncatingIfNeeded:))

The raw value of the data cast as an integer type and bound by the [`HIDElement`](/documentation/CoreHID/HIDElement)’s logical minimum and logical maximum values.

[`func physicalValue<IntegerType, FloatingType>(fromTypeTruncatingIfNeeded: IntegerType.Type, as: FloatingType.Type) -> FloatingType?`](/documentation/CoreHID/HIDElement/Value/physicalValue(fromTypeTruncatingIfNeeded:as:))

The logical value of the data, shifted and scaled by the [`HIDElement`](/documentation/CoreHID/HIDElement)’s physical minimum, physical maximum and exponent.

[`var timestamp: SuspendingClock.Instant`](/documentation/CoreHID/HIDElement/Value/timestamp)

The time that this data was received by the system.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`Copyable`](/documentation/Swift/Copyable)

[`Escapable`](/documentation/Swift/Escapable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Hashable`](/documentation/Swift/Hashable)

[`Equatable`](/documentation/Swift/Equatable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)