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

> 获取有关输入设备上某个触摸表面的信息。

获取有关输入设备上某个触摸表面的信息。

## 语法

```cpp theme={null}
HRESULT GetTouchSurfaceInfo(
    uint32_t surfaceIndex,
    GameInputTouchSurfaceInfo* info
);
```

### 参数

*surfaceIndex*\
类型：uint32\_t

触摸表面的从零开始的索引。该值必须小于 [IGameInputDevice::GetTouchSurfaceCount](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_gettouchsurfacecount.md) 返回的值。

*info*   \_Out\_\
类型：[GameInputTouchSurfaceInfo](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/structs/gameinputtouchsurfaceinfo)\*

接收有关该触摸表面的信息。

### 返回值

类型：HRESULT

成功时返回 `S_OK`。如果 *surfaceIndex* 大于或等于设备上触摸表面的数量，则返回 `E_BOUNDS`；在这种情况下，*info* 会被置零。

## 备注

返回的信息描述该表面可以报告的最大同时接触点数、以设备单位表示的表面尺寸，以及表面的类型（例如触摸板或触摸屏）。[IGameInputReading::GetTouchSurfaceState](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_gettouchsurfacestate.md) 报告的接触点位置是相对于这些尺寸的，因此你可以使用这些尺寸来规范化接触点位置。

该信息在设备对象的生存期内不会更改。

以下示例将设备每个触摸表面上第一个接触点的位置规范化到 \[0, 1) 范围内。

```cpp theme={null}
void ProcessTouch(IGameInputDevice* device, IGameInputReading* reading) noexcept
{
    const uint32_t surfaceCount = device->GetTouchSurfaceCount();
    for (uint32_t surfaceIndex = 0; surfaceIndex < surfaceCount; ++surfaceIndex)
    {
        GameInputTouchSurfaceInfo info = {};
        if (FAILED(device->GetTouchSurfaceInfo(surfaceIndex, &info)) ||
            info.padWidth == 0 || info.padHeight == 0)
        {
            continue;
        }

        GameInputTouchContact contact = {};
        if (reading->GetTouchSurfaceState(surfaceIndex, 1, &contact) == 1)
        {
            const float x = static_cast<float>(contact.padX) / info.padWidth;
            const float y = static_cast<float>(contact.padY) / info.padHeight;
            // Use the normalized position (x, y) of the contact.
        }
    }
}
```

> [!NOTE]
>
> 触摸支持取决于设备和平台。

## 要求

**头文件：** 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)\
[IGameInputDevice](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)\
[GameInputTouchSurfaceInfo](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/structs/gameinputtouchsurfaceinfo)\
[IGameInputDevice::GetTouchSurfaceCount](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_gettouchsurfacecount.md)\
[IGameInputReading::GetTouchSurfaceState](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_gettouchsurfacestate.md)

## 版本历史

| 版本 | 变更 |
| - | - |
| **v4** | 引入。 |


## Related topics

- [IGameInputDevice::GetTouchSurfaceCount](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_gettouchsurfacecount.md)
- [IGameInputReading::GetTouchSurfaceState](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_gettouchsurfacestate.md)
- [IGameInputReading::GetTouchContactCount](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_gettouchcontactcount.md)
- [IGameInputDevice::GetSupportedInput](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedinput.md)
- [IGameInputDevice::GetInputReportInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getinputreportinfo.md)
