使用openvr開發Oculus手柄,在操作Oculus手柄時發現trigger鍵十分靈敏,任何物體只要接觸到trigger鍵都會觸發trigger鍵綁定的事件響應
解決辦法:
在openvr中有個結構體
struct VRControllerState001_t
{
// If packet num matches that on your prior call, then the controller state hasn't been changed since
// your last call and there is no need to process it
uint32_t unPacketNum;
// bit flags for each of the buttons. Use ButtonMaskFromId to turn an ID into a mask
uint64_t ulButtonPressed;
uint64_t ulButtonTouched;
// Axis data for the controller's analog inputs
VRControllerAxis_t rAxis[ k_unControllerStateAxisCount ];
};
typedef VRControllerState001_t VRControllerState_t;
其中名爲VRControllerAxis_t rAxis[ k_unControllerStateAxisCount ]的數組,用於Oculus手柄後發現該數組的第二個元素的x值rAxis[1].x在手柄的trigger鍵被施加不同壓力時也會跟着變化,隨着壓力的增大而增大,減小而減小,範圍從0到1。因此,可以通過對該值增加一個判斷來控制trigger鍵的響應,具體設置多少因人而異;