14
14
// You should have received a copy of the GNU Lesser General Public License
15
15
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16
16
17
+ using System . Collections ;
17
18
using System . Collections . Generic ;
18
19
using System . Diagnostics . CodeAnalysis ;
19
20
using System . Linq ;
@@ -29,17 +30,18 @@ namespace CustomAvatar.Tracking.UnityXR
29
30
internal class UnityXRFingerTrackingProvider : IFingerTrackingProvider , ITickable
30
31
{
31
32
// these values are based on Index controllers and may not work as well with others
32
- private static readonly float [ ] kOpenFingerCurls = { - 17f , 7f , 11f , 13f , 10f } ;
33
- private static readonly float [ ] kClosedFingerCurls = { 136f , 291f , 291f , 292f , 287f } ;
33
+ private static readonly float [ ] kOpenFingerCurls = [ - 17f , 7f , 11f , 13f , 10f ] ;
34
+ private static readonly float [ ] kClosedFingerCurls = [ 136f , 291f , 291f , 292f , 287f ] ;
34
35
35
- private readonly List < XRHandSubsystem > _subsystems = new ( ) ;
36
+ // Can't use XRHandSubsystem for field types since they'll fail to load if Unity.XR.Hands isn't installed.
37
+ private readonly IList _subsystems = new List < XRHandSubsystem > ( ) ;
36
38
37
39
private readonly float [ ] _leftHandFingerCurls = new float [ 5 ] ;
38
40
private readonly float [ ] _rightHandFingerCurls = new float [ 5 ] ;
39
41
40
42
private readonly BeatSaberUtilities _beatSaberUtilities ;
41
43
42
- private XRHandSubsystem _subsystem ;
44
+ private ISubsystem _subsystem ;
43
45
44
46
private bool _leftJointsTracked ;
45
47
private bool _rightJointsTracked ;
@@ -57,8 +59,9 @@ public void Tick()
57
59
return ;
58
60
}
59
61
60
- SubsystemManager . GetSubsystems ( _subsystems ) ;
61
- XRHandSubsystem subsystem = _subsystems . FirstOrDefault ( s => s . running ) ;
62
+ var subsystems = ( List < XRHandSubsystem > ) _subsystems ;
63
+ SubsystemManager . GetSubsystems ( subsystems ) ;
64
+ XRHandSubsystem subsystem = subsystems . FirstOrDefault ( s => s . running ) ;
62
65
63
66
if ( subsystem == null )
64
67
{
@@ -67,12 +70,12 @@ public void Tick()
67
70
68
71
if ( _subsystem != null )
69
72
{
70
- _subsystem . updatedHands -= OnUpdatedHands ;
73
+ ( ( XRHandSubsystem ) _subsystem ) . updatedHands -= OnUpdatedHands ;
71
74
}
72
75
73
76
_subsystem = subsystem ;
74
77
75
- _subsystem . updatedHands += OnUpdatedHands ;
78
+ subsystem . updatedHands += OnUpdatedHands ;
76
79
}
77
80
78
81
private void OnUpdatedHands ( XRHandSubsystem handSubsystem , XRHandSubsystem . UpdateSuccessFlags updateSuccessFlags , XRHandSubsystem . UpdateType updateType )
0 commit comments