Skip to content

Commit

Permalink
feat(SDK): add support for start button
Browse files Browse the repository at this point in the history
The Oculus SDK supports a start button as the left controller
menu button can be overriden to be used as a start button although
the right controller menu button is reserved for Oculus Home.

This adds the support for the start button to the Oculus SDK and to
any other VRTK classes or prefabs that deal with buttons.
  • Loading branch information
thestonefox committed Jan 17, 2017
1 parent 1f92c13 commit ad631eb
Show file tree
Hide file tree
Showing 16 changed files with 1,393 additions and 140 deletions.
122 changes: 17 additions & 105 deletions Assets/VRTK/Examples/029_Controller_Tooltips.unity
Expand Up @@ -135,15 +135,15 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 22412712, guid: 9ab61c80dfd411f4c86b8553b0c42cf1, type: 2}
propertyPath: m_SizeDelta.y
value: 0
value: 16.5
objectReference: {fileID: 0}
- target: {fileID: 22482598, guid: 9ab61c80dfd411f4c86b8553b0c42cf1, type: 2}
propertyPath: m_SizeDelta.x
value: 62.5
objectReference: {fileID: 0}
- target: {fileID: 22482598, guid: 9ab61c80dfd411f4c86b8553b0c42cf1, type: 2}
propertyPath: m_SizeDelta.y
value: 0
value: 16.5
objectReference: {fileID: 0}
- target: {fileID: 441652, guid: 9ab61c80dfd411f4c86b8553b0c42cf1, type: 2}
propertyPath: m_LocalScale.x
Expand Down Expand Up @@ -388,15 +388,15 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 22412712, guid: 9ab61c80dfd411f4c86b8553b0c42cf1, type: 2}
propertyPath: m_SizeDelta.y
value: 0
value: 16.5
objectReference: {fileID: 0}
- target: {fileID: 22482598, guid: 9ab61c80dfd411f4c86b8553b0c42cf1, type: 2}
propertyPath: m_SizeDelta.x
value: 62.5
objectReference: {fileID: 0}
- target: {fileID: 22482598, guid: 9ab61c80dfd411f4c86b8553b0c42cf1, type: 2}
propertyPath: m_SizeDelta.y
value: 0
value: 16.5
objectReference: {fileID: 0}
- target: {fileID: 441652, guid: 9ab61c80dfd411f4c86b8553b0c42cf1, type: 2}
propertyPath: m_LocalScale.x
Expand Down Expand Up @@ -708,74 +708,6 @@ Prefab:
propertyPath: touchpadText
value: R-Touchpad
objectReference: {fileID: 0}
- target: {fileID: 11415184, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
propertyPath: appMenuText
value: R-App Menu
objectReference: {fileID: 0}
- target: {fileID: 22476268, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
propertyPath: m_SizeDelta.x
value: 62.5
objectReference: {fileID: 0}
- target: {fileID: 22476268, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 22422736, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
propertyPath: m_SizeDelta.x
value: 62.5
objectReference: {fileID: 0}
- target: {fileID: 22422736, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 22465506, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
propertyPath: m_SizeDelta.x
value: 62.5
objectReference: {fileID: 0}
- target: {fileID: 22465506, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 22481940, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
propertyPath: m_SizeDelta.x
value: 62.5
objectReference: {fileID: 0}
- target: {fileID: 22481940, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 22442990, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
propertyPath: m_SizeDelta.x
value: 62.5
objectReference: {fileID: 0}
- target: {fileID: 22442990, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 22432698, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
propertyPath: m_SizeDelta.x
value: 62.5
objectReference: {fileID: 0}
- target: {fileID: 22432698, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 22482542, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
propertyPath: m_SizeDelta.x
value: 62.5
objectReference: {fileID: 0}
- target: {fileID: 22482542, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 22454212, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
propertyPath: m_SizeDelta.x
value: 62.5
objectReference: {fileID: 0}
- target: {fileID: 22454212, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11415184, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
propertyPath: buttonOneText
value: R-ButtonOne
Expand All @@ -784,25 +716,9 @@ Prefab:
propertyPath: buttonTwoText
value:
objectReference: {fileID: 0}
- target: {fileID: 224000011018885128, guid: 910be6460ba00dc4bb13725c3ff972cb,
type: 2}
propertyPath: m_SizeDelta.x
value: 62.5
objectReference: {fileID: 0}
- target: {fileID: 224000011018885128, guid: 910be6460ba00dc4bb13725c3ff972cb,
type: 2}
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224000014259110642, guid: 910be6460ba00dc4bb13725c3ff972cb,
type: 2}
propertyPath: m_SizeDelta.x
value: 62.5
objectReference: {fileID: 0}
- target: {fileID: 224000014259110642, guid: 910be6460ba00dc4bb13725c3ff972cb,
type: 2}
propertyPath: m_SizeDelta.y
value: 0
- target: {fileID: 11415184, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
propertyPath: startMenuText
value:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
Expand Down Expand Up @@ -864,6 +780,7 @@ MonoBehaviour:
boundariesSDK: 1
headsetSDK: 1
controllerSDK: 1
autoManageScriptDefines: 1
actualBoundaries: {fileID: 1188569438}
actualHeadset: {fileID: 1589250222}
actualLeftController: {fileID: 697789100}
Expand Down Expand Up @@ -1126,6 +1043,7 @@ MonoBehaviour:
left: {fileID: 697789100}
right: {fileID: 1996941625}
objects: []
assignAllBeforeIdentified: 0
--- !u!4 &1188569444
Transform:
m_ObjectHideFlags: 0
Expand All @@ -1151,7 +1069,6 @@ GameObject:
m_Component:
- 4: {fileID: 1282067424}
- 20: {fileID: 1282067428}
- 114: {fileID: 1282067427}
- 114: {fileID: 1282067426}
- 92: {fileID: 1282067425}
m_Layer: 0
Expand Down Expand Up @@ -1199,18 +1116,6 @@ MonoBehaviour:
index: 0
origin: {fileID: 0}
isValid: 0
--- !u!114 &1282067427
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 11420968, guid: 4d293c8e162f3874b982baadd71153d2,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1282067423}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: be96d45fe21847a4a805d408a8015c84, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!20 &1282067428
Camera:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1296,6 +1201,7 @@ MonoBehaviour:
buttonOneModelPath:
buttonTwoModelPath:
systemMenuModelPath:
startMenuModelPath:
elementHighlighterOverrides:
body: {fileID: 0}
trigger: {fileID: 0}
Expand All @@ -1305,6 +1211,7 @@ MonoBehaviour:
buttonOne: {fileID: 0}
buttonTwo: {fileID: 0}
systemMenu: {fileID: 0}
startMenu: {fileID: 0}
--- !u!1 &1355444891
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1533,6 +1440,10 @@ Prefab:
propertyPath: m_SizeDelta.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 11415184, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
propertyPath: startMenuText
value:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 910be6460ba00dc4bb13725c3ff972cb, type: 2}
m_IsPrefabParent: 0
Expand Down Expand Up @@ -1732,6 +1643,7 @@ MonoBehaviour:
buttonOneModelPath:
buttonTwoModelPath:
systemMenuModelPath:
startMenuModelPath:
elementHighlighterOverrides:
body: {fileID: 0}
trigger: {fileID: 0}
Expand All @@ -1741,6 +1653,7 @@ MonoBehaviour:
buttonOne: {fileID: 0}
buttonTwo: {fileID: 0}
systemMenu: {fileID: 0}
startMenu: {fileID: 0}
--- !u!1 &1589250222
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1787,7 +1700,6 @@ MonoBehaviour:
_head: {fileID: 1282067424}
_ears: {fileID: 71119717}
wireframe: 0
flip: {fileID: 0}
--- !u!124 &1589250225
Behaviour:
m_ObjectHideFlags: 0
Expand Down
Expand Up @@ -29,6 +29,12 @@ private void Start()
events.ButtonOnePressed += new ControllerInteractionEventHandler(DoButtonOnePressed);
events.ButtonOneReleased += new ControllerInteractionEventHandler(DoButtonOneReleased);

events.ButtonTwoPressed += new ControllerInteractionEventHandler(DoButtonTwoPressed);
events.ButtonTwoReleased += new ControllerInteractionEventHandler(DoButtonTwoReleased);

events.StartMenuPressed += new ControllerInteractionEventHandler(DoStartMenuPressed);
events.StartMenuReleased += new ControllerInteractionEventHandler(DoStartMenuReleased);

events.GripPressed += new ControllerInteractionEventHandler(DoGripPressed);
events.GripReleased += new ControllerInteractionEventHandler(DoGripReleased);

Expand Down Expand Up @@ -72,6 +78,40 @@ private void DoButtonOneReleased(object sender, ControllerInteractionEventArgs e
}
}

private void DoButtonTwoPressed(object sender, ControllerInteractionEventArgs e)
{
tooltips.ToggleTips(true, VRTK_ControllerTooltips.TooltipButtons.ButtonTwoTooltip);
actions.ToggleHighlightButtonTwo(true, Color.yellow, 0.5f);
actions.SetControllerOpacity(0.8f);
}

private void DoButtonTwoReleased(object sender, ControllerInteractionEventArgs e)
{
tooltips.ToggleTips(false, VRTK_ControllerTooltips.TooltipButtons.ButtonTwoTooltip);
actions.ToggleHighlightButtonTwo(false);
if (!events.AnyButtonPressed())
{
actions.SetControllerOpacity(1f);
}
}

private void DoStartMenuPressed(object sender, ControllerInteractionEventArgs e)
{
tooltips.ToggleTips(true, VRTK_ControllerTooltips.TooltipButtons.StartMenuTooltip);
actions.ToggleHighlightStartMenu(true, Color.yellow, 0.5f);
actions.SetControllerOpacity(0.8f);
}

private void DoStartMenuReleased(object sender, ControllerInteractionEventArgs e)
{
tooltips.ToggleTips(false, VRTK_ControllerTooltips.TooltipButtons.StartMenuTooltip);
actions.ToggleHighlightStartMenu(false);
if (!events.AnyButtonPressed())
{
actions.SetControllerOpacity(1f);
}
}

private void DoGripPressed(object sender, ControllerInteractionEventArgs e)
{
tooltips.ToggleTips(true, VRTK_ControllerTooltips.TooltipButtons.GripTooltip);
Expand Down
Expand Up @@ -61,6 +61,9 @@ private void Start()
GetComponent<VRTK_ControllerEvents>().ButtonTwoTouchStart += new ControllerInteractionEventHandler(DoButtonTwoTouchStart);
GetComponent<VRTK_ControllerEvents>().ButtonTwoTouchEnd += new ControllerInteractionEventHandler(DoButtonTwoTouchEnd);

GetComponent<VRTK_ControllerEvents>().StartMenuPressed += new ControllerInteractionEventHandler(DoStartMenuPressed);
GetComponent<VRTK_ControllerEvents>().StartMenuReleased += new ControllerInteractionEventHandler(DoStartMenuReleased);

GetComponent<VRTK_ControllerEvents>().ControllerEnabled += new ControllerInteractionEventHandler(DoControllerEnabled);
GetComponent<VRTK_ControllerEvents>().ControllerDisabled += new ControllerInteractionEventHandler(DoControllerDisabled);

Expand Down Expand Up @@ -228,6 +231,16 @@ private void DoButtonTwoTouchEnd(object sender, ControllerInteractionEventArgs e
DebugLogger(e.controllerIndex, "BUTTON TWO", "untouched", e);
}

private void DoStartMenuPressed(object sender, ControllerInteractionEventArgs e)
{
DebugLogger(e.controllerIndex, "START MENU", "pressed down", e);
}

private void DoStartMenuReleased(object sender, ControllerInteractionEventArgs e)
{
DebugLogger(e.controllerIndex, "START MENU", "released", e);
}

private void DoControllerEnabled(object sender, ControllerInteractionEventArgs e)
{
DebugLogger(e.controllerIndex, "CONTROLLER STATE", "ENABLED", e);
Expand Down

0 comments on commit ad631eb

Please sign in to comment.