OVRPlugin.cs 92 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512
  1. /************************************************************************************
  2. Copyright : Copyright 2017 Oculus VR, LLC. All Rights reserved.
  3. Licensed under the Oculus VR Rift SDK License Version 3.4.1 (the "License");
  4. you may not use the Oculus VR Rift SDK except in compliance with the License,
  5. which is provided at the time of installation or download, or which
  6. otherwise accompanies this software in either electronic or hard copy form.
  7. You may obtain a copy of the License at
  8. https://developer.oculus.com/licenses/sdk-3.4.1
  9. Unless required by applicable law or agreed to in writing, the Oculus VR SDK
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ************************************************************************************/
  15. #if !(UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || (UNITY_ANDROID && !UNITY_EDITOR))
  16. #define OVRPLUGIN_UNSUPPORTED_PLATFORM
  17. #endif
  18. using System;
  19. using System.Runtime.InteropServices;
  20. using UnityEngine;
  21. // Internal C# wrapper for OVRPlugin.
  22. internal static class OVRPlugin
  23. {
  24. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  25. public const bool isSupportedPlatform = false;
  26. #else
  27. public const bool isSupportedPlatform = true;
  28. #endif
  29. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  30. public static readonly System.Version wrapperVersion = _versionZero;
  31. #else
  32. public static readonly System.Version wrapperVersion = OVRP_1_27_0.version;
  33. #endif
  34. private static System.Version _version;
  35. public static System.Version version
  36. {
  37. get {
  38. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  39. Debug.LogWarning("Platform is not currently supported by OVRPlugin");
  40. return _versionZero;
  41. #else
  42. if (_version == null)
  43. {
  44. try
  45. {
  46. string pluginVersion = OVRP_1_1_0.ovrp_GetVersion();
  47. if (pluginVersion != null)
  48. {
  49. // Truncate unsupported trailing version info for System.Version. Original string is returned if not present.
  50. pluginVersion = pluginVersion.Split('-')[0];
  51. _version = new System.Version(pluginVersion);
  52. }
  53. else
  54. {
  55. _version = _versionZero;
  56. }
  57. }
  58. catch
  59. {
  60. _version = _versionZero;
  61. }
  62. // Unity 5.1.1f3-p3 have OVRPlugin version "0.5.0", which isn't accurate.
  63. if (_version == OVRP_0_5_0.version)
  64. _version = OVRP_0_1_0.version;
  65. if (_version > _versionZero && _version < OVRP_1_3_0.version)
  66. throw new PlatformNotSupportedException("Oculus Utilities version " + wrapperVersion + " is too new for OVRPlugin version " + _version.ToString() + ". Update to the latest version of Unity.");
  67. }
  68. return _version;
  69. #endif
  70. }
  71. }
  72. private static System.Version _nativeSDKVersion;
  73. public static System.Version nativeSDKVersion
  74. {
  75. get {
  76. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  77. return _versionZero;
  78. #else
  79. if (_nativeSDKVersion == null)
  80. {
  81. try
  82. {
  83. string sdkVersion = string.Empty;
  84. if (version >= OVRP_1_1_0.version)
  85. sdkVersion = OVRP_1_1_0.ovrp_GetNativeSDKVersion();
  86. else
  87. sdkVersion = _versionZero.ToString();
  88. if (sdkVersion != null)
  89. {
  90. // Truncate unsupported trailing version info for System.Version. Original string is returned if not present.
  91. sdkVersion = sdkVersion.Split('-')[0];
  92. _nativeSDKVersion = new System.Version(sdkVersion);
  93. }
  94. else
  95. {
  96. _nativeSDKVersion = _versionZero;
  97. }
  98. }
  99. catch
  100. {
  101. _nativeSDKVersion = _versionZero;
  102. }
  103. }
  104. return _nativeSDKVersion;
  105. #endif
  106. }
  107. }
  108. [StructLayout(LayoutKind.Sequential)]
  109. private class GUID
  110. {
  111. public int a;
  112. public short b;
  113. public short c;
  114. public byte d0;
  115. public byte d1;
  116. public byte d2;
  117. public byte d3;
  118. public byte d4;
  119. public byte d5;
  120. public byte d6;
  121. public byte d7;
  122. }
  123. public enum Bool
  124. {
  125. False = 0,
  126. True
  127. }
  128. public enum Result
  129. {
  130. /// Success
  131. Success = 0,
  132. /// Failure
  133. Failure = -1000,
  134. Failure_InvalidParameter = -1001,
  135. Failure_NotInitialized = -1002,
  136. Failure_InvalidOperation = -1003,
  137. Failure_Unsupported = -1004,
  138. Failure_NotYetImplemented = -1005,
  139. Failure_OperationFailed = -1006,
  140. Failure_InsufficientSize = -1007,
  141. }
  142. public enum CameraStatus
  143. {
  144. CameraStatus_None,
  145. CameraStatus_Connected,
  146. CameraStatus_Calibrating,
  147. CameraStatus_CalibrationFailed,
  148. CameraStatus_Calibrated,
  149. CameraStatus_EnumSize = 0x7fffffff
  150. }
  151. public enum Eye
  152. {
  153. None = -1,
  154. Left = 0,
  155. Right = 1,
  156. Count = 2
  157. }
  158. public enum Tracker
  159. {
  160. None = -1,
  161. Zero = 0,
  162. One = 1,
  163. Two = 2,
  164. Three = 3,
  165. Count,
  166. }
  167. public enum Node
  168. {
  169. None = -1,
  170. EyeLeft = 0,
  171. EyeRight = 1,
  172. EyeCenter = 2,
  173. HandLeft = 3,
  174. HandRight = 4,
  175. TrackerZero = 5,
  176. TrackerOne = 6,
  177. TrackerTwo = 7,
  178. TrackerThree = 8,
  179. Head = 9,
  180. DeviceObjectZero = 10,
  181. Count,
  182. }
  183. public enum Controller
  184. {
  185. None = 0,
  186. LTouch = 0x00000001,
  187. RTouch = 0x00000002,
  188. Touch = LTouch | RTouch,
  189. Remote = 0x00000004,
  190. Gamepad = 0x00000010,
  191. Touchpad = 0x08000000,
  192. LTrackedRemote = 0x01000000,
  193. RTrackedRemote = 0x02000000,
  194. Active = unchecked((int)0x80000000),
  195. All = ~None,
  196. }
  197. public enum TrackingOrigin
  198. {
  199. EyeLevel = 0,
  200. FloorLevel = 1,
  201. Count,
  202. }
  203. public enum RecenterFlags
  204. {
  205. Default = 0,
  206. Controllers = 0x40000000,
  207. IgnoreAll = unchecked((int)0x80000000),
  208. Count,
  209. }
  210. public enum BatteryStatus
  211. {
  212. Charging = 0,
  213. Discharging,
  214. Full,
  215. NotCharging,
  216. Unknown,
  217. }
  218. public enum EyeTextureFormat
  219. {
  220. Default = 0,
  221. R8G8B8A8_sRGB = 0,
  222. R8G8B8A8 = 1,
  223. R16G16B16A16_FP = 2,
  224. R11G11B10_FP = 3,
  225. B8G8R8A8_sRGB = 4,
  226. B8G8R8A8 = 5,
  227. R5G6B5 = 11,
  228. EnumSize = 0x7fffffff
  229. }
  230. public enum PlatformUI
  231. {
  232. None = -1,
  233. ConfirmQuit = 1,
  234. GlobalMenuTutorial, // Deprecated
  235. }
  236. public enum SystemRegion
  237. {
  238. Unspecified = 0,
  239. Japan,
  240. China,
  241. }
  242. public enum SystemHeadset
  243. {
  244. None = 0,
  245. GearVR_R320, // Note4 Innovator
  246. GearVR_R321, // S6 Innovator
  247. GearVR_R322, // Commercial 1
  248. GearVR_R323, // Commercial 2 (USB Type C)
  249. GearVR_R324, // Commercial 3 (USB Type C)
  250. GearVR_R325, // Commercial 4 (USB Type C)
  251. Oculus_Go,
  252. Rift_DK1 = 0x1000,
  253. Rift_DK2,
  254. Rift_CV1,
  255. }
  256. public enum OverlayShape
  257. {
  258. Quad = 0,
  259. Cylinder = 1,
  260. Cubemap = 2,
  261. OffcenterCubemap = 4,
  262. Equirect = 5,
  263. }
  264. public enum Step
  265. {
  266. Render = -1,
  267. Physics = 0,
  268. }
  269. public enum CameraDevice
  270. {
  271. None = 0,
  272. WebCamera0 = 100,
  273. WebCamera1 = 101,
  274. ZEDCamera = 300,
  275. }
  276. public enum CameraDeviceDepthSensingMode
  277. {
  278. Standard = 0,
  279. Fill = 1,
  280. }
  281. public enum CameraDeviceDepthQuality
  282. {
  283. Low = 0,
  284. Medium = 1,
  285. High = 2,
  286. }
  287. public enum TiledMultiResLevel
  288. {
  289. Off = 0,
  290. LMSLow = 1,
  291. LMSMedium = 2,
  292. LMSHigh = 3,
  293. EnumSize = 0x7FFFFFFF
  294. }
  295. [StructLayout(LayoutKind.Sequential)]
  296. public struct CameraDeviceIntrinsicsParameters
  297. {
  298. float fx; /* Focal length in pixels along x axis. */
  299. float fy; /* Focal length in pixels along y axis. */
  300. float cx; /* Optical center along x axis, defined in pixels (usually close to width/2). */
  301. float cy; /* Optical center along y axis, defined in pixels (usually close to height/2). */
  302. double disto0; /* Distortion factor : [ k1, k2, p1, p2, k3 ]. Radial (k1,k2,k3) and Tangential (p1,p2) distortion.*/
  303. double disto1;
  304. double disto2;
  305. double disto3;
  306. double disto4;
  307. float v_fov; /* Vertical field of view after stereo rectification, in degrees. */
  308. float h_fov; /* Horizontal field of view after stereo rectification, in degrees.*/
  309. float d_fov; /* Diagonal field of view after stereo rectification, in degrees.*/
  310. int w; /* Resolution width */
  311. int h; /* Resolution height */
  312. }
  313. private const int OverlayShapeFlagShift = 4;
  314. private enum OverlayFlag
  315. {
  316. None = unchecked((int)0x00000000),
  317. OnTop = unchecked((int)0x00000001),
  318. HeadLocked = unchecked((int)0x00000002),
  319. // Using the 5-8 bits for shapes, total 16 potential shapes can be supported 0x000000[0]0 -> 0x000000[F]0
  320. ShapeFlag_Quad = unchecked((int)OverlayShape.Quad << OverlayShapeFlagShift),
  321. ShapeFlag_Cylinder = unchecked((int)OverlayShape.Cylinder << OverlayShapeFlagShift),
  322. ShapeFlag_Cubemap = unchecked((int)OverlayShape.Cubemap << OverlayShapeFlagShift),
  323. ShapeFlag_OffcenterCubemap = unchecked((int)OverlayShape.OffcenterCubemap << OverlayShapeFlagShift),
  324. ShapeFlagRangeMask = unchecked((int)0xF << OverlayShapeFlagShift),
  325. }
  326. [StructLayout(LayoutKind.Sequential)]
  327. public struct Vector2f
  328. {
  329. public float x;
  330. public float y;
  331. }
  332. [StructLayout(LayoutKind.Sequential)]
  333. public struct Vector3f
  334. {
  335. public float x;
  336. public float y;
  337. public float z;
  338. public static readonly Vector3f zero = new Vector3f { x = 0.0f, y = 0.0f, z = 0.0f };
  339. public override string ToString()
  340. {
  341. return string.Format("{0}, {1}, {2}", x, y, z);
  342. }
  343. }
  344. [StructLayout(LayoutKind.Sequential)]
  345. public struct Quatf
  346. {
  347. public float x;
  348. public float y;
  349. public float z;
  350. public float w;
  351. public static readonly Quatf identity = new Quatf {x = 0.0f, y = 0.0f, z = 0.0f, w = 1.0f};
  352. public override string ToString()
  353. {
  354. return string.Format("{0}, {1}, {2}, {3}", x, y, z, w);
  355. }
  356. }
  357. [StructLayout(LayoutKind.Sequential)]
  358. public struct Posef
  359. {
  360. public Quatf Orientation;
  361. public Vector3f Position;
  362. public static readonly Posef identity = new Posef { Orientation = Quatf.identity, Position = Vector3f.zero };
  363. public override string ToString()
  364. {
  365. return string.Format("Position ({0}), Orientation({1})", Position, Orientation);
  366. }
  367. }
  368. [StructLayout(LayoutKind.Sequential)]
  369. public struct PoseStatef
  370. {
  371. public Posef Pose;
  372. public Vector3f Velocity;
  373. public Vector3f Acceleration;
  374. public Vector3f AngularVelocity;
  375. public Vector3f AngularAcceleration;
  376. double Time;
  377. }
  378. [StructLayout(LayoutKind.Sequential)]
  379. public struct ControllerState4
  380. {
  381. public uint ConnectedControllers;
  382. public uint Buttons;
  383. public uint Touches;
  384. public uint NearTouches;
  385. public float LIndexTrigger;
  386. public float RIndexTrigger;
  387. public float LHandTrigger;
  388. public float RHandTrigger;
  389. public Vector2f LThumbstick;
  390. public Vector2f RThumbstick;
  391. public Vector2f LTouchpad;
  392. public Vector2f RTouchpad;
  393. public byte LBatteryPercentRemaining;
  394. public byte RBatteryPercentRemaining;
  395. public byte LRecenterCount;
  396. public byte RRecenterCount;
  397. public byte Reserved_27;
  398. public byte Reserved_26;
  399. public byte Reserved_25;
  400. public byte Reserved_24;
  401. public byte Reserved_23;
  402. public byte Reserved_22;
  403. public byte Reserved_21;
  404. public byte Reserved_20;
  405. public byte Reserved_19;
  406. public byte Reserved_18;
  407. public byte Reserved_17;
  408. public byte Reserved_16;
  409. public byte Reserved_15;
  410. public byte Reserved_14;
  411. public byte Reserved_13;
  412. public byte Reserved_12;
  413. public byte Reserved_11;
  414. public byte Reserved_10;
  415. public byte Reserved_09;
  416. public byte Reserved_08;
  417. public byte Reserved_07;
  418. public byte Reserved_06;
  419. public byte Reserved_05;
  420. public byte Reserved_04;
  421. public byte Reserved_03;
  422. public byte Reserved_02;
  423. public byte Reserved_01;
  424. public byte Reserved_00;
  425. public ControllerState4(ControllerState2 cs)
  426. {
  427. ConnectedControllers = cs.ConnectedControllers;
  428. Buttons = cs.Buttons;
  429. Touches = cs.Touches;
  430. NearTouches = cs.NearTouches;
  431. LIndexTrigger = cs.LIndexTrigger;
  432. RIndexTrigger = cs.RIndexTrigger;
  433. LHandTrigger = cs.LHandTrigger;
  434. RHandTrigger = cs.RHandTrigger;
  435. LThumbstick = cs.LThumbstick;
  436. RThumbstick = cs.RThumbstick;
  437. LTouchpad = cs.LTouchpad;
  438. RTouchpad = cs.RTouchpad;
  439. LBatteryPercentRemaining = 0;
  440. RBatteryPercentRemaining = 0;
  441. LRecenterCount = 0;
  442. RRecenterCount = 0;
  443. Reserved_27 = 0;
  444. Reserved_26 = 0;
  445. Reserved_25 = 0;
  446. Reserved_24 = 0;
  447. Reserved_23 = 0;
  448. Reserved_22 = 0;
  449. Reserved_21 = 0;
  450. Reserved_20 = 0;
  451. Reserved_19 = 0;
  452. Reserved_18 = 0;
  453. Reserved_17 = 0;
  454. Reserved_16 = 0;
  455. Reserved_15 = 0;
  456. Reserved_14 = 0;
  457. Reserved_13 = 0;
  458. Reserved_12 = 0;
  459. Reserved_11 = 0;
  460. Reserved_10 = 0;
  461. Reserved_09 = 0;
  462. Reserved_08 = 0;
  463. Reserved_07 = 0;
  464. Reserved_06 = 0;
  465. Reserved_05 = 0;
  466. Reserved_04 = 0;
  467. Reserved_03 = 0;
  468. Reserved_02 = 0;
  469. Reserved_01 = 0;
  470. Reserved_00 = 0;
  471. }
  472. }
  473. [StructLayout(LayoutKind.Sequential)]
  474. public struct ControllerState2
  475. {
  476. public uint ConnectedControllers;
  477. public uint Buttons;
  478. public uint Touches;
  479. public uint NearTouches;
  480. public float LIndexTrigger;
  481. public float RIndexTrigger;
  482. public float LHandTrigger;
  483. public float RHandTrigger;
  484. public Vector2f LThumbstick;
  485. public Vector2f RThumbstick;
  486. public Vector2f LTouchpad;
  487. public Vector2f RTouchpad;
  488. public ControllerState2(ControllerState cs)
  489. {
  490. ConnectedControllers = cs.ConnectedControllers;
  491. Buttons = cs.Buttons;
  492. Touches = cs.Touches;
  493. NearTouches = cs.NearTouches;
  494. LIndexTrigger = cs.LIndexTrigger;
  495. RIndexTrigger = cs.RIndexTrigger;
  496. LHandTrigger = cs.LHandTrigger;
  497. RHandTrigger = cs.RHandTrigger;
  498. LThumbstick = cs.LThumbstick;
  499. RThumbstick = cs.RThumbstick;
  500. LTouchpad = new Vector2f() { x = 0.0f, y = 0.0f };
  501. RTouchpad = new Vector2f() { x = 0.0f, y = 0.0f };
  502. }
  503. }
  504. [StructLayout(LayoutKind.Sequential)]
  505. public struct ControllerState
  506. {
  507. public uint ConnectedControllers;
  508. public uint Buttons;
  509. public uint Touches;
  510. public uint NearTouches;
  511. public float LIndexTrigger;
  512. public float RIndexTrigger;
  513. public float LHandTrigger;
  514. public float RHandTrigger;
  515. public Vector2f LThumbstick;
  516. public Vector2f RThumbstick;
  517. }
  518. [StructLayout(LayoutKind.Sequential)]
  519. public struct HapticsBuffer
  520. {
  521. public IntPtr Samples;
  522. public int SamplesCount;
  523. }
  524. [StructLayout(LayoutKind.Sequential)]
  525. public struct HapticsState
  526. {
  527. public int SamplesAvailable;
  528. public int SamplesQueued;
  529. }
  530. [StructLayout(LayoutKind.Sequential)]
  531. public struct HapticsDesc
  532. {
  533. public int SampleRateHz;
  534. public int SampleSizeInBytes;
  535. public int MinimumSafeSamplesQueued;
  536. public int MinimumBufferSamplesCount;
  537. public int OptimalBufferSamplesCount;
  538. public int MaximumBufferSamplesCount;
  539. }
  540. [StructLayout(LayoutKind.Sequential)]
  541. public struct AppPerfFrameStats
  542. {
  543. public int HmdVsyncIndex;
  544. public int AppFrameIndex;
  545. public int AppDroppedFrameCount;
  546. public float AppMotionToPhotonLatency;
  547. public float AppQueueAheadTime;
  548. public float AppCpuElapsedTime;
  549. public float AppGpuElapsedTime;
  550. public int CompositorFrameIndex;
  551. public int CompositorDroppedFrameCount;
  552. public float CompositorLatency;
  553. public float CompositorCpuElapsedTime;
  554. public float CompositorGpuElapsedTime;
  555. public float CompositorCpuStartToGpuEndElapsedTime;
  556. public float CompositorGpuEndToVsyncElapsedTime;
  557. }
  558. public const int AppPerfFrameStatsMaxCount = 5;
  559. [StructLayout(LayoutKind.Sequential)]
  560. public struct AppPerfStats
  561. {
  562. [MarshalAs(UnmanagedType.ByValArray, SizeConst = AppPerfFrameStatsMaxCount)]
  563. public AppPerfFrameStats[] FrameStats;
  564. public int FrameStatsCount;
  565. public Bool AnyFrameStatsDropped;
  566. public float AdaptiveGpuPerformanceScale;
  567. }
  568. [StructLayout(LayoutKind.Sequential)]
  569. public struct Sizei
  570. {
  571. public int w;
  572. public int h;
  573. }
  574. [StructLayout(LayoutKind.Sequential)]
  575. public struct Sizef
  576. {
  577. public float w;
  578. public float h;
  579. }
  580. [StructLayout(LayoutKind.Sequential)]
  581. public struct Vector2i
  582. {
  583. public int x;
  584. public int y;
  585. }
  586. [StructLayout(LayoutKind.Sequential)]
  587. public struct Recti {
  588. Vector2i Pos;
  589. Sizei Size;
  590. }
  591. [StructLayout(LayoutKind.Sequential)]
  592. public struct Rectf {
  593. Vector2f Pos;
  594. Sizef Size;
  595. }
  596. [StructLayout(LayoutKind.Sequential)]
  597. public struct Frustumf
  598. {
  599. public float zNear;
  600. public float zFar;
  601. public float fovX;
  602. public float fovY;
  603. }
  604. [StructLayout(LayoutKind.Sequential)]
  605. public struct Frustumf2
  606. {
  607. public float zNear;
  608. public float zFar;
  609. public Fovf Fov;
  610. }
  611. public enum BoundaryType
  612. {
  613. OuterBoundary = 0x0001,
  614. PlayArea = 0x0100,
  615. }
  616. [StructLayout(LayoutKind.Sequential)]
  617. public struct BoundaryTestResult
  618. {
  619. public Bool IsTriggering;
  620. public float ClosestDistance;
  621. public Vector3f ClosestPoint;
  622. public Vector3f ClosestPointNormal;
  623. }
  624. [StructLayout(LayoutKind.Sequential)]
  625. public struct BoundaryLookAndFeel
  626. {
  627. public Colorf Color;
  628. }
  629. [StructLayout(LayoutKind.Sequential)]
  630. public struct BoundaryGeometry
  631. {
  632. public BoundaryType BoundaryType;
  633. [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
  634. public Vector3f[] Points;
  635. public int PointsCount;
  636. }
  637. [StructLayout(LayoutKind.Sequential)]
  638. public struct Colorf
  639. {
  640. public float r;
  641. public float g;
  642. public float b;
  643. public float a;
  644. }
  645. [StructLayout(LayoutKind.Sequential)]
  646. public struct Fovf
  647. {
  648. public float UpTan;
  649. public float DownTan;
  650. public float LeftTan;
  651. public float RightTan;
  652. }
  653. [StructLayout(LayoutKind.Sequential)]
  654. public struct CameraIntrinsics
  655. {
  656. public bool IsValid;
  657. public double LastChangedTimeSeconds;
  658. public Fovf FOVPort;
  659. public float VirtualNearPlaneDistanceMeters;
  660. public float VirtualFarPlaneDistanceMeters;
  661. public Sizei ImageSensorPixelResolution;
  662. }
  663. [StructLayout(LayoutKind.Sequential)]
  664. public struct CameraExtrinsics
  665. {
  666. public bool IsValid;
  667. public double LastChangedTimeSeconds;
  668. public CameraStatus CameraStatusData;
  669. public Node AttachedToNode;
  670. public Posef RelativePose;
  671. }
  672. public enum LayerLayout
  673. {
  674. Stereo = 0,
  675. Mono = 1,
  676. DoubleWide = 2,
  677. Array = 3,
  678. EnumSize = 0xF
  679. }
  680. public enum LayerFlags
  681. {
  682. Static = (1 << 0),
  683. LoadingScreen = (1 << 1),
  684. SymmetricFov = (1 << 2),
  685. TextureOriginAtBottomLeft = (1 << 3),
  686. ChromaticAberrationCorrection = (1 << 4),
  687. NoAllocation = (1 << 5),
  688. ProtectedContent = (1 << 6),
  689. }
  690. [StructLayout(LayoutKind.Sequential)]
  691. public struct LayerDesc
  692. {
  693. public OverlayShape Shape;
  694. public LayerLayout Layout;
  695. public Sizei TextureSize;
  696. public int MipLevels;
  697. public int SampleCount;
  698. public EyeTextureFormat Format;
  699. public int LayerFlags;
  700. //Eye FOV-only members.
  701. [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
  702. public Fovf[] Fov;
  703. [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
  704. public Rectf[] VisibleRect;
  705. public Sizei MaxViewportSize;
  706. EyeTextureFormat DepthFormat;
  707. public override string ToString ()
  708. {
  709. string delim = ", ";
  710. return Shape.ToString()
  711. + delim + Layout.ToString()
  712. + delim + TextureSize.w.ToString() + "x" + TextureSize.h.ToString()
  713. + delim + MipLevels.ToString()
  714. + delim + SampleCount.ToString()
  715. + delim + Format.ToString()
  716. + delim + LayerFlags.ToString();
  717. }
  718. }
  719. [StructLayout(LayoutKind.Sequential)]
  720. public struct LayerSubmit
  721. {
  722. int LayerId;
  723. int TextureStage;
  724. [MarshalAs(UnmanagedType.ByValArray, SizeConst=2)]
  725. Recti[] ViewportRect;
  726. Posef Pose;
  727. int LayerSubmitFlags;
  728. }
  729. public static bool initialized
  730. {
  731. get {
  732. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  733. return false;
  734. #else
  735. return OVRP_1_1_0.ovrp_GetInitialized() == OVRPlugin.Bool.True;
  736. #endif
  737. }
  738. }
  739. public static bool chromatic
  740. {
  741. get {
  742. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  743. return false;
  744. #else
  745. if (version >= OVRP_1_7_0.version)
  746. return initialized && OVRP_1_7_0.ovrp_GetAppChromaticCorrection() == OVRPlugin.Bool.True;
  747. #if UNITY_ANDROID && !UNITY_EDITOR
  748. return false;
  749. #else
  750. return true;
  751. #endif
  752. #endif
  753. }
  754. set {
  755. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  756. return;
  757. #else
  758. if (initialized && version >= OVRP_1_7_0.version)
  759. OVRP_1_7_0.ovrp_SetAppChromaticCorrection(ToBool(value));
  760. #endif
  761. }
  762. }
  763. public static bool monoscopic
  764. {
  765. get {
  766. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  767. return false;
  768. #else
  769. return initialized && OVRP_1_1_0.ovrp_GetAppMonoscopic() == OVRPlugin.Bool.True;
  770. #endif
  771. }
  772. set {
  773. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  774. return;
  775. #else
  776. if (initialized)
  777. {
  778. OVRP_1_1_0.ovrp_SetAppMonoscopic(ToBool(value));
  779. }
  780. #endif
  781. }
  782. }
  783. public static bool rotation
  784. {
  785. get {
  786. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  787. return false;
  788. #else
  789. return initialized && OVRP_1_1_0.ovrp_GetTrackingOrientationEnabled() == Bool.True;
  790. #endif
  791. }
  792. set {
  793. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  794. return;
  795. #else
  796. if (initialized)
  797. {
  798. OVRP_1_1_0.ovrp_SetTrackingOrientationEnabled(ToBool(value));
  799. }
  800. #endif
  801. }
  802. }
  803. public static bool position
  804. {
  805. get {
  806. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  807. return false;
  808. #else
  809. return initialized && OVRP_1_1_0.ovrp_GetTrackingPositionEnabled() == Bool.True;
  810. #endif
  811. }
  812. set {
  813. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  814. return;
  815. #else
  816. if (initialized)
  817. {
  818. OVRP_1_1_0.ovrp_SetTrackingPositionEnabled(ToBool(value));
  819. }
  820. #endif
  821. }
  822. }
  823. public static bool useIPDInPositionTracking
  824. {
  825. get {
  826. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  827. return false;
  828. #else
  829. if (initialized && version >= OVRP_1_6_0.version)
  830. return OVRP_1_6_0.ovrp_GetTrackingIPDEnabled() == OVRPlugin.Bool.True;
  831. return true;
  832. #endif
  833. }
  834. set {
  835. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  836. return;
  837. #else
  838. if (initialized && version >= OVRP_1_6_0.version)
  839. OVRP_1_6_0.ovrp_SetTrackingIPDEnabled(ToBool(value));
  840. #endif
  841. }
  842. }
  843. public static bool positionSupported
  844. {
  845. get {
  846. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  847. return false;
  848. #else
  849. return initialized && OVRP_1_1_0.ovrp_GetTrackingPositionSupported() == Bool.True;
  850. #endif
  851. }
  852. }
  853. public static bool positionTracked
  854. {
  855. get {
  856. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  857. return false;
  858. #else
  859. return initialized && OVRP_1_1_0.ovrp_GetNodePositionTracked(Node.EyeCenter) == Bool.True;
  860. #endif
  861. }
  862. }
  863. public static bool powerSaving
  864. {
  865. get {
  866. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  867. return false;
  868. #else
  869. return initialized && OVRP_1_1_0.ovrp_GetSystemPowerSavingMode() == Bool.True;
  870. #endif
  871. }
  872. }
  873. public static bool hmdPresent
  874. {
  875. get {
  876. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  877. return false;
  878. #else
  879. return initialized && OVRP_1_1_0.ovrp_GetNodePresent(Node.EyeCenter) == Bool.True;
  880. #endif
  881. }
  882. }
  883. public static bool userPresent
  884. {
  885. get {
  886. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  887. return false;
  888. #else
  889. return initialized && OVRP_1_1_0.ovrp_GetUserPresent() == Bool.True;
  890. #endif
  891. }
  892. }
  893. public static bool headphonesPresent
  894. {
  895. get {
  896. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  897. return false;
  898. #else
  899. return initialized && OVRP_1_3_0.ovrp_GetSystemHeadphonesPresent() == OVRPlugin.Bool.True;
  900. #endif
  901. }
  902. }
  903. public static int recommendedMSAALevel
  904. {
  905. get {
  906. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  907. return 2;
  908. #else
  909. if (initialized && version >= OVRP_1_6_0.version)
  910. return OVRP_1_6_0.ovrp_GetSystemRecommendedMSAALevel();
  911. else
  912. return 2;
  913. #endif
  914. }
  915. }
  916. public static SystemRegion systemRegion
  917. {
  918. get {
  919. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  920. return SystemRegion.Unspecified;
  921. #else
  922. if (initialized && version >= OVRP_1_5_0.version)
  923. return OVRP_1_5_0.ovrp_GetSystemRegion();
  924. else
  925. return SystemRegion.Unspecified;
  926. #endif
  927. }
  928. }
  929. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  930. private static GUID _nativeAudioOutGuid = new OVRPlugin.GUID();
  931. private static Guid _cachedAudioOutGuid;
  932. private static string _cachedAudioOutString;
  933. #endif
  934. public static string audioOutId
  935. {
  936. get {
  937. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  938. return string.Empty;
  939. #else
  940. try
  941. {
  942. if (_nativeAudioOutGuid == null)
  943. _nativeAudioOutGuid = new OVRPlugin.GUID();
  944. IntPtr ptr = OVRP_1_1_0.ovrp_GetAudioOutId();
  945. if (ptr != IntPtr.Zero)
  946. {
  947. Marshal.PtrToStructure(ptr, _nativeAudioOutGuid);
  948. Guid managedGuid = new Guid(
  949. _nativeAudioOutGuid.a,
  950. _nativeAudioOutGuid.b,
  951. _nativeAudioOutGuid.c,
  952. _nativeAudioOutGuid.d0,
  953. _nativeAudioOutGuid.d1,
  954. _nativeAudioOutGuid.d2,
  955. _nativeAudioOutGuid.d3,
  956. _nativeAudioOutGuid.d4,
  957. _nativeAudioOutGuid.d5,
  958. _nativeAudioOutGuid.d6,
  959. _nativeAudioOutGuid.d7);
  960. if (managedGuid != _cachedAudioOutGuid)
  961. {
  962. _cachedAudioOutGuid = managedGuid;
  963. _cachedAudioOutString = _cachedAudioOutGuid.ToString();
  964. }
  965. return _cachedAudioOutString;
  966. }
  967. }
  968. catch { }
  969. return string.Empty;
  970. #endif
  971. }
  972. }
  973. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  974. private static GUID _nativeAudioInGuid = new OVRPlugin.GUID();
  975. private static Guid _cachedAudioInGuid;
  976. private static string _cachedAudioInString;
  977. #endif
  978. public static string audioInId
  979. {
  980. get {
  981. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  982. return string.Empty;
  983. #else
  984. try
  985. {
  986. if (_nativeAudioInGuid == null)
  987. _nativeAudioInGuid = new OVRPlugin.GUID();
  988. IntPtr ptr = OVRP_1_1_0.ovrp_GetAudioInId();
  989. if (ptr != IntPtr.Zero)
  990. {
  991. Marshal.PtrToStructure(ptr, _nativeAudioInGuid);
  992. Guid managedGuid = new Guid(
  993. _nativeAudioInGuid.a,
  994. _nativeAudioInGuid.b,
  995. _nativeAudioInGuid.c,
  996. _nativeAudioInGuid.d0,
  997. _nativeAudioInGuid.d1,
  998. _nativeAudioInGuid.d2,
  999. _nativeAudioInGuid.d3,
  1000. _nativeAudioInGuid.d4,
  1001. _nativeAudioInGuid.d5,
  1002. _nativeAudioInGuid.d6,
  1003. _nativeAudioInGuid.d7);
  1004. if (managedGuid != _cachedAudioInGuid)
  1005. {
  1006. _cachedAudioInGuid = managedGuid;
  1007. _cachedAudioInString = _cachedAudioInGuid.ToString();
  1008. }
  1009. return _cachedAudioInString;
  1010. }
  1011. }
  1012. catch { }
  1013. return string.Empty;
  1014. #endif
  1015. }
  1016. }
  1017. public static bool hasVrFocus
  1018. {
  1019. get {
  1020. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1021. return false;
  1022. #else
  1023. return OVRP_1_1_0.ovrp_GetAppHasVrFocus() == Bool.True;
  1024. #endif
  1025. }
  1026. }
  1027. public static bool hasInputFocus
  1028. {
  1029. get
  1030. {
  1031. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1032. return true;
  1033. #else
  1034. if (version >= OVRP_1_18_0.version)
  1035. {
  1036. Bool inputFocus = Bool.False;
  1037. Result result = OVRP_1_18_0.ovrp_GetAppHasInputFocus(out inputFocus);
  1038. if (Result.Success == result)
  1039. return inputFocus == Bool.True;
  1040. else
  1041. {
  1042. //Debug.LogWarning("ovrp_GetAppHasInputFocus return " + result);
  1043. return false;
  1044. }
  1045. }
  1046. return true;
  1047. #endif
  1048. }
  1049. }
  1050. public static bool shouldQuit
  1051. {
  1052. get {
  1053. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1054. return false;
  1055. #else
  1056. return OVRP_1_1_0.ovrp_GetAppShouldQuit() == Bool.True;
  1057. #endif
  1058. }
  1059. }
  1060. public static bool shouldRecenter
  1061. {
  1062. get {
  1063. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1064. return false;
  1065. #else
  1066. return OVRP_1_1_0.ovrp_GetAppShouldRecenter() == Bool.True;
  1067. #endif
  1068. }
  1069. }
  1070. public static string productName
  1071. {
  1072. get {
  1073. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1074. return string.Empty;
  1075. #else
  1076. return OVRP_1_1_0.ovrp_GetSystemProductName();
  1077. #endif
  1078. }
  1079. }
  1080. public static string latency
  1081. {
  1082. get {
  1083. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1084. return string.Empty;
  1085. #else
  1086. return OVRP_1_1_0.ovrp_GetAppLatencyTimings();
  1087. #endif
  1088. }
  1089. }
  1090. public static float eyeDepth
  1091. {
  1092. get {
  1093. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1094. return 0.0f;
  1095. #else
  1096. return OVRP_1_1_0.ovrp_GetUserEyeDepth();
  1097. #endif
  1098. }
  1099. set {
  1100. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1101. return;
  1102. #else
  1103. OVRP_1_1_0.ovrp_SetUserEyeDepth(value);
  1104. #endif
  1105. }
  1106. }
  1107. public static float eyeHeight
  1108. {
  1109. get {
  1110. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1111. return 0.0f;
  1112. #else
  1113. return OVRP_1_1_0.ovrp_GetUserEyeHeight();
  1114. #endif
  1115. }
  1116. set {
  1117. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1118. return;
  1119. #else
  1120. OVRP_1_1_0.ovrp_SetUserEyeHeight(value);
  1121. #endif
  1122. }
  1123. }
  1124. public static float batteryLevel
  1125. {
  1126. get {
  1127. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1128. return 0.0f;
  1129. #else
  1130. return OVRP_1_1_0.ovrp_GetSystemBatteryLevel();
  1131. #endif
  1132. }
  1133. }
  1134. public static float batteryTemperature
  1135. {
  1136. get {
  1137. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1138. return 0.0f;
  1139. #else
  1140. return OVRP_1_1_0.ovrp_GetSystemBatteryTemperature();
  1141. #endif
  1142. }
  1143. }
  1144. public static int cpuLevel
  1145. {
  1146. get {
  1147. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1148. return 0;
  1149. #else
  1150. return OVRP_1_1_0.ovrp_GetSystemCpuLevel();
  1151. #endif
  1152. }
  1153. set {
  1154. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1155. return;
  1156. #else
  1157. OVRP_1_1_0.ovrp_SetSystemCpuLevel(value);
  1158. #endif
  1159. }
  1160. }
  1161. public static int gpuLevel
  1162. {
  1163. get {
  1164. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1165. return 0;
  1166. #else
  1167. return OVRP_1_1_0.ovrp_GetSystemGpuLevel();
  1168. #endif
  1169. }
  1170. set {
  1171. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1172. return;
  1173. #else
  1174. OVRP_1_1_0.ovrp_SetSystemGpuLevel(value);
  1175. #endif
  1176. }
  1177. }
  1178. public static int vsyncCount
  1179. {
  1180. get {
  1181. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1182. return 0;
  1183. #else
  1184. return OVRP_1_1_0.ovrp_GetSystemVSyncCount();
  1185. #endif
  1186. }
  1187. set {
  1188. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1189. return;
  1190. #else
  1191. OVRP_1_2_0.ovrp_SetSystemVSyncCount(value);
  1192. #endif
  1193. }
  1194. }
  1195. public static float systemVolume
  1196. {
  1197. get {
  1198. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1199. return 0.0f;
  1200. #else
  1201. return OVRP_1_1_0.ovrp_GetSystemVolume();
  1202. #endif
  1203. }
  1204. }
  1205. public static float ipd
  1206. {
  1207. get {
  1208. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1209. return 0.0f;
  1210. #else
  1211. return OVRP_1_1_0.ovrp_GetUserIPD();
  1212. #endif
  1213. }
  1214. set {
  1215. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1216. return;
  1217. #else
  1218. OVRP_1_1_0.ovrp_SetUserIPD(value);
  1219. #endif
  1220. }
  1221. }
  1222. public static bool occlusionMesh
  1223. {
  1224. get {
  1225. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1226. return false;
  1227. #else
  1228. return OVRP_1_3_0.ovrp_GetEyeOcclusionMeshEnabled() == Bool.True;
  1229. #endif
  1230. }
  1231. set {
  1232. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1233. return;
  1234. #else
  1235. OVRP_1_3_0.ovrp_SetEyeOcclusionMeshEnabled(ToBool(value));
  1236. #endif
  1237. }
  1238. }
  1239. public static BatteryStatus batteryStatus
  1240. {
  1241. get {
  1242. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1243. return default(BatteryStatus);
  1244. #else
  1245. return OVRP_1_1_0.ovrp_GetSystemBatteryStatus();
  1246. #endif
  1247. }
  1248. }
  1249. public static Frustumf GetEyeFrustum(Eye eyeId)
  1250. {
  1251. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1252. return new Frustumf();
  1253. #else
  1254. return OVRP_1_1_0.ovrp_GetNodeFrustum((Node)eyeId);
  1255. #endif
  1256. }
  1257. public static Sizei GetEyeTextureSize(Eye eyeId)
  1258. {
  1259. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1260. return new Sizei();
  1261. #else
  1262. return OVRP_0_1_0.ovrp_GetEyeTextureSize(eyeId);
  1263. #endif
  1264. }
  1265. public static Posef GetTrackerPose(Tracker trackerId)
  1266. {
  1267. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1268. return Posef.identity;
  1269. #else
  1270. return GetNodePose((Node)((int)trackerId + (int)Node.TrackerZero), Step.Render);
  1271. #endif
  1272. }
  1273. public static Frustumf GetTrackerFrustum(Tracker trackerId)
  1274. {
  1275. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1276. return new Frustumf();
  1277. #else
  1278. return OVRP_1_1_0.ovrp_GetNodeFrustum((Node)((int)trackerId + (int)Node.TrackerZero));
  1279. #endif
  1280. }
  1281. public static bool ShowUI(PlatformUI ui)
  1282. {
  1283. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1284. return false;
  1285. #else
  1286. return OVRP_1_1_0.ovrp_ShowSystemUI(ui) == Bool.True;
  1287. #endif
  1288. }
  1289. public static bool EnqueueSubmitLayer(bool onTop, bool headLocked, IntPtr leftTexture, IntPtr rightTexture, int layerId, int frameIndex, Posef pose, Vector3f scale, int layerIndex=0, OverlayShape shape=OverlayShape.Quad)
  1290. {
  1291. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1292. return false;
  1293. #else
  1294. if (version >= OVRP_1_6_0.version)
  1295. {
  1296. uint flags = (uint)OverlayFlag.None;
  1297. if (onTop)
  1298. flags |= (uint)OverlayFlag.OnTop;
  1299. if (headLocked)
  1300. flags |= (uint)OverlayFlag.HeadLocked;
  1301. if (shape == OverlayShape.Cylinder || shape == OverlayShape.Cubemap)
  1302. {
  1303. #if UNITY_ANDROID
  1304. if (version >= OVRP_1_7_0.version)
  1305. flags |= (uint)(shape) << OverlayShapeFlagShift;
  1306. else
  1307. #else
  1308. if (shape == OverlayShape.Cubemap && version >= OVRP_1_10_0.version)
  1309. flags |= (uint)(shape) << OverlayShapeFlagShift;
  1310. else if (shape == OverlayShape.Cylinder && version >= OVRP_1_16_0.version)
  1311. flags |= (uint)(shape) << OverlayShapeFlagShift;
  1312. else
  1313. #endif
  1314. return false;
  1315. }
  1316. if (shape == OverlayShape.OffcenterCubemap)
  1317. {
  1318. #if UNITY_ANDROID
  1319. if (version >= OVRP_1_11_0.version)
  1320. flags |= (uint)(shape) << OverlayShapeFlagShift;
  1321. else
  1322. #endif
  1323. return false;
  1324. }
  1325. if (shape == OverlayShape.Equirect)
  1326. {
  1327. #if UNITY_ANDROID
  1328. if (version >= OVRP_1_21_0.version)
  1329. flags |= (uint)(shape) << OverlayShapeFlagShift;
  1330. else
  1331. #endif
  1332. return false;
  1333. }
  1334. if (version >= OVRP_1_15_0.version && layerId != -1)
  1335. return OVRP_1_15_0.ovrp_EnqueueSubmitLayer(flags, leftTexture, rightTexture, layerId, frameIndex, ref pose, ref scale, layerIndex) == Result.Success;
  1336. return OVRP_1_6_0.ovrp_SetOverlayQuad3(flags, leftTexture, rightTexture, IntPtr.Zero, pose, scale, layerIndex) == Bool.True;
  1337. }
  1338. if (layerIndex != 0)
  1339. return false;
  1340. return OVRP_0_1_1.ovrp_SetOverlayQuad2(ToBool(onTop), ToBool(headLocked), leftTexture, IntPtr.Zero, pose, scale) == Bool.True;
  1341. #endif
  1342. }
  1343. public static LayerDesc CalculateLayerDesc(OverlayShape shape, LayerLayout layout, Sizei textureSize,
  1344. int mipLevels, int sampleCount, EyeTextureFormat format, int layerFlags)
  1345. {
  1346. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1347. return new LayerDesc();
  1348. #else
  1349. LayerDesc layerDesc = new LayerDesc();
  1350. if (version >= OVRP_1_15_0.version)
  1351. {
  1352. OVRP_1_15_0.ovrp_CalculateLayerDesc (shape, layout, ref textureSize,
  1353. mipLevels, sampleCount, format, layerFlags, ref layerDesc);
  1354. }
  1355. return layerDesc;
  1356. #endif
  1357. }
  1358. public static bool EnqueueSetupLayer(LayerDesc desc, IntPtr layerID)
  1359. {
  1360. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1361. return false;
  1362. #else
  1363. if (version >= OVRP_1_15_0.version)
  1364. return OVRP_1_15_0.ovrp_EnqueueSetupLayer(ref desc, layerID) == Result.Success;
  1365. return false;
  1366. #endif
  1367. }
  1368. public static bool EnqueueDestroyLayer(IntPtr layerID)
  1369. {
  1370. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1371. return false;
  1372. #else
  1373. if (version >= OVRP_1_15_0.version)
  1374. return OVRP_1_15_0.ovrp_EnqueueDestroyLayer(layerID) == Result.Success;
  1375. return false;
  1376. #endif
  1377. }
  1378. public static IntPtr GetLayerTexture(int layerId, int stage, Eye eyeId)
  1379. {
  1380. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1381. return IntPtr.Zero;
  1382. #else
  1383. IntPtr textureHandle = IntPtr.Zero;
  1384. if (version >= OVRP_1_15_0.version)
  1385. OVRP_1_15_0.ovrp_GetLayerTexturePtr(layerId, stage, eyeId, ref textureHandle);
  1386. return textureHandle;
  1387. #endif
  1388. }
  1389. public static int GetLayerTextureStageCount(int layerId)
  1390. {
  1391. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1392. return 1;
  1393. #else
  1394. int stageCount = 1;
  1395. if (version >= OVRP_1_15_0.version)
  1396. OVRP_1_15_0.ovrp_GetLayerTextureStageCount(layerId, ref stageCount);
  1397. return stageCount;
  1398. #endif
  1399. }
  1400. public static bool UpdateNodePhysicsPoses(int frameIndex, double predictionSeconds)
  1401. {
  1402. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1403. return false;
  1404. #else
  1405. if (version >= OVRP_1_8_0.version)
  1406. return OVRP_1_8_0.ovrp_Update2((int)Step.Physics, frameIndex, predictionSeconds) == Bool.True;
  1407. return false;
  1408. #endif
  1409. }
  1410. public static Posef GetNodePose(Node nodeId, Step stepId)
  1411. {
  1412. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1413. return Posef.identity;
  1414. #else
  1415. if (version >= OVRP_1_12_0.version)
  1416. return OVRP_1_12_0.ovrp_GetNodePoseState(stepId, nodeId).Pose;
  1417. if (version >= OVRP_1_8_0.version && stepId == Step.Physics)
  1418. return OVRP_1_8_0.ovrp_GetNodePose2(0, nodeId);
  1419. return OVRP_0_1_2.ovrp_GetNodePose(nodeId);
  1420. #endif
  1421. }
  1422. public static Vector3f GetNodeVelocity(Node nodeId, Step stepId)
  1423. {
  1424. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1425. return new Vector3f();
  1426. #else
  1427. if (version >= OVRP_1_12_0.version)
  1428. return OVRP_1_12_0.ovrp_GetNodePoseState(stepId, nodeId).Velocity;
  1429. if (version >= OVRP_1_8_0.version && stepId == Step.Physics)
  1430. return OVRP_1_8_0.ovrp_GetNodeVelocity2(0, nodeId).Position;
  1431. return OVRP_0_1_3.ovrp_GetNodeVelocity(nodeId).Position;
  1432. #endif
  1433. }
  1434. public static Vector3f GetNodeAngularVelocity(Node nodeId, Step stepId)
  1435. {
  1436. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1437. return new Vector3f();
  1438. #else
  1439. if (version >= OVRP_1_12_0.version)
  1440. return OVRP_1_12_0.ovrp_GetNodePoseState(stepId, nodeId).AngularVelocity;
  1441. return new Vector3f(); //TODO: Convert legacy quat to vec3?
  1442. #endif
  1443. }
  1444. public static Vector3f GetNodeAcceleration(Node nodeId, Step stepId)
  1445. {
  1446. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1447. return new Vector3f();
  1448. #else
  1449. if (version >= OVRP_1_12_0.version)
  1450. return OVRP_1_12_0.ovrp_GetNodePoseState(stepId, nodeId).Acceleration;
  1451. if (version >= OVRP_1_8_0.version && stepId == Step.Physics)
  1452. return OVRP_1_8_0.ovrp_GetNodeAcceleration2(0, nodeId).Position;
  1453. return OVRP_0_1_3.ovrp_GetNodeAcceleration(nodeId).Position;
  1454. #endif
  1455. }
  1456. public static Vector3f GetNodeAngularAcceleration(Node nodeId, Step stepId)
  1457. {
  1458. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1459. return new Vector3f();
  1460. #else
  1461. if (version >= OVRP_1_12_0.version)
  1462. return OVRP_1_12_0.ovrp_GetNodePoseState(stepId, nodeId).AngularAcceleration;
  1463. return new Vector3f(); //TODO: Convert legacy quat to vec3?
  1464. #endif
  1465. }
  1466. public static bool GetNodePresent(Node nodeId)
  1467. {
  1468. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1469. return false;
  1470. #else
  1471. return OVRP_1_1_0.ovrp_GetNodePresent(nodeId) == Bool.True;
  1472. #endif
  1473. }
  1474. public static bool GetNodeOrientationTracked(Node nodeId)
  1475. {
  1476. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1477. return false;
  1478. #else
  1479. return OVRP_1_1_0.ovrp_GetNodeOrientationTracked(nodeId) == Bool.True;
  1480. #endif
  1481. }
  1482. public static bool GetNodePositionTracked(Node nodeId)
  1483. {
  1484. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1485. return false;
  1486. #else
  1487. return OVRP_1_1_0.ovrp_GetNodePositionTracked(nodeId) == Bool.True;
  1488. #endif
  1489. }
  1490. public static ControllerState GetControllerState(uint controllerMask)
  1491. {
  1492. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1493. return new ControllerState();
  1494. #else
  1495. return OVRP_1_1_0.ovrp_GetControllerState(controllerMask);
  1496. #endif
  1497. }
  1498. public static ControllerState2 GetControllerState2(uint controllerMask)
  1499. {
  1500. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1501. return new ControllerState2();
  1502. #else
  1503. if (version >= OVRP_1_12_0.version)
  1504. {
  1505. return OVRP_1_12_0.ovrp_GetControllerState2(controllerMask);
  1506. }
  1507. return new ControllerState2(OVRP_1_1_0.ovrp_GetControllerState(controllerMask));
  1508. #endif
  1509. }
  1510. public static ControllerState4 GetControllerState4(uint controllerMask)
  1511. {
  1512. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1513. return new ControllerState4();
  1514. #else
  1515. if (version >= OVRP_1_16_0.version)
  1516. {
  1517. ControllerState4 controllerState = new ControllerState4();
  1518. OVRP_1_16_0.ovrp_GetControllerState4(controllerMask, ref controllerState);
  1519. return controllerState;
  1520. }
  1521. return new ControllerState4(GetControllerState2(controllerMask));
  1522. #endif
  1523. }
  1524. public static bool SetControllerVibration(uint controllerMask, float frequency, float amplitude)
  1525. {
  1526. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1527. return false;
  1528. #else
  1529. return OVRP_0_1_2.ovrp_SetControllerVibration(controllerMask, frequency, amplitude) == Bool.True;
  1530. #endif
  1531. }
  1532. public static HapticsDesc GetControllerHapticsDesc(uint controllerMask)
  1533. {
  1534. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1535. return new HapticsDesc();
  1536. #else
  1537. if (version >= OVRP_1_6_0.version)
  1538. {
  1539. return OVRP_1_6_0.ovrp_GetControllerHapticsDesc(controllerMask);
  1540. }
  1541. else
  1542. {
  1543. return new HapticsDesc();
  1544. }
  1545. #endif
  1546. }
  1547. public static HapticsState GetControllerHapticsState(uint controllerMask)
  1548. {
  1549. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1550. return new HapticsState();
  1551. #else
  1552. if (version >= OVRP_1_6_0.version)
  1553. {
  1554. return OVRP_1_6_0.ovrp_GetControllerHapticsState(controllerMask);
  1555. }
  1556. else
  1557. {
  1558. return new HapticsState();
  1559. }
  1560. #endif
  1561. }
  1562. public static bool SetControllerHaptics(uint controllerMask, HapticsBuffer hapticsBuffer)
  1563. {
  1564. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1565. return false;
  1566. #else
  1567. if (version >= OVRP_1_6_0.version)
  1568. {
  1569. return OVRP_1_6_0.ovrp_SetControllerHaptics(controllerMask, hapticsBuffer) == Bool.True;
  1570. }
  1571. else
  1572. {
  1573. return false;
  1574. }
  1575. #endif
  1576. }
  1577. public static float GetEyeRecommendedResolutionScale()
  1578. {
  1579. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1580. return 1.0f;
  1581. #else
  1582. if (version >= OVRP_1_6_0.version)
  1583. {
  1584. return OVRP_1_6_0.ovrp_GetEyeRecommendedResolutionScale();
  1585. }
  1586. else
  1587. {
  1588. return 1.0f;
  1589. }
  1590. #endif
  1591. }
  1592. public static float GetAppCpuStartToGpuEndTime()
  1593. {
  1594. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1595. return 0.0f;
  1596. #else
  1597. if (version >= OVRP_1_6_0.version)
  1598. {
  1599. return OVRP_1_6_0.ovrp_GetAppCpuStartToGpuEndTime();
  1600. }
  1601. else
  1602. {
  1603. return 0.0f;
  1604. }
  1605. #endif
  1606. }
  1607. public static bool GetBoundaryConfigured()
  1608. {
  1609. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1610. return false;
  1611. #else
  1612. if (version >= OVRP_1_8_0.version)
  1613. {
  1614. return OVRP_1_8_0.ovrp_GetBoundaryConfigured() == OVRPlugin.Bool.True;
  1615. }
  1616. else
  1617. {
  1618. return false;
  1619. }
  1620. #endif
  1621. }
  1622. public static BoundaryTestResult TestBoundaryNode(Node nodeId, BoundaryType boundaryType)
  1623. {
  1624. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1625. return new BoundaryTestResult();
  1626. #else
  1627. if (version >= OVRP_1_8_0.version)
  1628. {
  1629. return OVRP_1_8_0.ovrp_TestBoundaryNode(nodeId, boundaryType);
  1630. }
  1631. else
  1632. {
  1633. return new BoundaryTestResult();
  1634. }
  1635. #endif
  1636. }
  1637. public static BoundaryTestResult TestBoundaryPoint(Vector3f point, BoundaryType boundaryType)
  1638. {
  1639. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1640. return new BoundaryTestResult();
  1641. #else
  1642. if (version >= OVRP_1_8_0.version)
  1643. {
  1644. return OVRP_1_8_0.ovrp_TestBoundaryPoint(point, boundaryType);
  1645. }
  1646. else
  1647. {
  1648. return new BoundaryTestResult();
  1649. }
  1650. #endif
  1651. }
  1652. public static bool SetBoundaryLookAndFeel(BoundaryLookAndFeel lookAndFeel)
  1653. {
  1654. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1655. return false;
  1656. #else
  1657. if (version >= OVRP_1_8_0.version)
  1658. {
  1659. return OVRP_1_8_0.ovrp_SetBoundaryLookAndFeel(lookAndFeel) == OVRPlugin.Bool.True;
  1660. }
  1661. else
  1662. {
  1663. return false;
  1664. }
  1665. #endif
  1666. }
  1667. public static bool ResetBoundaryLookAndFeel()
  1668. {
  1669. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1670. return false;
  1671. #else
  1672. if (version >= OVRP_1_8_0.version)
  1673. {
  1674. return OVRP_1_8_0.ovrp_ResetBoundaryLookAndFeel() == OVRPlugin.Bool.True;
  1675. }
  1676. else
  1677. {
  1678. return false;
  1679. }
  1680. #endif
  1681. }
  1682. public static BoundaryGeometry GetBoundaryGeometry(BoundaryType boundaryType)
  1683. {
  1684. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1685. return new BoundaryGeometry();
  1686. #else
  1687. if (version >= OVRP_1_8_0.version)
  1688. {
  1689. return OVRP_1_8_0.ovrp_GetBoundaryGeometry(boundaryType);
  1690. }
  1691. else
  1692. {
  1693. return new BoundaryGeometry();
  1694. }
  1695. #endif
  1696. }
  1697. public static bool GetBoundaryGeometry2(BoundaryType boundaryType, IntPtr points, ref int pointsCount)
  1698. {
  1699. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1700. pointsCount = 0;
  1701. return false;
  1702. #else
  1703. if (version >= OVRP_1_9_0.version)
  1704. {
  1705. return OVRP_1_9_0.ovrp_GetBoundaryGeometry2(boundaryType, points, ref pointsCount) == OVRPlugin.Bool.True;
  1706. }
  1707. else
  1708. {
  1709. pointsCount = 0;
  1710. return false;
  1711. }
  1712. #endif
  1713. }
  1714. public static AppPerfStats GetAppPerfStats()
  1715. {
  1716. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1717. return new AppPerfStats();
  1718. #else
  1719. if (version >= OVRP_1_9_0.version)
  1720. {
  1721. return OVRP_1_9_0.ovrp_GetAppPerfStats();
  1722. }
  1723. else
  1724. {
  1725. return new AppPerfStats();
  1726. }
  1727. #endif
  1728. }
  1729. public static bool ResetAppPerfStats()
  1730. {
  1731. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1732. return false;
  1733. #else
  1734. if (version >= OVRP_1_9_0.version)
  1735. {
  1736. return OVRP_1_9_0.ovrp_ResetAppPerfStats() == OVRPlugin.Bool.True;
  1737. }
  1738. else
  1739. {
  1740. return false;
  1741. }
  1742. #endif
  1743. }
  1744. public static float GetAppFramerate()
  1745. {
  1746. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1747. return 0.0f;
  1748. #else
  1749. if (version >= OVRP_1_12_0.version)
  1750. {
  1751. return OVRP_1_12_0.ovrp_GetAppFramerate();
  1752. }
  1753. else
  1754. {
  1755. return 0.0f;
  1756. }
  1757. #endif
  1758. }
  1759. public static bool SetHandNodePoseStateLatency(double latencyInSeconds)
  1760. {
  1761. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1762. return false;
  1763. #else
  1764. if (version >= OVRP_1_18_0.version)
  1765. {
  1766. Result result = OVRP_1_18_0.ovrp_SetHandNodePoseStateLatency(latencyInSeconds);
  1767. if (result == Result.Success)
  1768. {
  1769. return true;
  1770. }
  1771. else
  1772. {
  1773. //Debug.LogWarning("ovrp_SetHandNodePoseStateLatency return " + result);
  1774. return false;
  1775. }
  1776. }
  1777. else
  1778. {
  1779. return false;
  1780. }
  1781. #endif
  1782. }
  1783. public static double GetHandNodePoseStateLatency()
  1784. {
  1785. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1786. return 0.0;
  1787. #else
  1788. if (version >= OVRP_1_18_0.version)
  1789. {
  1790. double value = 0.0;
  1791. if (OVRP_1_18_0.ovrp_GetHandNodePoseStateLatency(out value) == OVRPlugin.Result.Success)
  1792. {
  1793. return value;
  1794. }
  1795. else
  1796. {
  1797. return 0.0;
  1798. }
  1799. }
  1800. else
  1801. {
  1802. return 0.0;
  1803. }
  1804. #endif
  1805. }
  1806. public static EyeTextureFormat GetDesiredEyeTextureFormat()
  1807. {
  1808. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1809. return EyeTextureFormat.Default;
  1810. #else
  1811. if (version >= OVRP_1_11_0.version)
  1812. {
  1813. uint eyeTextureFormatValue = (uint)OVRP_1_11_0.ovrp_GetDesiredEyeTextureFormat();
  1814. // convert both R8G8B8A8 and R8G8B8A8_SRGB to R8G8B8A8 here for avoid confusing developers
  1815. if (eyeTextureFormatValue == 1)
  1816. eyeTextureFormatValue = 0;
  1817. return (EyeTextureFormat)eyeTextureFormatValue;
  1818. }
  1819. else
  1820. {
  1821. return EyeTextureFormat.Default;
  1822. }
  1823. #endif
  1824. }
  1825. public static bool SetDesiredEyeTextureFormat(EyeTextureFormat value)
  1826. {
  1827. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1828. return false;
  1829. #else
  1830. if (version >= OVRP_1_11_0.version)
  1831. {
  1832. return OVRP_1_11_0.ovrp_SetDesiredEyeTextureFormat(value) == OVRPlugin.Bool.True;
  1833. }
  1834. else
  1835. {
  1836. return false;
  1837. }
  1838. #endif
  1839. }
  1840. public static bool InitializeMixedReality()
  1841. {
  1842. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1843. return false;
  1844. #else
  1845. if (version >= OVRP_1_15_0.version)
  1846. {
  1847. Result result = OVRP_1_15_0.ovrp_InitializeMixedReality();
  1848. if (result != Result.Success)
  1849. {
  1850. //Debug.LogWarning("ovrp_InitializeMixedReality return " + result);
  1851. }
  1852. return result == Result.Success;
  1853. }
  1854. else
  1855. {
  1856. return false;
  1857. }
  1858. #endif
  1859. }
  1860. public static bool ShutdownMixedReality()
  1861. {
  1862. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1863. return false;
  1864. #else
  1865. if (version >= OVRP_1_15_0.version)
  1866. {
  1867. Result result = OVRP_1_15_0.ovrp_ShutdownMixedReality();
  1868. if (result != Result.Success)
  1869. {
  1870. //Debug.LogWarning("ovrp_ShutdownMixedReality return " + result);
  1871. }
  1872. return result == Result.Success;
  1873. }
  1874. else
  1875. {
  1876. return false;
  1877. }
  1878. #endif
  1879. }
  1880. public static bool IsMixedRealityInitialized()
  1881. {
  1882. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1883. return false;
  1884. #else
  1885. if (version >= OVRP_1_15_0.version)
  1886. {
  1887. return OVRP_1_15_0.ovrp_GetMixedRealityInitialized() == Bool.True;
  1888. }
  1889. else
  1890. {
  1891. return false;
  1892. }
  1893. #endif
  1894. }
  1895. public static int GetExternalCameraCount()
  1896. {
  1897. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1898. return 0;
  1899. #else
  1900. if (version >= OVRP_1_15_0.version)
  1901. {
  1902. int cameraCount = 0;
  1903. Result result = OVRP_1_15_0.ovrp_GetExternalCameraCount(out cameraCount);
  1904. if (result != OVRPlugin.Result.Success)
  1905. {
  1906. //Debug.LogWarning("ovrp_GetExternalCameraCount return " + result);
  1907. return 0;
  1908. }
  1909. return cameraCount;
  1910. }
  1911. else
  1912. {
  1913. return 0;
  1914. }
  1915. #endif
  1916. }
  1917. public static bool UpdateExternalCamera()
  1918. {
  1919. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1920. return false;
  1921. #else
  1922. if (version >= OVRP_1_15_0.version)
  1923. {
  1924. Result result = OVRP_1_15_0.ovrp_UpdateExternalCamera();
  1925. if (result != Result.Success)
  1926. {
  1927. //Debug.LogWarning("ovrp_UpdateExternalCamera return " + result);
  1928. }
  1929. return result == Result.Success;
  1930. }
  1931. else
  1932. {
  1933. return false;
  1934. }
  1935. #endif
  1936. }
  1937. public static bool GetMixedRealityCameraInfo(int cameraId, out CameraExtrinsics cameraExtrinsics, out CameraIntrinsics cameraIntrinsics)
  1938. {
  1939. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1940. cameraExtrinsics = default(CameraExtrinsics);
  1941. cameraIntrinsics = default(CameraIntrinsics);
  1942. return false;
  1943. #else
  1944. cameraExtrinsics = default(CameraExtrinsics);
  1945. cameraIntrinsics = default(CameraIntrinsics);
  1946. if (version >= OVRP_1_15_0.version)
  1947. {
  1948. bool retValue = true;
  1949. Result result = OVRP_1_15_0.ovrp_GetExternalCameraExtrinsics(cameraId, out cameraExtrinsics);
  1950. if (result != Result.Success)
  1951. {
  1952. retValue = false;
  1953. //Debug.LogWarning("ovrp_GetExternalCameraExtrinsics return " + result);
  1954. }
  1955. result = OVRP_1_15_0.ovrp_GetExternalCameraIntrinsics(cameraId, out cameraIntrinsics);
  1956. if (result != Result.Success)
  1957. {
  1958. retValue = false;
  1959. //Debug.LogWarning("ovrp_GetExternalCameraIntrinsics return " + result);
  1960. }
  1961. return retValue;
  1962. }
  1963. else
  1964. {
  1965. return false;
  1966. }
  1967. #endif
  1968. }
  1969. public static Vector3f GetBoundaryDimensions(BoundaryType boundaryType)
  1970. {
  1971. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1972. return new Vector3f();
  1973. #else
  1974. if (version >= OVRP_1_8_0.version)
  1975. {
  1976. return OVRP_1_8_0.ovrp_GetBoundaryDimensions(boundaryType);
  1977. }
  1978. else
  1979. {
  1980. return new Vector3f();
  1981. }
  1982. #endif
  1983. }
  1984. public static bool GetBoundaryVisible()
  1985. {
  1986. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  1987. return false;
  1988. #else
  1989. if (version >= OVRP_1_8_0.version)
  1990. {
  1991. return OVRP_1_8_0.ovrp_GetBoundaryVisible() == OVRPlugin.Bool.True;
  1992. }
  1993. else
  1994. {
  1995. return false;
  1996. }
  1997. #endif
  1998. }
  1999. public static bool SetBoundaryVisible(bool value)
  2000. {
  2001. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2002. return false;
  2003. #else
  2004. if (version >= OVRP_1_8_0.version)
  2005. {
  2006. return OVRP_1_8_0.ovrp_SetBoundaryVisible(ToBool(value)) == OVRPlugin.Bool.True;
  2007. }
  2008. else
  2009. {
  2010. return false;
  2011. }
  2012. #endif
  2013. }
  2014. public static SystemHeadset GetSystemHeadsetType()
  2015. {
  2016. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2017. return SystemHeadset.None;
  2018. #else
  2019. if (version >= OVRP_1_9_0.version)
  2020. return OVRP_1_9_0.ovrp_GetSystemHeadsetType();
  2021. return SystemHeadset.None;
  2022. #endif
  2023. }
  2024. public static Controller GetActiveController()
  2025. {
  2026. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2027. return Controller.None;
  2028. #else
  2029. if (version >= OVRP_1_9_0.version)
  2030. return OVRP_1_9_0.ovrp_GetActiveController();
  2031. return Controller.None;
  2032. #endif
  2033. }
  2034. public static Controller GetConnectedControllers()
  2035. {
  2036. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2037. return Controller.None;
  2038. #else
  2039. if (version >= OVRP_1_9_0.version)
  2040. return OVRP_1_9_0.ovrp_GetConnectedControllers();
  2041. return Controller.None;
  2042. #endif
  2043. }
  2044. private static Bool ToBool(bool b)
  2045. {
  2046. return (b) ? OVRPlugin.Bool.True : OVRPlugin.Bool.False;
  2047. }
  2048. public static TrackingOrigin GetTrackingOriginType()
  2049. {
  2050. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2051. return default(TrackingOrigin);
  2052. #else
  2053. return OVRP_1_0_0.ovrp_GetTrackingOriginType();
  2054. #endif
  2055. }
  2056. public static bool SetTrackingOriginType(TrackingOrigin originType)
  2057. {
  2058. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2059. return false;
  2060. #else
  2061. return OVRP_1_0_0.ovrp_SetTrackingOriginType(originType) == Bool.True;
  2062. #endif
  2063. }
  2064. public static Posef GetTrackingCalibratedOrigin()
  2065. {
  2066. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2067. return Posef.identity;
  2068. #else
  2069. return OVRP_1_0_0.ovrp_GetTrackingCalibratedOrigin();
  2070. #endif
  2071. }
  2072. public static bool SetTrackingCalibratedOrigin()
  2073. {
  2074. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2075. return false;
  2076. #else
  2077. return OVRP_1_2_0.ovrpi_SetTrackingCalibratedOrigin() == Bool.True;
  2078. #endif
  2079. }
  2080. public static bool RecenterTrackingOrigin(RecenterFlags flags)
  2081. {
  2082. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2083. return false;
  2084. #else
  2085. return OVRP_1_0_0.ovrp_RecenterTrackingOrigin((uint)flags) == Bool.True;
  2086. #endif
  2087. }
  2088. #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
  2089. public static bool UpdateCameraDevices()
  2090. {
  2091. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2092. return false;
  2093. #else
  2094. if (version >= OVRP_1_16_0.version)
  2095. {
  2096. Result result = OVRP_1_16_0.ovrp_UpdateCameraDevices();
  2097. if (result != Result.Success)
  2098. {
  2099. //Debug.LogWarning("ovrp_UpdateCameraDevices return " + result);
  2100. }
  2101. return result == Result.Success;
  2102. }
  2103. else
  2104. {
  2105. return false;
  2106. }
  2107. #endif
  2108. }
  2109. public static bool IsCameraDeviceAvailable(CameraDevice cameraDevice)
  2110. {
  2111. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2112. return false;
  2113. #else
  2114. if (version >= OVRP_1_16_0.version)
  2115. {
  2116. Bool result = OVRP_1_16_0.ovrp_IsCameraDeviceAvailable(cameraDevice);
  2117. return result == Bool.True;
  2118. }
  2119. else
  2120. {
  2121. return false;
  2122. }
  2123. #endif
  2124. }
  2125. public static bool SetCameraDevicePreferredColorFrameSize(CameraDevice cameraDevice, int width, int height)
  2126. {
  2127. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2128. return false;
  2129. #else
  2130. if (version >= OVRP_1_16_0.version)
  2131. {
  2132. Sizei size = new Sizei();
  2133. size.w = width;
  2134. size.h = height;
  2135. Result result = OVRP_1_16_0.ovrp_SetCameraDevicePreferredColorFrameSize(cameraDevice, size);
  2136. if (result != Result.Success)
  2137. {
  2138. //Debug.LogWarning("ovrp_SetCameraDevicePreferredColorFrameSize return " + result);
  2139. }
  2140. return result == Result.Success;
  2141. }
  2142. else
  2143. {
  2144. return false;
  2145. }
  2146. #endif
  2147. }
  2148. public static bool OpenCameraDevice(CameraDevice cameraDevice)
  2149. {
  2150. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2151. return false;
  2152. #else
  2153. if (version >= OVRP_1_16_0.version)
  2154. {
  2155. Result result = OVRP_1_16_0.ovrp_OpenCameraDevice(cameraDevice);
  2156. if (result != Result.Success)
  2157. {
  2158. //Debug.LogWarning("ovrp_OpenCameraDevice return " + result);
  2159. }
  2160. return result == Result.Success;
  2161. }
  2162. else
  2163. {
  2164. return false;
  2165. }
  2166. #endif
  2167. }
  2168. public static bool CloseCameraDevice(CameraDevice cameraDevice)
  2169. {
  2170. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2171. return false;
  2172. #else
  2173. if (version >= OVRP_1_16_0.version)
  2174. {
  2175. Result result = OVRP_1_16_0.ovrp_CloseCameraDevice(cameraDevice);
  2176. if (result != Result.Success)
  2177. {
  2178. //Debug.LogWarning("ovrp_OpenCameraDevice return " + result);
  2179. }
  2180. return result == Result.Success;
  2181. }
  2182. else
  2183. {
  2184. return false;
  2185. }
  2186. #endif
  2187. }
  2188. public static bool HasCameraDeviceOpened(CameraDevice cameraDevice)
  2189. {
  2190. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2191. return false;
  2192. #else
  2193. if (version >= OVRP_1_16_0.version)
  2194. {
  2195. Bool result = OVRP_1_16_0.ovrp_HasCameraDeviceOpened(cameraDevice);
  2196. return result == Bool.True;
  2197. }
  2198. else
  2199. {
  2200. return false;
  2201. }
  2202. #endif
  2203. }
  2204. public static bool IsCameraDeviceColorFrameAvailable(CameraDevice cameraDevice)
  2205. {
  2206. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2207. return false;
  2208. #else
  2209. if (version >= OVRP_1_16_0.version)
  2210. {
  2211. Bool result = OVRP_1_16_0.ovrp_IsCameraDeviceColorFrameAvailable(cameraDevice);
  2212. return result == Bool.True;
  2213. }
  2214. else
  2215. {
  2216. return false;
  2217. }
  2218. #endif
  2219. }
  2220. private static Texture2D cachedCameraFrameTexture = null;
  2221. public static Texture2D GetCameraDeviceColorFrameTexture(CameraDevice cameraDevice)
  2222. {
  2223. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2224. return null;
  2225. #else
  2226. if (version >= OVRP_1_16_0.version)
  2227. {
  2228. Sizei size = new Sizei();
  2229. Result result = OVRP_1_16_0.ovrp_GetCameraDeviceColorFrameSize(cameraDevice, out size);
  2230. if (result != Result.Success)
  2231. {
  2232. //Debug.LogWarning("ovrp_GetCameraDeviceColorFrameSize return " + result);
  2233. return null;
  2234. }
  2235. IntPtr pixels;
  2236. int rowPitch;
  2237. result = OVRP_1_16_0.ovrp_GetCameraDeviceColorFrameBgraPixels(cameraDevice, out pixels, out rowPitch);
  2238. if (result != Result.Success)
  2239. {
  2240. //Debug.LogWarning("ovrp_GetCameraDeviceColorFrameBgraPixels return " + result);
  2241. return null;
  2242. }
  2243. if (rowPitch != size.w * 4)
  2244. {
  2245. //Debug.LogWarning(string.Format("RowPitch mismatch, expected {0}, get {1}", size.w * 4, rowPitch));
  2246. return null;
  2247. }
  2248. if (!cachedCameraFrameTexture || cachedCameraFrameTexture.width != size.w || cachedCameraFrameTexture.height != size.h)
  2249. {
  2250. cachedCameraFrameTexture = new Texture2D(size.w, size.h, TextureFormat.BGRA32, false);
  2251. }
  2252. cachedCameraFrameTexture.LoadRawTextureData(pixels, rowPitch * size.h);
  2253. cachedCameraFrameTexture.Apply();
  2254. return cachedCameraFrameTexture;
  2255. }
  2256. else
  2257. {
  2258. return null;
  2259. }
  2260. #endif
  2261. }
  2262. public static bool DoesCameraDeviceSupportDepth(CameraDevice cameraDevice)
  2263. {
  2264. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2265. return false;
  2266. #else
  2267. if (version >= OVRP_1_17_0.version)
  2268. {
  2269. Bool supportDepth;
  2270. Result result = OVRP_1_17_0.ovrp_DoesCameraDeviceSupportDepth(cameraDevice, out supportDepth);
  2271. return result == Result.Success && supportDepth == Bool.True;
  2272. }
  2273. else
  2274. {
  2275. return false;
  2276. }
  2277. #endif
  2278. }
  2279. public static bool SetCameraDeviceDepthSensingMode(CameraDevice camera, CameraDeviceDepthSensingMode depthSensoringMode)
  2280. {
  2281. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2282. return false;
  2283. #else
  2284. if (version >= OVRP_1_17_0.version)
  2285. {
  2286. Result result = OVRP_1_17_0.ovrp_SetCameraDeviceDepthSensingMode(camera, depthSensoringMode);
  2287. return result == Result.Success;
  2288. }
  2289. else
  2290. {
  2291. return false;
  2292. }
  2293. #endif
  2294. }
  2295. public static bool SetCameraDevicePreferredDepthQuality(CameraDevice camera, CameraDeviceDepthQuality depthQuality)
  2296. {
  2297. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2298. return false;
  2299. #else
  2300. if (version >= OVRP_1_17_0.version)
  2301. {
  2302. Result result = OVRP_1_17_0.ovrp_SetCameraDevicePreferredDepthQuality(camera, depthQuality);
  2303. return result == Result.Success;
  2304. }
  2305. else
  2306. {
  2307. return false;
  2308. }
  2309. #endif
  2310. }
  2311. public static bool IsCameraDeviceDepthFrameAvailable(CameraDevice cameraDevice)
  2312. {
  2313. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2314. return false;
  2315. #else
  2316. if (version >= OVRP_1_17_0.version)
  2317. {
  2318. Bool available;
  2319. Result result = OVRP_1_17_0.ovrp_IsCameraDeviceDepthFrameAvailable(cameraDevice, out available);
  2320. return result == Result.Success && available == Bool.True;
  2321. }
  2322. else
  2323. {
  2324. return false;
  2325. }
  2326. #endif
  2327. }
  2328. private static Texture2D cachedCameraDepthTexture = null;
  2329. public static Texture2D GetCameraDeviceDepthFrameTexture(CameraDevice cameraDevice)
  2330. {
  2331. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2332. return null;
  2333. #else
  2334. if (version >= OVRP_1_17_0.version)
  2335. {
  2336. Sizei size = new Sizei();
  2337. Result result = OVRP_1_17_0.ovrp_GetCameraDeviceDepthFrameSize(cameraDevice, out size);
  2338. if (result != Result.Success)
  2339. {
  2340. //Debug.LogWarning("ovrp_GetCameraDeviceDepthFrameSize return " + result);
  2341. return null;
  2342. }
  2343. IntPtr depthData;
  2344. int rowPitch;
  2345. result = OVRP_1_17_0.ovrp_GetCameraDeviceDepthFramePixels(cameraDevice, out depthData, out rowPitch);
  2346. if (result != Result.Success)
  2347. {
  2348. //Debug.LogWarning("ovrp_GetCameraDeviceDepthFramePixels return " + result);
  2349. return null;
  2350. }
  2351. if (rowPitch != size.w * 4)
  2352. {
  2353. //Debug.LogWarning(string.Format("RowPitch mismatch, expected {0}, get {1}", size.w * 4, rowPitch));
  2354. return null;
  2355. }
  2356. if (!cachedCameraDepthTexture || cachedCameraDepthTexture.width != size.w || cachedCameraDepthTexture.height != size.h)
  2357. {
  2358. cachedCameraDepthTexture = new Texture2D(size.w, size.h, TextureFormat.RFloat, false);
  2359. cachedCameraDepthTexture.filterMode = FilterMode.Point;
  2360. }
  2361. cachedCameraDepthTexture.LoadRawTextureData(depthData, rowPitch * size.h);
  2362. cachedCameraDepthTexture.Apply();
  2363. return cachedCameraDepthTexture;
  2364. }
  2365. else
  2366. {
  2367. return null;
  2368. }
  2369. #endif
  2370. }
  2371. private static Texture2D cachedCameraDepthConfidenceTexture = null;
  2372. public static Texture2D GetCameraDeviceDepthConfidenceTexture(CameraDevice cameraDevice)
  2373. {
  2374. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2375. return null;
  2376. #else
  2377. if (version >= OVRP_1_17_0.version)
  2378. {
  2379. Sizei size = new Sizei();
  2380. Result result = OVRP_1_17_0.ovrp_GetCameraDeviceDepthFrameSize(cameraDevice, out size);
  2381. if (result != Result.Success)
  2382. {
  2383. //Debug.LogWarning("ovrp_GetCameraDeviceDepthFrameSize return " + result);
  2384. return null;
  2385. }
  2386. IntPtr confidenceData;
  2387. int rowPitch;
  2388. result = OVRP_1_17_0.ovrp_GetCameraDeviceDepthConfidencePixels(cameraDevice, out confidenceData, out rowPitch);
  2389. if (result != Result.Success)
  2390. {
  2391. //Debug.LogWarning("ovrp_GetCameraDeviceDepthConfidencePixels return " + result);
  2392. return null;
  2393. }
  2394. if (rowPitch != size.w * 4)
  2395. {
  2396. //Debug.LogWarning(string.Format("RowPitch mismatch, expected {0}, get {1}", size.w * 4, rowPitch));
  2397. return null;
  2398. }
  2399. if (!cachedCameraDepthConfidenceTexture || cachedCameraDepthConfidenceTexture.width != size.w || cachedCameraDepthConfidenceTexture.height != size.h)
  2400. {
  2401. cachedCameraDepthConfidenceTexture = new Texture2D(size.w, size.h, TextureFormat.RFloat, false);
  2402. }
  2403. cachedCameraDepthConfidenceTexture.LoadRawTextureData(confidenceData, rowPitch * size.h);
  2404. cachedCameraDepthConfidenceTexture.Apply();
  2405. return cachedCameraDepthConfidenceTexture;
  2406. }
  2407. else
  2408. {
  2409. return null;
  2410. }
  2411. #endif
  2412. }
  2413. #endif
  2414. public static bool tiledMultiResSupported
  2415. {
  2416. get
  2417. {
  2418. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2419. return false;
  2420. #else
  2421. if (version >= OVRP_1_21_0.version)
  2422. {
  2423. Bool supported;
  2424. Result result = OVRP_1_21_0.ovrp_GetTiledMultiResSupported(out supported);
  2425. if (result == Result.Success)
  2426. {
  2427. return supported == Bool.True;
  2428. }
  2429. else
  2430. {
  2431. //Debug.LogWarning("ovrp_GetTiledMultiResSupported return " + result);
  2432. return false;
  2433. }
  2434. }
  2435. else
  2436. {
  2437. return false;
  2438. }
  2439. #endif
  2440. }
  2441. }
  2442. public static TiledMultiResLevel tiledMultiResLevel
  2443. {
  2444. get
  2445. {
  2446. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2447. return TiledMultiResLevel.Off;
  2448. #else
  2449. if (version >= OVRP_1_21_0.version && tiledMultiResSupported)
  2450. {
  2451. TiledMultiResLevel level;
  2452. Result result = OVRP_1_21_0.ovrp_GetTiledMultiResLevel(out level);
  2453. if (result != Result.Success)
  2454. {
  2455. //Debug.LogWarning("ovrp_GetTiledMultiResLevel return " + result);
  2456. }
  2457. return level;
  2458. }
  2459. else
  2460. {
  2461. return TiledMultiResLevel.Off;
  2462. }
  2463. #endif
  2464. }
  2465. set
  2466. {
  2467. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2468. return;
  2469. #else
  2470. if (version >= OVRP_1_21_0.version && tiledMultiResSupported)
  2471. {
  2472. Result result = OVRP_1_21_0.ovrp_SetTiledMultiResLevel(value);
  2473. if (result != Result.Success)
  2474. {
  2475. //Debug.LogWarning("ovrp_SetTiledMultiResLevel return " + result);
  2476. }
  2477. }
  2478. #endif
  2479. }
  2480. }
  2481. public static bool gpuUtilSupported
  2482. {
  2483. get
  2484. {
  2485. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2486. return false;
  2487. #else
  2488. if (version >= OVRP_1_21_0.version)
  2489. {
  2490. Bool supported;
  2491. Result result = OVRP_1_21_0.ovrp_GetGPUUtilSupported(out supported);
  2492. if (result == Result.Success)
  2493. {
  2494. return supported == Bool.True;
  2495. }
  2496. else
  2497. {
  2498. //Debug.LogWarning("ovrp_GetGPUUtilSupported return " + result);
  2499. return false;
  2500. }
  2501. }
  2502. else
  2503. {
  2504. return false;
  2505. }
  2506. #endif
  2507. }
  2508. }
  2509. public static float gpuUtilLevel
  2510. {
  2511. get
  2512. {
  2513. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2514. return 0.0f;
  2515. #else
  2516. if (version >= OVRP_1_21_0.version && gpuUtilSupported)
  2517. {
  2518. float level;
  2519. Result result = OVRP_1_21_0.ovrp_GetGPUUtilLevel(out level);
  2520. if (result == Result.Success)
  2521. {
  2522. return level;
  2523. }
  2524. else
  2525. {
  2526. //Debug.LogWarning("ovrp_GetGPUUtilLevel return " + result);
  2527. return 0.0f;
  2528. }
  2529. }
  2530. else
  2531. {
  2532. return 0.0f;
  2533. }
  2534. #endif
  2535. }
  2536. }
  2537. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  2538. private static OVRNativeBuffer _nativeSystemDisplayFrequenciesAvailable = null;
  2539. private static float[] _cachedSystemDisplayFrequenciesAvailable = null;
  2540. #endif
  2541. public static float[] systemDisplayFrequenciesAvailable
  2542. {
  2543. get
  2544. {
  2545. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2546. return new float[0];
  2547. #else
  2548. if (_cachedSystemDisplayFrequenciesAvailable == null)
  2549. {
  2550. _cachedSystemDisplayFrequenciesAvailable = new float[0];
  2551. if (version >= OVRP_1_21_0.version)
  2552. {
  2553. int numFrequencies = 0;
  2554. Result result = OVRP_1_21_0.ovrp_GetSystemDisplayAvailableFrequencies(IntPtr.Zero, out numFrequencies);
  2555. if (result == Result.Success)
  2556. {
  2557. if (numFrequencies > 0)
  2558. {
  2559. int maxNumElements = numFrequencies;
  2560. _nativeSystemDisplayFrequenciesAvailable = new OVRNativeBuffer(sizeof(float) * maxNumElements);
  2561. result = OVRP_1_21_0.ovrp_GetSystemDisplayAvailableFrequencies(_nativeSystemDisplayFrequenciesAvailable.GetPointer(), out numFrequencies);
  2562. if (result == Result.Success)
  2563. {
  2564. int numElementsToCopy = (numFrequencies <= maxNumElements) ? numFrequencies : maxNumElements;
  2565. if (numElementsToCopy > 0)
  2566. {
  2567. _cachedSystemDisplayFrequenciesAvailable = new float[numElementsToCopy];
  2568. Marshal.Copy(_nativeSystemDisplayFrequenciesAvailable.GetPointer(), _cachedSystemDisplayFrequenciesAvailable, 0, numElementsToCopy);
  2569. }
  2570. }
  2571. }
  2572. }
  2573. }
  2574. }
  2575. return _cachedSystemDisplayFrequenciesAvailable;
  2576. #endif
  2577. }
  2578. }
  2579. public static float systemDisplayFrequency
  2580. {
  2581. get
  2582. {
  2583. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2584. return 0.0f;
  2585. #else
  2586. if (version >= OVRP_1_21_0.version)
  2587. {
  2588. float displayFrequency;
  2589. Result result = OVRP_1_21_0.ovrp_GetSystemDisplayFrequency2(out displayFrequency);
  2590. if (result == Result.Success)
  2591. {
  2592. return displayFrequency;
  2593. }
  2594. return 0.0f;
  2595. }
  2596. else if (version >= OVRP_1_1_0.version)
  2597. {
  2598. return OVRP_1_1_0.ovrp_GetSystemDisplayFrequency();
  2599. }
  2600. else
  2601. {
  2602. return 0.0f;
  2603. }
  2604. #endif
  2605. }
  2606. set
  2607. {
  2608. #if OVRPLUGIN_UNSUPPORTED_PLATFORM
  2609. return;
  2610. #else
  2611. if (version >= OVRP_1_21_0.version)
  2612. {
  2613. OVRP_1_21_0.ovrp_SetSystemDisplayFrequency(value);
  2614. }
  2615. #endif
  2616. }
  2617. }
  2618. public static bool GetNodeFrustum2(Node nodeId, out Frustumf2 frustum)
  2619. {
  2620. frustum = default(Frustumf2);
  2621. if (version >= OVRP_1_15_0.version)
  2622. {
  2623. Result result = OVRP_1_15_0.ovrp_GetNodeFrustum2(nodeId, out frustum);
  2624. if (result != Result.Success)
  2625. {
  2626. return false;
  2627. }
  2628. else
  2629. {
  2630. return true;
  2631. }
  2632. }
  2633. else
  2634. {
  2635. return false;
  2636. }
  2637. }
  2638. public static bool AsymmetricFovEnabled
  2639. {
  2640. get
  2641. {
  2642. if (version >= OVRP_1_21_0.version)
  2643. {
  2644. Bool asymmetricFovEnabled = Bool.False;
  2645. Result result = OVRP_1_21_0.ovrp_GetAppAsymmetricFov(out asymmetricFovEnabled);
  2646. if (result != Result.Success)
  2647. {
  2648. return false;
  2649. }
  2650. else
  2651. {
  2652. return asymmetricFovEnabled == Bool.True;
  2653. }
  2654. }
  2655. else
  2656. {
  2657. return false;
  2658. }
  2659. }
  2660. }
  2661. public static bool EyeTextureArrayEnabled
  2662. {
  2663. get
  2664. {
  2665. if (version >= OVRP_1_15_0.version)
  2666. {
  2667. Bool enabled = Bool.False;
  2668. enabled = OVRP_1_15_0.ovrp_GetEyeTextureArrayEnabled();
  2669. return enabled == Bool.True;
  2670. }
  2671. else
  2672. {
  2673. return false;
  2674. }
  2675. }
  2676. }
  2677. private const string pluginName = "OVRPlugin";
  2678. private static System.Version _versionZero = new System.Version(0, 0, 0);
  2679. // Disable all the DllImports when the platform is not supported
  2680. #if !OVRPLUGIN_UNSUPPORTED_PLATFORM
  2681. private static class OVRP_0_1_0
  2682. {
  2683. public static readonly System.Version version = new System.Version(0, 1, 0);
  2684. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2685. public static extern Sizei ovrp_GetEyeTextureSize(Eye eyeId);
  2686. }
  2687. private static class OVRP_0_1_1
  2688. {
  2689. public static readonly System.Version version = new System.Version(0, 1, 1);
  2690. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2691. public static extern Bool ovrp_SetOverlayQuad2(Bool onTop, Bool headLocked, IntPtr texture, IntPtr device, Posef pose, Vector3f scale);
  2692. }
  2693. private static class OVRP_0_1_2
  2694. {
  2695. public static readonly System.Version version = new System.Version(0, 1, 2);
  2696. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2697. public static extern Posef ovrp_GetNodePose(Node nodeId);
  2698. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2699. public static extern Bool ovrp_SetControllerVibration(uint controllerMask, float frequency, float amplitude);
  2700. }
  2701. private static class OVRP_0_1_3
  2702. {
  2703. public static readonly System.Version version = new System.Version(0, 1, 3);
  2704. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2705. public static extern Posef ovrp_GetNodeVelocity(Node nodeId);
  2706. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2707. public static extern Posef ovrp_GetNodeAcceleration(Node nodeId);
  2708. }
  2709. private static class OVRP_0_5_0
  2710. {
  2711. public static readonly System.Version version = new System.Version(0, 5, 0);
  2712. }
  2713. private static class OVRP_1_0_0
  2714. {
  2715. public static readonly System.Version version = new System.Version(1, 0, 0);
  2716. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2717. public static extern TrackingOrigin ovrp_GetTrackingOriginType();
  2718. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2719. public static extern Bool ovrp_SetTrackingOriginType(TrackingOrigin originType);
  2720. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2721. public static extern Posef ovrp_GetTrackingCalibratedOrigin();
  2722. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2723. public static extern Bool ovrp_RecenterTrackingOrigin(uint flags);
  2724. }
  2725. private static class OVRP_1_1_0
  2726. {
  2727. public static readonly System.Version version = new System.Version(1, 1, 0);
  2728. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2729. public static extern Bool ovrp_GetInitialized();
  2730. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrp_GetVersion")]
  2731. private static extern IntPtr _ovrp_GetVersion();
  2732. public static string ovrp_GetVersion() { return Marshal.PtrToStringAnsi(_ovrp_GetVersion()); }
  2733. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrp_GetNativeSDKVersion")]
  2734. private static extern IntPtr _ovrp_GetNativeSDKVersion();
  2735. public static string ovrp_GetNativeSDKVersion() { return Marshal.PtrToStringAnsi(_ovrp_GetNativeSDKVersion()); }
  2736. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2737. public static extern IntPtr ovrp_GetAudioOutId();
  2738. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2739. public static extern IntPtr ovrp_GetAudioInId();
  2740. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2741. public static extern float ovrp_GetEyeTextureScale();
  2742. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2743. public static extern Bool ovrp_SetEyeTextureScale(float value);
  2744. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2745. public static extern Bool ovrp_GetTrackingOrientationSupported();
  2746. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2747. public static extern Bool ovrp_GetTrackingOrientationEnabled();
  2748. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2749. public static extern Bool ovrp_SetTrackingOrientationEnabled(Bool value);
  2750. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2751. public static extern Bool ovrp_GetTrackingPositionSupported();
  2752. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2753. public static extern Bool ovrp_GetTrackingPositionEnabled();
  2754. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2755. public static extern Bool ovrp_SetTrackingPositionEnabled(Bool value);
  2756. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2757. public static extern Bool ovrp_GetNodePresent(Node nodeId);
  2758. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2759. public static extern Bool ovrp_GetNodeOrientationTracked(Node nodeId);
  2760. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2761. public static extern Bool ovrp_GetNodePositionTracked(Node nodeId);
  2762. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2763. public static extern Frustumf ovrp_GetNodeFrustum(Node nodeId);
  2764. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2765. public static extern ControllerState ovrp_GetControllerState(uint controllerMask);
  2766. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2767. public static extern int ovrp_GetSystemCpuLevel();
  2768. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2769. public static extern Bool ovrp_SetSystemCpuLevel(int value);
  2770. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2771. public static extern int ovrp_GetSystemGpuLevel();
  2772. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2773. public static extern Bool ovrp_SetSystemGpuLevel(int value);
  2774. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2775. public static extern Bool ovrp_GetSystemPowerSavingMode();
  2776. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2777. public static extern float ovrp_GetSystemDisplayFrequency();
  2778. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2779. public static extern int ovrp_GetSystemVSyncCount();
  2780. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2781. public static extern float ovrp_GetSystemVolume();
  2782. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2783. public static extern BatteryStatus ovrp_GetSystemBatteryStatus();
  2784. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2785. public static extern float ovrp_GetSystemBatteryLevel();
  2786. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2787. public static extern float ovrp_GetSystemBatteryTemperature();
  2788. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrp_GetSystemProductName")]
  2789. private static extern IntPtr _ovrp_GetSystemProductName();
  2790. public static string ovrp_GetSystemProductName() { return Marshal.PtrToStringAnsi(_ovrp_GetSystemProductName()); }
  2791. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2792. public static extern Bool ovrp_ShowSystemUI(PlatformUI ui);
  2793. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2794. public static extern Bool ovrp_GetAppMonoscopic();
  2795. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2796. public static extern Bool ovrp_SetAppMonoscopic(Bool value);
  2797. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2798. public static extern Bool ovrp_GetAppHasVrFocus();
  2799. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2800. public static extern Bool ovrp_GetAppShouldQuit();
  2801. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2802. public static extern Bool ovrp_GetAppShouldRecenter();
  2803. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "ovrp_GetAppLatencyTimings")]
  2804. private static extern IntPtr _ovrp_GetAppLatencyTimings();
  2805. public static string ovrp_GetAppLatencyTimings() { return Marshal.PtrToStringAnsi(_ovrp_GetAppLatencyTimings()); }
  2806. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2807. public static extern Bool ovrp_GetUserPresent();
  2808. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2809. public static extern float ovrp_GetUserIPD();
  2810. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2811. public static extern Bool ovrp_SetUserIPD(float value);
  2812. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2813. public static extern float ovrp_GetUserEyeDepth();
  2814. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2815. public static extern Bool ovrp_SetUserEyeDepth(float value);
  2816. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2817. public static extern float ovrp_GetUserEyeHeight();
  2818. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2819. public static extern Bool ovrp_SetUserEyeHeight(float value);
  2820. }
  2821. private static class OVRP_1_2_0
  2822. {
  2823. public static readonly System.Version version = new System.Version(1, 2, 0);
  2824. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2825. public static extern Bool ovrp_SetSystemVSyncCount(int vsyncCount);
  2826. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2827. public static extern Bool ovrpi_SetTrackingCalibratedOrigin();
  2828. }
  2829. private static class OVRP_1_3_0
  2830. {
  2831. public static readonly System.Version version = new System.Version(1, 3, 0);
  2832. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2833. public static extern Bool ovrp_GetEyeOcclusionMeshEnabled();
  2834. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2835. public static extern Bool ovrp_SetEyeOcclusionMeshEnabled(Bool value);
  2836. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2837. public static extern Bool ovrp_GetSystemHeadphonesPresent();
  2838. }
  2839. private static class OVRP_1_5_0
  2840. {
  2841. public static readonly System.Version version = new System.Version(1, 5, 0);
  2842. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2843. public static extern SystemRegion ovrp_GetSystemRegion();
  2844. }
  2845. private static class OVRP_1_6_0
  2846. {
  2847. public static readonly System.Version version = new System.Version(1, 6, 0);
  2848. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2849. public static extern Bool ovrp_GetTrackingIPDEnabled();
  2850. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2851. public static extern Bool ovrp_SetTrackingIPDEnabled(Bool value);
  2852. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2853. public static extern HapticsDesc ovrp_GetControllerHapticsDesc(uint controllerMask);
  2854. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2855. public static extern HapticsState ovrp_GetControllerHapticsState(uint controllerMask);
  2856. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2857. public static extern Bool ovrp_SetControllerHaptics(uint controllerMask, HapticsBuffer hapticsBuffer);
  2858. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2859. public static extern Bool ovrp_SetOverlayQuad3(uint flags, IntPtr textureLeft, IntPtr textureRight, IntPtr device, Posef pose, Vector3f scale, int layerIndex);
  2860. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2861. public static extern float ovrp_GetEyeRecommendedResolutionScale();
  2862. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2863. public static extern float ovrp_GetAppCpuStartToGpuEndTime();
  2864. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2865. public static extern int ovrp_GetSystemRecommendedMSAALevel();
  2866. }
  2867. private static class OVRP_1_7_0
  2868. {
  2869. public static readonly System.Version version = new System.Version(1, 7, 0);
  2870. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2871. public static extern Bool ovrp_GetAppChromaticCorrection();
  2872. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2873. public static extern Bool ovrp_SetAppChromaticCorrection(Bool value);
  2874. }
  2875. private static class OVRP_1_8_0
  2876. {
  2877. public static readonly System.Version version = new System.Version(1, 8, 0);
  2878. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2879. public static extern Bool ovrp_GetBoundaryConfigured();
  2880. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2881. public static extern BoundaryTestResult ovrp_TestBoundaryNode(Node nodeId, BoundaryType boundaryType);
  2882. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2883. public static extern BoundaryTestResult ovrp_TestBoundaryPoint(Vector3f point, BoundaryType boundaryType);
  2884. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2885. public static extern Bool ovrp_SetBoundaryLookAndFeel(BoundaryLookAndFeel lookAndFeel);
  2886. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2887. public static extern Bool ovrp_ResetBoundaryLookAndFeel();
  2888. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2889. public static extern BoundaryGeometry ovrp_GetBoundaryGeometry(BoundaryType boundaryType);
  2890. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2891. public static extern Vector3f ovrp_GetBoundaryDimensions(BoundaryType boundaryType);
  2892. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2893. public static extern Bool ovrp_GetBoundaryVisible();
  2894. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2895. public static extern Bool ovrp_SetBoundaryVisible(Bool value);
  2896. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2897. public static extern Bool ovrp_Update2(int stateId, int frameIndex, double predictionSeconds);
  2898. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2899. public static extern Posef ovrp_GetNodePose2(int stateId, Node nodeId);
  2900. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2901. public static extern Posef ovrp_GetNodeVelocity2(int stateId, Node nodeId);
  2902. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2903. public static extern Posef ovrp_GetNodeAcceleration2(int stateId, Node nodeId);
  2904. }
  2905. private static class OVRP_1_9_0
  2906. {
  2907. public static readonly System.Version version = new System.Version(1, 9, 0);
  2908. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2909. public static extern SystemHeadset ovrp_GetSystemHeadsetType();
  2910. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2911. public static extern Controller ovrp_GetActiveController();
  2912. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2913. public static extern Controller ovrp_GetConnectedControllers();
  2914. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2915. public static extern Bool ovrp_GetBoundaryGeometry2(BoundaryType boundaryType, IntPtr points, ref int pointsCount);
  2916. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2917. public static extern AppPerfStats ovrp_GetAppPerfStats();
  2918. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2919. public static extern Bool ovrp_ResetAppPerfStats();
  2920. }
  2921. private static class OVRP_1_10_0
  2922. {
  2923. public static readonly System.Version version = new System.Version(1, 10, 0);
  2924. }
  2925. private static class OVRP_1_11_0
  2926. {
  2927. public static readonly System.Version version = new System.Version(1, 11, 0);
  2928. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2929. public static extern Bool ovrp_SetDesiredEyeTextureFormat(EyeTextureFormat value);
  2930. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2931. public static extern EyeTextureFormat ovrp_GetDesiredEyeTextureFormat();
  2932. }
  2933. private static class OVRP_1_12_0
  2934. {
  2935. public static readonly System.Version version = new System.Version(1, 12, 0);
  2936. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2937. public static extern float ovrp_GetAppFramerate();
  2938. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2939. public static extern PoseStatef ovrp_GetNodePoseState(Step stepId, Node nodeId);
  2940. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2941. public static extern ControllerState2 ovrp_GetControllerState2(uint controllerMask);
  2942. }
  2943. private static class OVRP_1_15_0
  2944. {
  2945. public const int OVRP_EXTERNAL_CAMERA_NAME_SIZE = 32;
  2946. public static readonly System.Version version = new System.Version(1, 15, 0);
  2947. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2948. public static extern Result ovrp_InitializeMixedReality();
  2949. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2950. public static extern Result ovrp_ShutdownMixedReality();
  2951. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2952. public static extern Bool ovrp_GetMixedRealityInitialized();
  2953. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2954. public static extern Result ovrp_UpdateExternalCamera();
  2955. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2956. public static extern Result ovrp_GetExternalCameraCount(out int cameraCount);
  2957. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2958. public static extern Result ovrp_GetExternalCameraName(int cameraId, [MarshalAs(UnmanagedType.LPArray, SizeConst = OVRP_EXTERNAL_CAMERA_NAME_SIZE)] char[] cameraName);
  2959. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2960. public static extern Result ovrp_GetExternalCameraIntrinsics(int cameraId, out CameraIntrinsics cameraIntrinsics);
  2961. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2962. public static extern Result ovrp_GetExternalCameraExtrinsics(int cameraId, out CameraExtrinsics cameraExtrinsics);
  2963. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2964. public static extern Result ovrp_CalculateLayerDesc(OverlayShape shape, LayerLayout layout, ref Sizei textureSize,
  2965. int mipLevels, int sampleCount, EyeTextureFormat format, int layerFlags, ref LayerDesc layerDesc);
  2966. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2967. public static extern Result ovrp_EnqueueSetupLayer(ref LayerDesc desc, IntPtr layerId);
  2968. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2969. public static extern Result ovrp_EnqueueDestroyLayer(IntPtr layerId);
  2970. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2971. public static extern Result ovrp_GetLayerTextureStageCount(int layerId, ref int layerTextureStageCount);
  2972. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2973. public static extern Result ovrp_GetLayerTexturePtr(int layerId, int stage, Eye eyeId, ref IntPtr textureHandle);
  2974. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2975. public static extern Result ovrp_EnqueueSubmitLayer(uint flags, IntPtr textureLeft, IntPtr textureRight, int layerId, int frameIndex, ref Posef pose, ref Vector3f scale, int layerIndex);
  2976. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2977. public static extern Result ovrp_GetNodeFrustum2(Node nodeId, out Frustumf2 nodeFrustum);
  2978. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2979. public static extern Bool ovrp_GetEyeTextureArrayEnabled();
  2980. }
  2981. private static class OVRP_1_16_0
  2982. {
  2983. public static readonly System.Version version = new System.Version(1, 16, 0);
  2984. #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
  2985. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2986. public static extern Result ovrp_UpdateCameraDevices();
  2987. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2988. public static extern Bool ovrp_IsCameraDeviceAvailable(CameraDevice cameraDevice);
  2989. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2990. public static extern Result ovrp_SetCameraDevicePreferredColorFrameSize(CameraDevice cameraDevice, Sizei preferredColorFrameSize);
  2991. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2992. public static extern Result ovrp_OpenCameraDevice(CameraDevice cameraDevice);
  2993. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2994. public static extern Result ovrp_CloseCameraDevice(CameraDevice cameraDevice);
  2995. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2996. public static extern Bool ovrp_HasCameraDeviceOpened(CameraDevice cameraDevice);
  2997. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  2998. public static extern Bool ovrp_IsCameraDeviceColorFrameAvailable(CameraDevice cameraDevice);
  2999. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3000. public static extern Result ovrp_GetCameraDeviceColorFrameSize(CameraDevice cameraDevice, out Sizei colorFrameSize);
  3001. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3002. public static extern Result ovrp_GetCameraDeviceColorFrameBgraPixels(CameraDevice cameraDevice, out IntPtr colorFrameBgraPixels, out int colorFrameRowPitch);
  3003. #endif
  3004. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3005. public static extern Result ovrp_GetControllerState4(uint controllerMask, ref ControllerState4 controllerState);
  3006. }
  3007. private static class OVRP_1_17_0
  3008. {
  3009. public static readonly System.Version version = new System.Version(1, 17, 0);
  3010. #if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
  3011. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3012. public static extern Result ovrp_GetExternalCameraPose(CameraDevice camera, out Posef cameraPose);
  3013. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3014. public static extern Result ovrp_ConvertPoseToCameraSpace(CameraDevice camera, ref Posef trackingSpacePose, out Posef cameraSpacePose);
  3015. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3016. public static extern Result ovrp_GetCameraDeviceIntrinsicsParameters(CameraDevice camera, out Bool supportIntrinsics, out CameraDeviceIntrinsicsParameters intrinsicsParameters);
  3017. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3018. public static extern Result ovrp_DoesCameraDeviceSupportDepth(CameraDevice camera, out Bool supportDepth);
  3019. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3020. public static extern Result ovrp_GetCameraDeviceDepthSensingMode(CameraDevice camera, out CameraDeviceDepthSensingMode depthSensoringMode);
  3021. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3022. public static extern Result ovrp_SetCameraDeviceDepthSensingMode(CameraDevice camera, CameraDeviceDepthSensingMode depthSensoringMode);
  3023. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3024. public static extern Result ovrp_GetCameraDevicePreferredDepthQuality(CameraDevice camera, out CameraDeviceDepthQuality depthQuality);
  3025. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3026. public static extern Result ovrp_SetCameraDevicePreferredDepthQuality(CameraDevice camera, CameraDeviceDepthQuality depthQuality);
  3027. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3028. public static extern Result ovrp_IsCameraDeviceDepthFrameAvailable(CameraDevice camera, out Bool available);
  3029. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3030. public static extern Result ovrp_GetCameraDeviceDepthFrameSize(CameraDevice camera, out Sizei depthFrameSize);
  3031. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3032. public static extern Result ovrp_GetCameraDeviceDepthFramePixels(CameraDevice cameraDevice, out IntPtr depthFramePixels, out int depthFrameRowPitch);
  3033. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3034. public static extern Result ovrp_GetCameraDeviceDepthConfidencePixels(CameraDevice cameraDevice, out IntPtr depthConfidencePixels, out int depthConfidenceRowPitch);
  3035. #endif
  3036. }
  3037. private static class OVRP_1_18_0
  3038. {
  3039. public static readonly System.Version version = new System.Version(1, 18, 0);
  3040. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3041. public static extern Result ovrp_SetHandNodePoseStateLatency(double latencyInSeconds);
  3042. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3043. public static extern Result ovrp_GetHandNodePoseStateLatency(out double latencyInSeconds);
  3044. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3045. public static extern Result ovrp_GetAppHasInputFocus(out Bool appHasInputFocus);
  3046. }
  3047. private static class OVRP_1_19_0
  3048. {
  3049. public static readonly System.Version version = new System.Version(1, 19, 0);
  3050. }
  3051. private static class OVRP_1_21_0
  3052. {
  3053. public static readonly System.Version version = new System.Version(1, 21, 0);
  3054. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3055. public static extern Result ovrp_GetTiledMultiResSupported(out Bool foveationSupported);
  3056. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3057. public static extern Result ovrp_GetTiledMultiResLevel(out TiledMultiResLevel level);
  3058. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3059. public static extern Result ovrp_SetTiledMultiResLevel(TiledMultiResLevel level);
  3060. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3061. public static extern Result ovrp_GetGPUUtilSupported(out Bool gpuUtilSupported);
  3062. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3063. public static extern Result ovrp_GetGPUUtilLevel(out float gpuUtil);
  3064. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3065. public static extern Result ovrp_GetSystemDisplayFrequency2(out float systemDisplayFrequency);
  3066. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3067. public static extern Result ovrp_GetSystemDisplayAvailableFrequencies(IntPtr systemDisplayAvailableFrequencies, out int numFrequencies);
  3068. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3069. public static extern Result ovrp_SetSystemDisplayFrequency(float requestedFrequency);
  3070. [DllImport(pluginName, CallingConvention = CallingConvention.Cdecl)]
  3071. public static extern Result ovrp_GetAppAsymmetricFov(out Bool useAsymmetricFov);
  3072. }
  3073. private static class OVRP_1_27_0
  3074. {
  3075. public static readonly System.Version version = new System.Version(1, 27, 0);
  3076. }
  3077. #endif // !OVRPLUGIN_UNSUPPORTED_PLATFORM
  3078. }