Skip to content

Commit c3c5dc0

Browse files
committed
Merge pull request #58 from OSVR/JeroMiya-Adapters
Implements OSVR.ClientKit.InterfaceAdapter sub-classes for Unity and uses them in the Unity specific wrappers in place of InterfaceCallbacks. Obsoletes InterfaceCallbacks and InterfaceBase classes.
2 parents b73661e + aacd093 commit c3c5dc0

47 files changed

Lines changed: 1962 additions & 688 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# editorconfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Default settings:
7+
# A newline ending every file
8+
# Use 2 spaces as indentation
9+
# Trim trailing whitespace
10+
[*]
11+
end_of_line = lf
12+
insert_final_newline = true
13+
indent_style = space
14+
indent_size = 2
15+
trim_trailing_whitespace = true
16+
17+
[*.cs]
18+
indent_style = tab
19+
20+
[*.csproj]
21+
indent_size = 2

.gitattributes

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Source files - keep them lf
5+
*.cs text eol=lf
6+
7+
# Custom for Visual Studio
8+
*.cs diff=csharp
9+
*.sln merge=union
10+
*.csproj merge=union
11+
*.vbproj merge=union
12+
*.fsproj merge=union
13+
*.dbproj merge=union
14+
15+
# Standard to msysgit
16+
*.doc diff=astextplain
17+
*.DOC diff=astextplain
18+
*.docx diff=astextplain
19+
*.DOCX diff=astextplain
20+
*.dot diff=astextplain
21+
*.DOT diff=astextplain
22+
*.pdf diff=astextplain
23+
*.PDF diff=astextplain
24+
*.rtf diff=astextplain
25+
*.RTF diff=astextplain
26+
27+
# cmake launcher templates
28+
*.cmd.in text eol=crlf
29+
*vcproj.user.in text eol=crlf
30+
*vcxproj.user.in text eol=crlf
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!1 &175070
4+
GameObject:
5+
m_ObjectHideFlags: 0
6+
m_PrefabParentObject: {fileID: 0}
7+
m_PrefabInternal: {fileID: 100100000}
8+
serializedVersion: 4
9+
m_Component:
10+
- 4: {fileID: 475070}
11+
- 114: {fileID: 11475070}
12+
m_Layer: 0
13+
m_Name: AnalogInterface
14+
m_TagString: Untagged
15+
m_Icon: {fileID: 0}
16+
m_NavMeshLayer: 0
17+
m_StaticEditorFlags: 0
18+
m_IsActive: 1
19+
--- !u!4 &475070
20+
Transform:
21+
m_ObjectHideFlags: 1
22+
m_PrefabParentObject: {fileID: 0}
23+
m_PrefabInternal: {fileID: 100100000}
24+
m_GameObject: {fileID: 175070}
25+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
26+
m_LocalPosition: {x: 0, y: 0, z: 0}
27+
m_LocalScale: {x: 1, y: 1, z: 1}
28+
m_Children: []
29+
m_Father: {fileID: 0}
30+
m_RootOrder: 0
31+
--- !u!114 &11475070
32+
MonoBehaviour:
33+
m_ObjectHideFlags: 1
34+
m_PrefabParentObject: {fileID: 0}
35+
m_PrefabInternal: {fileID: 100100000}
36+
m_GameObject: {fileID: 175070}
37+
m_Enabled: 1
38+
m_EditorHideFlags: 0
39+
m_Script: {fileID: 11500000, guid: c64efdc2d6901004499459f19b204544, type: 3}
40+
m_Name:
41+
m_EditorClassIdentifier:
42+
path:
43+
--- !u!1001 &100100000
44+
Prefab:
45+
m_ObjectHideFlags: 1
46+
serializedVersion: 2
47+
m_Modification:
48+
m_TransformParent: {fileID: 0}
49+
m_Modifications: []
50+
m_RemovedComponents: []
51+
m_ParentPrefab: {fileID: 0}
52+
m_RootGameObject: {fileID: 175070}
53+
m_IsPrefabParent: 1
54+
m_IsExploded: 1

