> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# IGameInputDevice::GetRawDeviceFeature

> 从设备读取原始功能报告。

从设备读取原始功能报告。

## 语法

```cpp theme={null}
HRESULT GetRawDeviceFeature(
    uint32_t reportId,
    IGameInputRawDeviceReport** report
);
```

### 参数

*reportId*   \_In\_\
类型：uint32\_t

要读取的功能报告的 ID。必须与 [GetFeatureReportInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getfeaturereportinfo.md) 返回的某个报告的 `id` 成员相匹配。

*report*   \_COM\_Outptr\_\
类型：[IGameInputRawDeviceReport](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputrawdevicereport/igameinputrawdevicereport.md)\*\*

接收一个新的 `IGameInputRawDeviceReport` 对象，该对象包含从设备读取的功能报告数据。失败时设置为 `nullptr`。

### 返回值

类型：HRESULT

成功时返回 `S_OK`。如果设备未定义具有指定 ID 的功能报告，则返回 `E_NOTFOUND`；如果设备是聚合设备，则返回 `GAMEINPUT_E_AGGREGATE_OPERATION_NOT_SUPPORTED`。如果无法从设备读取报告，则返回其他错误代码。

## 备注

`GetRawDeviceFeature` 方法向设备请求功能报告的当前内容，并在一个新的 [IGameInputRawDeviceReport](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputrawdevicereport/igameinputrawdevicereport.md) 对象中返回这些内容。该报告的 [GameInputRawDeviceReportInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/structs/gameinputrawdevicereportinfo.md) 的 `kind` 成员为 `GameInputRawFeatureReport`，其数据大小与 [GetFeatureReportInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getfeaturereportinfo.md) 返回的相应元素的 `size` 成员相匹配。通过调用 [GetRawDataSize](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputrawdevicereport/methods/igameinputrawdevicereport_getrawdatasize.md) 和 [IGameInputRawDeviceReport::GetRawData](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputrawdevicereport/methods/igameinputrawdevicereport_getrawdata.md) 读取数据。

使用 [GetFeatureReportCount](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getfeaturereportcount.md) 和 [GetFeatureReportInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getfeaturereportinfo.md) 发现设备定义了哪些功能报告。目前仅对 HID 设备公开功能报告。对于 HID 设备，报告数据的第一个字节是报告 ID。

与其他原始报告方法不同，`GetRawDeviceFeature` 会等待设备回复后才返回，因此请避免在时间关键型线程（例如渲染线程或输入轮询线程）上调用它。

```cpp theme={null}
Microsoft::WRL::ComPtr<IGameInputRawDeviceReport> report;
if (SUCCEEDED(device->GetRawDeviceFeature(reportId, &report)))
{
    std::vector<uint8_t> data(report->GetRawDataSize());
    data.resize(report->GetRawData(data.size(), data.data()));
    // Parse the device-specific feature report data...
}
```

有关 GameInput API 的中级和高级用例，请参阅 [GameInput 高级主题](https://docs.xbox.com/zh-CN/build/core-features/common/input/advanced/input-advanced-topics.md)。

## 要求

**头文件：** GameInput.h

**库：** gameinput.lib

**支持的平台：** Windows、XBOX One 系列主机和 XBOX Series 主机

## 另请参阅

[GameInput 概述](https://docs.xbox.com/zh-CN/build/core-features/common/input/overviews/input-overview.md)\
[SetRawDeviceFeature](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_setrawdevicefeature.md)\
[GetFeatureReportCount](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getfeaturereportcount.md)\
[GetFeatureReportInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getfeaturereportinfo.md)\
[IGameInputRawDeviceReport](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputrawdevicereport/igameinputrawdevicereport.md)\
[CreateRawDeviceReport](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_createrawdevicereport.md)\
[IGameInputDevice](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)

## 版本历史

| 版本 | 变更 |
| - | - |
| **v4** | 重新引入。 |
| **v1** | 已移除。 |
| **v0** | 引入（未实现）。 |

## 附录：以前的版本

### v0

在 GameInput v0 中，此方法以相同的签名声明，但未实现。有关详细信息，请参阅 [IGameInputDevice::GetRawDeviceFeature（已弃用）](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/interfaces/igameinputdevice/methods/igameinputdevice_getrawdevicefeature.md)。


## Related topics

- [IGameInputDevice::GetRawDeviceFeature（已弃用）](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/interfaces/igameinputdevice/methods/igameinputdevice_getrawdevicefeature.md)
- [GameInputRawDeviceReportKind](https://docs.xbox.com/zh-CN/reference/input/gameinput/enums/gameinputrawdevicereportkind.md)
- [GameInput API 成员](https://docs.xbox.com/zh-CN/reference/input/gameinput/gameinput_members.md)
- [IGameInputDevice::SetRawDeviceFeature](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_setrawdevicefeature.md)
- [IGameInputDevice::GetFeatureReportInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getfeaturereportinfo.md)
