---
# System prepended metadata

title: 手把相關

---

# 手把相關

:::success
新套件包有包好的函式庫 (`PicoInput`)，可以去看看
:::

![](https://i.imgur.com/c4vRmKP.png)


## ~~VR SDK~~
:::info
**基本上所有手柄相關函式的接口都在 `Pvr_UnitySDKAPI.Controller` 底下**
e.g. `Pvr_UnitySDKAPI.Controller.UPvr_GetKey(1, Pvr_UnitySDKAPI.Pvr_KeyCode.Y)`
:::

## XR SDK

```csharp
InputDevices.GetDeviceAtXRNode(XRNode.XXX).TryGetFeatureValue(CommonUsages.XXX, out bool value)
```



|   鍵位   | CommonUsages                      |
|:--------:|:--------------------------------- |
|   Menu   | `CommonUsages.menuButton`         |
| Trigger  | `CommonUsages.TriggerButton`      |
|   Grip   | `CommonUsages.GripButton`         |
| Joystick | `CommonUsages.primary2DAxisClick` |
|   X/A    | `CommonUsages.primaryButton`      |
|   Y/B    | `CommonUsages.secondaryButton`    |


上例是否按下的值會放在 `value`，而函式回傳結果是是否成功取得，如我們想要判斷左手柄 X 按鈕是否按下可以寫成：

```csharp
if(InputDevices.GetDeviceAtXRNode(XRNode.LeftHand).TryGetFeatureValue(CommonUsages.primaryButton, out bool x) && x)
{
    // ...
}
```

Note: 這類似於 GetButton 而非 GetButtonDown (需要自己做按下判斷)
**(新套件包有 GetButtonDown)*

-------

###### References
- https://blog.csdn.net/weixin_38239050/article/details/117567561
- https://developer.pico-interactive.com/document/doc