OSVR-Unity/Assets/OSVRUnity/Prefabs/AnalogInterface.prefab.meta

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!1 &181240
4+
GameObject:
5+
m_ObjectHideFlags: 0
6+
m_PrefabParentObject: {fileID: 0}
7+
m_PrefabInternal: {fileID: 100100000}
8+
serializedVersion: 4
9+
m_Component:
10+
- 4: {fileID: 481240}
11+
- 114: {fileID: 11481240}
12+
m_Layer: 0
13+
m_Name: ButtonInterface
14+
m_TagString: Untagged
15+
m_Icon: {fileID: 0}
16+
m_NavMeshLayer: 0
17+
m_StaticEditorFlags: 0
18+
m_IsActive: 1
19+
--- !u!4 &481240
20+
Transform:
21+
m_ObjectHideFlags: 1
22+
m_PrefabParentObject: {fileID: 0}
23+
m_PrefabInternal: {fileID: 100100000}
24+
m_GameObject: {fileID: 181240}
25+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
26+
m_LocalPosition: {x: 0, y: 0, z: 0}
27+
m_LocalScale: {x: 1, y: 1, z: 1}
28+
m_Children: []
29+
m_Father: {fileID: 0}
30+
m_RootOrder: 0
31+
--- !u!114 &11481240
32+
MonoBehaviour:
33+
m_ObjectHideFlags: 1
34+
m_PrefabParentObject: {fileID: 0}
35+
m_PrefabInternal: {fileID: 100100000}
36+
m_GameObject: {fileID: 181240}
37+
m_Enabled: 1
38+
m_EditorHideFlags: 0
39+
m_Script: {fileID: 11500000, guid: 6724792d0a561444c96a95c819782403, type: 3}
40+
m_Name:
41+
m_EditorClassIdentifier:
42+
path:
43+
--- !u!1001 &100100000
44+
Prefab:
45+
m_ObjectHideFlags: 1
46+
serializedVersion: 2
47+
m_Modification:
48+
m_TransformParent: {fileID: 0}
49+
m_Modifications: []
50+
m_RemovedComponents: []
51+
m_ParentPrefab: {fileID: 0}
52+
m_RootGameObject: {fileID: 181240}
53+
m_IsPrefabParent: 1
54+
m_IsExploded: 1

OSVR-Unity/Assets/OSVRUnity/Prefabs/ButtonInterface.prefab.meta

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OSVR-Unity/Assets/OSVRUnity/Sample/Demo/Scenes/OSVRDemo.unity

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,7 +2353,7 @@ Prefab:
23532353
objectReference: {fileID: 0}
23542354
- target: {fileID: 11436198, guid: 0b82dd794175b304a87805e4b38fbe84, type: 2}
23552355
propertyPath: AppID
2356-
value: org.opengoggles.osvr-unity.sample.demo
2356+
value: com.osvr.osvr-unity.sample.demo
23572357
objectReference: {fileID: 0}
23582358
- target: {fileID: 11436198, guid: 0b82dd794175b304a87805e4b38fbe84, type: 2}
23592359
propertyPath: m_Enabled
@@ -2475,7 +2475,7 @@ MonoBehaviour:
24752475
m_Script: {fileID: 11500000, guid: e2550bc6af558044baf4aa2ee88d5e8b, type: 3}
24762476
m_Name:
24772477
m_EditorClassIdentifier:
2478-
AppID: org.opengoggles.osvr-unity.sample.demo
2478+
AppID: com.osvr.osvr-unity.sample.demo
24792479
--- !u!1 &1818608091
24802480
GameObject:
24812481
m_ObjectHideFlags: 0
@@ -2592,7 +2592,6 @@ MonoBehaviour:
25922592
m_Script: {fileID: 11500000, guid: a288e4aec9950634b83d232abc73d1bb, type: 3}
25932593
m_Name:
25942594
m_EditorClassIdentifier:
2595-
JsonDescriptorFile: {fileID: 4900000, guid: 903a53a7997a82c42b329c472b623a4e, type: 3}
25962595
--- !u!114 &1818608098
25972596
MonoBehaviour:
25982597
m_ObjectHideFlags: 0

