XrInputAction QML Type

代表来自输入控制器的操作。更多

Import Statement: import QtQuick3D.Xr
Since: Qt 6.8
Inherits:

QtObject

Status: Technical Preview

属性

信号

详细说明

操作可以是布尔操作(如按下按钮),也可以是模拟操作(如操纵杆轴)。

使用pressed 属性或triggered 信号可对布尔操作作出反应。模拟操作将设置value 属性。

注: 为方便起见,模拟属性也会设置pressed 属性并发出triggered 信号,而布尔属性在按下时会将value 设置为 1.0。

下面显示的是如何对右手握柄按下或手部追踪的右手捏手势做出反应:

XrInputAction {
    hand: XrInputAction.RightHand
    actionId: [XrInputAction.SqueezePressed, XrInputAction.SqueezeValue, XrInputAction.IndexFingerPinch]
    onTriggered: console.log("Do action here.")
}

同时指定SqueezePressedSqueezeValue 的原因是,有些控制器有一个模拟手柄按钮,而有些控制器只有一个开/关手柄开关。

属性文档

actionId : List<enumeration>

指定要作出反应的动作

持有一个 ID 列表,可以是以下值:

常量说明
XrInputAction.Button1Pressed按钮 1 已按下。布尔值
XrInputAction.Button1Touched按钮 1 被触摸。布尔值
XrInputAction.Button2Pressed按钮 2 被按下。布尔
XrInputAction.Button2Touched按钮 2 被触碰。布尔
XrInputAction.ButtonMenuPressed菜单按钮被按下。布尔
XrInputAction.ButtonMenuTouched触摸菜单按钮。布尔
XrInputAction.ButtonSystemPressed系统按钮被按下。布尔
XrInputAction.ButtonSystemTouched系统按钮被触摸。布尔值
XrInputAction.SqueezeValue手柄按钮按下的距离。模拟
XrInputAction.SqueezeForce施加到手柄按钮上的力。模拟
XrInputAction.SqueezePressed手柄按钮被按下的程度。布尔值
XrInputAction.TriggerValue触发按钮被按下的程度。模拟
XrInputAction.TriggerPressed触发器已按下。布尔值
XrInputAction.TriggerTouched触发器被触动。布尔值
XrInputAction.ThumbstickX拇指摇杆的 X 轴值。模拟
XrInputAction.ThumbstickY拇指摇杆的 Y 轴值。模拟
XrInputAction.ThumbstickPressed拇指摇杆已按下。布尔值
XrInputAction.ThumbstickTouched拇指摇杆被触碰。布尔值
XrInputAction.ThumbrestTouched触碰拇指托。布尔值
XrInputAction.TrackpadX触控板上的 X 轴位置。模拟
XrInputAction.TrackpadY触控板上的 Y 轴位置。模拟
XrInputAction.TrackpadForce施加在触控板上的力。模拟
XrInputAction.TrackpadTouched触控板被触碰。布尔值
XrInputAction.TrackpadPressed触控板被按下。布尔
XrInputAction.IndexFingerPinch拇指与食指捏合手势。布尔
XrInputAction.MiddleFingerPinch拇指到中指的捏合手势。布尔
XrInputAction.RingFingerPinch拇指掐无名指手势布尔
XrInputAction.LittleFingerPinch拇指掐小指手势布尔手势
XrInputAction.HandTrackingMenuPress手部追踪菜单手势布尔

actionName : string

输入操作名称

使用此属性可指定要作出反应的自定义输入操作的名称。如果设置了actionId ,则此属性不起作用。


enabled : bool [default: true, since 6.9]

该属性决定输入操作是否对事件作出反应。

此属性在 Qt 6.9 中引入。


hand : enumeration

此输入操作将适用的手。

指定对哪个手做出反应。

它可以是

常量
XrInputAction.LeftHand
XrInputAction.RightHand
XrInputAction.Unknown

pressed : bool

表示输入操作当前是否已按下。

使用此属性可检查输入操作(例如按钮)是否被按下。


value : real

输入操作的模拟值。

对于拇指杆位置等模拟输入,该属性保存输入值(范围通常为 [0,1])。


信号文档

triggered()

该信号在布尔操作被激活时发出。这与pressed 属性设置为true 时同时发生。

注: 相应的处理程序是onTriggered


© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.