跳转到主要内容
从输入读数中检索某个触摸表面上的接触点。

语法

参数

surfaceIndex   _In_
类型:uint32_t
触摸表面的索引。必须小于 IGameInputDevice::GetTouchSurfaceCount 返回的值。 contactArrayCount   _In_
类型:uint32_t
contactArray 中的元素数量。 contactArray   _Out_writes_to_opt_(contactArrayCount, return)
类型:GameInputTouchContact*
接收该触摸表面上接触点的数组。可以为 null。

返回值

类型:uint32_t 如果 contactArray 为 null,则返回该触摸表面上的接触点数量。否则,返回写入 contactArray 的接触点数量,该值为接触点数量与 contactArrayCount 中的较小者。如果读数不包含触摸数据,或者 surfaceIndex 不是有效的表面索引,则返回 0。

备注

contactArray 的每个元素描述表面上的一个接触点,例如一根手指。contactArray 中未写入接触点的元素设置为零。只要接触点仍停留在表面上,GameInputTouchContact 的 contactId 成员就会保持不变,因此你可以使用它在多个读数之间跟踪某个接触点。 若要确定 contactArray 的大小,请调用 IGameInputReading::GetTouchContactCount,或者使用 GameInputTouchSurfaceInfo 的 maxContactCount 成员分配一个对任何读数都足够大的数组。若要解释接触点坐标,请使用相同的表面索引调用 IGameInputDevice::GetTouchSurfaceInfo。 包含触摸数据的读数会在 IGameInputReading::GetInputKind 中包含 GameInputKindTouch。
触摸支持取决于设备和平台。
以下示例读取设备每个触摸表面上的接触点。

要求

头文件: GameInput.h 库: gameinput.lib 支持的平台: Windows、XBOX One 系列主机和 XBOX Series 主机

另请参阅

GameInput 概述
IGameInputReading
IGameInputReading::GetTouchContactCount
IGameInputDevice::GetTouchSurfaceInfo
GameInputTouchContact
GameInputTouchSurfaceInfo

版本历史

最后修改于 2026年11月6日