OVRInput.cs 84 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Runtime.InteropServices;
  4. using UnityEngine;
  5. public static class OVRInput
  6. {
  7. static OVRInput()
  8. {
  9. OVRInput.controllers = new List<OVRInput.OVRControllerBase>
  10. {
  11. new OVRInput.OVRControllerGamepadPC(),
  12. new OVRInput.OVRControllerTouch(),
  13. new OVRInput.OVRControllerLTouch(),
  14. new OVRInput.OVRControllerRTouch(),
  15. new OVRInput.OVRControllerRemote()
  16. };
  17. }
  18. private static bool pluginSupportsActiveController
  19. {
  20. get
  21. {
  22. if (!OVRInput._pluginSupportsActiveControllerCached)
  23. {
  24. bool flag = true;
  25. OVRInput._pluginSupportsActiveController = (flag && OVRPlugin.version >= OVRInput._pluginSupportsActiveControllerMinVersion);
  26. OVRInput._pluginSupportsActiveControllerCached = true;
  27. }
  28. return OVRInput._pluginSupportsActiveController;
  29. }
  30. }
  31. public static void Update()
  32. {
  33. OVRInput.connectedControllerTypes = OVRInput.Controller.None;
  34. OVRInput.useFixedPoses = false;
  35. OVRInput.fixedUpdateCount = 0;
  36. for (int i = 0; i < OVRInput.controllers.Count; i++)
  37. {
  38. OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
  39. OVRInput.connectedControllerTypes |= ovrcontrollerBase.Update();
  40. if ((OVRInput.connectedControllerTypes & ovrcontrollerBase.controllerType) != OVRInput.Controller.None && (OVRInput.Get(OVRInput.RawButton.Any, ovrcontrollerBase.controllerType) || OVRInput.Get(OVRInput.RawTouch.Any, ovrcontrollerBase.controllerType)))
  41. {
  42. OVRInput.activeControllerType = ovrcontrollerBase.controllerType;
  43. }
  44. }
  45. if (OVRInput.activeControllerType == OVRInput.Controller.LTouch || OVRInput.activeControllerType == OVRInput.Controller.RTouch)
  46. {
  47. OVRInput.activeControllerType = OVRInput.Controller.Touch;
  48. }
  49. if ((OVRInput.connectedControllerTypes & OVRInput.activeControllerType) == OVRInput.Controller.None)
  50. {
  51. OVRInput.activeControllerType = OVRInput.Controller.None;
  52. }
  53. if (OVRInput.pluginSupportsActiveController)
  54. {
  55. OVRInput.connectedControllerTypes = (OVRInput.Controller)OVRPlugin.GetConnectedControllers();
  56. OVRInput.activeControllerType = (OVRInput.Controller)OVRPlugin.GetActiveController();
  57. }
  58. }
  59. public static void FixedUpdate()
  60. {
  61. OVRInput.useFixedPoses = true;
  62. double predictionSeconds = (double)OVRInput.fixedUpdateCount * (double)Time.fixedDeltaTime / (double)Mathf.Max(Time.timeScale, 1E-06f);
  63. OVRInput.fixedUpdateCount++;
  64. OVRPlugin.UpdateNodePhysicsPoses(0, predictionSeconds);
  65. }
  66. public static bool GetControllerOrientationTracked(OVRInput.Controller controllerType)
  67. {
  68. if (controllerType != OVRInput.Controller.LTouch)
  69. {
  70. return controllerType == OVRInput.Controller.RTouch && OVRPlugin.GetNodeOrientationTracked(OVRPlugin.Node.HandRight);
  71. }
  72. return OVRPlugin.GetNodeOrientationTracked(OVRPlugin.Node.HandLeft);
  73. }
  74. public static bool GetControllerPositionTracked(OVRInput.Controller controllerType)
  75. {
  76. if (controllerType != OVRInput.Controller.LTouch)
  77. {
  78. return controllerType == OVRInput.Controller.RTouch && OVRPlugin.GetNodePositionTracked(OVRPlugin.Node.HandRight);
  79. }
  80. return OVRPlugin.GetNodePositionTracked(OVRPlugin.Node.HandLeft);
  81. }
  82. public static Vector3 GetLocalControllerPosition(OVRInput.Controller controllerType)
  83. {
  84. if (controllerType == OVRInput.Controller.LTouch)
  85. {
  86. return OVRPlugin.GetNodePose(OVRPlugin.Node.HandLeft, OVRInput.useFixedPoses).ToOVRPose().position;
  87. }
  88. if (controllerType != OVRInput.Controller.RTouch)
  89. {
  90. return Vector3.zero;
  91. }
  92. return OVRPlugin.GetNodePose(OVRPlugin.Node.HandRight, OVRInput.useFixedPoses).ToOVRPose().position;
  93. }
  94. public static Vector3 GetLocalControllerVelocity(OVRInput.Controller controllerType)
  95. {
  96. if (controllerType == OVRInput.Controller.LTouch)
  97. {
  98. return OVRPlugin.GetNodeVelocity(OVRPlugin.Node.HandLeft, OVRInput.useFixedPoses).ToOVRPose().position;
  99. }
  100. if (controllerType != OVRInput.Controller.RTouch)
  101. {
  102. return Vector3.zero;
  103. }
  104. return OVRPlugin.GetNodeVelocity(OVRPlugin.Node.HandRight, OVRInput.useFixedPoses).ToOVRPose().position;
  105. }
  106. public static Vector3 GetLocalControllerAcceleration(OVRInput.Controller controllerType)
  107. {
  108. if (controllerType == OVRInput.Controller.LTouch)
  109. {
  110. return OVRPlugin.GetNodeAcceleration(OVRPlugin.Node.HandLeft, OVRInput.useFixedPoses).ToOVRPose().position;
  111. }
  112. if (controllerType != OVRInput.Controller.RTouch)
  113. {
  114. return Vector3.zero;
  115. }
  116. return OVRPlugin.GetNodeAcceleration(OVRPlugin.Node.HandRight, OVRInput.useFixedPoses).ToOVRPose().position;
  117. }
  118. public static Quaternion GetLocalControllerRotation(OVRInput.Controller controllerType)
  119. {
  120. if (controllerType == OVRInput.Controller.LTouch)
  121. {
  122. return OVRPlugin.GetNodePose(OVRPlugin.Node.HandLeft, OVRInput.useFixedPoses).ToOVRPose().orientation;
  123. }
  124. if (controllerType != OVRInput.Controller.RTouch)
  125. {
  126. return Quaternion.identity;
  127. }
  128. return OVRPlugin.GetNodePose(OVRPlugin.Node.HandRight, OVRInput.useFixedPoses).ToOVRPose().orientation;
  129. }
  130. public static Quaternion GetLocalControllerAngularVelocity(OVRInput.Controller controllerType)
  131. {
  132. if (controllerType == OVRInput.Controller.LTouch)
  133. {
  134. return OVRPlugin.GetNodeVelocity(OVRPlugin.Node.HandLeft, OVRInput.useFixedPoses).ToOVRPose().orientation;
  135. }
  136. if (controllerType != OVRInput.Controller.RTouch)
  137. {
  138. return Quaternion.identity;
  139. }
  140. return OVRPlugin.GetNodeVelocity(OVRPlugin.Node.HandRight, OVRInput.useFixedPoses).ToOVRPose().orientation;
  141. }
  142. public static Quaternion GetLocalControllerAngularAcceleration(OVRInput.Controller controllerType)
  143. {
  144. if (controllerType == OVRInput.Controller.LTouch)
  145. {
  146. return OVRPlugin.GetNodeAcceleration(OVRPlugin.Node.HandLeft, OVRInput.useFixedPoses).ToOVRPose().orientation;
  147. }
  148. if (controllerType != OVRInput.Controller.RTouch)
  149. {
  150. return Quaternion.identity;
  151. }
  152. return OVRPlugin.GetNodeAcceleration(OVRPlugin.Node.HandRight, OVRInput.useFixedPoses).ToOVRPose().orientation;
  153. }
  154. public static bool Get(OVRInput.Button virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  155. {
  156. return OVRInput.GetResolvedButton(virtualMask, OVRInput.RawButton.None, controllerMask);
  157. }
  158. public static bool Get(OVRInput.RawButton rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  159. {
  160. return OVRInput.GetResolvedButton(OVRInput.Button.None, rawMask, controllerMask);
  161. }
  162. private static bool GetResolvedButton(OVRInput.Button virtualMask, OVRInput.RawButton rawMask, OVRInput.Controller controllerMask)
  163. {
  164. if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
  165. {
  166. controllerMask |= OVRInput.activeControllerType;
  167. }
  168. for (int i = 0; i < OVRInput.controllers.Count; i++)
  169. {
  170. OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
  171. if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
  172. {
  173. OVRInput.RawButton rawButton = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
  174. if ((ovrcontrollerBase.currentState.Buttons & (uint)rawButton) != 0u)
  175. {
  176. return true;
  177. }
  178. }
  179. }
  180. return false;
  181. }
  182. public static bool GetDown(OVRInput.Button virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  183. {
  184. return OVRInput.GetResolvedButtonDown(virtualMask, OVRInput.RawButton.None, controllerMask);
  185. }
  186. public static bool GetDown(OVRInput.RawButton rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  187. {
  188. return OVRInput.GetResolvedButtonDown(OVRInput.Button.None, rawMask, controllerMask);
  189. }
  190. private static bool GetResolvedButtonDown(OVRInput.Button virtualMask, OVRInput.RawButton rawMask, OVRInput.Controller controllerMask)
  191. {
  192. bool result = false;
  193. if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
  194. {
  195. controllerMask |= OVRInput.activeControllerType;
  196. }
  197. for (int i = 0; i < OVRInput.controllers.Count; i++)
  198. {
  199. OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
  200. if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
  201. {
  202. OVRInput.RawButton rawButton = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
  203. if ((ovrcontrollerBase.previousState.Buttons & (uint)rawButton) != 0u)
  204. {
  205. return false;
  206. }
  207. if ((ovrcontrollerBase.currentState.Buttons & (uint)rawButton) != 0u && (ovrcontrollerBase.previousState.Buttons & (uint)rawButton) == 0u)
  208. {
  209. result = true;
  210. }
  211. }
  212. }
  213. return result;
  214. }
  215. public static bool GetUp(OVRInput.Button virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  216. {
  217. return OVRInput.GetResolvedButtonUp(virtualMask, OVRInput.RawButton.None, controllerMask);
  218. }
  219. public static bool GetUp(OVRInput.RawButton rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  220. {
  221. return OVRInput.GetResolvedButtonUp(OVRInput.Button.None, rawMask, controllerMask);
  222. }
  223. private static bool GetResolvedButtonUp(OVRInput.Button virtualMask, OVRInput.RawButton rawMask, OVRInput.Controller controllerMask)
  224. {
  225. bool result = false;
  226. if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
  227. {
  228. controllerMask |= OVRInput.activeControllerType;
  229. }
  230. for (int i = 0; i < OVRInput.controllers.Count; i++)
  231. {
  232. OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
  233. if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
  234. {
  235. OVRInput.RawButton rawButton = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
  236. if ((ovrcontrollerBase.currentState.Buttons & (uint)rawButton) != 0u)
  237. {
  238. return false;
  239. }
  240. if ((ovrcontrollerBase.currentState.Buttons & (uint)rawButton) == 0u && (ovrcontrollerBase.previousState.Buttons & (uint)rawButton) != 0u)
  241. {
  242. result = true;
  243. }
  244. }
  245. }
  246. return result;
  247. }
  248. public static bool Get(OVRInput.Touch virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  249. {
  250. return OVRInput.GetResolvedTouch(virtualMask, OVRInput.RawTouch.None, controllerMask);
  251. }
  252. public static bool Get(OVRInput.RawTouch rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  253. {
  254. return OVRInput.GetResolvedTouch(OVRInput.Touch.None, rawMask, controllerMask);
  255. }
  256. private static bool GetResolvedTouch(OVRInput.Touch virtualMask, OVRInput.RawTouch rawMask, OVRInput.Controller controllerMask)
  257. {
  258. if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
  259. {
  260. controllerMask |= OVRInput.activeControllerType;
  261. }
  262. for (int i = 0; i < OVRInput.controllers.Count; i++)
  263. {
  264. OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
  265. if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
  266. {
  267. OVRInput.RawTouch rawTouch = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
  268. if ((ovrcontrollerBase.currentState.Touches & (uint)rawTouch) != 0u)
  269. {
  270. return true;
  271. }
  272. }
  273. }
  274. return false;
  275. }
  276. public static bool GetDown(OVRInput.Touch virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  277. {
  278. return OVRInput.GetResolvedTouchDown(virtualMask, OVRInput.RawTouch.None, controllerMask);
  279. }
  280. public static bool GetDown(OVRInput.RawTouch rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  281. {
  282. return OVRInput.GetResolvedTouchDown(OVRInput.Touch.None, rawMask, controllerMask);
  283. }
  284. private static bool GetResolvedTouchDown(OVRInput.Touch virtualMask, OVRInput.RawTouch rawMask, OVRInput.Controller controllerMask)
  285. {
  286. bool result = false;
  287. if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
  288. {
  289. controllerMask |= OVRInput.activeControllerType;
  290. }
  291. for (int i = 0; i < OVRInput.controllers.Count; i++)
  292. {
  293. OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
  294. if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
  295. {
  296. OVRInput.RawTouch rawTouch = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
  297. if ((ovrcontrollerBase.previousState.Touches & (uint)rawTouch) != 0u)
  298. {
  299. return false;
  300. }
  301. if ((ovrcontrollerBase.currentState.Touches & (uint)rawTouch) != 0u && (ovrcontrollerBase.previousState.Touches & (uint)rawTouch) == 0u)
  302. {
  303. result = true;
  304. }
  305. }
  306. }
  307. return result;
  308. }
  309. public static bool GetUp(OVRInput.Touch virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  310. {
  311. return OVRInput.GetResolvedTouchUp(virtualMask, OVRInput.RawTouch.None, controllerMask);
  312. }
  313. public static bool GetUp(OVRInput.RawTouch rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  314. {
  315. return OVRInput.GetResolvedTouchUp(OVRInput.Touch.None, rawMask, controllerMask);
  316. }
  317. private static bool GetResolvedTouchUp(OVRInput.Touch virtualMask, OVRInput.RawTouch rawMask, OVRInput.Controller controllerMask)
  318. {
  319. bool result = false;
  320. if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
  321. {
  322. controllerMask |= OVRInput.activeControllerType;
  323. }
  324. for (int i = 0; i < OVRInput.controllers.Count; i++)
  325. {
  326. OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
  327. if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
  328. {
  329. OVRInput.RawTouch rawTouch = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
  330. if ((ovrcontrollerBase.currentState.Touches & (uint)rawTouch) != 0u)
  331. {
  332. return false;
  333. }
  334. if ((ovrcontrollerBase.currentState.Touches & (uint)rawTouch) == 0u && (ovrcontrollerBase.previousState.Touches & (uint)rawTouch) != 0u)
  335. {
  336. result = true;
  337. }
  338. }
  339. }
  340. return result;
  341. }
  342. public static bool Get(OVRInput.NearTouch virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  343. {
  344. return OVRInput.GetResolvedNearTouch(virtualMask, OVRInput.RawNearTouch.None, controllerMask);
  345. }
  346. public static bool Get(OVRInput.RawNearTouch rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  347. {
  348. return OVRInput.GetResolvedNearTouch(OVRInput.NearTouch.None, rawMask, controllerMask);
  349. }
  350. private static bool GetResolvedNearTouch(OVRInput.NearTouch virtualMask, OVRInput.RawNearTouch rawMask, OVRInput.Controller controllerMask)
  351. {
  352. if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
  353. {
  354. controllerMask |= OVRInput.activeControllerType;
  355. }
  356. for (int i = 0; i < OVRInput.controllers.Count; i++)
  357. {
  358. OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
  359. if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
  360. {
  361. OVRInput.RawNearTouch rawNearTouch = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
  362. if ((ovrcontrollerBase.currentState.NearTouches & (uint)rawNearTouch) != 0u)
  363. {
  364. return true;
  365. }
  366. }
  367. }
  368. return false;
  369. }
  370. public static bool GetDown(OVRInput.NearTouch virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  371. {
  372. return OVRInput.GetResolvedNearTouchDown(virtualMask, OVRInput.RawNearTouch.None, controllerMask);
  373. }
  374. public static bool GetDown(OVRInput.RawNearTouch rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  375. {
  376. return OVRInput.GetResolvedNearTouchDown(OVRInput.NearTouch.None, rawMask, controllerMask);
  377. }
  378. private static bool GetResolvedNearTouchDown(OVRInput.NearTouch virtualMask, OVRInput.RawNearTouch rawMask, OVRInput.Controller controllerMask)
  379. {
  380. bool result = false;
  381. if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
  382. {
  383. controllerMask |= OVRInput.activeControllerType;
  384. }
  385. for (int i = 0; i < OVRInput.controllers.Count; i++)
  386. {
  387. OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
  388. if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
  389. {
  390. OVRInput.RawNearTouch rawNearTouch = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
  391. if ((ovrcontrollerBase.previousState.NearTouches & (uint)rawNearTouch) != 0u)
  392. {
  393. return false;
  394. }
  395. if ((ovrcontrollerBase.currentState.NearTouches & (uint)rawNearTouch) != 0u && (ovrcontrollerBase.previousState.NearTouches & (uint)rawNearTouch) == 0u)
  396. {
  397. result = true;
  398. }
  399. }
  400. }
  401. return result;
  402. }
  403. public static bool GetUp(OVRInput.NearTouch virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  404. {
  405. return OVRInput.GetResolvedNearTouchUp(virtualMask, OVRInput.RawNearTouch.None, controllerMask);
  406. }
  407. public static bool GetUp(OVRInput.RawNearTouch rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  408. {
  409. return OVRInput.GetResolvedNearTouchUp(OVRInput.NearTouch.None, rawMask, controllerMask);
  410. }
  411. private static bool GetResolvedNearTouchUp(OVRInput.NearTouch virtualMask, OVRInput.RawNearTouch rawMask, OVRInput.Controller controllerMask)
  412. {
  413. bool result = false;
  414. if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
  415. {
  416. controllerMask |= OVRInput.activeControllerType;
  417. }
  418. for (int i = 0; i < OVRInput.controllers.Count; i++)
  419. {
  420. OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
  421. if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
  422. {
  423. OVRInput.RawNearTouch rawNearTouch = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
  424. if ((ovrcontrollerBase.currentState.NearTouches & (uint)rawNearTouch) != 0u)
  425. {
  426. return false;
  427. }
  428. if ((ovrcontrollerBase.currentState.NearTouches & (uint)rawNearTouch) == 0u && (ovrcontrollerBase.previousState.NearTouches & (uint)rawNearTouch) != 0u)
  429. {
  430. result = true;
  431. }
  432. }
  433. }
  434. return result;
  435. }
  436. public static float Get(OVRInput.Axis1D virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  437. {
  438. return OVRInput.GetResolvedAxis1D(virtualMask, OVRInput.RawAxis1D.None, controllerMask);
  439. }
  440. public static float Get(OVRInput.RawAxis1D rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  441. {
  442. return OVRInput.GetResolvedAxis1D(OVRInput.Axis1D.None, rawMask, controllerMask);
  443. }
  444. private static float GetResolvedAxis1D(OVRInput.Axis1D virtualMask, OVRInput.RawAxis1D rawMask, OVRInput.Controller controllerMask)
  445. {
  446. float a = 0f;
  447. if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
  448. {
  449. controllerMask |= OVRInput.activeControllerType;
  450. }
  451. for (int i = 0; i < OVRInput.controllers.Count; i++)
  452. {
  453. OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
  454. if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
  455. {
  456. OVRInput.RawAxis1D rawAxis1D = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
  457. if ((OVRInput.RawAxis1D.LIndexTrigger & rawAxis1D) != OVRInput.RawAxis1D.None)
  458. {
  459. a = OVRInput.CalculateAbsMax(a, ovrcontrollerBase.currentState.LIndexTrigger);
  460. }
  461. if ((OVRInput.RawAxis1D.RIndexTrigger & rawAxis1D) != OVRInput.RawAxis1D.None)
  462. {
  463. a = OVRInput.CalculateAbsMax(a, ovrcontrollerBase.currentState.RIndexTrigger);
  464. }
  465. if ((OVRInput.RawAxis1D.LHandTrigger & rawAxis1D) != OVRInput.RawAxis1D.None)
  466. {
  467. a = OVRInput.CalculateAbsMax(a, ovrcontrollerBase.currentState.LHandTrigger);
  468. }
  469. if ((OVRInput.RawAxis1D.RHandTrigger & rawAxis1D) != OVRInput.RawAxis1D.None)
  470. {
  471. a = OVRInput.CalculateAbsMax(a, ovrcontrollerBase.currentState.RHandTrigger);
  472. }
  473. }
  474. }
  475. return OVRInput.CalculateDeadzone(a, OVRInput.AXIS_DEADZONE_THRESHOLD);
  476. }
  477. public static Vector2 Get(OVRInput.Axis2D virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  478. {
  479. return OVRInput.GetResolvedAxis2D(virtualMask, OVRInput.RawAxis2D.None, controllerMask);
  480. }
  481. public static Vector2 Get(OVRInput.RawAxis2D rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  482. {
  483. return OVRInput.GetResolvedAxis2D(OVRInput.Axis2D.None, rawMask, controllerMask);
  484. }
  485. private static Vector2 GetResolvedAxis2D(OVRInput.Axis2D virtualMask, OVRInput.RawAxis2D rawMask, OVRInput.Controller controllerMask)
  486. {
  487. Vector2 a = Vector2.zero;
  488. if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
  489. {
  490. controllerMask |= OVRInput.activeControllerType;
  491. }
  492. for (int i = 0; i < OVRInput.controllers.Count; i++)
  493. {
  494. OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
  495. if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
  496. {
  497. OVRInput.RawAxis2D rawAxis2D = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
  498. if ((OVRInput.RawAxis2D.LThumbstick & rawAxis2D) != OVRInput.RawAxis2D.None)
  499. {
  500. Vector2 b = new Vector2(ovrcontrollerBase.currentState.LThumbstick.x, ovrcontrollerBase.currentState.LThumbstick.y);
  501. a = OVRInput.CalculateAbsMax(a, b);
  502. }
  503. if ((OVRInput.RawAxis2D.RThumbstick & rawAxis2D) != OVRInput.RawAxis2D.None)
  504. {
  505. Vector2 b2 = new Vector2(ovrcontrollerBase.currentState.RThumbstick.x, ovrcontrollerBase.currentState.RThumbstick.y);
  506. a = OVRInput.CalculateAbsMax(a, b2);
  507. }
  508. }
  509. }
  510. return OVRInput.CalculateDeadzone(a, OVRInput.AXIS_DEADZONE_THRESHOLD);
  511. }
  512. public static OVRInput.Controller GetConnectedControllers()
  513. {
  514. return OVRInput.connectedControllerTypes;
  515. }
  516. public static OVRInput.Controller GetActiveController()
  517. {
  518. return OVRInput.activeControllerType;
  519. }
  520. public static void SetControllerVibration(float frequency, float amplitude, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
  521. {
  522. if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
  523. {
  524. controllerMask |= OVRInput.activeControllerType;
  525. }
  526. for (int i = 0; i < OVRInput.controllers.Count; i++)
  527. {
  528. OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
  529. if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
  530. {
  531. ovrcontrollerBase.SetControllerVibration(frequency, amplitude);
  532. }
  533. }
  534. }
  535. private static Vector2 CalculateAbsMax(Vector2 a, Vector2 b)
  536. {
  537. float sqrMagnitude = a.sqrMagnitude;
  538. float sqrMagnitude2 = b.sqrMagnitude;
  539. if (sqrMagnitude >= sqrMagnitude2)
  540. {
  541. return a;
  542. }
  543. return b;
  544. }
  545. private static float CalculateAbsMax(float a, float b)
  546. {
  547. float num = (a < 0f) ? (-a) : a;
  548. float num2 = (b < 0f) ? (-b) : b;
  549. if (num >= num2)
  550. {
  551. return a;
  552. }
  553. return b;
  554. }
  555. private static Vector2 CalculateDeadzone(Vector2 a, float deadzone)
  556. {
  557. if (a.sqrMagnitude <= deadzone * deadzone)
  558. {
  559. return Vector2.zero;
  560. }
  561. a *= (a.magnitude - deadzone) / (1f - deadzone);
  562. if (a.sqrMagnitude > 1f)
  563. {
  564. return a.normalized;
  565. }
  566. return a;
  567. }
  568. private static float CalculateDeadzone(float a, float deadzone)
  569. {
  570. float num = (a < 0f) ? (-a) : a;
  571. if (num <= deadzone)
  572. {
  573. return 0f;
  574. }
  575. a *= (num - deadzone) / (1f - deadzone);
  576. if (a * a > 1f)
  577. {
  578. return (a < 0f) ? -1f : 1f;
  579. }
  580. return a;
  581. }
  582. private static bool ShouldResolveController(OVRInput.Controller controllerType, OVRInput.Controller controllerMask)
  583. {
  584. bool result = false;
  585. if ((controllerType & controllerMask) == controllerType)
  586. {
  587. result = true;
  588. }
  589. if ((controllerMask & OVRInput.Controller.Touch) == OVRInput.Controller.Touch && (controllerType & OVRInput.Controller.Touch) != OVRInput.Controller.None && (controllerType & OVRInput.Controller.Touch) != OVRInput.Controller.Touch)
  590. {
  591. result = false;
  592. }
  593. return result;
  594. }
  595. private static readonly float AXIS_AS_BUTTON_THRESHOLD = 0.5f;
  596. private static readonly float AXIS_DEADZONE_THRESHOLD = 0.2f;
  597. private static List<OVRInput.OVRControllerBase> controllers;
  598. private static OVRInput.Controller activeControllerType = OVRInput.Controller.None;
  599. private static OVRInput.Controller connectedControllerTypes = OVRInput.Controller.None;
  600. private static bool useFixedPoses = false;
  601. private static int fixedUpdateCount = 0;
  602. private static bool _pluginSupportsActiveController = false;
  603. private static bool _pluginSupportsActiveControllerCached = false;
  604. private static Version _pluginSupportsActiveControllerMinVersion = new Version(1, 9, 0);
  605. [Flags]
  606. public enum Button
  607. {
  608. None = 0,
  609. One = 1,
  610. Two = 2,
  611. Three = 4,
  612. Four = 8,
  613. Start = 256,
  614. Back = 512,
  615. PrimaryShoulder = 4096,
  616. PrimaryIndexTrigger = 8192,
  617. PrimaryHandTrigger = 16384,
  618. PrimaryThumbstick = 32768,
  619. PrimaryThumbstickUp = 65536,
  620. PrimaryThumbstickDown = 131072,
  621. PrimaryThumbstickLeft = 262144,
  622. PrimaryThumbstickRight = 524288,
  623. SecondaryShoulder = 1048576,
  624. SecondaryIndexTrigger = 2097152,
  625. SecondaryHandTrigger = 4194304,
  626. SecondaryThumbstick = 8388608,
  627. SecondaryThumbstickUp = 16777216,
  628. SecondaryThumbstickDown = 33554432,
  629. SecondaryThumbstickLeft = 67108864,
  630. SecondaryThumbstickRight = 134217728,
  631. DpadUp = 16,
  632. DpadDown = 32,
  633. DpadLeft = 64,
  634. DpadRight = 128,
  635. Up = 268435456,
  636. Down = 536870912,
  637. Left = 1073741824,
  638. Right = -2147483648,
  639. Any = -1
  640. }
  641. [Flags]
  642. public enum RawButton
  643. {
  644. None = 0,
  645. A = 1,
  646. B = 2,
  647. X = 256,
  648. Y = 512,
  649. Start = 1048576,
  650. Back = 2097152,
  651. LShoulder = 2048,
  652. LIndexTrigger = 268435456,
  653. LHandTrigger = 536870912,
  654. LThumbstick = 1024,
  655. LThumbstickUp = 16,
  656. LThumbstickDown = 32,
  657. LThumbstickLeft = 64,
  658. LThumbstickRight = 128,
  659. RShoulder = 8,
  660. RIndexTrigger = 67108864,
  661. RHandTrigger = 134217728,
  662. RThumbstick = 4,
  663. RThumbstickUp = 4096,
  664. RThumbstickDown = 8192,
  665. RThumbstickLeft = 16384,
  666. RThumbstickRight = 32768,
  667. DpadUp = 65536,
  668. DpadDown = 131072,
  669. DpadLeft = 262144,
  670. DpadRight = 524288,
  671. Any = -1
  672. }
  673. [Flags]
  674. public enum Touch
  675. {
  676. None = 0,
  677. One = 1,
  678. Two = 2,
  679. Three = 4,
  680. Four = 8,
  681. PrimaryIndexTrigger = 8192,
  682. PrimaryThumbstick = 32768,
  683. PrimaryThumbRest = 4096,
  684. SecondaryIndexTrigger = 2097152,
  685. SecondaryThumbstick = 8388608,
  686. SecondaryThumbRest = 1048576,
  687. Any = -1
  688. }
  689. [Flags]
  690. public enum RawTouch
  691. {
  692. None = 0,
  693. A = 1,
  694. B = 2,
  695. X = 256,
  696. Y = 512,
  697. LIndexTrigger = 4096,
  698. LThumbstick = 1024,
  699. LThumbRest = 2048,
  700. RIndexTrigger = 16,
  701. RThumbstick = 4,
  702. RThumbRest = 8,
  703. Any = -1
  704. }
  705. [Flags]
  706. public enum NearTouch
  707. {
  708. None = 0,
  709. PrimaryIndexTrigger = 1,
  710. PrimaryThumbButtons = 2,
  711. SecondaryIndexTrigger = 4,
  712. SecondaryThumbButtons = 8,
  713. Any = -1
  714. }
  715. [Flags]
  716. public enum RawNearTouch
  717. {
  718. None = 0,
  719. LIndexTrigger = 1,
  720. LThumbButtons = 2,
  721. RIndexTrigger = 4,
  722. RThumbButtons = 8,
  723. Any = -1
  724. }
  725. [Flags]
  726. public enum Axis1D
  727. {
  728. None = 0,
  729. PrimaryIndexTrigger = 1,
  730. PrimaryHandTrigger = 4,
  731. SecondaryIndexTrigger = 2,
  732. SecondaryHandTrigger = 8,
  733. Any = -1
  734. }
  735. [Flags]
  736. public enum RawAxis1D
  737. {
  738. None = 0,
  739. LIndexTrigger = 1,
  740. LHandTrigger = 4,
  741. RIndexTrigger = 2,
  742. RHandTrigger = 8,
  743. Any = -1
  744. }
  745. [Flags]
  746. public enum Axis2D
  747. {
  748. None = 0,
  749. PrimaryThumbstick = 1,
  750. SecondaryThumbstick = 2,
  751. Any = -1
  752. }
  753. [Flags]
  754. public enum RawAxis2D
  755. {
  756. None = 0,
  757. LThumbstick = 1,
  758. RThumbstick = 2,
  759. Any = -1
  760. }
  761. [Flags]
  762. public enum Controller
  763. {
  764. None = 0,
  765. LTouch = 1,
  766. RTouch = 2,
  767. Touch = 3,
  768. Remote = 4,
  769. Gamepad = 16,
  770. Touchpad = 134217728,
  771. Active = -2147483648,
  772. All = -1
  773. }
  774. private abstract class OVRControllerBase
  775. {
  776. public OVRControllerBase()
  777. {
  778. this.ConfigureButtonMap();
  779. this.ConfigureTouchMap();
  780. this.ConfigureNearTouchMap();
  781. this.ConfigureAxis1DMap();
  782. this.ConfigureAxis2DMap();
  783. }
  784. public virtual OVRInput.Controller Update()
  785. {
  786. OVRPlugin.ControllerState controllerState = OVRPlugin.GetControllerState((uint)this.controllerType);
  787. if (controllerState.LIndexTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  788. {
  789. controllerState.Buttons |= 268435456u;
  790. }
  791. if (controllerState.LHandTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  792. {
  793. controllerState.Buttons |= 536870912u;
  794. }
  795. if (controllerState.LThumbstick.y >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  796. {
  797. controllerState.Buttons |= 16u;
  798. }
  799. if (controllerState.LThumbstick.y <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  800. {
  801. controllerState.Buttons |= 32u;
  802. }
  803. if (controllerState.LThumbstick.x <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  804. {
  805. controllerState.Buttons |= 64u;
  806. }
  807. if (controllerState.LThumbstick.x >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  808. {
  809. controllerState.Buttons |= 128u;
  810. }
  811. if (controllerState.RIndexTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  812. {
  813. controllerState.Buttons |= 67108864u;
  814. }
  815. if (controllerState.RHandTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  816. {
  817. controllerState.Buttons |= 134217728u;
  818. }
  819. if (controllerState.RThumbstick.y >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  820. {
  821. controllerState.Buttons |= 4096u;
  822. }
  823. if (controllerState.RThumbstick.y <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  824. {
  825. controllerState.Buttons |= 8192u;
  826. }
  827. if (controllerState.RThumbstick.x <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  828. {
  829. controllerState.Buttons |= 16384u;
  830. }
  831. if (controllerState.RThumbstick.x >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  832. {
  833. controllerState.Buttons |= 32768u;
  834. }
  835. this.previousState = this.currentState;
  836. this.currentState = controllerState;
  837. return (OVRInput.Controller)(this.currentState.ConnectedControllers & (uint)this.controllerType);
  838. }
  839. public virtual void SetControllerVibration(float frequency, float amplitude)
  840. {
  841. OVRPlugin.SetControllerVibration((uint)this.controllerType, frequency, amplitude);
  842. }
  843. public abstract void ConfigureButtonMap();
  844. public abstract void ConfigureTouchMap();
  845. public abstract void ConfigureNearTouchMap();
  846. public abstract void ConfigureAxis1DMap();
  847. public abstract void ConfigureAxis2DMap();
  848. public OVRInput.RawButton ResolveToRawMask(OVRInput.Button virtualMask)
  849. {
  850. return this.buttonMap.ToRawMask(virtualMask);
  851. }
  852. public OVRInput.RawTouch ResolveToRawMask(OVRInput.Touch virtualMask)
  853. {
  854. return this.touchMap.ToRawMask(virtualMask);
  855. }
  856. public OVRInput.RawNearTouch ResolveToRawMask(OVRInput.NearTouch virtualMask)
  857. {
  858. return this.nearTouchMap.ToRawMask(virtualMask);
  859. }
  860. public OVRInput.RawAxis1D ResolveToRawMask(OVRInput.Axis1D virtualMask)
  861. {
  862. return this.axis1DMap.ToRawMask(virtualMask);
  863. }
  864. public OVRInput.RawAxis2D ResolveToRawMask(OVRInput.Axis2D virtualMask)
  865. {
  866. return this.axis2DMap.ToRawMask(virtualMask);
  867. }
  868. public OVRInput.Controller controllerType;
  869. public OVRInput.OVRControllerBase.VirtualButtonMap buttonMap = new OVRInput.OVRControllerBase.VirtualButtonMap();
  870. public OVRInput.OVRControllerBase.VirtualTouchMap touchMap = new OVRInput.OVRControllerBase.VirtualTouchMap();
  871. public OVRInput.OVRControllerBase.VirtualNearTouchMap nearTouchMap = new OVRInput.OVRControllerBase.VirtualNearTouchMap();
  872. public OVRInput.OVRControllerBase.VirtualAxis1DMap axis1DMap = new OVRInput.OVRControllerBase.VirtualAxis1DMap();
  873. public OVRInput.OVRControllerBase.VirtualAxis2DMap axis2DMap = new OVRInput.OVRControllerBase.VirtualAxis2DMap();
  874. public OVRPlugin.ControllerState previousState = default(OVRPlugin.ControllerState);
  875. public OVRPlugin.ControllerState currentState = default(OVRPlugin.ControllerState);
  876. public class VirtualButtonMap
  877. {
  878. public OVRInput.RawButton ToRawMask(OVRInput.Button virtualMask)
  879. {
  880. OVRInput.RawButton rawButton = OVRInput.RawButton.None;
  881. if (virtualMask == OVRInput.Button.None)
  882. {
  883. return OVRInput.RawButton.None;
  884. }
  885. if ((virtualMask & OVRInput.Button.One) != OVRInput.Button.None)
  886. {
  887. rawButton |= this.One;
  888. }
  889. if ((virtualMask & OVRInput.Button.Two) != OVRInput.Button.None)
  890. {
  891. rawButton |= this.Two;
  892. }
  893. if ((virtualMask & OVRInput.Button.Three) != OVRInput.Button.None)
  894. {
  895. rawButton |= this.Three;
  896. }
  897. if ((virtualMask & OVRInput.Button.Four) != OVRInput.Button.None)
  898. {
  899. rawButton |= this.Four;
  900. }
  901. if ((virtualMask & OVRInput.Button.Start) != OVRInput.Button.None)
  902. {
  903. rawButton |= this.Start;
  904. }
  905. if ((virtualMask & OVRInput.Button.Back) != OVRInput.Button.None)
  906. {
  907. rawButton |= this.Back;
  908. }
  909. if ((virtualMask & OVRInput.Button.PrimaryShoulder) != OVRInput.Button.None)
  910. {
  911. rawButton |= this.PrimaryShoulder;
  912. }
  913. if ((virtualMask & OVRInput.Button.PrimaryIndexTrigger) != OVRInput.Button.None)
  914. {
  915. rawButton |= this.PrimaryIndexTrigger;
  916. }
  917. if ((virtualMask & OVRInput.Button.PrimaryHandTrigger) != OVRInput.Button.None)
  918. {
  919. rawButton |= this.PrimaryHandTrigger;
  920. }
  921. if ((virtualMask & OVRInput.Button.PrimaryThumbstick) != OVRInput.Button.None)
  922. {
  923. rawButton |= this.PrimaryThumbstick;
  924. }
  925. if ((virtualMask & OVRInput.Button.PrimaryThumbstickUp) != OVRInput.Button.None)
  926. {
  927. rawButton |= this.PrimaryThumbstickUp;
  928. }
  929. if ((virtualMask & OVRInput.Button.PrimaryThumbstickDown) != OVRInput.Button.None)
  930. {
  931. rawButton |= this.PrimaryThumbstickDown;
  932. }
  933. if ((virtualMask & OVRInput.Button.PrimaryThumbstickLeft) != OVRInput.Button.None)
  934. {
  935. rawButton |= this.PrimaryThumbstickLeft;
  936. }
  937. if ((virtualMask & OVRInput.Button.PrimaryThumbstickRight) != OVRInput.Button.None)
  938. {
  939. rawButton |= this.PrimaryThumbstickRight;
  940. }
  941. if ((virtualMask & OVRInput.Button.SecondaryShoulder) != OVRInput.Button.None)
  942. {
  943. rawButton |= this.SecondaryShoulder;
  944. }
  945. if ((virtualMask & OVRInput.Button.SecondaryIndexTrigger) != OVRInput.Button.None)
  946. {
  947. rawButton |= this.SecondaryIndexTrigger;
  948. }
  949. if ((virtualMask & OVRInput.Button.SecondaryHandTrigger) != OVRInput.Button.None)
  950. {
  951. rawButton |= this.SecondaryHandTrigger;
  952. }
  953. if ((virtualMask & OVRInput.Button.SecondaryThumbstick) != OVRInput.Button.None)
  954. {
  955. rawButton |= this.SecondaryThumbstick;
  956. }
  957. if ((virtualMask & OVRInput.Button.SecondaryThumbstickUp) != OVRInput.Button.None)
  958. {
  959. rawButton |= this.SecondaryThumbstickUp;
  960. }
  961. if ((virtualMask & OVRInput.Button.SecondaryThumbstickDown) != OVRInput.Button.None)
  962. {
  963. rawButton |= this.SecondaryThumbstickDown;
  964. }
  965. if ((virtualMask & OVRInput.Button.SecondaryThumbstickLeft) != OVRInput.Button.None)
  966. {
  967. rawButton |= this.SecondaryThumbstickLeft;
  968. }
  969. if ((virtualMask & OVRInput.Button.SecondaryThumbstickRight) != OVRInput.Button.None)
  970. {
  971. rawButton |= this.SecondaryThumbstickRight;
  972. }
  973. if ((virtualMask & OVRInput.Button.DpadUp) != OVRInput.Button.None)
  974. {
  975. rawButton |= this.DpadUp;
  976. }
  977. if ((virtualMask & OVRInput.Button.DpadDown) != OVRInput.Button.None)
  978. {
  979. rawButton |= this.DpadDown;
  980. }
  981. if ((virtualMask & OVRInput.Button.DpadLeft) != OVRInput.Button.None)
  982. {
  983. rawButton |= this.DpadLeft;
  984. }
  985. if ((virtualMask & OVRInput.Button.DpadRight) != OVRInput.Button.None)
  986. {
  987. rawButton |= this.DpadRight;
  988. }
  989. if ((virtualMask & OVRInput.Button.Up) != OVRInput.Button.None)
  990. {
  991. rawButton |= this.Up;
  992. }
  993. if ((virtualMask & OVRInput.Button.Down) != OVRInput.Button.None)
  994. {
  995. rawButton |= this.Down;
  996. }
  997. if ((virtualMask & OVRInput.Button.Left) != OVRInput.Button.None)
  998. {
  999. rawButton |= this.Left;
  1000. }
  1001. if ((virtualMask & OVRInput.Button.Right) != OVRInput.Button.None)
  1002. {
  1003. rawButton |= this.Right;
  1004. }
  1005. return rawButton;
  1006. }
  1007. public OVRInput.RawButton None;
  1008. public OVRInput.RawButton One;
  1009. public OVRInput.RawButton Two;
  1010. public OVRInput.RawButton Three;
  1011. public OVRInput.RawButton Four;
  1012. public OVRInput.RawButton Start;
  1013. public OVRInput.RawButton Back;
  1014. public OVRInput.RawButton PrimaryShoulder;
  1015. public OVRInput.RawButton PrimaryIndexTrigger;
  1016. public OVRInput.RawButton PrimaryHandTrigger;
  1017. public OVRInput.RawButton PrimaryThumbstick;
  1018. public OVRInput.RawButton PrimaryThumbstickUp;
  1019. public OVRInput.RawButton PrimaryThumbstickDown;
  1020. public OVRInput.RawButton PrimaryThumbstickLeft;
  1021. public OVRInput.RawButton PrimaryThumbstickRight;
  1022. public OVRInput.RawButton SecondaryShoulder;
  1023. public OVRInput.RawButton SecondaryIndexTrigger;
  1024. public OVRInput.RawButton SecondaryHandTrigger;
  1025. public OVRInput.RawButton SecondaryThumbstick;
  1026. public OVRInput.RawButton SecondaryThumbstickUp;
  1027. public OVRInput.RawButton SecondaryThumbstickDown;
  1028. public OVRInput.RawButton SecondaryThumbstickLeft;
  1029. public OVRInput.RawButton SecondaryThumbstickRight;
  1030. public OVRInput.RawButton DpadUp;
  1031. public OVRInput.RawButton DpadDown;
  1032. public OVRInput.RawButton DpadLeft;
  1033. public OVRInput.RawButton DpadRight;
  1034. public OVRInput.RawButton Up;
  1035. public OVRInput.RawButton Down;
  1036. public OVRInput.RawButton Left;
  1037. public OVRInput.RawButton Right;
  1038. }
  1039. public class VirtualTouchMap
  1040. {
  1041. public OVRInput.RawTouch ToRawMask(OVRInput.Touch virtualMask)
  1042. {
  1043. OVRInput.RawTouch rawTouch = OVRInput.RawTouch.None;
  1044. if (virtualMask == OVRInput.Touch.None)
  1045. {
  1046. return OVRInput.RawTouch.None;
  1047. }
  1048. if ((virtualMask & OVRInput.Touch.One) != OVRInput.Touch.None)
  1049. {
  1050. rawTouch |= this.One;
  1051. }
  1052. if ((virtualMask & OVRInput.Touch.Two) != OVRInput.Touch.None)
  1053. {
  1054. rawTouch |= this.Two;
  1055. }
  1056. if ((virtualMask & OVRInput.Touch.Three) != OVRInput.Touch.None)
  1057. {
  1058. rawTouch |= this.Three;
  1059. }
  1060. if ((virtualMask & OVRInput.Touch.Four) != OVRInput.Touch.None)
  1061. {
  1062. rawTouch |= this.Four;
  1063. }
  1064. if ((virtualMask & OVRInput.Touch.PrimaryIndexTrigger) != OVRInput.Touch.None)
  1065. {
  1066. rawTouch |= this.PrimaryIndexTrigger;
  1067. }
  1068. if ((virtualMask & OVRInput.Touch.PrimaryThumbstick) != OVRInput.Touch.None)
  1069. {
  1070. rawTouch |= this.PrimaryThumbstick;
  1071. }
  1072. if ((virtualMask & OVRInput.Touch.PrimaryThumbRest) != OVRInput.Touch.None)
  1073. {
  1074. rawTouch |= this.PrimaryThumbRest;
  1075. }
  1076. if ((virtualMask & OVRInput.Touch.SecondaryIndexTrigger) != OVRInput.Touch.None)
  1077. {
  1078. rawTouch |= this.SecondaryIndexTrigger;
  1079. }
  1080. if ((virtualMask & OVRInput.Touch.SecondaryThumbstick) != OVRInput.Touch.None)
  1081. {
  1082. rawTouch |= this.SecondaryThumbstick;
  1083. }
  1084. if ((virtualMask & OVRInput.Touch.SecondaryThumbRest) != OVRInput.Touch.None)
  1085. {
  1086. rawTouch |= this.SecondaryThumbRest;
  1087. }
  1088. return rawTouch;
  1089. }
  1090. public OVRInput.RawTouch None;
  1091. public OVRInput.RawTouch One;
  1092. public OVRInput.RawTouch Two;
  1093. public OVRInput.RawTouch Three;
  1094. public OVRInput.RawTouch Four;
  1095. public OVRInput.RawTouch PrimaryIndexTrigger;
  1096. public OVRInput.RawTouch PrimaryThumbstick;
  1097. public OVRInput.RawTouch PrimaryThumbRest;
  1098. public OVRInput.RawTouch SecondaryIndexTrigger;
  1099. public OVRInput.RawTouch SecondaryThumbstick;
  1100. public OVRInput.RawTouch SecondaryThumbRest;
  1101. }
  1102. public class VirtualNearTouchMap
  1103. {
  1104. public OVRInput.RawNearTouch ToRawMask(OVRInput.NearTouch virtualMask)
  1105. {
  1106. OVRInput.RawNearTouch rawNearTouch = OVRInput.RawNearTouch.None;
  1107. if (virtualMask == OVRInput.NearTouch.None)
  1108. {
  1109. return OVRInput.RawNearTouch.None;
  1110. }
  1111. if ((virtualMask & OVRInput.NearTouch.PrimaryIndexTrigger) != OVRInput.NearTouch.None)
  1112. {
  1113. rawNearTouch |= this.PrimaryIndexTrigger;
  1114. }
  1115. if ((virtualMask & OVRInput.NearTouch.PrimaryThumbButtons) != OVRInput.NearTouch.None)
  1116. {
  1117. rawNearTouch |= this.PrimaryThumbButtons;
  1118. }
  1119. if ((virtualMask & OVRInput.NearTouch.SecondaryIndexTrigger) != OVRInput.NearTouch.None)
  1120. {
  1121. rawNearTouch |= this.SecondaryIndexTrigger;
  1122. }
  1123. if ((virtualMask & OVRInput.NearTouch.SecondaryThumbButtons) != OVRInput.NearTouch.None)
  1124. {
  1125. rawNearTouch |= this.SecondaryThumbButtons;
  1126. }
  1127. return rawNearTouch;
  1128. }
  1129. public OVRInput.RawNearTouch None;
  1130. public OVRInput.RawNearTouch PrimaryIndexTrigger;
  1131. public OVRInput.RawNearTouch PrimaryThumbButtons;
  1132. public OVRInput.RawNearTouch SecondaryIndexTrigger;
  1133. public OVRInput.RawNearTouch SecondaryThumbButtons;
  1134. }
  1135. public class VirtualAxis1DMap
  1136. {
  1137. public OVRInput.RawAxis1D ToRawMask(OVRInput.Axis1D virtualMask)
  1138. {
  1139. OVRInput.RawAxis1D rawAxis1D = OVRInput.RawAxis1D.None;
  1140. if (virtualMask == OVRInput.Axis1D.None)
  1141. {
  1142. return OVRInput.RawAxis1D.None;
  1143. }
  1144. if ((virtualMask & OVRInput.Axis1D.PrimaryIndexTrigger) != OVRInput.Axis1D.None)
  1145. {
  1146. rawAxis1D |= this.PrimaryIndexTrigger;
  1147. }
  1148. if ((virtualMask & OVRInput.Axis1D.PrimaryHandTrigger) != OVRInput.Axis1D.None)
  1149. {
  1150. rawAxis1D |= this.PrimaryHandTrigger;
  1151. }
  1152. if ((virtualMask & OVRInput.Axis1D.SecondaryIndexTrigger) != OVRInput.Axis1D.None)
  1153. {
  1154. rawAxis1D |= this.SecondaryIndexTrigger;
  1155. }
  1156. if ((virtualMask & OVRInput.Axis1D.SecondaryHandTrigger) != OVRInput.Axis1D.None)
  1157. {
  1158. rawAxis1D |= this.SecondaryHandTrigger;
  1159. }
  1160. return rawAxis1D;
  1161. }
  1162. public OVRInput.RawAxis1D None;
  1163. public OVRInput.RawAxis1D PrimaryIndexTrigger;
  1164. public OVRInput.RawAxis1D PrimaryHandTrigger;
  1165. public OVRInput.RawAxis1D SecondaryIndexTrigger;
  1166. public OVRInput.RawAxis1D SecondaryHandTrigger;
  1167. }
  1168. public class VirtualAxis2DMap
  1169. {
  1170. public OVRInput.RawAxis2D ToRawMask(OVRInput.Axis2D virtualMask)
  1171. {
  1172. OVRInput.RawAxis2D rawAxis2D = OVRInput.RawAxis2D.None;
  1173. if (virtualMask == OVRInput.Axis2D.None)
  1174. {
  1175. return OVRInput.RawAxis2D.None;
  1176. }
  1177. if ((virtualMask & OVRInput.Axis2D.PrimaryThumbstick) != OVRInput.Axis2D.None)
  1178. {
  1179. rawAxis2D |= this.PrimaryThumbstick;
  1180. }
  1181. if ((virtualMask & OVRInput.Axis2D.SecondaryThumbstick) != OVRInput.Axis2D.None)
  1182. {
  1183. rawAxis2D |= this.SecondaryThumbstick;
  1184. }
  1185. return rawAxis2D;
  1186. }
  1187. public OVRInput.RawAxis2D None;
  1188. public OVRInput.RawAxis2D PrimaryThumbstick;
  1189. public OVRInput.RawAxis2D SecondaryThumbstick;
  1190. }
  1191. }
  1192. private class OVRControllerTouch : OVRInput.OVRControllerBase
  1193. {
  1194. public OVRControllerTouch()
  1195. {
  1196. this.controllerType = OVRInput.Controller.Touch;
  1197. }
  1198. public override void ConfigureButtonMap()
  1199. {
  1200. this.buttonMap.None = OVRInput.RawButton.None;
  1201. this.buttonMap.One = OVRInput.RawButton.A;
  1202. this.buttonMap.Two = OVRInput.RawButton.B;
  1203. this.buttonMap.Three = OVRInput.RawButton.X;
  1204. this.buttonMap.Four = OVRInput.RawButton.Y;
  1205. this.buttonMap.Start = OVRInput.RawButton.Start;
  1206. this.buttonMap.Back = OVRInput.RawButton.None;
  1207. this.buttonMap.PrimaryShoulder = OVRInput.RawButton.None;
  1208. this.buttonMap.PrimaryIndexTrigger = OVRInput.RawButton.LIndexTrigger;
  1209. this.buttonMap.PrimaryHandTrigger = OVRInput.RawButton.LHandTrigger;
  1210. this.buttonMap.PrimaryThumbstick = OVRInput.RawButton.LThumbstick;
  1211. this.buttonMap.PrimaryThumbstickUp = OVRInput.RawButton.LThumbstickUp;
  1212. this.buttonMap.PrimaryThumbstickDown = OVRInput.RawButton.LThumbstickDown;
  1213. this.buttonMap.PrimaryThumbstickLeft = OVRInput.RawButton.LThumbstickLeft;
  1214. this.buttonMap.PrimaryThumbstickRight = OVRInput.RawButton.LThumbstickRight;
  1215. this.buttonMap.SecondaryShoulder = OVRInput.RawButton.None;
  1216. this.buttonMap.SecondaryIndexTrigger = OVRInput.RawButton.RIndexTrigger;
  1217. this.buttonMap.SecondaryHandTrigger = OVRInput.RawButton.RHandTrigger;
  1218. this.buttonMap.SecondaryThumbstick = OVRInput.RawButton.RThumbstick;
  1219. this.buttonMap.SecondaryThumbstickUp = OVRInput.RawButton.RThumbstickUp;
  1220. this.buttonMap.SecondaryThumbstickDown = OVRInput.RawButton.RThumbstickDown;
  1221. this.buttonMap.SecondaryThumbstickLeft = OVRInput.RawButton.RThumbstickLeft;
  1222. this.buttonMap.SecondaryThumbstickRight = OVRInput.RawButton.RThumbstickRight;
  1223. this.buttonMap.DpadUp = OVRInput.RawButton.None;
  1224. this.buttonMap.DpadDown = OVRInput.RawButton.None;
  1225. this.buttonMap.DpadLeft = OVRInput.RawButton.None;
  1226. this.buttonMap.DpadRight = OVRInput.RawButton.None;
  1227. this.buttonMap.Up = OVRInput.RawButton.LThumbstickUp;
  1228. this.buttonMap.Down = OVRInput.RawButton.LThumbstickDown;
  1229. this.buttonMap.Left = OVRInput.RawButton.LThumbstickLeft;
  1230. this.buttonMap.Right = OVRInput.RawButton.LThumbstickRight;
  1231. }
  1232. public override void ConfigureTouchMap()
  1233. {
  1234. this.touchMap.None = OVRInput.RawTouch.None;
  1235. this.touchMap.One = OVRInput.RawTouch.A;
  1236. this.touchMap.Two = OVRInput.RawTouch.B;
  1237. this.touchMap.Three = OVRInput.RawTouch.X;
  1238. this.touchMap.Four = OVRInput.RawTouch.Y;
  1239. this.touchMap.PrimaryIndexTrigger = OVRInput.RawTouch.LIndexTrigger;
  1240. this.touchMap.PrimaryThumbstick = OVRInput.RawTouch.LThumbstick;
  1241. this.touchMap.PrimaryThumbRest = OVRInput.RawTouch.LThumbRest;
  1242. this.touchMap.SecondaryIndexTrigger = OVRInput.RawTouch.RIndexTrigger;
  1243. this.touchMap.SecondaryThumbstick = OVRInput.RawTouch.RThumbstick;
  1244. this.touchMap.SecondaryThumbRest = OVRInput.RawTouch.RThumbRest;
  1245. }
  1246. public override void ConfigureNearTouchMap()
  1247. {
  1248. this.nearTouchMap.None = OVRInput.RawNearTouch.None;
  1249. this.nearTouchMap.PrimaryIndexTrigger = OVRInput.RawNearTouch.LIndexTrigger;
  1250. this.nearTouchMap.PrimaryThumbButtons = OVRInput.RawNearTouch.LThumbButtons;
  1251. this.nearTouchMap.SecondaryIndexTrigger = OVRInput.RawNearTouch.RIndexTrigger;
  1252. this.nearTouchMap.SecondaryThumbButtons = OVRInput.RawNearTouch.RThumbButtons;
  1253. }
  1254. public override void ConfigureAxis1DMap()
  1255. {
  1256. this.axis1DMap.None = OVRInput.RawAxis1D.None;
  1257. this.axis1DMap.PrimaryIndexTrigger = OVRInput.RawAxis1D.LIndexTrigger;
  1258. this.axis1DMap.PrimaryHandTrigger = OVRInput.RawAxis1D.LHandTrigger;
  1259. this.axis1DMap.SecondaryIndexTrigger = OVRInput.RawAxis1D.RIndexTrigger;
  1260. this.axis1DMap.SecondaryHandTrigger = OVRInput.RawAxis1D.RHandTrigger;
  1261. }
  1262. public override void ConfigureAxis2DMap()
  1263. {
  1264. this.axis2DMap.None = OVRInput.RawAxis2D.None;
  1265. this.axis2DMap.PrimaryThumbstick = OVRInput.RawAxis2D.LThumbstick;
  1266. this.axis2DMap.SecondaryThumbstick = OVRInput.RawAxis2D.RThumbstick;
  1267. }
  1268. }
  1269. private class OVRControllerLTouch : OVRInput.OVRControllerBase
  1270. {
  1271. public OVRControllerLTouch()
  1272. {
  1273. this.controllerType = OVRInput.Controller.LTouch;
  1274. }
  1275. public override void ConfigureButtonMap()
  1276. {
  1277. this.buttonMap.None = OVRInput.RawButton.None;
  1278. this.buttonMap.One = OVRInput.RawButton.X;
  1279. this.buttonMap.Two = OVRInput.RawButton.Y;
  1280. this.buttonMap.Three = OVRInput.RawButton.None;
  1281. this.buttonMap.Four = OVRInput.RawButton.None;
  1282. this.buttonMap.Start = OVRInput.RawButton.Start;
  1283. this.buttonMap.Back = OVRInput.RawButton.None;
  1284. this.buttonMap.PrimaryShoulder = OVRInput.RawButton.None;
  1285. this.buttonMap.PrimaryIndexTrigger = OVRInput.RawButton.LIndexTrigger;
  1286. this.buttonMap.PrimaryHandTrigger = OVRInput.RawButton.LHandTrigger;
  1287. this.buttonMap.PrimaryThumbstick = OVRInput.RawButton.LThumbstick;
  1288. this.buttonMap.PrimaryThumbstickUp = OVRInput.RawButton.LThumbstickUp;
  1289. this.buttonMap.PrimaryThumbstickDown = OVRInput.RawButton.LThumbstickDown;
  1290. this.buttonMap.PrimaryThumbstickLeft = OVRInput.RawButton.LThumbstickLeft;
  1291. this.buttonMap.PrimaryThumbstickRight = OVRInput.RawButton.LThumbstickRight;
  1292. this.buttonMap.SecondaryShoulder = OVRInput.RawButton.None;
  1293. this.buttonMap.SecondaryIndexTrigger = OVRInput.RawButton.None;
  1294. this.buttonMap.SecondaryHandTrigger = OVRInput.RawButton.None;
  1295. this.buttonMap.SecondaryThumbstick = OVRInput.RawButton.None;
  1296. this.buttonMap.SecondaryThumbstickUp = OVRInput.RawButton.None;
  1297. this.buttonMap.SecondaryThumbstickDown = OVRInput.RawButton.None;
  1298. this.buttonMap.SecondaryThumbstickLeft = OVRInput.RawButton.None;
  1299. this.buttonMap.SecondaryThumbstickRight = OVRInput.RawButton.None;
  1300. this.buttonMap.DpadUp = OVRInput.RawButton.None;
  1301. this.buttonMap.DpadDown = OVRInput.RawButton.None;
  1302. this.buttonMap.DpadLeft = OVRInput.RawButton.None;
  1303. this.buttonMap.DpadRight = OVRInput.RawButton.None;
  1304. this.buttonMap.Up = OVRInput.RawButton.LThumbstickUp;
  1305. this.buttonMap.Down = OVRInput.RawButton.LThumbstickDown;
  1306. this.buttonMap.Left = OVRInput.RawButton.LThumbstickLeft;
  1307. this.buttonMap.Right = OVRInput.RawButton.LThumbstickRight;
  1308. }
  1309. public override void ConfigureTouchMap()
  1310. {
  1311. this.touchMap.None = OVRInput.RawTouch.None;
  1312. this.touchMap.One = OVRInput.RawTouch.X;
  1313. this.touchMap.Two = OVRInput.RawTouch.Y;
  1314. this.touchMap.Three = OVRInput.RawTouch.None;
  1315. this.touchMap.Four = OVRInput.RawTouch.None;
  1316. this.touchMap.PrimaryIndexTrigger = OVRInput.RawTouch.LIndexTrigger;
  1317. this.touchMap.PrimaryThumbstick = OVRInput.RawTouch.LThumbstick;
  1318. this.touchMap.PrimaryThumbRest = OVRInput.RawTouch.LThumbRest;
  1319. this.touchMap.SecondaryIndexTrigger = OVRInput.RawTouch.None;
  1320. this.touchMap.SecondaryThumbstick = OVRInput.RawTouch.None;
  1321. this.touchMap.SecondaryThumbRest = OVRInput.RawTouch.None;
  1322. }
  1323. public override void ConfigureNearTouchMap()
  1324. {
  1325. this.nearTouchMap.None = OVRInput.RawNearTouch.None;
  1326. this.nearTouchMap.PrimaryIndexTrigger = OVRInput.RawNearTouch.LIndexTrigger;
  1327. this.nearTouchMap.PrimaryThumbButtons = OVRInput.RawNearTouch.LThumbButtons;
  1328. this.nearTouchMap.SecondaryIndexTrigger = OVRInput.RawNearTouch.None;
  1329. this.nearTouchMap.SecondaryThumbButtons = OVRInput.RawNearTouch.None;
  1330. }
  1331. public override void ConfigureAxis1DMap()
  1332. {
  1333. this.axis1DMap.None = OVRInput.RawAxis1D.None;
  1334. this.axis1DMap.PrimaryIndexTrigger = OVRInput.RawAxis1D.LIndexTrigger;
  1335. this.axis1DMap.PrimaryHandTrigger = OVRInput.RawAxis1D.LHandTrigger;
  1336. this.axis1DMap.SecondaryIndexTrigger = OVRInput.RawAxis1D.None;
  1337. this.axis1DMap.SecondaryHandTrigger = OVRInput.RawAxis1D.None;
  1338. }
  1339. public override void ConfigureAxis2DMap()
  1340. {
  1341. this.axis2DMap.None = OVRInput.RawAxis2D.None;
  1342. this.axis2DMap.PrimaryThumbstick = OVRInput.RawAxis2D.LThumbstick;
  1343. this.axis2DMap.SecondaryThumbstick = OVRInput.RawAxis2D.None;
  1344. }
  1345. }
  1346. private class OVRControllerRTouch : OVRInput.OVRControllerBase
  1347. {
  1348. public OVRControllerRTouch()
  1349. {
  1350. this.controllerType = OVRInput.Controller.RTouch;
  1351. }
  1352. public override void ConfigureButtonMap()
  1353. {
  1354. this.buttonMap.None = OVRInput.RawButton.None;
  1355. this.buttonMap.One = OVRInput.RawButton.A;
  1356. this.buttonMap.Two = OVRInput.RawButton.B;
  1357. this.buttonMap.Three = OVRInput.RawButton.None;
  1358. this.buttonMap.Four = OVRInput.RawButton.None;
  1359. this.buttonMap.Start = OVRInput.RawButton.None;
  1360. this.buttonMap.Back = OVRInput.RawButton.None;
  1361. this.buttonMap.PrimaryShoulder = OVRInput.RawButton.None;
  1362. this.buttonMap.PrimaryIndexTrigger = OVRInput.RawButton.RIndexTrigger;
  1363. this.buttonMap.PrimaryHandTrigger = OVRInput.RawButton.RHandTrigger;
  1364. this.buttonMap.PrimaryThumbstick = OVRInput.RawButton.RThumbstick;
  1365. this.buttonMap.PrimaryThumbstickUp = OVRInput.RawButton.RThumbstickUp;
  1366. this.buttonMap.PrimaryThumbstickDown = OVRInput.RawButton.RThumbstickDown;
  1367. this.buttonMap.PrimaryThumbstickLeft = OVRInput.RawButton.RThumbstickLeft;
  1368. this.buttonMap.PrimaryThumbstickRight = OVRInput.RawButton.RThumbstickRight;
  1369. this.buttonMap.SecondaryShoulder = OVRInput.RawButton.None;
  1370. this.buttonMap.SecondaryIndexTrigger = OVRInput.RawButton.None;
  1371. this.buttonMap.SecondaryHandTrigger = OVRInput.RawButton.None;
  1372. this.buttonMap.SecondaryThumbstick = OVRInput.RawButton.None;
  1373. this.buttonMap.SecondaryThumbstickUp = OVRInput.RawButton.None;
  1374. this.buttonMap.SecondaryThumbstickDown = OVRInput.RawButton.None;
  1375. this.buttonMap.SecondaryThumbstickLeft = OVRInput.RawButton.None;
  1376. this.buttonMap.SecondaryThumbstickRight = OVRInput.RawButton.None;
  1377. this.buttonMap.DpadUp = OVRInput.RawButton.None;
  1378. this.buttonMap.DpadDown = OVRInput.RawButton.None;
  1379. this.buttonMap.DpadLeft = OVRInput.RawButton.None;
  1380. this.buttonMap.DpadRight = OVRInput.RawButton.None;
  1381. this.buttonMap.Up = OVRInput.RawButton.RThumbstickUp;
  1382. this.buttonMap.Down = OVRInput.RawButton.RThumbstickDown;
  1383. this.buttonMap.Left = OVRInput.RawButton.RThumbstickLeft;
  1384. this.buttonMap.Right = OVRInput.RawButton.RThumbstickRight;
  1385. }
  1386. public override void ConfigureTouchMap()
  1387. {
  1388. this.touchMap.None = OVRInput.RawTouch.None;
  1389. this.touchMap.One = OVRInput.RawTouch.A;
  1390. this.touchMap.Two = OVRInput.RawTouch.B;
  1391. this.touchMap.Three = OVRInput.RawTouch.None;
  1392. this.touchMap.Four = OVRInput.RawTouch.None;
  1393. this.touchMap.PrimaryIndexTrigger = OVRInput.RawTouch.RIndexTrigger;
  1394. this.touchMap.PrimaryThumbstick = OVRInput.RawTouch.RThumbstick;
  1395. this.touchMap.PrimaryThumbRest = OVRInput.RawTouch.RThumbRest;
  1396. this.touchMap.SecondaryIndexTrigger = OVRInput.RawTouch.None;
  1397. this.touchMap.SecondaryThumbstick = OVRInput.RawTouch.None;
  1398. this.touchMap.SecondaryThumbRest = OVRInput.RawTouch.None;
  1399. }
  1400. public override void ConfigureNearTouchMap()
  1401. {
  1402. this.nearTouchMap.None = OVRInput.RawNearTouch.None;
  1403. this.nearTouchMap.PrimaryIndexTrigger = OVRInput.RawNearTouch.RIndexTrigger;
  1404. this.nearTouchMap.PrimaryThumbButtons = OVRInput.RawNearTouch.RThumbButtons;
  1405. this.nearTouchMap.SecondaryIndexTrigger = OVRInput.RawNearTouch.None;
  1406. this.nearTouchMap.SecondaryThumbButtons = OVRInput.RawNearTouch.None;
  1407. }
  1408. public override void ConfigureAxis1DMap()
  1409. {
  1410. this.axis1DMap.None = OVRInput.RawAxis1D.None;
  1411. this.axis1DMap.PrimaryIndexTrigger = OVRInput.RawAxis1D.RIndexTrigger;
  1412. this.axis1DMap.PrimaryHandTrigger = OVRInput.RawAxis1D.RHandTrigger;
  1413. this.axis1DMap.SecondaryIndexTrigger = OVRInput.RawAxis1D.None;
  1414. this.axis1DMap.SecondaryHandTrigger = OVRInput.RawAxis1D.None;
  1415. }
  1416. public override void ConfigureAxis2DMap()
  1417. {
  1418. this.axis2DMap.None = OVRInput.RawAxis2D.None;
  1419. this.axis2DMap.PrimaryThumbstick = OVRInput.RawAxis2D.RThumbstick;
  1420. this.axis2DMap.SecondaryThumbstick = OVRInput.RawAxis2D.None;
  1421. }
  1422. }
  1423. private class OVRControllerRemote : OVRInput.OVRControllerBase
  1424. {
  1425. public OVRControllerRemote()
  1426. {
  1427. this.controllerType = OVRInput.Controller.Remote;
  1428. }
  1429. public override void ConfigureButtonMap()
  1430. {
  1431. this.buttonMap.None = OVRInput.RawButton.None;
  1432. this.buttonMap.One = OVRInput.RawButton.Start;
  1433. this.buttonMap.Two = OVRInput.RawButton.Back;
  1434. this.buttonMap.Three = OVRInput.RawButton.None;
  1435. this.buttonMap.Four = OVRInput.RawButton.None;
  1436. this.buttonMap.Start = OVRInput.RawButton.Start;
  1437. this.buttonMap.Back = OVRInput.RawButton.Back;
  1438. this.buttonMap.PrimaryShoulder = OVRInput.RawButton.None;
  1439. this.buttonMap.PrimaryIndexTrigger = OVRInput.RawButton.None;
  1440. this.buttonMap.PrimaryHandTrigger = OVRInput.RawButton.None;
  1441. this.buttonMap.PrimaryThumbstick = OVRInput.RawButton.None;
  1442. this.buttonMap.PrimaryThumbstickUp = OVRInput.RawButton.None;
  1443. this.buttonMap.PrimaryThumbstickDown = OVRInput.RawButton.None;
  1444. this.buttonMap.PrimaryThumbstickLeft = OVRInput.RawButton.None;
  1445. this.buttonMap.PrimaryThumbstickRight = OVRInput.RawButton.None;
  1446. this.buttonMap.SecondaryShoulder = OVRInput.RawButton.None;
  1447. this.buttonMap.SecondaryIndexTrigger = OVRInput.RawButton.None;
  1448. this.buttonMap.SecondaryHandTrigger = OVRInput.RawButton.None;
  1449. this.buttonMap.SecondaryThumbstick = OVRInput.RawButton.None;
  1450. this.buttonMap.SecondaryThumbstickUp = OVRInput.RawButton.None;
  1451. this.buttonMap.SecondaryThumbstickDown = OVRInput.RawButton.None;
  1452. this.buttonMap.SecondaryThumbstickLeft = OVRInput.RawButton.None;
  1453. this.buttonMap.SecondaryThumbstickRight = OVRInput.RawButton.None;
  1454. this.buttonMap.DpadUp = OVRInput.RawButton.DpadUp;
  1455. this.buttonMap.DpadDown = OVRInput.RawButton.DpadDown;
  1456. this.buttonMap.DpadLeft = OVRInput.RawButton.DpadLeft;
  1457. this.buttonMap.DpadRight = OVRInput.RawButton.DpadRight;
  1458. this.buttonMap.Up = OVRInput.RawButton.DpadUp;
  1459. this.buttonMap.Down = OVRInput.RawButton.DpadDown;
  1460. this.buttonMap.Left = OVRInput.RawButton.DpadLeft;
  1461. this.buttonMap.Right = OVRInput.RawButton.DpadRight;
  1462. }
  1463. public override void ConfigureTouchMap()
  1464. {
  1465. this.touchMap.None = OVRInput.RawTouch.None;
  1466. this.touchMap.One = OVRInput.RawTouch.None;
  1467. this.touchMap.Two = OVRInput.RawTouch.None;
  1468. this.touchMap.Three = OVRInput.RawTouch.None;
  1469. this.touchMap.Four = OVRInput.RawTouch.None;
  1470. this.touchMap.PrimaryIndexTrigger = OVRInput.RawTouch.None;
  1471. this.touchMap.PrimaryThumbstick = OVRInput.RawTouch.None;
  1472. this.touchMap.PrimaryThumbRest = OVRInput.RawTouch.None;
  1473. this.touchMap.SecondaryIndexTrigger = OVRInput.RawTouch.None;
  1474. this.touchMap.SecondaryThumbstick = OVRInput.RawTouch.None;
  1475. this.touchMap.SecondaryThumbRest = OVRInput.RawTouch.None;
  1476. }
  1477. public override void ConfigureNearTouchMap()
  1478. {
  1479. this.nearTouchMap.None = OVRInput.RawNearTouch.None;
  1480. this.nearTouchMap.PrimaryIndexTrigger = OVRInput.RawNearTouch.None;
  1481. this.nearTouchMap.PrimaryThumbButtons = OVRInput.RawNearTouch.None;
  1482. this.nearTouchMap.SecondaryIndexTrigger = OVRInput.RawNearTouch.None;
  1483. this.nearTouchMap.SecondaryThumbButtons = OVRInput.RawNearTouch.None;
  1484. }
  1485. public override void ConfigureAxis1DMap()
  1486. {
  1487. this.axis1DMap.None = OVRInput.RawAxis1D.None;
  1488. this.axis1DMap.PrimaryIndexTrigger = OVRInput.RawAxis1D.None;
  1489. this.axis1DMap.PrimaryHandTrigger = OVRInput.RawAxis1D.None;
  1490. this.axis1DMap.SecondaryIndexTrigger = OVRInput.RawAxis1D.None;
  1491. this.axis1DMap.SecondaryHandTrigger = OVRInput.RawAxis1D.None;
  1492. }
  1493. public override void ConfigureAxis2DMap()
  1494. {
  1495. this.axis2DMap.None = OVRInput.RawAxis2D.None;
  1496. this.axis2DMap.PrimaryThumbstick = OVRInput.RawAxis2D.None;
  1497. this.axis2DMap.SecondaryThumbstick = OVRInput.RawAxis2D.None;
  1498. }
  1499. }
  1500. private class OVRControllerGamepadPC : OVRInput.OVRControllerBase
  1501. {
  1502. public OVRControllerGamepadPC()
  1503. {
  1504. this.controllerType = OVRInput.Controller.Gamepad;
  1505. }
  1506. public override void ConfigureButtonMap()
  1507. {
  1508. this.buttonMap.None = OVRInput.RawButton.None;
  1509. this.buttonMap.One = OVRInput.RawButton.A;
  1510. this.buttonMap.Two = OVRInput.RawButton.B;
  1511. this.buttonMap.Three = OVRInput.RawButton.X;
  1512. this.buttonMap.Four = OVRInput.RawButton.Y;
  1513. this.buttonMap.Start = OVRInput.RawButton.Start;
  1514. this.buttonMap.Back = OVRInput.RawButton.Back;
  1515. this.buttonMap.PrimaryShoulder = OVRInput.RawButton.LShoulder;
  1516. this.buttonMap.PrimaryIndexTrigger = OVRInput.RawButton.LIndexTrigger;
  1517. this.buttonMap.PrimaryHandTrigger = OVRInput.RawButton.None;
  1518. this.buttonMap.PrimaryThumbstick = OVRInput.RawButton.LThumbstick;
  1519. this.buttonMap.PrimaryThumbstickUp = OVRInput.RawButton.LThumbstickUp;
  1520. this.buttonMap.PrimaryThumbstickDown = OVRInput.RawButton.LThumbstickDown;
  1521. this.buttonMap.PrimaryThumbstickLeft = OVRInput.RawButton.LThumbstickLeft;
  1522. this.buttonMap.PrimaryThumbstickRight = OVRInput.RawButton.LThumbstickRight;
  1523. this.buttonMap.SecondaryShoulder = OVRInput.RawButton.RShoulder;
  1524. this.buttonMap.SecondaryIndexTrigger = OVRInput.RawButton.RIndexTrigger;
  1525. this.buttonMap.SecondaryHandTrigger = OVRInput.RawButton.None;
  1526. this.buttonMap.SecondaryThumbstick = OVRInput.RawButton.RThumbstick;
  1527. this.buttonMap.SecondaryThumbstickUp = OVRInput.RawButton.RThumbstickUp;
  1528. this.buttonMap.SecondaryThumbstickDown = OVRInput.RawButton.RThumbstickDown;
  1529. this.buttonMap.SecondaryThumbstickLeft = OVRInput.RawButton.RThumbstickLeft;
  1530. this.buttonMap.SecondaryThumbstickRight = OVRInput.RawButton.RThumbstickRight;
  1531. this.buttonMap.DpadUp = OVRInput.RawButton.DpadUp;
  1532. this.buttonMap.DpadDown = OVRInput.RawButton.DpadDown;
  1533. this.buttonMap.DpadLeft = OVRInput.RawButton.DpadLeft;
  1534. this.buttonMap.DpadRight = OVRInput.RawButton.DpadRight;
  1535. this.buttonMap.Up = OVRInput.RawButton.LThumbstickUp;
  1536. this.buttonMap.Down = OVRInput.RawButton.LThumbstickDown;
  1537. this.buttonMap.Left = OVRInput.RawButton.LThumbstickLeft;
  1538. this.buttonMap.Right = OVRInput.RawButton.LThumbstickRight;
  1539. }
  1540. public override void ConfigureTouchMap()
  1541. {
  1542. this.touchMap.None = OVRInput.RawTouch.None;
  1543. this.touchMap.One = OVRInput.RawTouch.None;
  1544. this.touchMap.Two = OVRInput.RawTouch.None;
  1545. this.touchMap.Three = OVRInput.RawTouch.None;
  1546. this.touchMap.Four = OVRInput.RawTouch.None;
  1547. this.touchMap.PrimaryIndexTrigger = OVRInput.RawTouch.None;
  1548. this.touchMap.PrimaryThumbstick = OVRInput.RawTouch.None;
  1549. this.touchMap.PrimaryThumbRest = OVRInput.RawTouch.None;
  1550. this.touchMap.SecondaryIndexTrigger = OVRInput.RawTouch.None;
  1551. this.touchMap.SecondaryThumbstick = OVRInput.RawTouch.None;
  1552. this.touchMap.SecondaryThumbRest = OVRInput.RawTouch.None;
  1553. }
  1554. public override void ConfigureNearTouchMap()
  1555. {
  1556. this.nearTouchMap.None = OVRInput.RawNearTouch.None;
  1557. this.nearTouchMap.PrimaryIndexTrigger = OVRInput.RawNearTouch.None;
  1558. this.nearTouchMap.PrimaryThumbButtons = OVRInput.RawNearTouch.None;
  1559. this.nearTouchMap.SecondaryIndexTrigger = OVRInput.RawNearTouch.None;
  1560. this.nearTouchMap.SecondaryThumbButtons = OVRInput.RawNearTouch.None;
  1561. }
  1562. public override void ConfigureAxis1DMap()
  1563. {
  1564. this.axis1DMap.None = OVRInput.RawAxis1D.None;
  1565. this.axis1DMap.PrimaryIndexTrigger = OVRInput.RawAxis1D.LIndexTrigger;
  1566. this.axis1DMap.PrimaryHandTrigger = OVRInput.RawAxis1D.None;
  1567. this.axis1DMap.SecondaryIndexTrigger = OVRInput.RawAxis1D.RIndexTrigger;
  1568. this.axis1DMap.SecondaryHandTrigger = OVRInput.RawAxis1D.None;
  1569. }
  1570. public override void ConfigureAxis2DMap()
  1571. {
  1572. this.axis2DMap.None = OVRInput.RawAxis2D.None;
  1573. this.axis2DMap.PrimaryThumbstick = OVRInput.RawAxis2D.LThumbstick;
  1574. this.axis2DMap.SecondaryThumbstick = OVRInput.RawAxis2D.RThumbstick;
  1575. }
  1576. }
  1577. private class OVRControllerGamepadMac : OVRInput.OVRControllerBase
  1578. {
  1579. public OVRControllerGamepadMac()
  1580. {
  1581. this.controllerType = OVRInput.Controller.Gamepad;
  1582. this.initialized = OVRInput.OVRControllerGamepadMac.OVR_GamepadController_Initialize();
  1583. }
  1584. ~OVRControllerGamepadMac()
  1585. {
  1586. if (this.initialized)
  1587. {
  1588. OVRInput.OVRControllerGamepadMac.OVR_GamepadController_Destroy();
  1589. }
  1590. }
  1591. public override OVRInput.Controller Update()
  1592. {
  1593. if (!this.initialized)
  1594. {
  1595. return OVRInput.Controller.None;
  1596. }
  1597. OVRPlugin.ControllerState currentState = default(OVRPlugin.ControllerState);
  1598. bool flag = OVRInput.OVRControllerGamepadMac.OVR_GamepadController_Update();
  1599. if (flag)
  1600. {
  1601. currentState.ConnectedControllers = 16u;
  1602. }
  1603. if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(0))
  1604. {
  1605. currentState.Buttons |= 1u;
  1606. }
  1607. if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(1))
  1608. {
  1609. currentState.Buttons |= 2u;
  1610. }
  1611. if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(2))
  1612. {
  1613. currentState.Buttons |= 256u;
  1614. }
  1615. if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(3))
  1616. {
  1617. currentState.Buttons |= 512u;
  1618. }
  1619. if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(4))
  1620. {
  1621. currentState.Buttons |= 65536u;
  1622. }
  1623. if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(5))
  1624. {
  1625. currentState.Buttons |= 131072u;
  1626. }
  1627. if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(6))
  1628. {
  1629. currentState.Buttons |= 262144u;
  1630. }
  1631. if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(7))
  1632. {
  1633. currentState.Buttons |= 524288u;
  1634. }
  1635. if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(8))
  1636. {
  1637. currentState.Buttons |= 1048576u;
  1638. }
  1639. if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(9))
  1640. {
  1641. currentState.Buttons |= 2097152u;
  1642. }
  1643. if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(10))
  1644. {
  1645. currentState.Buttons |= 1024u;
  1646. }
  1647. if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(11))
  1648. {
  1649. currentState.Buttons |= 4u;
  1650. }
  1651. if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(12))
  1652. {
  1653. currentState.Buttons |= 2048u;
  1654. }
  1655. if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(13))
  1656. {
  1657. currentState.Buttons |= 8u;
  1658. }
  1659. currentState.LThumbstick.x = OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetAxis(0);
  1660. currentState.LThumbstick.y = OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetAxis(1);
  1661. currentState.RThumbstick.x = OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetAxis(2);
  1662. currentState.RThumbstick.y = OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetAxis(3);
  1663. currentState.LIndexTrigger = OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetAxis(4);
  1664. currentState.RIndexTrigger = OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetAxis(5);
  1665. if (currentState.LIndexTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1666. {
  1667. currentState.Buttons |= 268435456u;
  1668. }
  1669. if (currentState.LHandTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1670. {
  1671. currentState.Buttons |= 536870912u;
  1672. }
  1673. if (currentState.LThumbstick.y >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1674. {
  1675. currentState.Buttons |= 16u;
  1676. }
  1677. if (currentState.LThumbstick.y <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1678. {
  1679. currentState.Buttons |= 32u;
  1680. }
  1681. if (currentState.LThumbstick.x <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1682. {
  1683. currentState.Buttons |= 64u;
  1684. }
  1685. if (currentState.LThumbstick.x >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1686. {
  1687. currentState.Buttons |= 128u;
  1688. }
  1689. if (currentState.RIndexTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1690. {
  1691. currentState.Buttons |= 67108864u;
  1692. }
  1693. if (currentState.RHandTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1694. {
  1695. currentState.Buttons |= 134217728u;
  1696. }
  1697. if (currentState.RThumbstick.y >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1698. {
  1699. currentState.Buttons |= 4096u;
  1700. }
  1701. if (currentState.RThumbstick.y <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1702. {
  1703. currentState.Buttons |= 8192u;
  1704. }
  1705. if (currentState.RThumbstick.x <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1706. {
  1707. currentState.Buttons |= 16384u;
  1708. }
  1709. if (currentState.RThumbstick.x >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1710. {
  1711. currentState.Buttons |= 32768u;
  1712. }
  1713. this.previousState = this.currentState;
  1714. this.currentState = currentState;
  1715. return (OVRInput.Controller)(this.currentState.ConnectedControllers & (uint)this.controllerType);
  1716. }
  1717. public override void ConfigureButtonMap()
  1718. {
  1719. this.buttonMap.None = OVRInput.RawButton.None;
  1720. this.buttonMap.One = OVRInput.RawButton.A;
  1721. this.buttonMap.Two = OVRInput.RawButton.B;
  1722. this.buttonMap.Three = OVRInput.RawButton.X;
  1723. this.buttonMap.Four = OVRInput.RawButton.Y;
  1724. this.buttonMap.Start = OVRInput.RawButton.Start;
  1725. this.buttonMap.Back = OVRInput.RawButton.Back;
  1726. this.buttonMap.PrimaryShoulder = OVRInput.RawButton.LShoulder;
  1727. this.buttonMap.PrimaryIndexTrigger = OVRInput.RawButton.LIndexTrigger;
  1728. this.buttonMap.PrimaryHandTrigger = OVRInput.RawButton.None;
  1729. this.buttonMap.PrimaryThumbstick = OVRInput.RawButton.LThumbstick;
  1730. this.buttonMap.PrimaryThumbstickUp = OVRInput.RawButton.LThumbstickUp;
  1731. this.buttonMap.PrimaryThumbstickDown = OVRInput.RawButton.LThumbstickDown;
  1732. this.buttonMap.PrimaryThumbstickLeft = OVRInput.RawButton.LThumbstickLeft;
  1733. this.buttonMap.PrimaryThumbstickRight = OVRInput.RawButton.LThumbstickRight;
  1734. this.buttonMap.SecondaryShoulder = OVRInput.RawButton.RShoulder;
  1735. this.buttonMap.SecondaryIndexTrigger = OVRInput.RawButton.RIndexTrigger;
  1736. this.buttonMap.SecondaryHandTrigger = OVRInput.RawButton.None;
  1737. this.buttonMap.SecondaryThumbstick = OVRInput.RawButton.RThumbstick;
  1738. this.buttonMap.SecondaryThumbstickUp = OVRInput.RawButton.RThumbstickUp;
  1739. this.buttonMap.SecondaryThumbstickDown = OVRInput.RawButton.RThumbstickDown;
  1740. this.buttonMap.SecondaryThumbstickLeft = OVRInput.RawButton.RThumbstickLeft;
  1741. this.buttonMap.SecondaryThumbstickRight = OVRInput.RawButton.RThumbstickRight;
  1742. this.buttonMap.DpadUp = OVRInput.RawButton.DpadUp;
  1743. this.buttonMap.DpadDown = OVRInput.RawButton.DpadDown;
  1744. this.buttonMap.DpadLeft = OVRInput.RawButton.DpadLeft;
  1745. this.buttonMap.DpadRight = OVRInput.RawButton.DpadRight;
  1746. this.buttonMap.Up = OVRInput.RawButton.LThumbstickUp;
  1747. this.buttonMap.Down = OVRInput.RawButton.LThumbstickDown;
  1748. this.buttonMap.Left = OVRInput.RawButton.LThumbstickLeft;
  1749. this.buttonMap.Right = OVRInput.RawButton.LThumbstickRight;
  1750. }
  1751. public override void ConfigureTouchMap()
  1752. {
  1753. this.touchMap.None = OVRInput.RawTouch.None;
  1754. this.touchMap.One = OVRInput.RawTouch.None;
  1755. this.touchMap.Two = OVRInput.RawTouch.None;
  1756. this.touchMap.Three = OVRInput.RawTouch.None;
  1757. this.touchMap.Four = OVRInput.RawTouch.None;
  1758. this.touchMap.PrimaryIndexTrigger = OVRInput.RawTouch.None;
  1759. this.touchMap.PrimaryThumbstick = OVRInput.RawTouch.None;
  1760. this.touchMap.PrimaryThumbRest = OVRInput.RawTouch.None;
  1761. this.touchMap.SecondaryIndexTrigger = OVRInput.RawTouch.None;
  1762. this.touchMap.SecondaryThumbstick = OVRInput.RawTouch.None;
  1763. this.touchMap.SecondaryThumbRest = OVRInput.RawTouch.None;
  1764. }
  1765. public override void ConfigureNearTouchMap()
  1766. {
  1767. this.nearTouchMap.None = OVRInput.RawNearTouch.None;
  1768. this.nearTouchMap.PrimaryIndexTrigger = OVRInput.RawNearTouch.None;
  1769. this.nearTouchMap.PrimaryThumbButtons = OVRInput.RawNearTouch.None;
  1770. this.nearTouchMap.SecondaryIndexTrigger = OVRInput.RawNearTouch.None;
  1771. this.nearTouchMap.SecondaryThumbButtons = OVRInput.RawNearTouch.None;
  1772. }
  1773. public override void ConfigureAxis1DMap()
  1774. {
  1775. this.axis1DMap.None = OVRInput.RawAxis1D.None;
  1776. this.axis1DMap.PrimaryIndexTrigger = OVRInput.RawAxis1D.LIndexTrigger;
  1777. this.axis1DMap.PrimaryHandTrigger = OVRInput.RawAxis1D.None;
  1778. this.axis1DMap.SecondaryIndexTrigger = OVRInput.RawAxis1D.RIndexTrigger;
  1779. this.axis1DMap.SecondaryHandTrigger = OVRInput.RawAxis1D.None;
  1780. }
  1781. public override void ConfigureAxis2DMap()
  1782. {
  1783. this.axis2DMap.None = OVRInput.RawAxis2D.None;
  1784. this.axis2DMap.PrimaryThumbstick = OVRInput.RawAxis2D.LThumbstick;
  1785. this.axis2DMap.SecondaryThumbstick = OVRInput.RawAxis2D.RThumbstick;
  1786. }
  1787. public override void SetControllerVibration(float frequency, float amplitude)
  1788. {
  1789. int node = 0;
  1790. float frequency2 = frequency * 200f;
  1791. OVRInput.OVRControllerGamepadMac.OVR_GamepadController_SetVibration(node, amplitude, frequency2);
  1792. }
  1793. [DllImport("OVRGamepad", CallingConvention = CallingConvention.Cdecl)]
  1794. private static extern bool OVR_GamepadController_Initialize();
  1795. [DllImport("OVRGamepad", CallingConvention = CallingConvention.Cdecl)]
  1796. private static extern bool OVR_GamepadController_Destroy();
  1797. [DllImport("OVRGamepad", CallingConvention = CallingConvention.Cdecl)]
  1798. private static extern bool OVR_GamepadController_Update();
  1799. [DllImport("OVRGamepad", CallingConvention = CallingConvention.Cdecl)]
  1800. private static extern float OVR_GamepadController_GetAxis(int axis);
  1801. [DllImport("OVRGamepad", CallingConvention = CallingConvention.Cdecl)]
  1802. private static extern bool OVR_GamepadController_GetButton(int button);
  1803. [DllImport("OVRGamepad", CallingConvention = CallingConvention.Cdecl)]
  1804. private static extern bool OVR_GamepadController_SetVibration(int node, float strength, float frequency);
  1805. private bool initialized;
  1806. private const string DllName = "OVRGamepad";
  1807. private enum AxisGPC
  1808. {
  1809. None = -1,
  1810. LeftXAxis,
  1811. LeftYAxis,
  1812. RightXAxis,
  1813. RightYAxis,
  1814. LeftTrigger,
  1815. RightTrigger,
  1816. DPad_X_Axis,
  1817. DPad_Y_Axis,
  1818. Max
  1819. }
  1820. public enum ButtonGPC
  1821. {
  1822. None = -1,
  1823. A,
  1824. B,
  1825. X,
  1826. Y,
  1827. Up,
  1828. Down,
  1829. Left,
  1830. Right,
  1831. Start,
  1832. Back,
  1833. LStick,
  1834. RStick,
  1835. LeftShoulder,
  1836. RightShoulder,
  1837. Max
  1838. }
  1839. }
  1840. private class OVRControllerGamepadAndroid : OVRInput.OVRControllerBase
  1841. {
  1842. public OVRControllerGamepadAndroid()
  1843. {
  1844. this.controllerType = OVRInput.Controller.Gamepad;
  1845. }
  1846. private bool ShouldUpdate()
  1847. {
  1848. if (Time.realtimeSinceStartup - this.joystickCheckTime > this.joystickCheckInterval)
  1849. {
  1850. this.joystickCheckTime = Time.realtimeSinceStartup;
  1851. this.joystickDetected = false;
  1852. string[] joystickNames = Input.GetJoystickNames();
  1853. for (int i = 0; i < joystickNames.Length; i++)
  1854. {
  1855. if (joystickNames[i] != string.Empty)
  1856. {
  1857. this.joystickDetected = true;
  1858. break;
  1859. }
  1860. }
  1861. }
  1862. return this.joystickDetected;
  1863. }
  1864. public override OVRInput.Controller Update()
  1865. {
  1866. if (!this.ShouldUpdate())
  1867. {
  1868. return OVRInput.Controller.None;
  1869. }
  1870. OVRPlugin.ControllerState currentState = default(OVRPlugin.ControllerState);
  1871. currentState.ConnectedControllers = 16u;
  1872. if (Input.GetKey(OVRInput.OVRControllerGamepadAndroid.AndroidButtonNames.A))
  1873. {
  1874. currentState.Buttons |= 1u;
  1875. }
  1876. if (Input.GetKey(OVRInput.OVRControllerGamepadAndroid.AndroidButtonNames.B))
  1877. {
  1878. currentState.Buttons |= 2u;
  1879. }
  1880. if (Input.GetKey(OVRInput.OVRControllerGamepadAndroid.AndroidButtonNames.X))
  1881. {
  1882. currentState.Buttons |= 256u;
  1883. }
  1884. if (Input.GetKey(OVRInput.OVRControllerGamepadAndroid.AndroidButtonNames.Y))
  1885. {
  1886. currentState.Buttons |= 512u;
  1887. }
  1888. if (Input.GetKey(OVRInput.OVRControllerGamepadAndroid.AndroidButtonNames.Start))
  1889. {
  1890. currentState.Buttons |= 1048576u;
  1891. }
  1892. if (Input.GetKey(OVRInput.OVRControllerGamepadAndroid.AndroidButtonNames.Back) || Input.GetKey(KeyCode.Escape))
  1893. {
  1894. currentState.Buttons |= 2097152u;
  1895. }
  1896. if (Input.GetKey(OVRInput.OVRControllerGamepadAndroid.AndroidButtonNames.LThumbstick))
  1897. {
  1898. currentState.Buttons |= 1024u;
  1899. }
  1900. if (Input.GetKey(OVRInput.OVRControllerGamepadAndroid.AndroidButtonNames.RThumbstick))
  1901. {
  1902. currentState.Buttons |= 4u;
  1903. }
  1904. if (Input.GetKey(OVRInput.OVRControllerGamepadAndroid.AndroidButtonNames.LShoulder))
  1905. {
  1906. currentState.Buttons |= 2048u;
  1907. }
  1908. if (Input.GetKey(OVRInput.OVRControllerGamepadAndroid.AndroidButtonNames.RShoulder))
  1909. {
  1910. currentState.Buttons |= 8u;
  1911. }
  1912. currentState.LThumbstick.x = Input.GetAxisRaw(OVRInput.OVRControllerGamepadAndroid.AndroidAxisNames.LThumbstickX);
  1913. currentState.LThumbstick.y = Input.GetAxisRaw(OVRInput.OVRControllerGamepadAndroid.AndroidAxisNames.LThumbstickY);
  1914. currentState.RThumbstick.x = Input.GetAxisRaw(OVRInput.OVRControllerGamepadAndroid.AndroidAxisNames.RThumbstickX);
  1915. currentState.RThumbstick.y = Input.GetAxisRaw(OVRInput.OVRControllerGamepadAndroid.AndroidAxisNames.RThumbstickY);
  1916. currentState.LIndexTrigger = Input.GetAxisRaw(OVRInput.OVRControllerGamepadAndroid.AndroidAxisNames.LIndexTrigger);
  1917. currentState.RIndexTrigger = Input.GetAxisRaw(OVRInput.OVRControllerGamepadAndroid.AndroidAxisNames.RIndexTrigger);
  1918. if (currentState.LIndexTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1919. {
  1920. currentState.Buttons |= 268435456u;
  1921. }
  1922. if (currentState.LHandTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1923. {
  1924. currentState.Buttons |= 536870912u;
  1925. }
  1926. if (currentState.LThumbstick.y >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1927. {
  1928. currentState.Buttons |= 16u;
  1929. }
  1930. if (currentState.LThumbstick.y <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1931. {
  1932. currentState.Buttons |= 32u;
  1933. }
  1934. if (currentState.LThumbstick.x <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1935. {
  1936. currentState.Buttons |= 64u;
  1937. }
  1938. if (currentState.LThumbstick.x >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1939. {
  1940. currentState.Buttons |= 128u;
  1941. }
  1942. if (currentState.RIndexTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1943. {
  1944. currentState.Buttons |= 67108864u;
  1945. }
  1946. if (currentState.RHandTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1947. {
  1948. currentState.Buttons |= 134217728u;
  1949. }
  1950. if (currentState.RThumbstick.y >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1951. {
  1952. currentState.Buttons |= 4096u;
  1953. }
  1954. if (currentState.RThumbstick.y <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1955. {
  1956. currentState.Buttons |= 8192u;
  1957. }
  1958. if (currentState.RThumbstick.x <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1959. {
  1960. currentState.Buttons |= 16384u;
  1961. }
  1962. if (currentState.RThumbstick.x >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1963. {
  1964. currentState.Buttons |= 32768u;
  1965. }
  1966. float axisRaw = Input.GetAxisRaw(OVRInput.OVRControllerGamepadAndroid.AndroidAxisNames.DpadX);
  1967. float axisRaw2 = Input.GetAxisRaw(OVRInput.OVRControllerGamepadAndroid.AndroidAxisNames.DpadY);
  1968. if (axisRaw <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1969. {
  1970. currentState.Buttons |= 262144u;
  1971. }
  1972. if (axisRaw >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1973. {
  1974. currentState.Buttons |= 524288u;
  1975. }
  1976. if (axisRaw2 <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1977. {
  1978. currentState.Buttons |= 131072u;
  1979. }
  1980. if (axisRaw2 >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
  1981. {
  1982. currentState.Buttons |= 65536u;
  1983. }
  1984. this.previousState = this.currentState;
  1985. this.currentState = currentState;
  1986. return (OVRInput.Controller)(this.currentState.ConnectedControllers & (uint)this.controllerType);
  1987. }
  1988. public override void ConfigureButtonMap()
  1989. {
  1990. this.buttonMap.None = OVRInput.RawButton.None;
  1991. this.buttonMap.One = OVRInput.RawButton.A;
  1992. this.buttonMap.Two = OVRInput.RawButton.B;
  1993. this.buttonMap.Three = OVRInput.RawButton.X;
  1994. this.buttonMap.Four = OVRInput.RawButton.Y;
  1995. this.buttonMap.Start = OVRInput.RawButton.Start;
  1996. this.buttonMap.Back = OVRInput.RawButton.Back;
  1997. this.buttonMap.PrimaryShoulder = OVRInput.RawButton.LShoulder;
  1998. this.buttonMap.PrimaryIndexTrigger = OVRInput.RawButton.LIndexTrigger;
  1999. this.buttonMap.PrimaryHandTrigger = OVRInput.RawButton.None;
  2000. this.buttonMap.PrimaryThumbstick = OVRInput.RawButton.LThumbstick;
  2001. this.buttonMap.PrimaryThumbstickUp = OVRInput.RawButton.LThumbstickUp;
  2002. this.buttonMap.PrimaryThumbstickDown = OVRInput.RawButton.LThumbstickDown;
  2003. this.buttonMap.PrimaryThumbstickLeft = OVRInput.RawButton.LThumbstickLeft;
  2004. this.buttonMap.PrimaryThumbstickRight = OVRInput.RawButton.LThumbstickRight;
  2005. this.buttonMap.SecondaryShoulder = OVRInput.RawButton.RShoulder;
  2006. this.buttonMap.SecondaryIndexTrigger = OVRInput.RawButton.RIndexTrigger;
  2007. this.buttonMap.SecondaryHandTrigger = OVRInput.RawButton.None;
  2008. this.buttonMap.SecondaryThumbstick = OVRInput.RawButton.RThumbstick;
  2009. this.buttonMap.SecondaryThumbstickUp = OVRInput.RawButton.RThumbstickUp;
  2010. this.buttonMap.SecondaryThumbstickDown = OVRInput.RawButton.RThumbstickDown;
  2011. this.buttonMap.SecondaryThumbstickLeft = OVRInput.RawButton.RThumbstickLeft;
  2012. this.buttonMap.SecondaryThumbstickRight = OVRInput.RawButton.RThumbstickRight;
  2013. this.buttonMap.DpadUp = OVRInput.RawButton.DpadUp;
  2014. this.buttonMap.DpadDown = OVRInput.RawButton.DpadDown;
  2015. this.buttonMap.DpadLeft = OVRInput.RawButton.DpadLeft;
  2016. this.buttonMap.DpadRight = OVRInput.RawButton.DpadRight;
  2017. this.buttonMap.Up = OVRInput.RawButton.LThumbstickUp;
  2018. this.buttonMap.Down = OVRInput.RawButton.LThumbstickDown;
  2019. this.buttonMap.Left = OVRInput.RawButton.LThumbstickLeft;
  2020. this.buttonMap.Right = OVRInput.RawButton.LThumbstickRight;
  2021. }
  2022. public override void ConfigureTouchMap()
  2023. {
  2024. this.touchMap.None = OVRInput.RawTouch.None;
  2025. this.touchMap.One = OVRInput.RawTouch.None;
  2026. this.touchMap.Two = OVRInput.RawTouch.None;
  2027. this.touchMap.Three = OVRInput.RawTouch.None;
  2028. this.touchMap.Four = OVRInput.RawTouch.None;
  2029. this.touchMap.PrimaryIndexTrigger = OVRInput.RawTouch.None;
  2030. this.touchMap.PrimaryThumbstick = OVRInput.RawTouch.None;
  2031. this.touchMap.PrimaryThumbRest = OVRInput.RawTouch.None;
  2032. this.touchMap.SecondaryIndexTrigger = OVRInput.RawTouch.None;
  2033. this.touchMap.SecondaryThumbstick = OVRInput.RawTouch.None;
  2034. this.touchMap.SecondaryThumbRest = OVRInput.RawTouch.None;
  2035. }
  2036. public override void ConfigureNearTouchMap()
  2037. {
  2038. this.nearTouchMap.None = OVRInput.RawNearTouch.None;
  2039. this.nearTouchMap.PrimaryIndexTrigger = OVRInput.RawNearTouch.None;
  2040. this.nearTouchMap.PrimaryThumbButtons = OVRInput.RawNearTouch.None;
  2041. this.nearTouchMap.SecondaryIndexTrigger = OVRInput.RawNearTouch.None;
  2042. this.nearTouchMap.SecondaryThumbButtons = OVRInput.RawNearTouch.None;
  2043. }
  2044. public override void ConfigureAxis1DMap()
  2045. {
  2046. this.axis1DMap.None = OVRInput.RawAxis1D.None;
  2047. this.axis1DMap.PrimaryIndexTrigger = OVRInput.RawAxis1D.LIndexTrigger;
  2048. this.axis1DMap.PrimaryHandTrigger = OVRInput.RawAxis1D.None;
  2049. this.axis1DMap.SecondaryIndexTrigger = OVRInput.RawAxis1D.RIndexTrigger;
  2050. this.axis1DMap.SecondaryHandTrigger = OVRInput.RawAxis1D.None;
  2051. }
  2052. public override void ConfigureAxis2DMap()
  2053. {
  2054. this.axis2DMap.None = OVRInput.RawAxis2D.None;
  2055. this.axis2DMap.PrimaryThumbstick = OVRInput.RawAxis2D.LThumbstick;
  2056. this.axis2DMap.SecondaryThumbstick = OVRInput.RawAxis2D.RThumbstick;
  2057. }
  2058. public override void SetControllerVibration(float frequency, float amplitude)
  2059. {
  2060. }
  2061. private bool joystickDetected;
  2062. private float joystickCheckInterval = 1f;
  2063. private float joystickCheckTime;
  2064. private static class AndroidButtonNames
  2065. {
  2066. public static readonly KeyCode A = KeyCode.JoystickButton0;
  2067. public static readonly KeyCode B = KeyCode.JoystickButton1;
  2068. public static readonly KeyCode X = KeyCode.JoystickButton2;
  2069. public static readonly KeyCode Y = KeyCode.JoystickButton3;
  2070. public static readonly KeyCode Start = KeyCode.JoystickButton10;
  2071. public static readonly KeyCode Back = KeyCode.JoystickButton11;
  2072. public static readonly KeyCode LThumbstick = KeyCode.JoystickButton8;
  2073. public static readonly KeyCode RThumbstick = KeyCode.JoystickButton9;
  2074. public static readonly KeyCode LShoulder = KeyCode.JoystickButton4;
  2075. public static readonly KeyCode RShoulder = KeyCode.JoystickButton5;
  2076. }
  2077. private static class AndroidAxisNames
  2078. {
  2079. public static readonly string LThumbstickX = "Oculus_GearVR_LThumbstickX";
  2080. public static readonly string LThumbstickY = "Oculus_GearVR_LThumbstickY";
  2081. public static readonly string RThumbstickX = "Oculus_GearVR_RThumbstickX";
  2082. public static readonly string RThumbstickY = "Oculus_GearVR_RThumbstickY";
  2083. public static readonly string LIndexTrigger = "Oculus_GearVR_LIndexTrigger";
  2084. public static readonly string RIndexTrigger = "Oculus_GearVR_RIndexTrigger";
  2085. public static readonly string DpadX = "Oculus_GearVR_DpadX";
  2086. public static readonly string DpadY = "Oculus_GearVR_DpadY";
  2087. }
  2088. }
  2089. private class OVRControllerTouchpad : OVRInput.OVRControllerBase
  2090. {
  2091. public OVRControllerTouchpad()
  2092. {
  2093. this.controllerType = OVRInput.Controller.Touchpad;
  2094. }
  2095. public override OVRInput.Controller Update()
  2096. {
  2097. OVRPlugin.ControllerState currentState = default(OVRPlugin.ControllerState);
  2098. if (Input.mousePresent)
  2099. {
  2100. currentState.ConnectedControllers = 134217728u;
  2101. }
  2102. if (Input.GetMouseButtonDown(0))
  2103. {
  2104. this.moveAmountMouse = Input.mousePosition;
  2105. }
  2106. if (Input.GetMouseButtonUp(0))
  2107. {
  2108. this.moveAmountMouse -= Input.mousePosition;
  2109. Vector3 vector = this.moveAmountMouse;
  2110. if (vector.magnitude < this.minMovMagnitudeMouse)
  2111. {
  2112. currentState.Buttons |= 1u;
  2113. }
  2114. else
  2115. {
  2116. vector.Normalize();
  2117. if (Mathf.Abs(vector.x) > Mathf.Abs(vector.y))
  2118. {
  2119. if (vector.x > 0f)
  2120. {
  2121. currentState.Buttons |= 524288u;
  2122. }
  2123. else
  2124. {
  2125. currentState.Buttons |= 262144u;
  2126. }
  2127. }
  2128. else if (vector.y > 0f)
  2129. {
  2130. currentState.Buttons |= 131072u;
  2131. }
  2132. else
  2133. {
  2134. currentState.Buttons |= 65536u;
  2135. }
  2136. }
  2137. }
  2138. if (Input.GetKey(KeyCode.Escape))
  2139. {
  2140. currentState.Buttons |= 2u;
  2141. }
  2142. this.previousState = this.currentState;
  2143. this.currentState = currentState;
  2144. return (OVRInput.Controller)(this.currentState.ConnectedControllers & (uint)this.controllerType);
  2145. }
  2146. public override void ConfigureButtonMap()
  2147. {
  2148. this.buttonMap.None = OVRInput.RawButton.None;
  2149. this.buttonMap.One = OVRInput.RawButton.A;
  2150. this.buttonMap.Two = OVRInput.RawButton.B;
  2151. this.buttonMap.Three = OVRInput.RawButton.None;
  2152. this.buttonMap.Four = OVRInput.RawButton.None;
  2153. this.buttonMap.Start = OVRInput.RawButton.None;
  2154. this.buttonMap.Back = OVRInput.RawButton.None;
  2155. this.buttonMap.PrimaryShoulder = OVRInput.RawButton.None;
  2156. this.buttonMap.PrimaryIndexTrigger = OVRInput.RawButton.None;
  2157. this.buttonMap.PrimaryHandTrigger = OVRInput.RawButton.None;
  2158. this.buttonMap.PrimaryThumbstick = OVRInput.RawButton.None;
  2159. this.buttonMap.PrimaryThumbstickUp = OVRInput.RawButton.None;
  2160. this.buttonMap.PrimaryThumbstickDown = OVRInput.RawButton.None;
  2161. this.buttonMap.PrimaryThumbstickLeft = OVRInput.RawButton.None;
  2162. this.buttonMap.PrimaryThumbstickRight = OVRInput.RawButton.None;
  2163. this.buttonMap.SecondaryShoulder = OVRInput.RawButton.None;
  2164. this.buttonMap.SecondaryIndexTrigger = OVRInput.RawButton.None;
  2165. this.buttonMap.SecondaryHandTrigger = OVRInput.RawButton.None;
  2166. this.buttonMap.SecondaryThumbstick = OVRInput.RawButton.None;
  2167. this.buttonMap.SecondaryThumbstickUp = OVRInput.RawButton.None;
  2168. this.buttonMap.SecondaryThumbstickDown = OVRInput.RawButton.None;
  2169. this.buttonMap.SecondaryThumbstickLeft = OVRInput.RawButton.None;
  2170. this.buttonMap.SecondaryThumbstickRight = OVRInput.RawButton.None;
  2171. this.buttonMap.DpadUp = OVRInput.RawButton.DpadUp;
  2172. this.buttonMap.DpadDown = OVRInput.RawButton.DpadDown;
  2173. this.buttonMap.DpadLeft = OVRInput.RawButton.DpadLeft;
  2174. this.buttonMap.DpadRight = OVRInput.RawButton.DpadRight;
  2175. this.buttonMap.Up = OVRInput.RawButton.DpadUp;
  2176. this.buttonMap.Down = OVRInput.RawButton.DpadDown;
  2177. this.buttonMap.Left = OVRInput.RawButton.DpadLeft;
  2178. this.buttonMap.Right = OVRInput.RawButton.DpadRight;
  2179. }
  2180. public override void ConfigureTouchMap()
  2181. {
  2182. this.touchMap.None = OVRInput.RawTouch.None;
  2183. this.touchMap.One = OVRInput.RawTouch.None;
  2184. this.touchMap.Two = OVRInput.RawTouch.None;
  2185. this.touchMap.Three = OVRInput.RawTouch.None;
  2186. this.touchMap.Four = OVRInput.RawTouch.None;
  2187. this.touchMap.PrimaryIndexTrigger = OVRInput.RawTouch.None;
  2188. this.touchMap.PrimaryThumbstick = OVRInput.RawTouch.None;
  2189. this.touchMap.PrimaryThumbRest = OVRInput.RawTouch.None;
  2190. this.touchMap.SecondaryIndexTrigger = OVRInput.RawTouch.None;
  2191. this.touchMap.SecondaryThumbstick = OVRInput.RawTouch.None;
  2192. this.touchMap.SecondaryThumbRest = OVRInput.RawTouch.None;
  2193. }
  2194. public override void ConfigureNearTouchMap()
  2195. {
  2196. this.nearTouchMap.None = OVRInput.RawNearTouch.None;
  2197. this.nearTouchMap.PrimaryIndexTrigger = OVRInput.RawNearTouch.None;
  2198. this.nearTouchMap.PrimaryThumbButtons = OVRInput.RawNearTouch.None;
  2199. this.nearTouchMap.SecondaryIndexTrigger = OVRInput.RawNearTouch.None;
  2200. this.nearTouchMap.SecondaryThumbButtons = OVRInput.RawNearTouch.None;
  2201. }
  2202. public override void ConfigureAxis1DMap()
  2203. {
  2204. this.axis1DMap.None = OVRInput.RawAxis1D.None;
  2205. this.axis1DMap.PrimaryIndexTrigger = OVRInput.RawAxis1D.None;
  2206. this.axis1DMap.PrimaryHandTrigger = OVRInput.RawAxis1D.None;
  2207. this.axis1DMap.SecondaryIndexTrigger = OVRInput.RawAxis1D.None;
  2208. this.axis1DMap.SecondaryHandTrigger = OVRInput.RawAxis1D.None;
  2209. }
  2210. public override void ConfigureAxis2DMap()
  2211. {
  2212. this.axis2DMap.None = OVRInput.RawAxis2D.None;
  2213. this.axis2DMap.PrimaryThumbstick = OVRInput.RawAxis2D.None;
  2214. this.axis2DMap.SecondaryThumbstick = OVRInput.RawAxis2D.None;
  2215. }
  2216. private Vector3 moveAmountMouse;
  2217. private float minMovMagnitudeMouse = 25f;
  2218. }
  2219. }