/// <summary> /// Feed the HandDataManager with the apollo hand data, this will only work if the stream type is set to custom. /// </summary> /// <param name="apolloHandData">The new apollo hand data.</param> /// <param name="side">The side for which this data applies.</param> public static void FeedCustomStreamHandData(ApolloHandData apolloHandData, GloveLaterality side) { if (OnNewCustomStreamHandData != null) { OnNewCustomStreamHandData(apolloHandData, side); } }
public ApolloRawData GetRawHandData(GloveLaterality laterality) { switch (laterality) { case GloveLaterality.GLOVE_LEFT: return(_leftHandRaw); case GloveLaterality.GLOVE_RIGHT: return(_rightHandRaw); default: throw new ArgumentOutOfRangeException("laterality", laterality, null); } }
public bool HasReceivedData(GloveLaterality laterality) { switch (laterality) { case GloveLaterality.GLOVE_LEFT: return(_leftHand.IsValid); case GloveLaterality.GLOVE_RIGHT: return(_rightHand.IsValid); default: throw new ArgumentOutOfRangeException("laterality", laterality, null); } }
public static void rumble(GloveLaterality side, ushort duration, ushort power) { // try to find a glove with the inserted handedness foreach (var glove in sourceList) { if (glove.Value.handedness == side) { var eventId = randomEventId; var packet = ApolloSDK.generateDeviceVibrate(_session, glove.Key, duration, power, eventId); sendPacket(packet); eventList.Add(eventId, new eventData(EventType.RUMBLE)); } } }
private static void NewRawData(ApolloRawData data, GloveLaterality side) { //Log("Received new raw data for a " + side + " glove with device ID " + data.deviceID + "."); // Get ready to store the new data. int playerIndex = -1; device_type_t deviceType = device_type_t.GLOVE_LEFT; if (!PrepareForNewData(data.IsValid, side, data.deviceID, out playerIndex, out deviceType)) { // Failed to prepare for the new data. The new data cannot be stored. // Printing a log message is done in the function, so don't print anything here. return; } // Set the data. playerData[playerIndex].handData[deviceType].SetRawData(data); }
private static bool PrepareForNewData(bool isValid, GloveLaterality laterality, UInt64 deviceID, out int playerIndex, out device_type_t deviceType) { int numPlayersStored = playerData.Count; int numGlovesKnown = GetNumberOfGlovesKnown(); playerIndex = -1; deviceType = device_type_t.GLOVE_LEFT; // Make sure the new data is usable. if (!isValid) { Debug.LogWarning("Received new hand data, but its contents are invalid."); return(false); } // Check the glove laterality. if (!ConvertGloveLateralityToDeviceType(laterality, out deviceType)) { // The laterality could not be converted. // A log message is printed in the function, so don't print anything here. return(false); } // Find the player for this data. if (!FindExistingPlayerUsingDeviceID(deviceID, deviceType, out playerIndex)) { AddNewPlayerForDeviceID(deviceID, out playerIndex); } // Make sure the hand data exists. if (!playerData[playerIndex].handData.ContainsKey(deviceType)) { playerData[playerIndex].handData.Add(deviceType, new ApolloHandData()); } LogIfNumbersChanged(numPlayersStored, numGlovesKnown); return(true); }
public void newRawData(ApolloRawData data, GloveLaterality side) { if (!ShouldAcceptApolloData) { return; } switch (side) { case GloveLaterality.GLOVE_LEFT: // store the raw data _leftHandRaw = data; break; case GloveLaterality.GLOVE_RIGHT: // store the raw data _rightHandRaw = data; break; } }
public void newHandData(ApolloJointData data, GloveLaterality side) { //todo clean up null check if (!ShouldAcceptApolloData || data.fingers == null) { return; } switch (side) { case GloveLaterality.GLOVE_LEFT: // store the jointData for later use _leftHand = data; break; case GloveLaterality.GLOVE_RIGHT: // store the jointData for later use _rightHand = data; break; } }
private static bool ConvertGloveLateralityToDeviceType(GloveLaterality input, out device_type_t output) { output = device_type_t.GLOVE_LEFT; switch (input) { case GloveLaterality.UNKNOWN: Debug.LogError("Tried to convert a GloveLaterality to a device_type_t, but its value was UNKNOWN."); return(false); case GloveLaterality.GLOVE_LEFT: output = device_type_t.GLOVE_LEFT; return(true); case GloveLaterality.GLOVE_RIGHT: output = device_type_t.GLOVE_RIGHT; return(true); default: Debug.LogError("Tried to convert a GloveLaterality to a device_type_t, but it had an unrecognised value. Its value was " + input + "."); return(false); } }
public GloveInfo(GloveState state) { this.state = state; this.handedness = GloveLaterality.UNKNOWN; }