OLD_STEP_LIST_EDITOR
Documentation for the Unity C# Library
Loading...
Searching...
No Matches
InputListener.cs
Go to the documentation of this file.
1
using
System;
2
using
System.Collections;
3
using
System.Collections.Generic;
4
using
Autohand;
5
using
Autohand.Demo;
6
using
PixoVR.Core
;
7
using
PixoVR.Event
;
8
using
UnityEngine;
9
10
public
class
InputListener
: MonoBehaviour
11
{
12
public
event
Action<Hand>
TriggerPressed
;
13
public
event
Action<Hand>
TriggerReleased
;
14
15
[SerializeField]
private
XRHandControllerLink
_rightController
;
16
[SerializeField]
private
XRHandControllerLink
_leftController
;
17
18
private
bool
_rightTriggerPressed
;
19
private
bool
_leftTriggerPressed
;
20
21
public
bool
IsButtonPressed
(Hand hand, CommonButton button)
22
{
23
if
(
_rightController
.hand == hand &&
_rightController
.ButtonPressed(button))
24
{
25
return
true
;
26
}
27
28
if
(
_leftController
.hand == hand &&
_leftController
.ButtonPressed(button))
29
{
30
return
true
;
31
}
32
33
return
false
;
34
}
35
36
private
void
Update
()
37
{
38
if
(
_rightController
.ButtonPressed(CommonButton.triggerButton) && !
_rightTriggerPressed
)
39
{
40
_rightTriggerPressed
=
true
;
41
TriggerPressed
?.Invoke(
_rightController
.hand);
42
}
43
if
(!
_rightController
.ButtonPressed(CommonButton.triggerButton) &&
_rightTriggerPressed
)
44
{
45
_rightTriggerPressed
=
false
;
46
TriggerReleased
?.Invoke(
_rightController
.hand);
47
}
48
49
if
(
_leftController
.ButtonPressed(CommonButton.triggerButton) && !
_leftTriggerPressed
)
50
{
51
_leftTriggerPressed
=
true
;
52
TriggerPressed
?.Invoke(
_leftController
.hand);
53
}
54
if
(!
_leftController
.ButtonPressed(CommonButton.triggerButton) &&
_leftTriggerPressed
)
55
{
56
_leftTriggerPressed
=
false
;
57
TriggerReleased
?.Invoke(
_leftController
.hand);
58
}
59
}
60
61
public
Vector2
GetAxis
(Hand hand)
62
{
63
if
(
_rightController
.hand == hand )
64
{
65
return
_rightController
.GetAxis2D(Common2DAxis.primaryAxis);
66
}
67
68
if
(
_leftController
.hand == hand)
69
{
70
return
_leftController
.GetAxis2D(Common2DAxis.primaryAxis);
71
}
72
73
return
Vector2.zero;
74
}
75
}
InputListener
Definition
InputListener.cs:11
InputListener._leftTriggerPressed
bool _leftTriggerPressed
Definition
InputListener.cs:28
InputListener.GetAxis
Vector2 GetAxis(Hand hand)
Definition
InputListener.cs:70
InputListener._rightTriggerPressed
bool _rightTriggerPressed
Definition
InputListener.cs:27
InputListener.TriggerPressed
Action< Hand > TriggerPressed
Definition
InputListener.cs:12
InputListener.Update
void Update()
Definition
InputListener.cs:45
InputListener.IsButtonPressed
bool IsButtonPressed(Hand hand, CommonButton button)
Definition
InputListener.cs:30
InputListener._rightController
XRHandControllerLink _rightController
[SerializeField]
Definition
InputListener.cs:21
InputListener._leftController
XRHandControllerLink _leftController
[SerializeField]
Definition
InputListener.cs:25
InputListener.TriggerReleased
Action< Hand > TriggerReleased
Definition
InputListener.cs:13
PixoVR.Core
Definition
EventBetter.cs:14
PixoVR.Event
Definition
ItemIDAttribute.cs:5
com.pixovr.eventunitysdk
Runtime
Sdk
Scripts
InputListener.cs
Generated
Wed Oct 9 2024 19:24:02
by Doxygen version
1.10.0