Skip to content

Commit b4f0580

Browse files
committed
Add new input sources, add support to load skeleton summaries
1 parent edc0da5 commit b4f0580

1 file changed

Lines changed: 50 additions & 6 deletions

File tree

EasyOpenVRSingleton.cs

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,14 @@ public VREvent_t[] GetNewEvents()
434434
public enum InputSource
435435
{
436436
[Description("/unrestricted")] Any,
437+
438+
[Description(OpenVR.k_pchPathDevices)] Devices,
437439

438440
[Description(OpenVR.k_pchPathUserHandLeft)]
439441
LeftHand,
442+
443+
[Description(OpenVR.k_pchPathUserWristLeft)]
444+
LeftWrist,
440445

441446
[Description(OpenVR.k_pchPathUserElbowLeft)]
442447
LeftElbow,
@@ -446,12 +451,18 @@ public enum InputSource
446451

447452
[Description(OpenVR.k_pchPathUserKneeLeft)]
448453
LeftKnee,
454+
455+
[Description(OpenVR.k_pchPathUserAnkleLeft)]
456+
LeftAnkle,
449457

450458
[Description(OpenVR.k_pchPathUserFootLeft)]
451459
LeftFoot,
452460

453461
[Description(OpenVR.k_pchPathUserHandRight)]
454462
RightHand,
463+
464+
[Description(OpenVR.k_pchPathUserWristRight)]
465+
RightWrist,
455466

456467
[Description(OpenVR.k_pchPathUserElbowRight)]
457468
RightElbow,
@@ -461,6 +472,9 @@ public enum InputSource
461472

462473
[Description(OpenVR.k_pchPathUserKneeRight)]
463474
RightKnee,
475+
476+
[Description(OpenVR.k_pchPathUserAnkleRight)]
477+
RightAnkle,
464478

465479
[Description(OpenVR.k_pchPathUserFootRight)]
466480
RightFoot,
@@ -494,7 +508,8 @@ public enum InputType
494508
{
495509
Analog,
496510
Digital,
497-
Pose
511+
Pose,
512+
SkeletonSummary
498513
}
499514

500515
private class InputAction
@@ -598,6 +613,22 @@ public bool RegisterAnalogAction(string path, Action<InputAnalogActionData_t, In
598613
var error = RegisterAction(ref ia);
599614
return DebugLog(error);
600615
}
616+
617+
/**
618+
* Register a skeleton action with a callback action
619+
*/
620+
public bool RegisterSkeletonSummaryAction(string path, Action<VRSkeletalSummaryData_t, InputActionInfo> action)
621+
{
622+
var ia = new InputAction
623+
{
624+
path = path,
625+
type = InputType.SkeletonSummary,
626+
action = action,
627+
data = new VRSkeletalSummaryData_t()
628+
};
629+
var error = RegisterAction(ref ia);
630+
return DebugLog(error);
631+
}
601632

602633
/**
603634
* Register a digital action with a callback action
@@ -658,12 +689,13 @@ public ulong GetInputSourceHandle(InputSource inputSource)
658689
* Digital actions triggers on change, analog actions every update.
659690
* OBS: Only run this once per update, or you'll get no input data at all.
660691
*/
661-
public bool UpdateActionStates(ulong[] inputSourceHandles = null)
692+
public bool UpdateActionStates(ulong[] inputSourceHandles, ulong skeletonSummaryInputSourceHandle)
662693
{
663-
if (inputSourceHandles == null) inputSourceHandles = new ulong[] { OpenVR.k_ulInvalidPathHandle };
664-
var error = OpenVR.Input.UpdateActionState(_inputActionSets.ToArray(),
665-
(uint)Marshal.SizeOf(typeof(VRActiveActionSet_t)));
666-
694+
if (inputSourceHandles.Length == 0) inputSourceHandles = [OpenVR.k_ulInvalidPathHandle];
695+
var error = OpenVR.Input.UpdateActionState(
696+
_inputActionSets.ToArray(),
697+
(uint)Marshal.SizeOf(typeof(VRActiveActionSet_t))
698+
);
667699
_inputActions.ForEach((InputAction action) =>
668700
{
669701
switch (action.type)
@@ -677,10 +709,22 @@ public bool UpdateActionStates(ulong[] inputSourceHandles = null)
677709
case InputType.Pose:
678710
foreach (var handle in inputSourceHandles) GetPoseAction(action, handle);
679711
break;
712+
case InputType.SkeletonSummary:
713+
GetSkeletalSummary(action, skeletonSummaryInputSourceHandle);
714+
break;
680715
}
681716
});
682717
return DebugLog(error);
683718
}
719+
720+
private bool GetSkeletalSummary(InputAction inputAction, ulong inputSourceHandle)
721+
{
722+
var data = (VRSkeletalSummaryData_t)inputAction.data;
723+
var error = OpenVR.Input.GetSkeletalSummaryData(inputAction.handle, EVRSummaryType.FromDevice, ref data);
724+
var action = ((Action<VRSkeletalSummaryData_t, InputActionInfo>)inputAction.action);
725+
action.Invoke(data, inputAction.getInfo(inputSourceHandle));
726+
return DebugLog(error, $"handle: {inputAction.handle}, error");
727+
}
684728

685729
private bool GetAnalogAction(InputAction inputAction, ulong inputSourceHandle)
686730
{

0 commit comments

Comments
 (0)