> ## 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-TW/reference/input/gameinput/interfaces/igameinputrawdevicereport/igameinputrawdevicereport.md)\*

要傳送的功能報告。請以 `GameInputRawFeatureReport` 呼叫 [CreateRawDeviceReport](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_createrawdevicereport.md) 來建立報告，並呼叫 [IGameInputRawDeviceReport::SetRawData](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputrawdevicereport/methods/igameinputrawdevicereport_setrawdata.md) 加以填入。

### 傳回值

類型：HRESULT

如果報告已提交至裝置，則傳回 `S_OK`。如果裝置是彙總裝置，則傳回 `GAMEINPUT_E_AGGREGATE_OPERATION_NOT_SUPPORTED`；如果無法提交報告，則傳回其他錯誤碼。

## 備註

`SetRawDeviceFeature` 方法會將功能報告寫入裝置。報告識別碼取自報告的 [GameInputRawDeviceReportInfo](https://docs.xbox.com/zh-TW/reference/input/gameinput/structs/gameinputrawdevicereportinfo.md)，而承載則是使用 [IGameInputRawDeviceReport::SetRawData](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputrawdevicereport/methods/igameinputrawdevicereport_setrawdata.md) 設定的資料。

使用 [GetFeatureReportCount](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getfeaturereportcount.md) 和 [GetFeatureReportInfo](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getfeaturereportinfo.md) 找出裝置定義了哪些功能報告，以及每個功能報告的大小。目前會針對 HID 裝置公開功能報告。對於 HID 裝置，報告資料的第一個位元組是報告識別碼。

`SetRawDeviceFeature` 會將報告排入佇列以進行傳遞，並在不等待裝置處理報告的情況下傳回。成功的傳回值表示報告已提交，而不表示裝置已接受報告。若要確認新的狀態，請呼叫 [GetRawDeviceFeature](https://docs.xbox.com/zh-TW/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-TW/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-TW/build/core-features/common/input/overviews/input-overview.md)\
[GetRawDeviceFeature](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getrawdevicefeature.md)\
[GetFeatureReportCount](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getfeaturereportcount.md)\
[GetFeatureReportInfo](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getfeaturereportinfo.md)\
[CreateRawDeviceReport](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_createrawdevicereport.md)\
[IGameInputRawDeviceReport](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputrawdevicereport/igameinputrawdevicereport.md)\
[IGameInputDevice](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)

## 版本歷程記錄

| 版本 | 變更 |
| - | - |
| **v4** | 重新推出。 |
| **v1** | 已移除。 |
| **v0** | 已推出 (未實作)。 |

## 附錄：先前版本

### v0

在 GameInput v0 中，此方法以相同的簽章宣告，但並未實作。如需詳細資訊，請參閱 [IGameInputDevice::SetRawDeviceFeature (已淘汰)](https://docs.xbox.com/zh-TW/reference/input/gameinput/deprecated/interfaces/igameinputdevice/methods/igameinputdevice_setrawdevicefeature.md)。


## Related topics

- [IGameInputDevice::SetRawDeviceFeature (已淘汰)](https://docs.xbox.com/zh-TW/reference/input/gameinput/deprecated/interfaces/igameinputdevice/methods/igameinputdevice_setrawdevicefeature.md)
- [GameInputRawDeviceReportKind](https://docs.xbox.com/zh-TW/reference/input/gameinput/enums/gameinputrawdevicereportkind.md)
- [GameInput API 成員](https://docs.xbox.com/zh-TW/reference/input/gameinput/gameinput_members.md)
- [IGameInputDevice::GetRawDeviceFeature](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getrawdevicefeature.md)
- [IGameInputDevice::GetFeatureReportCount](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getfeaturereportcount.md)
