Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Change requests/hand input #192

Merged
merged 1 commit into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
namespace XRTK.SDK.Input
{
/// <summary>
/// Utilitiy component to record a hand controller's data into a file.
/// Utility component to record a hand controller's data into a file.
/// </summary>
public class HandDataRecorder : InputSystemGlobalListener, IMixedRealityInputHandler<HandData>
{
private RecordedHandJoints currentRecording;
RecordedHandJoints recordedHandJoints = new RecordedHandJoints();
RecordedHandJoint[] jointPoses = new RecordedHandJoint[HandData.JointCount];

[SerializeField]
[Tooltip("The handedness of the hand to record data for.")]
Expand All @@ -26,35 +28,29 @@ public class HandDataRecorder : InputSystemGlobalListener, IMixedRealityInputHan

private void Update()
{
if (currentRecording != null && UnityEngine.Input.GetKeyDown(saveRecordingKey))
// TODO Update this to use an action instead of raw keyboard input
if (currentRecording != null && UnityEngine.Input.GetKeyUp(saveRecordingKey))
{
// TODO dump to XRTK.Generated/Recorded Poses?
Debug.Log(JsonUtility.ToJson(currentRecording));
}
}

/// <inheritdoc />
public void OnInputChanged(InputEventData<HandData> eventData)
{
#if UNITY_EDITOR

if (targetHandedness != eventData.Handedness)
{
return;
}

var handData = eventData.InputData;
var recordedHandJoints = new RecordedHandJoints();
var jointPoses = new RecordedHandJoint[HandData.JointCount];

for (int i = 0; i < HandData.JointCount; i++)
{
var jointPose = handData.Joints[i];
jointPoses[i] = new RecordedHandJoint((TrackedHandJoint)i, jointPose);
jointPoses[i] = new RecordedHandJoint((TrackedHandJoint)i, eventData.InputData.Joints[i]);
}

recordedHandJoints.items = jointPoses;
recordedHandJoints.Joints = jointPoses;
currentRecording = recordedHandJoints;

#endif
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public override void OnInputChanged(InputEventData<HandData> eventData)
// This pointer type must only be used with hand controllers.
if (!(Controller is IMixedRealityHandController handController))
{
Debug.LogError($"{typeof(HandNearPointer).Name} is only for use with {typeof(IMixedRealityHandController).Name} controllers!", this);
Debug.LogError($"{nameof(HandNearPointer)} is only for use with {nameof(IMixedRealityHandController)} controllers!", this);
return;
}

Expand Down