├── .gitignore ├── Assets ├── MobileVRController.meta ├── MobileVRController │ ├── MControllerVisualizer.cs │ ├── MControllerVisualizer.cs.meta │ ├── Prefab.meta │ ├── Prefab │ │ ├── MController.prefab │ │ ├── MController.prefab.meta │ │ ├── MobileSurface.mat │ │ ├── MobileSurface.mat.meta │ │ ├── ScreenSurface.mat │ │ ├── ScreenSurface.mat.meta │ │ ├── TouchPoint.mat │ │ └── TouchPoint.mat.meta │ ├── ServiceManager.cs │ ├── ServiceManager.cs.meta │ ├── Services.meta │ ├── Services │ │ ├── AccelServiceProvider.cs │ │ ├── AccelServiceProvider.cs.meta │ │ ├── FeedbackServiceProvider.cs │ │ ├── FeedbackServiceProvider.cs.meta │ │ ├── GyroServiceProvider.cs │ │ ├── GyroServiceProvider.cs.meta │ │ ├── IServiceProvider.cs │ │ ├── IServiceProvider.cs.meta │ │ ├── SwipeServiceProvider.cs │ │ ├── SwipeServiceProvider.cs.meta │ │ ├── TouchServiceProvider.cs │ │ └── TouchServiceProvider.cs.meta │ ├── UIServerPanel.cs │ └── UIServerPanel.cs.meta ├── Scenes.meta └── Scenes │ ├── Receiver.unity │ ├── Receiver.unity.meta │ ├── Sender.unity │ ├── Sender.unity.meta │ ├── VibrateTriggerTest.cs │ └── VibrateTriggerTest.cs.meta ├── LICENSE.md ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset └── UnityConnectSettings.asset └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /[Ll]ibrary/ 2 | /[Tt]emp/ 3 | /[Oo]bj/ 4 | /[Bb]uild/ 5 | /[Bb]uilds/ 6 | /[Bb]in/ 7 | /Assets/AssetStoreTools* 8 | 9 | # Autogenerated VS/MD/Consulo solution and project files 10 | ExportedObj/ 11 | .consulo/ 12 | *.csproj 13 | *.unityproj 14 | *.sln 15 | *.suo 16 | *.tmp 17 | *.user 18 | *.userprefs 19 | *.pidb 20 | *.booproj 21 | *.svd 22 | 23 | 24 | # Unity3D generated meta files 25 | *.pidb.meta 26 | 27 | # Unity3D Generated File On Crash Reports 28 | sysinfo.txt 29 | 30 | # Builds 31 | *.apk 32 | *.unitypackage 33 | -------------------------------------------------------------------------------- /Assets/MobileVRController.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 71e6d3006f6b84472976c21bed0348c5 3 | folderAsset: yes 4 | timeCreated: 1482181900 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/MobileVRController/MControllerVisualizer.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class MControllerVisualizer : MonoBehaviour { 6 | public ServiceManager Service; 7 | public Vector3 Rotation; 8 | Quaternion _rawRotation; 9 | public Vector3[] Points; 10 | public SwipeServiceProvider.ESwipeType Swipe; 11 | public Vector3 Acceleration; 12 | 13 | public GameObject TouchObject; 14 | public GameObject ScreenSurface; 15 | 16 | LineRenderer AccelerationRenderer; 17 | 18 | List _touchObjects=new List(); 19 | 20 | // Use this for initialization 21 | void Start () { 22 | Service.OnValueChanged += OnValueChanged; 23 | 24 | for (int i = 0; i < 5; ++i) { 25 | GameObject o = GameObject.Instantiate (TouchObject); 26 | o.transform.parent = ScreenSurface.transform; 27 | o.transform.localPosition = Vector3.zero; 28 | o.SetActive (false); 29 | _touchObjects.Add (o); 30 | } 31 | 32 | AccelerationRenderer = gameObject.AddComponent (); 33 | AccelerationRenderer.useWorldSpace = false; 34 | AccelerationRenderer.startWidth = 0.02f; 35 | AccelerationRenderer.endWidth = 0.02f; 36 | AccelerationRenderer.SetPosition (0, new Vector3 (0, 0, 0)); 37 | AccelerationRenderer.SetPosition(1,new Vector3 (0, 0, 0)); 38 | } 39 | 40 | void OnValueChanged(ServiceManager m,IServiceProvider s) 41 | { 42 | if (s.GetName () == GyroServiceProvider.ServiceName) { 43 | _rawRotation = (s as GyroServiceProvider).Value; 44 | Vector3 e = _rawRotation.eulerAngles; 45 | Rotation.x = -e.x; 46 | Rotation.y = -e.z; 47 | Rotation.z = -e.y; 48 | 49 | _rawRotation.x = -(s as GyroServiceProvider).Value.x; 50 | _rawRotation.y = -(s as GyroServiceProvider).Value.z; 51 | _rawRotation.z = -(s as GyroServiceProvider).Value.y; 52 | } else if (s.GetName ()==TouchServiceProvider.ServiceName) { 53 | Points = (s as TouchServiceProvider).Value.ToArray(); 54 | 55 | } else if (s.GetName ()==SwipeServiceProvider.ServiceName) { 56 | Swipe = (s as SwipeServiceProvider).Value; 57 | 58 | } else if (s.GetName ()==AccelServiceProvider.ServiceName) { 59 | Acceleration.x = (s as AccelServiceProvider).Value.x; 60 | Acceleration.y = (s as AccelServiceProvider).Value.z; 61 | Acceleration.z = (s as AccelServiceProvider).Value.y; 62 | } 63 | } 64 | 65 | // Update is called once per frame 66 | void Update () { 67 | transform.rotation = _rawRotation;// Quaternion.Euler(Rotation); 68 | 69 | Vector3 pos=transform.position; 70 | //AccelerationRenderer.SetPosition (0, ); 71 | AccelerationRenderer.SetPosition(1,Acceleration*2); 72 | 73 | for (int i = 0; i < Points.Length;++i) { 74 | _touchObjects [i].SetActive (true); 75 | _touchObjects [i].transform.localPosition = new Vector3 (Points [i].x-0.5f, 0.55f,Points [i].y-0.5f); 76 | _touchObjects [i].transform.localScale = new Vector3(Points [i].z,Points [i].z,Points [i].z); 77 | } 78 | for (int i = Points.Length; i < _touchObjects.Count; ++i) { 79 | _touchObjects [i].SetActive (false); 80 | } 81 | } 82 | 83 | 84 | public void CalibrateGyro() 85 | { 86 | Service.CalibrateGyro (); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Assets/MobileVRController/MControllerVisualizer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 98203835ab4064db6b85ba6e145c5b4f 3 | timeCreated: 1482181918 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/MobileVRController/Prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2c841b6ba59854df38d92eec92f23253 3 | folderAsset: yes 4 | timeCreated: 1482270721 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/MobileVRController/Prefab/MController.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/Assets/MobileVRController/Prefab/MController.prefab -------------------------------------------------------------------------------- /Assets/MobileVRController/Prefab/MController.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c91fd06d4834d4c4a9e93276f09cdd6c 3 | timeCreated: 1482185515 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MobileVRController/Prefab/MobileSurface.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/Assets/MobileVRController/Prefab/MobileSurface.mat -------------------------------------------------------------------------------- /Assets/MobileVRController/Prefab/MobileSurface.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 524263ffb76894174ba68cddaa916f4d 3 | timeCreated: 1482181569 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MobileVRController/Prefab/ScreenSurface.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/Assets/MobileVRController/Prefab/ScreenSurface.mat -------------------------------------------------------------------------------- /Assets/MobileVRController/Prefab/ScreenSurface.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 32becca07748e4f38ba9ce8cfa3fd448 3 | timeCreated: 1482181569 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MobileVRController/Prefab/TouchPoint.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/Assets/MobileVRController/Prefab/TouchPoint.mat -------------------------------------------------------------------------------- /Assets/MobileVRController/Prefab/TouchPoint.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1b9caa3f806794e80a7872227e187dcc 3 | timeCreated: 1482181569 4 | licenseType: Free 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MobileVRController/ServiceManager.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using System.Net.Sockets; 5 | using System.Threading; 6 | using System.Net; 7 | using System; 8 | using System.IO; 9 | 10 | public class ServiceManager : MonoBehaviour { 11 | 12 | 13 | List _Services=new List(); 14 | 15 | UdpClient _udpClient; 16 | UdpClient _udpSender; 17 | TcpClient _tcpClient; 18 | 19 | TcpClient _currentClient; 20 | 21 | TcpListener _tcpServer; 22 | 23 | Thread _serverThread; 24 | 25 | Thread _tcpThread; 26 | Thread _udpThread; 27 | 28 | public bool IsReceiver=false; 29 | 30 | public bool DebugPrint=false; 31 | 32 | public int TCPPort= 7000; 33 | public int UDPPort= 7001; 34 | 35 | //public int MobileTCPPort= 7005; 36 | //public int MobileUDPPort = 7070; 37 | 38 | //public string MobileIP=""; 39 | 40 | bool _isDone=false; 41 | 42 | MemoryStream _ReliableDataMem; 43 | MemoryStream _UnReliableDataMem ; 44 | 45 | bool _ReliableDataDirty=false; 46 | bool _UnReliableDataDirty=false; 47 | 48 | BinaryWriter _ReliableDataWriter ; 49 | BinaryWriter _UnReliableDataWriter ; 50 | 51 | public delegate void OnValueChangedDeleg(ServiceManager m,IServiceProvider s); 52 | public OnValueChangedDeleg OnValueChanged; 53 | 54 | 55 | public enum EMessageType 56 | { 57 | ControlMessage, 58 | ServiceMessage 59 | } 60 | 61 | 62 | public enum EServiceMessage 63 | { 64 | EnableService, 65 | DisableService, 66 | ServiceData 67 | } 68 | void _OnServiceValueChanged(IServiceProvider service) 69 | { 70 | if (OnValueChanged != null) 71 | OnValueChanged (this,service); 72 | } 73 | 74 | // Use this for initialization 75 | void Start () { 76 | 77 | _ReliableDataMem = new MemoryStream (); 78 | _UnReliableDataMem = new MemoryStream (); 79 | 80 | _ReliableDataWriter = new BinaryWriter (_ReliableDataMem); 81 | _UnReliableDataWriter = new BinaryWriter (_UnReliableDataMem); 82 | 83 | if (IsReceiver) { 84 | } else { 85 | 86 | } 87 | _tcpClient = new TcpClient (); 88 | _tcpServer = new TcpListener (IPAddress.Any, TCPPort); 89 | _udpClient = new UdpClient (UDPPort); 90 | _udpSender = new UdpClient (); 91 | 92 | _tcpServer.Start (); 93 | _serverThread = new Thread (new ThreadStart (TcpServerThreadHandler)); 94 | _serverThread.Start (); 95 | 96 | 97 | _udpThread=new Thread (new ThreadStart (UdpClientThreadHandler)); 98 | _udpThread.Start (); 99 | 100 | 101 | _Services.Add(new GyroServiceProvider (this)); 102 | _Services.Add(new AccelServiceProvider (this)); 103 | _Services.Add(new SwipeServiceProvider (this)); 104 | _Services.Add(new TouchServiceProvider (this)); 105 | _Services.Add(new FeedbackServiceProvider (this)); 106 | 107 | 108 | for (int i = 0; i < _Services.Count; ++i) 109 | _Services [i].OnValueChanged += _OnServiceValueChanged; 110 | 111 | } 112 | 113 | void OnDestroy() 114 | { 115 | _isDone = true; 116 | 117 | if (_currentClient != null) 118 | _currentClient.Close (); 119 | if(_tcpClient!=null) 120 | _tcpClient.Close (); 121 | _udpClient.Close (); 122 | _udpSender.Close (); 123 | _tcpServer.Stop (); 124 | 125 | //_serverThread.Abort (); 126 | _serverThread.Join (); 127 | _udpThread.Join (); 128 | } 129 | 130 | void _CloseConnection() 131 | { 132 | //if (IsReceiver) 133 | if(_tcpClient!=null) 134 | _tcpClient.Close (); 135 | if(_udpSender!=null) 136 | _udpSender.Close (); 137 | 138 | _tcpClient = null; 139 | _udpSender = null; 140 | 141 | } 142 | 143 | void _NewClientConnected() 144 | { 145 | Debug.Log ("_NewClientConnected() - Client connected!"); 146 | IPEndPoint addr=((IPEndPoint)_currentClient.Client.RemoteEndPoint); 147 | _CloseConnection (); 148 | _tcpClient = new TcpClient (); 149 | //connect back to the other end 150 | _tcpClient.Connect (addr.Address, TCPPort); 151 | _udpSender = new UdpClient (); 152 | _udpSender.Connect(addr.Address, UDPPort); 153 | 154 | 155 | } 156 | 157 | public IServiceProvider GetService(string name) 158 | { 159 | name = name.ToLower (); 160 | foreach(var s in _Services) 161 | { 162 | if(s.GetName().ToLower()==name) 163 | return s; 164 | } 165 | return null; 166 | } 167 | 168 | bool _ProcessControlMessage(BinaryReader rdr) 169 | { 170 | return false; 171 | } 172 | 173 | bool _ProcessServiceMessage(BinaryReader rdr) 174 | { 175 | string serviceName=rdr.ReadString ().ToLower(); 176 | EServiceMessage msg=(EServiceMessage) rdr.ReadInt32 (); 177 | IServiceProvider s = GetService (serviceName); 178 | if (s == null) 179 | return false; 180 | switch (msg) { 181 | case EServiceMessage.ServiceData: 182 | { 183 | int len = rdr.ReadInt32 (); 184 | byte[] data = rdr.ReadBytes (len); 185 | s.ProcessData (data); 186 | } 187 | break; 188 | case EServiceMessage.EnableService: 189 | s.SetEnabled (true); 190 | break; 191 | case EServiceMessage.DisableService: 192 | s.SetEnabled (false); 193 | break; 194 | } 195 | return true; 196 | } 197 | 198 | 199 | 200 | void _ProcessReceivedData(EndPoint src, byte[] data,int len) 201 | { 202 | 203 | BinaryReader rdr; 204 | MemoryStream ms; 205 | 206 | ms = new MemoryStream (data, 0, len, false); 207 | rdr=new BinaryReader(ms); 208 | //parse message name 209 | EMessageType msg=(EMessageType) rdr.ReadInt32(); 210 | switch (msg) { 211 | case EMessageType.ControlMessage: 212 | _ProcessControlMessage (rdr); 213 | break; 214 | case EMessageType.ServiceMessage: 215 | while (ms.Position < ms.Length) 216 | if (!_ProcessServiceMessage (rdr)) 217 | break; 218 | break; 219 | } 220 | } 221 | 222 | public void UdpClientThreadHandler() 223 | { 224 | IPEndPoint ip=new IPEndPoint(IPAddress.Any, 0);; 225 | while (!_isDone) { 226 | try{ 227 | byte[] data= _udpClient.Receive (ref ip); 228 | if (data != null && data.Length > 0) { 229 | _ProcessReceivedData (ip, data,data.Length); 230 | } 231 | }catch(Exception e) { 232 | Debug.LogError ("UdpClientThreadHandler() - "+e.Message); 233 | Thread.Sleep (100); 234 | } 235 | } 236 | } 237 | 238 | public void TcpServerThreadHandler() 239 | { 240 | Byte[] bytes = new Byte[256]; 241 | while(!_isDone) 242 | { 243 | try 244 | { 245 | Debug.Log ("TcpServerThreadHandler() - Waiting for connection."); 246 | TcpClient client= _tcpServer.AcceptTcpClient (); 247 | if (client != null) { 248 | /*//new client, make sure only one client is connected at a time 249 | if (_currentClient != null && _currentClient.Connected) { 250 | //ignore the new client 251 | client.Close (); 252 | Debug.Log ("TcpServerThreadHandler() - Ignoring connection."); 253 | continue; 254 | } else */ 255 | { 256 | _currentClient = client; 257 | _NewClientConnected (); 258 | } 259 | } 260 | }catch(Exception e) { 261 | Debug.LogError ("TcpServerThreadHandler() - "+e.Message); 262 | continue; 263 | } 264 | 265 | if (_currentClient == null) 266 | continue; 267 | 268 | var stream=_currentClient.GetStream(); 269 | while (_currentClient!=null && _tcpClient!=null && _currentClient.Connected 270 | && _tcpClient.Connected) { 271 | //process client 272 | try 273 | { 274 | int len=stream.Read (bytes, 0, bytes.Length); 275 | 276 | if (len == 0) 277 | continue;//investigate more why the socket return 0, although the socket is still open 278 | try{ 279 | _ProcessReceivedData (_currentClient.Client.RemoteEndPoint, bytes, len); 280 | }catch(Exception) 281 | { 282 | continue; 283 | } 284 | }catch(SocketException e) { 285 | Debug.LogError ("TcpServerThreadHandler() - "+e.Message); 286 | break; 287 | }catch(Exception e) { 288 | Debug.LogError ("TcpServerThreadHandler() - "+e.Message); 289 | break; 290 | } 291 | 292 | } 293 | Debug.Log ("TcpServerThreadHandler() - Remote Disconnected."); 294 | if(_tcpClient!=null) 295 | _tcpClient.Close (); 296 | _currentClient.Close (); 297 | _currentClient = null; 298 | } 299 | } 300 | 301 | 302 | void _WriteData(BinaryWriter w, string service,byte[] data) 303 | { 304 | w.Write (service.ToLower()); 305 | w.Write ((int)EServiceMessage.ServiceData); 306 | w.Write (data.Length); 307 | w.Write (data); 308 | } 309 | void _AddReliableData(string service,byte[] data) 310 | { 311 | _ReliableDataDirty = true; 312 | _WriteData (_ReliableDataWriter, service, data); 313 | } 314 | 315 | void _AddUnReliableData(string service,byte[] data) 316 | { 317 | _UnReliableDataDirty = true; 318 | _WriteData (_UnReliableDataWriter, service, data); 319 | } 320 | 321 | void _ProcessSendData() 322 | { 323 | if (_tcpClient == null || !_tcpClient.Connected) 324 | return; 325 | _ReliableDataDirty = false; 326 | _UnReliableDataDirty = false; 327 | 328 | _ReliableDataMem.Seek (0,SeekOrigin.Begin); 329 | _ReliableDataMem.SetLength (0); 330 | _UnReliableDataMem.Seek (0,SeekOrigin.Begin); 331 | _UnReliableDataMem.SetLength (0); 332 | 333 | _ReliableDataWriter.Write ((int)EMessageType.ServiceMessage); 334 | _UnReliableDataWriter.Write ((int)EMessageType.ServiceMessage); 335 | foreach (var s in _Services) { 336 | if (!s.IsEnabled ()) 337 | continue; 338 | s.Update (); 339 | byte[] data=s.GetData (); 340 | if (data.Length == 0) 341 | continue; 342 | if (s.IsReliable ()) 343 | _AddReliableData (s.GetName (), data); 344 | else 345 | _AddUnReliableData (s.GetName (), data); 346 | } 347 | 348 | try{ 349 | if (_ReliableDataDirty && _tcpClient.Connected) 350 | _tcpClient.GetStream ().Write (_ReliableDataMem.GetBuffer (), 0, (int) _ReliableDataMem.Length); 351 | if (_UnReliableDataDirty && _udpSender.Client.Connected) 352 | _udpSender.Send (_UnReliableDataMem.GetBuffer (), (int)_UnReliableDataMem.Length); 353 | } 354 | catch(SocketException e) 355 | { 356 | Debug.LogError ("_ProcessSendData() - Socket Error: "+e.Message); 357 | _CloseConnection (); 358 | 359 | } 360 | catch(Exception e) { 361 | Debug.LogError ("_ProcessSendData() - "+e.Message); 362 | } 363 | } 364 | // Update is called once per frame 365 | void Update () { 366 | 367 | //if(!IsReceiver) 368 | _ProcessSendData (); 369 | 370 | } 371 | 372 | 373 | GUIStyle _style=new GUIStyle(); 374 | 375 | void OnGUI() 376 | { 377 | if (!DebugPrint) 378 | return; 379 | _style.fontSize = 24; 380 | _style.normal.textColor=Color.white; 381 | // _style.font.material.color = Color.white; 382 | string text = "IP Address:"+Network.player.ipAddress + "\n"; 383 | foreach (var s in _Services) { 384 | text += s.GetName () + ": "; 385 | text += s.GetDebugString (); 386 | text += "\n"; 387 | } 388 | //if (!IsReceiver) 389 | { 390 | text += "UDP Size:"+_UnReliableDataMem.Length.ToString()+"\n"; 391 | text += "TCP Size:"+_ReliableDataMem.Length.ToString()+"\n"; 392 | } 393 | 394 | GUI.Label (new Rect (20, 20, 500, 500), text,_style); 395 | } 396 | 397 | 398 | 399 | public void CalibrateGyro() 400 | { 401 | var s=GetService(GyroServiceProvider.ServiceName) as GyroServiceProvider; 402 | s.Calibrate (); 403 | } 404 | 405 | public void ConnectTo(string OtherEnd) 406 | { 407 | //if (!IsReceiver) 408 | { 409 | _CloseConnection (); 410 | if (_tcpClient == null) 411 | _tcpClient = new TcpClient (); 412 | IPAddress addr = IPAddress.Parse (OtherEnd); 413 | _tcpClient.BeginConnect (addr, TCPPort, null, false); 414 | } 415 | } 416 | } 417 | -------------------------------------------------------------------------------- /Assets/MobileVRController/ServiceManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8629ded37c90d436f83d074998571a8c 3 | timeCreated: 1482118589 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/MobileVRController/Services.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76557da22ed274956abe189fb39b631a 3 | folderAsset: yes 4 | timeCreated: 1482118554 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/MobileVRController/Services/AccelServiceProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using System; 5 | 6 | public class AccelServiceProvider : IServiceProvider { 7 | 8 | 9 | public const string ServiceName="Accel"; 10 | Vector3 _AccelData = new Vector3 (); 11 | List _data=new List(); 12 | 13 | 14 | public Vector3 Value { 15 | get { 16 | return _AccelData; 17 | } 18 | } 19 | public AccelServiceProvider (ServiceManager m):base(m) 20 | { 21 | } 22 | 23 | 24 | public override string GetName() 25 | { 26 | return ServiceName; 27 | } 28 | 29 | 30 | public override bool IsReliable(){ 31 | return false; 32 | } 33 | 34 | 35 | public override byte[] GetData(){ 36 | return _data.ToArray (); 37 | } 38 | 39 | public override void Update() 40 | { 41 | if (!_enabled || _mngr.IsReceiver) 42 | return; 43 | _AccelData= Input.acceleration; 44 | 45 | _data.Clear (); 46 | _data.AddRange (BitConverter.GetBytes (_AccelData.x)); 47 | _data.AddRange (BitConverter.GetBytes (_AccelData.y)); 48 | _data.AddRange (BitConverter.GetBytes (_AccelData.z)); 49 | 50 | //if (OnValueChanged != null) 51 | // OnValueChanged (this); 52 | } 53 | 54 | 55 | 56 | public override void ProcessData(byte[] data) 57 | { 58 | _AccelData.x=BitConverter.ToSingle (data, 0); 59 | _AccelData.y=BitConverter.ToSingle (data, 4); 60 | _AccelData.z=BitConverter.ToSingle (data, 8); 61 | if (OnValueChanged != null) 62 | OnValueChanged (this); 63 | } 64 | 65 | public override string GetDebugString() 66 | { 67 | return _AccelData.ToString (); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Assets/MobileVRController/Services/AccelServiceProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 165ccd4cacf94479089dc544f62d5055 3 | timeCreated: 1482118121 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/MobileVRController/Services/FeedbackServiceProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using System; 5 | 6 | public class FeedbackServiceProvider : IServiceProvider { 7 | 8 | 9 | public const string ServiceName="Feedback"; 10 | 11 | List _data=new List(); 12 | public float _force=0; 13 | 14 | float _lastForace=0; 15 | 16 | 17 | public float Value { 18 | get { 19 | return _force; 20 | } 21 | } 22 | public FeedbackServiceProvider (ServiceManager m):base(m) 23 | { 24 | } 25 | 26 | 27 | public override string GetName() 28 | { 29 | return ServiceName; 30 | } 31 | 32 | 33 | public override bool IsReliable(){ 34 | return true; 35 | } 36 | 37 | 38 | public override byte[] GetData(){ 39 | return _data.ToArray (); 40 | } 41 | 42 | public override void Update() 43 | { 44 | if (!_enabled) 45 | return; 46 | 47 | if (!_mngr.IsReceiver) { 48 | if (_force > 0) { 49 | Handheld.Vibrate (); 50 | _force = 0; 51 | } 52 | return; 53 | } 54 | 55 | _data.Clear (); 56 | if (_force == _lastForace) 57 | return; 58 | _lastForace = _force; 59 | _data.AddRange (BitConverter.GetBytes (_force)); 60 | _force = 0; 61 | } 62 | 63 | 64 | 65 | public override void ProcessData(byte[] data) 66 | { 67 | _force=BitConverter.ToSingle (data, 0); 68 | 69 | if (_force > 0) { 70 | Debug.Log ("Vibrate"); 71 | } 72 | 73 | if (OnValueChanged != null) 74 | OnValueChanged (this); 75 | } 76 | 77 | public override string GetDebugString() 78 | { 79 | return _force.ToString (); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Assets/MobileVRController/Services/FeedbackServiceProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 624ce57e8dd174048b8472ce16041166 3 | timeCreated: 1482118121 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/MobileVRController/Services/GyroServiceProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using System; 5 | using System.IO; 6 | 7 | public class GyroServiceProvider : IServiceProvider { 8 | 9 | public const string ServiceName="Gyro"; 10 | Quaternion _GyroData = new Quaternion (); 11 | Quaternion _CalibGyro = new Quaternion (); 12 | List _data=new List(); 13 | 14 | 15 | public Quaternion Value { 16 | get { 17 | return _GyroData; 18 | } 19 | } 20 | 21 | public GyroServiceProvider (ServiceManager m):base(m) 22 | { 23 | Input.gyro.enabled = true; 24 | Calibrate (); 25 | } 26 | 27 | public void Calibrate() 28 | { 29 | _CalibGyro = Quaternion.AngleAxis(-Input.gyro.attitude.eulerAngles.z,Vector3.forward); 30 | } 31 | 32 | public override string GetName() 33 | { 34 | return ServiceName; 35 | } 36 | 37 | public override bool IsReliable(){ 38 | return false; 39 | } 40 | 41 | 42 | public override byte[] GetData(){ 43 | return _data.ToArray (); 44 | } 45 | 46 | public override void Update() 47 | { 48 | if (!_enabled || _mngr.IsReceiver) 49 | return; 50 | _GyroData= _CalibGyro*Input.gyro.attitude; 51 | 52 | _data.Clear (); 53 | 54 | _data.AddRange (BitConverter.GetBytes (_GyroData.x)); 55 | _data.AddRange (BitConverter.GetBytes (_GyroData.y)); 56 | _data.AddRange (BitConverter.GetBytes (_GyroData.z)); 57 | _data.AddRange (BitConverter.GetBytes (_GyroData.w)); 58 | 59 | //if (OnValueChanged != null) 60 | // OnValueChanged (this); 61 | } 62 | 63 | 64 | 65 | public override void ProcessData(byte[] data) 66 | { 67 | _GyroData.x=BitConverter.ToSingle (data, 0); 68 | _GyroData.y=BitConverter.ToSingle (data, 4); 69 | _GyroData.z=BitConverter.ToSingle (data, 8); 70 | _GyroData.w=BitConverter.ToSingle (data, 12); 71 | if (OnValueChanged != null) 72 | OnValueChanged (this); 73 | } 74 | 75 | public override string GetDebugString() 76 | { 77 | return _GyroData.eulerAngles.ToString (); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Assets/MobileVRController/Services/GyroServiceProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e88bb335ab8cb4f5ab8dd29bbd593de2 3 | timeCreated: 1482118121 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/MobileVRController/Services/IServiceProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public abstract class IServiceProvider 6 | { 7 | 8 | protected bool _enabled=true; 9 | protected ServiceManager _mngr; 10 | 11 | public delegate void OnValueChangedDeleg(IServiceProvider s); 12 | public OnValueChangedDeleg OnValueChanged; 13 | 14 | public IServiceProvider(ServiceManager m) 15 | { 16 | _mngr = m; 17 | } 18 | 19 | public virtual void SetEnabled(bool e) 20 | { 21 | _enabled = e; 22 | } 23 | public virtual bool IsEnabled() 24 | { 25 | return _enabled; 26 | } 27 | 28 | public abstract string GetName(); 29 | 30 | //Is TCP required for reliable data send 31 | public abstract bool IsReliable(); 32 | 33 | public abstract byte[] GetData(); 34 | 35 | public abstract void Update(); 36 | 37 | public abstract void ProcessData(byte[] data); 38 | 39 | public abstract string GetDebugString(); 40 | } 41 | -------------------------------------------------------------------------------- /Assets/MobileVRController/Services/IServiceProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fed50823a80144dda8a9ad795d98ed73 3 | timeCreated: 1482118022 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/MobileVRController/Services/SwipeServiceProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using System; 5 | 6 | public class SwipeServiceProvider : IServiceProvider { 7 | 8 | public const string ServiceName="Swipe"; 9 | 10 | 11 | public enum ESwipeType 12 | { 13 | None, 14 | Left, 15 | Right, 16 | Top, 17 | Bottom, 18 | } 19 | 20 | ESwipeType _swipe=ESwipeType.None; 21 | List _data=new List(); 22 | 23 | float threshold=1000; 24 | 25 | 26 | public ESwipeType Value { 27 | get { 28 | return _swipe; 29 | } 30 | } 31 | 32 | public SwipeServiceProvider (ServiceManager m):base(m) 33 | { 34 | 35 | } 36 | 37 | 38 | public override string GetName() 39 | { 40 | return ServiceName; 41 | } 42 | public override bool IsReliable(){ 43 | return true; 44 | } 45 | 46 | 47 | public override byte[] GetData(){ 48 | return _data.ToArray (); 49 | } 50 | 51 | 52 | ESwipeType DetectSwipe() 53 | { 54 | 55 | if (Input.touches.Length != 1) 56 | return ESwipeType.None; 57 | 58 | if (Input.touches [0].phase != TouchPhase.Moved) 59 | return ESwipeType.None; 60 | 61 | Vector2 dir=Input.touches [0].deltaPosition / Input.touches [0].deltaTime; 62 | float len = dir.magnitude; 63 | if (len < threshold) 64 | return ESwipeType.None; 65 | dir /= len; 66 | 67 | float angle = Mathf.Atan2 (dir.y, dir.x)*Mathf.Rad2Deg; 68 | bool neg = angle < 0; 69 | angle = Mathf.Abs (angle); 70 | if(angle<45) 71 | return ESwipeType.Right; 72 | if(angle<135) 73 | return neg ? ESwipeType.Bottom:ESwipeType.Top; 74 | 75 | return ESwipeType.Left; 76 | } 77 | 78 | public override void Update() 79 | { 80 | if (!_enabled || _mngr.IsReceiver) 81 | return; 82 | 83 | _data.Clear (); 84 | ESwipeType s= DetectSwipe (); 85 | if (s == _swipe) 86 | return;//no change 87 | 88 | _swipe = s; 89 | 90 | _data.AddRange (BitConverter.GetBytes ((int)_swipe)); 91 | 92 | //if (OnValueChanged != null) 93 | // OnValueChanged (this); 94 | } 95 | 96 | 97 | 98 | public override void ProcessData(byte[] data) 99 | { 100 | _swipe=(ESwipeType) BitConverter.ToInt32 (data, 0); 101 | if (OnValueChanged != null) 102 | OnValueChanged (this); 103 | 104 | } 105 | 106 | public override string GetDebugString() 107 | { 108 | return _swipe.ToString (); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /Assets/MobileVRController/Services/SwipeServiceProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3e6667b01f95e4edfaa2b0ccb2972865 3 | timeCreated: 1482118121 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/MobileVRController/Services/TouchServiceProvider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using System; 5 | 6 | public class TouchServiceProvider : IServiceProvider { 7 | 8 | 9 | public const string ServiceName="Touch"; 10 | 11 | List _touchPos=new List(); 12 | List _data=new List(); 13 | 14 | 15 | public List Value { 16 | get { 17 | return _touchPos; 18 | } 19 | } 20 | 21 | public TouchServiceProvider (ServiceManager m):base(m) 22 | { 23 | } 24 | 25 | 26 | public override string GetName() 27 | { 28 | return ServiceName; 29 | } 30 | public override bool IsReliable(){ 31 | return false; 32 | } 33 | 34 | 35 | public override byte[] GetData(){ 36 | return _data.ToArray (); 37 | } 38 | 39 | 40 | public override void Update() 41 | { 42 | if (!_enabled || _mngr.IsReceiver) 43 | return; 44 | 45 | _data.Clear (); 46 | _touchPos.Clear (); 47 | _data.AddRange(BitConverter.GetBytes ((int)Input.touches.Length)); 48 | Vector2 screenInv = new Vector2 (1.0f / Screen.width, 1.0f / Screen.height); 49 | 50 | foreach (var t in Input.touches) { 51 | Vector3 p = new Vector3 (t.position.x*screenInv.x, t.position.y*screenInv.y, t.pressure/t.maximumPossiblePressure); 52 | _touchPos.Add (p); 53 | _data.AddRange (BitConverter.GetBytes (p.x)); 54 | _data.AddRange (BitConverter.GetBytes (p.y)); 55 | _data.AddRange (BitConverter.GetBytes (p.z)); 56 | } 57 | //if (OnValueChanged != null) 58 | // OnValueChanged (this); 59 | } 60 | 61 | 62 | public override void ProcessData(byte[] data) 63 | { 64 | int idx = 0; 65 | int count=BitConverter.ToInt32 (data, idx); 66 | idx += sizeof(int); 67 | _touchPos.Clear (); 68 | Vector3 p = new Vector3 (); 69 | for (int i = 0; i < count; ++i) { 70 | p.x = BitConverter.ToSingle (data, idx+0); 71 | p.y = BitConverter.ToSingle (data, idx+4); 72 | p.z = BitConverter.ToSingle (data, idx+8); 73 | _touchPos.Add (p); 74 | idx += 3 * sizeof(float); 75 | } 76 | if (OnValueChanged != null) 77 | OnValueChanged (this); 78 | } 79 | 80 | public override string GetDebugString() 81 | { 82 | return _touchPos.Count.ToString(); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Assets/MobileVRController/Services/TouchServiceProvider.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dd8759cf9763f4730882dbae43cdea35 3 | timeCreated: 1482118121 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/MobileVRController/UIServerPanel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEngine.UI; 5 | 6 | public class UIServerPanel : MonoBehaviour { 7 | 8 | public RectTransform ConfigPanel; 9 | public Text ConfigButton; 10 | public Text IPAddress; 11 | public ServiceManager ServiceMngr; 12 | // Use this for initialization 13 | void Start () { 14 | 15 | } 16 | 17 | // Update is called once per frame 18 | void Update () { 19 | 20 | } 21 | 22 | public void ToggleConfig() 23 | { 24 | ConfigPanel.gameObject.SetActive (!ConfigPanel.gameObject.activeSelf); 25 | ConfigButton.text = ConfigPanel.gameObject.activeSelf ? "<" : ">"; 26 | } 27 | public void ConnectTo() 28 | { 29 | ServiceMngr.ConnectTo (IPAddress.text); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Assets/MobileVRController/UIServerPanel.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b88d75bc54564cbbabdf09756ba07dc 3 | timeCreated: 1483385285 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 39848bf24ea0a485c8b478479ccf10bc 3 | folderAsset: yes 4 | timeCreated: 1482181900 5 | licenseType: Free 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Scenes/Receiver.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/Assets/Scenes/Receiver.unity -------------------------------------------------------------------------------- /Assets/Scenes/Receiver.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 09c8169a4e6464141a099dbc5b43285f 3 | timeCreated: 1482181902 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/Sender.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/Assets/Scenes/Sender.unity -------------------------------------------------------------------------------- /Assets/Scenes/Sender.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 94e252717fde34f5d899335e084d923b 3 | timeCreated: 1482181902 4 | licenseType: Free 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Scenes/VibrateTriggerTest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | public class VibrateTriggerTest : MonoBehaviour { 6 | 7 | ServiceManager manager; 8 | // Use this for initialization 9 | void Start () { 10 | manager = GetComponent (); 11 | } 12 | 13 | // Update is called once per frame 14 | void Update () { 15 | if(Input.GetKeyDown(KeyCode.Space)) 16 | { 17 | var s= manager.GetService (FeedbackServiceProvider.ServiceName) as FeedbackServiceProvider; 18 | s._force = 1; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Assets/Scenes/VibrateTriggerTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e15b92003c55a4a7988057b7922ac30b 3 | timeCreated: 1483123650 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.5.0f3 2 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrayy/MobileVRController/9c6d09e7a79ae5487e3d1573931c382108150847/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MobileVRController 2 | 3 | ![gif](http://myamens.com/Uploads/MobileVRController/V1.gif) 4 | ![gif](http://myamens.com/Uploads/MobileVRController/V2.gif) 5 | ![gif](http://myamens.com/Uploads/MobileVRController/V3.gif) 6 | 7 | This project is a simple and easy way to hook your smart phone into your Unity project and use it as a remote controller. 8 | 9 | Usage: 10 | ------ 11 | First build the project to your mobile device (iOS/Android) using Sender scene file. This file has only a single object that handles mobile sensors data sending. 12 | In your project, add ServiceManager object, and set IsReceiver property to true, also configure the IP address property to points to mobile's IP address (Make sure both the mobile and PC are connected on the same WiFi network). You can now register to ServiceManager.OnValueChanged delegate to receive notificaitions about new data arrival. 13 | Before running Unity application, make sure the mobile app is running (ready to get connections). 14 | 15 | 16 | 17 | Features: 18 | --------- 19 | - Send Realtime sensors information to client device 20 | - Easy to add new service provides for data mapping 21 | - Event based system to notify when new data arrives 22 | 23 | Current Service Providers: 24 | -------------------------- 25 | - GyroServiceProvider: provides realtime gyroscope information 26 | - AccelServiceProvider: provides realtime acceleration information 27 | - TouchServiceProvider: provides touch points with the pressure information from the touch screen 28 | - SwipeServiceProvider: provides swiping direction 29 | - (new)FeedbackServiceProvider: provides feedback (vibration) to mobile side 30 | 31 | Expanding Support: 32 | ------------------ 33 | You can expand the number of services provided by the mobile by implementing IServiceProvider class. Study the previous classes as examples of how to implement it. 34 | --------------------------------------------------------------------------------