Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
Merge pull request #77 from mixer/new-control-infrastructure
Browse files Browse the repository at this point in the history
New control infrastructure
  • Loading branch information
payzer authored Apr 30, 2018
2 parents 56ea9dd + 818eed7 commit ce3858a
Show file tree
Hide file tree
Showing 17 changed files with 1,101 additions and 373 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public int RemainingCooldown
get
{
Int64 now = (Int64)DateTime.UtcNow.ToUniversalTime().Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds;
int timeRemaining = (int)(cooldownExpirationTime - now);
int timeRemaining = (int)(_cooldownExpirationTime - now);
if (timeRemaining < 0)
{
timeRemaining = 0;
Expand Down Expand Up @@ -90,7 +90,7 @@ public bool ButtonDown
bool isDown = false;
if (ControlID != null)
{
InternalButtonCountState ButtonCountState;
_InternalButtonCountState ButtonCountState;
if (InteractivityManager._buttonStates.TryGetValue(ControlID, out ButtonCountState))
{
isDown = ButtonCountState.CountOfButtonDownEvents > 0;
Expand All @@ -110,7 +110,7 @@ public bool ButtonPressed
bool isPressed = false;
if (ControlID != null)
{
InternalButtonCountState ButtonCountState;
_InternalButtonCountState ButtonCountState;
if (InteractivityManager._buttonStates.TryGetValue(ControlID, out ButtonCountState))
{
isPressed = ButtonCountState.CountOfButtonPressEvents > 0;
Expand All @@ -130,7 +130,7 @@ public bool ButtonUp
bool isUp = false;
if (ControlID != null)
{
InternalButtonCountState ButtonCountState;
_InternalButtonCountState ButtonCountState;
if (InteractivityManager._buttonStates.TryGetValue(ControlID, out ButtonCountState))
{
isUp = ButtonCountState.CountOfButtonUpEvents > 0;
Expand All @@ -150,7 +150,7 @@ public uint CountOfButtonDowns
uint countOfButtonDownEvents = 0;
if (ControlID != null)
{
InternalButtonCountState ButtonCountState;
_InternalButtonCountState ButtonCountState;
if (InteractivityManager._buttonStates.TryGetValue(ControlID, out ButtonCountState))
{
countOfButtonDownEvents = ButtonCountState.CountOfButtonDownEvents;
Expand All @@ -170,7 +170,7 @@ public uint CountOfButtonPresses
uint countOfButtonPressEvents = 0;
if (ControlID != null)
{
InternalButtonCountState ButtonCountState;
_InternalButtonCountState ButtonCountState;
if (InteractivityManager._buttonStates.TryGetValue(ControlID, out ButtonCountState))
{
countOfButtonPressEvents = ButtonCountState.CountOfButtonPressEvents;
Expand All @@ -190,7 +190,7 @@ public uint CountOfButtonUps
uint countOfButtonPressEvents = 0;
if (ControlID != null)
{
InternalButtonCountState ButtonCountState;
_InternalButtonCountState ButtonCountState;
if (InteractivityManager._buttonStates.TryGetValue(ControlID, out ButtonCountState))
{
countOfButtonPressEvents = ButtonCountState.CountOfButtonUpEvents;
Expand All @@ -206,9 +206,9 @@ public uint CountOfButtonUps
/// <param name="progress">Value from 0.0 to 1.0.</param>
public void SetProgress(float progress)
{
InteractivityManager.SingletonInstance.SendSetButtonControlProperties(
InteractivityManager.SingletonInstance._SendSetButtonControlProperties(
ControlID,
InteractivityManager.WS_MESSAGE_KEY_PROGRESS,
InteractivityManager._WS_MESSAGE_KEY_PROGRESS,
false,
progress,
string.Empty,
Expand All @@ -221,9 +221,9 @@ public void SetProgress(float progress)
/// <param name="text">String to display on the button.</param>
public void SetText(string text)
{
InteractivityManager.SingletonInstance.SendSetButtonControlProperties(
InteractivityManager.SingletonInstance._SendSetButtonControlProperties(
ControlID,
InteractivityManager.WS_MESSAGE_KEY_TEXT,
InteractivityManager._WS_MESSAGE_KEY_TEXT,
false,
0,
text,
Expand All @@ -236,9 +236,9 @@ public void SetText(string text)
/// <param name="cost">The number of sparks for this action.</param>
public void SetCost(uint cost)
{
InteractivityManager.SingletonInstance.SendSetButtonControlProperties(
InteractivityManager.SingletonInstance._SendSetButtonControlProperties(
ControlID,
InteractivityManager.WS_MESSAGE_KEY_COST,
InteractivityManager._WS_MESSAGE_KEY_COST,
false,
0,
string.Empty,
Expand All @@ -251,7 +251,7 @@ public void SetCost(uint cost)
/// <param name="userID">The ID of the user who used the input control.</param>
public bool GetButtonDown(uint userID)
{
return InteractivityManager.SingletonInstance.GetButtonDown(ControlID, userID);
return InteractivityManager.SingletonInstance._GetButtonDown(ControlID, userID);
}

/// <summary>
Expand All @@ -260,7 +260,7 @@ public bool GetButtonDown(uint userID)
/// <param name="userID">The ID of the user who used the input control.</param>
public bool GetButtonPressed(uint userID)
{
return InteractivityManager.SingletonInstance.GetButtonPressed(ControlID, userID);
return InteractivityManager.SingletonInstance._GetButtonPressed(ControlID, userID);
}

/// <summary>
Expand All @@ -269,7 +269,7 @@ public bool GetButtonPressed(uint userID)
/// <param name="userID">The ID of the user who used the input control.</param>
public bool GetButtonUp(uint userID)
{
return InteractivityManager.SingletonInstance.GetButtonUp(ControlID, userID);
return InteractivityManager.SingletonInstance._GetButtonUp(ControlID, userID);
}

/// <summary>
Expand All @@ -278,7 +278,7 @@ public bool GetButtonUp(uint userID)
/// <param name="userID">The ID of the user who used the input control.</param>
public uint GetCountOfButtonDowns(uint userID)
{
return InteractivityManager.SingletonInstance.GetCountOfButtonDowns(ControlID, userID);
return InteractivityManager.SingletonInstance._GetCountOfButtonDowns(ControlID, userID);
}

/// <summary>
Expand All @@ -287,7 +287,7 @@ public uint GetCountOfButtonDowns(uint userID)
/// <param name="userID">The ID of the user who used the input control.</param>
public uint GetCountOfButtonPresses(uint userID)
{
return InteractivityManager.SingletonInstance.GetCountOfButtonPresses(ControlID, userID);
return InteractivityManager.SingletonInstance._GetCountOfButtonPresses(ControlID, userID);
}

/// <summary>
Expand All @@ -296,7 +296,7 @@ public uint GetCountOfButtonPresses(uint userID)
/// <param name="userID">The ID of the user who used the input control.</param>
public uint GetCountOfButtonUps(uint userID)
{
return InteractivityManager.SingletonInstance.GetCountOfButtonUps(ControlID, userID);
return InteractivityManager.SingletonInstance._GetCountOfButtonUps(ControlID, userID);
}

/// <summary>
Expand All @@ -308,8 +308,9 @@ public void TriggerCooldown(int cooldown)
InteractivityManager.SingletonInstance.TriggerCooldown(ControlID, cooldown);
}

internal Int64 cooldownExpirationTime;
public InteractiveButtonControl(string controlID, InteractiveEventType type, bool disabled, string helpText, uint cost, string eTag, string sceneID) : base(controlID, InteractivityManager.CONTROL_TYPE_BUTTON, type, disabled, helpText, eTag, sceneID)
internal Int64 _cooldownExpirationTime;
public InteractiveButtonControl(string controlID, InteractiveEventType type, bool disabled, string helpText, uint cost, string eTag, string sceneID, Dictionary<string, object> metaproperties) :
base(controlID, InteractivityManager._CONTROL_TYPE_BUTTON, type, disabled, helpText, eTag, sceneID, metaproperties)
{
Cost = cost;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
using System.Collections.Generic;

namespace Microsoft.Mixer
{
/// Base class for Interactivity controls. All controls are created and
Expand Down Expand Up @@ -59,10 +61,19 @@ public string HelpText
private set;
}

internal string ETag;
internal string SceneID;
internal string Kind;
internal InteractiveEventType Type;
/// <summary>
/// Returns a read only dictionary of name, value pairs for the control's metadata.
/// </summary>
public IDictionary<string, object> MetaProperties
{
get;
private set;
}

internal string _eTag;
internal string _sceneID;
internal string _kind;
internal InteractiveEventType _type;
internal int participantID;

/// <summary>
Expand All @@ -72,9 +83,9 @@ public string HelpText
public void SetDisabled(bool disabled)
{
Disabled = disabled;
InteractivityManager.SingletonInstance.SendSetButtonControlProperties(
InteractivityManager.SingletonInstance._SendSetButtonControlProperties(
ControlID,
InteractivityManager.WS_MESSAGE_VALUE_DISABLED,
InteractivityManager._WS_MESSAGE_VALUE_DISABLED,
disabled,
0,
string.Empty,
Expand All @@ -89,28 +100,28 @@ public void SetDisabled(bool disabled)
public void SetProperty(InteractiveControlProperty name, bool value)
{
SetPropertyImpl(
InteractivityManager.SingletonInstance.InteractiveControlPropertyToString(name),
InteractivityManager.SingletonInstance._InteractiveControlPropertyToString(name),
value
);
}
public void SetProperty(InteractiveControlProperty name, double value)
{
SetPropertyImpl(
InteractivityManager.SingletonInstance.InteractiveControlPropertyToString(name),
InteractivityManager.SingletonInstance._InteractiveControlPropertyToString(name),
value
);
}
public void SetProperty(InteractiveControlProperty name, string value)
{
SetPropertyImpl(
InteractivityManager.SingletonInstance.InteractiveControlPropertyToString(name),
InteractivityManager.SingletonInstance._InteractiveControlPropertyToString(name),
value
);
}
public void SetProperty(InteractiveControlProperty name, object value)
{
SetPropertyImpl(
InteractivityManager.SingletonInstance.InteractiveControlPropertyToString(name),
InteractivityManager.SingletonInstance._InteractiveControlPropertyToString(name),
value
);
}
Expand Down Expand Up @@ -139,31 +150,32 @@ public void SetProperty(string name, object value)

private void SetPropertyImpl(string name, bool value)
{
InteractivityManager.SingletonInstance._QueuePropertyUpdate(SceneID, ControlID, name, value);
InteractivityManager.SingletonInstance._QueuePropertyUpdate(_sceneID, ControlID, name, value);
}
private void SetPropertyImpl(string name, double value)
{
InteractivityManager.SingletonInstance._QueuePropertyUpdate(SceneID, ControlID, name, value);
InteractivityManager.SingletonInstance._QueuePropertyUpdate(_sceneID, ControlID, name, value);
}
private void SetPropertyImpl(string name, string value)
{
InteractivityManager.SingletonInstance._QueuePropertyUpdate(SceneID, ControlID, name, value);
InteractivityManager.SingletonInstance._QueuePropertyUpdate(_sceneID, ControlID, name, value);
}
private void SetPropertyImpl(string name, object value)
{
InteractivityManager.SingletonInstance._QueuePropertyUpdate(SceneID, ControlID, name, value);
InteractivityManager.SingletonInstance._QueuePropertyUpdate(_sceneID, ControlID, name, value);
}

internal InteractiveControl(string controlID, string kind, InteractiveEventType type, bool disabled, string helpText, string eTag, string sceneID)
internal InteractiveControl(string controlID, string kind, InteractiveEventType type, bool disabled, string helpText, string eTag, string sceneID, Dictionary<string, object> metaProperties)
{
ControlID = controlID;
Kind = kind;
Type = type;
_kind = kind;
_type = type;
Disabled = disabled;
HelpText = helpText;
ETag = eTag;
SceneID = sceneID;
_eTag = eTag;
_sceneID = sceneID;
participantID = -1;
MetaProperties = metaProperties;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using UnityEngine;

namespace Microsoft.Mixer
{
public class InteractiveCoordinatesChangedEventArgs : InteractiveEventArgs
{
public string ControlID
{
get;
private set;
}

public InteractiveParticipant Participant
{
get;
private set;
}

public Vector3 Position
{
get;
private set;
}

internal InteractiveCoordinatesChangedEventArgs(
string id,
InteractiveParticipant participant,
Vector3 position) : base(InteractiveEventType.Coordinates)
{
ControlID = id;
Participant = participant;
Position = position;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ public enum InteractiveEventType
/// </summary>
Joystick,

/// <summary>
/// Events representing mouse button input.
/// </summary>
MouseButton,

/// <summary>
/// Events representing coordinate input, where input are x, y, z values from 0 to 1.
/// </summary>
Coordinates,

/// <summary>
/// Events representing text input.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public List<InteractiveParticipant> Participants
List<InteractiveParticipant> allParticipants = InteractivityManager.SingletonInstance.Participants as List<InteractiveParticipant>;
foreach (InteractiveParticipant participant in allParticipants)
{
if (participant.groupID == GroupID)
if (participant._groupID == GroupID)
{
participantsInGroup.Add(participant);
}
Expand All @@ -85,10 +85,10 @@ public string SceneID
public void SetScene(string sceneID)
{
SceneID = sceneID;
InteractivityManager.SingletonInstance.SetCurrentSceneInternal(this, sceneID);
InteractivityManager.SingletonInstance._SetCurrentSceneInternal(this, sceneID);
}

internal string etag;
internal string _etag;

/// <summary>
/// Function to construct a InteractiveGroup object.
Expand All @@ -102,7 +102,7 @@ public InteractiveGroup(string groupID)
}

GroupID = groupID;
InteractivityManager.SingletonInstance.SendCreateGroupsMessage(GroupID, InteractivityManager.WS_MESSAGE_VALUE_DEFAULT_SCENE_ID);
InteractivityManager.SingletonInstance._SendCreateGroupsMessage(GroupID, InteractivityManager._WS_MESSAGE_VALUE_DEFAULT_SCENE_ID);
}

/// <summary>
Expand All @@ -118,12 +118,12 @@ public InteractiveGroup(string groupID, string sceneID)

GroupID = groupID;
SceneID = sceneID;
InteractivityManager.SingletonInstance.SendCreateGroupsMessage(GroupID, SceneID);
InteractivityManager.SingletonInstance._SendCreateGroupsMessage(GroupID, SceneID);
}

internal InteractiveGroup(string newEtag, string sceneID, string groupID)
{
etag = newEtag;
_etag = newEtag;
SceneID = sceneID;
GroupID = groupID;
}
Expand Down
Loading

0 comments on commit ce3858a

Please sign in to comment.