Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.5 KiB

  1. /************************************************************************************
  2. Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
  3. Licensed under the Oculus Utilities SDK License Version 1.31 (the "License"); you may not use
  4. the Utilities SDK except in compliance with the License, which is provided at the time of installation
  5. or download, or which otherwise accompanies this software in either electronic or hard copy form.
  6. You may obtain a copy of the License at
  7. https://developer.oculus.com/licenses/utilities-1.31
  8. Unless required by applicable law or agreed to in writing, the Utilities SDK distributed
  9. under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
  10. ANY KIND, either express or implied. See the License for the specific language governing
  11. permissions and limitations under the License.
  12. ************************************************************************************/
  13. using UnityEngine;
  14. /// <summary>
  15. /// Logs when the application enters power save mode and allows you to a low-power CPU/GPU level with a button press.
  16. /// </summary>
  17. public class OVRModeParms : MonoBehaviour
  18. {
  19. #region Member Variables
  20. /// <summary>
  21. /// The gamepad button that will switch the application to CPU level 0 and GPU level 1.
  22. /// </summary>
  23. public OVRInput.RawButton resetButton = OVRInput.RawButton.X;
  24. #endregion
  25. /// <summary>
  26. /// Invoke power state mode test.
  27. /// </summary>
  28. void Start()
  29. {
  30. if (!OVRManager.isHmdPresent)
  31. {
  32. enabled = false;
  33. return;
  34. }
  35. // Call TestPowerLevelState after 10 seconds
  36. // and repeats every 10 seconds.
  37. InvokeRepeating ( "TestPowerStateMode", 10, 10.0f );
  38. }
  39. /// <summary>
  40. /// Change default vr mode parms dynamically.
  41. /// </summary>
  42. void Update()
  43. {
  44. // NOTE: some of the buttons defined in OVRInput.RawButton are not available on the Android game pad controller
  45. if ( OVRInput.GetDown(resetButton))
  46. {
  47. //*************************
  48. // Dynamically change VrModeParms cpu and gpu level.
  49. // NOTE: Reset will cause 1 frame of flicker as it leaves
  50. // and re-enters Vr mode.
  51. //*************************
  52. OVRPlugin.cpuLevel = 0;
  53. OVRPlugin.gpuLevel = 1;
  54. }
  55. }
  56. /// <summary>
  57. /// Check current power state mode.
  58. /// </summary>
  59. void TestPowerStateMode()
  60. {
  61. //*************************
  62. // Check power-level state mode
  63. //*************************
  64. if (OVRPlugin.powerSaving)
  65. {
  66. // The device has been throttled
  67. Debug.Log("POWER SAVE MODE ACTIVATED");
  68. }
  69. }
  70. }