> ## 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::SetRawDeviceFeature

> 向设备发送原始功能报告。

向设备发送原始功能报告。

## 语法

```cpp theme={null}
HRESULT SetRawDeviceFeature(
    IGameInputRawDeviceReport* report
);
```

### 参数

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

要发送的功能报告。通过使用 `GameInputRawFeatureReport` 调用 [CreateRawDeviceReport](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_createrawdevicereport.md) 来创建该报告，并通过调用 [IGameInputRawDeviceReport::SetRawData](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputrawdevicereport/methods/igameinputrawdevicereport_setrawdata.md) 填充该报告。

### 返回值

类型：HRESULT

如果报告已提交到设备，则返回 `S_OK`。如果设备是聚合设备，则返回 `GAMEINPUT_E_AGGREGATE_OPERATION_NOT_SUPPORTED`；如果无法提交报告，则返回其他错误代码。

## 备注

`SetRawDeviceFeature` 方法将功能报告写入设备。报告 ID 取自该报告的 [GameInputRawDeviceReportInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/structs/gameinputrawdevicereportinfo.md)，有效负载是通过 [IGameInputRawDeviceReport::SetRawData](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputrawdevicereport/methods/igameinputrawdevicereport_setrawdata.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。

`SetRawDeviceFeature` 会将报告排队等待传送，并在不等待设备处理的情况下返回。成功的返回值表示报告已提交，而不表示设备已接受该报告。若要确认新状态，请通过调用 [GetRawDeviceFeature](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getrawdevicefeature.md) 读回该报告。

```cpp theme={null}
Microsoft::WRL::ComPtr<IGameInputRawDeviceReport> report;
if (SUCCEEDED(device->CreateRawDeviceReport(reportId, GameInputRawFeatureReport, &report)))
{
    // The first byte of a HID feature report is the report ID.
    uint8_t data[] = { static_cast<uint8_t>(reportId), 0x01, 0x00 };
    if (report->SetRawData(sizeof(data), data))
    {
        device->SetRawDeviceFeature(report.Get());
    }
}
```

有关 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)\
[GetRawDeviceFeature](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getrawdevicefeature.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)\
[CreateRawDeviceReport](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_createrawdevicereport.md)\
[IGameInputRawDeviceReport](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputrawdevicereport/igameinputrawdevicereport.md)\
[IGameInputDevice](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)

## 版本历史

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

## 附录：以前的版本

### v0

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


## Related topics

- [IGameInputDevice::SetRawDeviceFeature（已弃用）](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/interfaces/igameinputdevice/methods/igameinputdevice_setrawdevicefeature.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::GetRawDeviceFeature](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getrawdevicefeature.md)
- [IGameInputDevice::GetFeatureReportCount](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getfeaturereportcount.md)
