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

要讀取之功能報告的識別碼。必須符合 [GetFeatureReportInfo](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getfeaturereportinfo.md) 所傳回其中一個報告的 `id` 成員。

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

接收新的 `IGameInputRawDeviceReport` 物件，其中包含從裝置讀取的功能報告資料。失敗時設定為 `nullptr`。

### 傳回值

類型：HRESULT

成功時傳回 `S_OK`。如果裝置未定義具有指定識別碼的功能報告，則傳回 `E_NOTFOUND`；如果裝置是彙總裝置，則傳回 `GAMEINPUT_E_AGGREGATE_OPERATION_NOT_SUPPORTED`。如果無法從裝置讀取報告，則傳回其他錯誤碼。

## 備註

`GetRawDeviceFeature` 方法會向裝置要求功能報告的目前內容，並在新的 [IGameInputRawDeviceReport](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputrawdevicereport/igameinputrawdevicereport.md) 物件中傳回這些內容。報告之 [GameInputRawDeviceReportInfo](https://docs.xbox.com/zh-TW/reference/input/gameinput/structs/gameinputrawdevicereportinfo.md) 的 `kind` 成員為 `GameInputRawFeatureReport`，且其資料大小符合 [GetFeatureReportInfo](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getfeaturereportinfo.md) 所傳回之對應元素的 `size` 成員。呼叫 [GetRawDataSize](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputrawdevicereport/methods/igameinputrawdevicereport_getrawdatasize.md) 和 [IGameInputRawDeviceReport::GetRawData](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputrawdevicereport/methods/igameinputrawdevicereport_getrawdata.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 裝置，報告資料的第一個位元組是報告識別碼。

與其他原始報告方法不同，`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-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)\
[SetRawDeviceFeature](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_setrawdevicefeature.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)\
[IGameInputRawDeviceReport](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputrawdevicereport/igameinputrawdevicereport.md)\
[CreateRawDeviceReport](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_createrawdevicereport.md)\
[IGameInputDevice](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)

## 版本歷程記錄

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

## 附錄：先前版本

### v0

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


## Related topics

- [IGameInputDevice::GetRawDeviceFeature (已淘汰)](https://docs.xbox.com/zh-TW/reference/input/gameinput/deprecated/interfaces/igameinputdevice/methods/igameinputdevice_getrawdevicefeature.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::SetRawDeviceFeature](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_setrawdevicefeature.md)
- [IGameInputDevice::GetFeatureReportInfo](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getfeaturereportinfo.md)
