跳轉到主要內容
從輸入讀數擷取觸控表面上的接觸點。

語法

參數

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日