OSVR-Unity/Assets/OSVRUnity/Sample/Demo/Scenes/OSVRDemo2.unity

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ Prefab:
970970
objectReference: {fileID: 0}
971971
- target: {fileID: 11436198, guid: 0b82dd794175b304a87805e4b38fbe84, type: 2}
972972
propertyPath: AppID
973-
value: org.opengoggles.osvr-unity.sample.demo
973+
value: com.osvr.osvr-unity.sample.demo
974974
objectReference: {fileID: 0}
975975
m_RemovedComponents: []
976976
m_ParentPrefab: {fileID: 100100000, guid: 0b82dd794175b304a87805e4b38fbe84, type: 2}
@@ -2922,7 +2922,7 @@ MonoBehaviour:
29222922
m_Script: {fileID: 11500000, guid: e2550bc6af558044baf4aa2ee88d5e8b, type: 3}
29232923
m_Name:
29242924
m_EditorClassIdentifier:
2925-
AppID: org.opengoggles.osvr-unity.sample.demo
2925+
AppID: com.osvr.osvr-unity.sample.demo
29262926
--- !u!4 &2077590280
29272927
Transform:
29282928
m_ObjectHideFlags: 0

OSVR-Unity/Assets/OSVRUnity/Sample/Scripts/SampleAnalog.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@
2727
/// GetComponent usage required to get to the InterfaceGameObject. We can just rely on it being there and use
2828
/// the inherited properties to access it concisely. Thus, this is the preferred technique for handling callbacks.
2929
/// </summary>
30-
public class SampleAnalog : OSVR.Unity.InterfaceBase
30+
public class SampleAnalog : OSVR.Unity.RequiresAnalogInterface
3131
{
3232

3333
// Use this for initialization
3434
void Start()
3535
{
36-
osvrInterface.RegisterCallback(callback);
36+
this.Interface.StateChanged += Interface_StateChanged;
3737
}
3838

39-
void callback(string path, float value)
39+
void Interface_StateChanged(object sender, OSVR.ClientKit.TimeValue timestamp, int sensor, double report)
4040
{
41-
Debug.Log("Got analog value " + value);
41+
Debug.Log("Got analog value " + report);
4242
}
4343
}

OSVR-Unity/Assets/OSVRUnity/Sample/Scripts/SampleButtonScript.cs renamed to OSVR-Unity/Assets/OSVRUnity/Sample/Scripts/SampleButton.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@
2222
using System.Collections;
2323

2424
/// <summary>
25-
/// Note that this derives from the OSVR.Unity.InterfaceBase, and so unlike the code in HandleButtonPress.cs,
26-
/// no class attributes are required to enforce the presence of an InterfaceGameObject component, nor is any
27-
/// GetComponent usage required to get to the InterfaceGameObject. We can just rely on it being there and use
25+
/// Note that this derives from the OSVR.Unity.RequiresButtonInterface, and so unlike the code in HandleButtonPress.cs,
26+
/// no class attributes are required to enforce the presence of an ButtonInterface component, nor is any
27+
/// GetComponent usage required to get to the ButtonInterface. We can just rely on it being there and use
2828
/// the inherited properties to access it concisely. Thus, this is the preferred technique for handling callbacks.
2929
/// </summary>
30-
public class SampleButtonScript : OSVR.Unity.InterfaceBase
30+
public class SampleButton : OSVR.Unity.RequiresButtonInterface
3131
{
3232
void Start()
3333
{
34-
osvrInterface.RegisterCallback(handleButton);
34+
this.Interface.StateChanged += handleButton;
3535
}
3636

37-
void handleButton(string path, bool state)
37+
void handleButton(object sender, OSVR.ClientKit.TimeValue timestamp, int sensor, byte report)
3838
{
39-
Debug.Log("Got button: " + path + " state is " + state);
39+
Debug.Log("Got button: " + sensor.ToString() + " state is " + report);
4040
}
4141
}

0 commit comments

Comments
 (0)