12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462 |
- using System;
- using System.Collections.Generic;
- using System.Runtime.InteropServices;
- using UnityEngine;
- public static class OVRInput
- {
- static OVRInput()
- {
- OVRInput.controllers = new List<OVRInput.OVRControllerBase>
- {
- new OVRInput.OVRControllerGamepadPC(),
- new OVRInput.OVRControllerTouch(),
- new OVRInput.OVRControllerLTouch(),
- new OVRInput.OVRControllerRTouch(),
- new OVRInput.OVRControllerRemote()
- };
- }
- private static bool pluginSupportsActiveController
- {
- get
- {
- if (!OVRInput._pluginSupportsActiveControllerCached)
- {
- bool flag = true;
- OVRInput._pluginSupportsActiveController = (flag && OVRPlugin.version >= OVRInput._pluginSupportsActiveControllerMinVersion);
- OVRInput._pluginSupportsActiveControllerCached = true;
- }
- return OVRInput._pluginSupportsActiveController;
- }
- }
- public static void Update()
- {
- OVRInput.connectedControllerTypes = OVRInput.Controller.None;
- OVRInput.useFixedPoses = false;
- OVRInput.fixedUpdateCount = 0;
- for (int i = 0; i < OVRInput.controllers.Count; i++)
- {
- OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
- OVRInput.connectedControllerTypes |= ovrcontrollerBase.Update();
- if ((OVRInput.connectedControllerTypes & ovrcontrollerBase.controllerType) != OVRInput.Controller.None && (OVRInput.Get(OVRInput.RawButton.Any, ovrcontrollerBase.controllerType) || OVRInput.Get(OVRInput.RawTouch.Any, ovrcontrollerBase.controllerType)))
- {
- OVRInput.activeControllerType = ovrcontrollerBase.controllerType;
- }
- }
- if (OVRInput.activeControllerType == OVRInput.Controller.LTouch || OVRInput.activeControllerType == OVRInput.Controller.RTouch)
- {
- OVRInput.activeControllerType = OVRInput.Controller.Touch;
- }
- if ((OVRInput.connectedControllerTypes & OVRInput.activeControllerType) == OVRInput.Controller.None)
- {
- OVRInput.activeControllerType = OVRInput.Controller.None;
- }
- if (OVRInput.pluginSupportsActiveController)
- {
- OVRInput.connectedControllerTypes = (OVRInput.Controller)OVRPlugin.GetConnectedControllers();
- OVRInput.activeControllerType = (OVRInput.Controller)OVRPlugin.GetActiveController();
- }
- }
- public static void FixedUpdate()
- {
- OVRInput.useFixedPoses = true;
- double predictionSeconds = (double)OVRInput.fixedUpdateCount * (double)Time.fixedDeltaTime / (double)Mathf.Max(Time.timeScale, 1E-06f);
- OVRInput.fixedUpdateCount++;
- OVRPlugin.UpdateNodePhysicsPoses(0, predictionSeconds);
- }
- public static bool GetControllerOrientationTracked(OVRInput.Controller controllerType)
- {
- if (controllerType != OVRInput.Controller.LTouch)
- {
- return controllerType == OVRInput.Controller.RTouch && OVRPlugin.GetNodeOrientationTracked(OVRPlugin.Node.HandRight);
- }
- return OVRPlugin.GetNodeOrientationTracked(OVRPlugin.Node.HandLeft);
- }
- public static bool GetControllerPositionTracked(OVRInput.Controller controllerType)
- {
- if (controllerType != OVRInput.Controller.LTouch)
- {
- return controllerType == OVRInput.Controller.RTouch && OVRPlugin.GetNodePositionTracked(OVRPlugin.Node.HandRight);
- }
- return OVRPlugin.GetNodePositionTracked(OVRPlugin.Node.HandLeft);
- }
- public static Vector3 GetLocalControllerPosition(OVRInput.Controller controllerType)
- {
- if (controllerType == OVRInput.Controller.LTouch)
- {
- return OVRPlugin.GetNodePose(OVRPlugin.Node.HandLeft, OVRInput.useFixedPoses).ToOVRPose().position;
- }
- if (controllerType != OVRInput.Controller.RTouch)
- {
- return Vector3.zero;
- }
- return OVRPlugin.GetNodePose(OVRPlugin.Node.HandRight, OVRInput.useFixedPoses).ToOVRPose().position;
- }
- public static Vector3 GetLocalControllerVelocity(OVRInput.Controller controllerType)
- {
- if (controllerType == OVRInput.Controller.LTouch)
- {
- return OVRPlugin.GetNodeVelocity(OVRPlugin.Node.HandLeft, OVRInput.useFixedPoses).ToOVRPose().position;
- }
- if (controllerType != OVRInput.Controller.RTouch)
- {
- return Vector3.zero;
- }
- return OVRPlugin.GetNodeVelocity(OVRPlugin.Node.HandRight, OVRInput.useFixedPoses).ToOVRPose().position;
- }
- public static Vector3 GetLocalControllerAcceleration(OVRInput.Controller controllerType)
- {
- if (controllerType == OVRInput.Controller.LTouch)
- {
- return OVRPlugin.GetNodeAcceleration(OVRPlugin.Node.HandLeft, OVRInput.useFixedPoses).ToOVRPose().position;
- }
- if (controllerType != OVRInput.Controller.RTouch)
- {
- return Vector3.zero;
- }
- return OVRPlugin.GetNodeAcceleration(OVRPlugin.Node.HandRight, OVRInput.useFixedPoses).ToOVRPose().position;
- }
- public static Quaternion GetLocalControllerRotation(OVRInput.Controller controllerType)
- {
- if (controllerType == OVRInput.Controller.LTouch)
- {
- return OVRPlugin.GetNodePose(OVRPlugin.Node.HandLeft, OVRInput.useFixedPoses).ToOVRPose().orientation;
- }
- if (controllerType != OVRInput.Controller.RTouch)
- {
- return Quaternion.identity;
- }
- return OVRPlugin.GetNodePose(OVRPlugin.Node.HandRight, OVRInput.useFixedPoses).ToOVRPose().orientation;
- }
- public static Quaternion GetLocalControllerAngularVelocity(OVRInput.Controller controllerType)
- {
- if (controllerType == OVRInput.Controller.LTouch)
- {
- return OVRPlugin.GetNodeVelocity(OVRPlugin.Node.HandLeft, OVRInput.useFixedPoses).ToOVRPose().orientation;
- }
- if (controllerType != OVRInput.Controller.RTouch)
- {
- return Quaternion.identity;
- }
- return OVRPlugin.GetNodeVelocity(OVRPlugin.Node.HandRight, OVRInput.useFixedPoses).ToOVRPose().orientation;
- }
- public static Quaternion GetLocalControllerAngularAcceleration(OVRInput.Controller controllerType)
- {
- if (controllerType == OVRInput.Controller.LTouch)
- {
- return OVRPlugin.GetNodeAcceleration(OVRPlugin.Node.HandLeft, OVRInput.useFixedPoses).ToOVRPose().orientation;
- }
- if (controllerType != OVRInput.Controller.RTouch)
- {
- return Quaternion.identity;
- }
- return OVRPlugin.GetNodeAcceleration(OVRPlugin.Node.HandRight, OVRInput.useFixedPoses).ToOVRPose().orientation;
- }
- public static bool Get(OVRInput.Button virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedButton(virtualMask, OVRInput.RawButton.None, controllerMask);
- }
- public static bool Get(OVRInput.RawButton rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedButton(OVRInput.Button.None, rawMask, controllerMask);
- }
- private static bool GetResolvedButton(OVRInput.Button virtualMask, OVRInput.RawButton rawMask, OVRInput.Controller controllerMask)
- {
- if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
- {
- controllerMask |= OVRInput.activeControllerType;
- }
- for (int i = 0; i < OVRInput.controllers.Count; i++)
- {
- OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
- if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
- {
- OVRInput.RawButton rawButton = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
- if ((ovrcontrollerBase.currentState.Buttons & (uint)rawButton) != 0u)
- {
- return true;
- }
- }
- }
- return false;
- }
- public static bool GetDown(OVRInput.Button virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedButtonDown(virtualMask, OVRInput.RawButton.None, controllerMask);
- }
- public static bool GetDown(OVRInput.RawButton rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedButtonDown(OVRInput.Button.None, rawMask, controllerMask);
- }
- private static bool GetResolvedButtonDown(OVRInput.Button virtualMask, OVRInput.RawButton rawMask, OVRInput.Controller controllerMask)
- {
- bool result = false;
- if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
- {
- controllerMask |= OVRInput.activeControllerType;
- }
- for (int i = 0; i < OVRInput.controllers.Count; i++)
- {
- OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
- if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
- {
- OVRInput.RawButton rawButton = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
- if ((ovrcontrollerBase.previousState.Buttons & (uint)rawButton) != 0u)
- {
- return false;
- }
- if ((ovrcontrollerBase.currentState.Buttons & (uint)rawButton) != 0u && (ovrcontrollerBase.previousState.Buttons & (uint)rawButton) == 0u)
- {
- result = true;
- }
- }
- }
- return result;
- }
- public static bool GetUp(OVRInput.Button virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedButtonUp(virtualMask, OVRInput.RawButton.None, controllerMask);
- }
- public static bool GetUp(OVRInput.RawButton rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedButtonUp(OVRInput.Button.None, rawMask, controllerMask);
- }
- private static bool GetResolvedButtonUp(OVRInput.Button virtualMask, OVRInput.RawButton rawMask, OVRInput.Controller controllerMask)
- {
- bool result = false;
- if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
- {
- controllerMask |= OVRInput.activeControllerType;
- }
- for (int i = 0; i < OVRInput.controllers.Count; i++)
- {
- OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
- if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
- {
- OVRInput.RawButton rawButton = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
- if ((ovrcontrollerBase.currentState.Buttons & (uint)rawButton) != 0u)
- {
- return false;
- }
- if ((ovrcontrollerBase.currentState.Buttons & (uint)rawButton) == 0u && (ovrcontrollerBase.previousState.Buttons & (uint)rawButton) != 0u)
- {
- result = true;
- }
- }
- }
- return result;
- }
- public static bool Get(OVRInput.Touch virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedTouch(virtualMask, OVRInput.RawTouch.None, controllerMask);
- }
- public static bool Get(OVRInput.RawTouch rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedTouch(OVRInput.Touch.None, rawMask, controllerMask);
- }
- private static bool GetResolvedTouch(OVRInput.Touch virtualMask, OVRInput.RawTouch rawMask, OVRInput.Controller controllerMask)
- {
- if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
- {
- controllerMask |= OVRInput.activeControllerType;
- }
- for (int i = 0; i < OVRInput.controllers.Count; i++)
- {
- OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
- if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
- {
- OVRInput.RawTouch rawTouch = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
- if ((ovrcontrollerBase.currentState.Touches & (uint)rawTouch) != 0u)
- {
- return true;
- }
- }
- }
- return false;
- }
- public static bool GetDown(OVRInput.Touch virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedTouchDown(virtualMask, OVRInput.RawTouch.None, controllerMask);
- }
- public static bool GetDown(OVRInput.RawTouch rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedTouchDown(OVRInput.Touch.None, rawMask, controllerMask);
- }
- private static bool GetResolvedTouchDown(OVRInput.Touch virtualMask, OVRInput.RawTouch rawMask, OVRInput.Controller controllerMask)
- {
- bool result = false;
- if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
- {
- controllerMask |= OVRInput.activeControllerType;
- }
- for (int i = 0; i < OVRInput.controllers.Count; i++)
- {
- OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
- if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
- {
- OVRInput.RawTouch rawTouch = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
- if ((ovrcontrollerBase.previousState.Touches & (uint)rawTouch) != 0u)
- {
- return false;
- }
- if ((ovrcontrollerBase.currentState.Touches & (uint)rawTouch) != 0u && (ovrcontrollerBase.previousState.Touches & (uint)rawTouch) == 0u)
- {
- result = true;
- }
- }
- }
- return result;
- }
- public static bool GetUp(OVRInput.Touch virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedTouchUp(virtualMask, OVRInput.RawTouch.None, controllerMask);
- }
- public static bool GetUp(OVRInput.RawTouch rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedTouchUp(OVRInput.Touch.None, rawMask, controllerMask);
- }
- private static bool GetResolvedTouchUp(OVRInput.Touch virtualMask, OVRInput.RawTouch rawMask, OVRInput.Controller controllerMask)
- {
- bool result = false;
- if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
- {
- controllerMask |= OVRInput.activeControllerType;
- }
- for (int i = 0; i < OVRInput.controllers.Count; i++)
- {
- OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
- if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
- {
- OVRInput.RawTouch rawTouch = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
- if ((ovrcontrollerBase.currentState.Touches & (uint)rawTouch) != 0u)
- {
- return false;
- }
- if ((ovrcontrollerBase.currentState.Touches & (uint)rawTouch) == 0u && (ovrcontrollerBase.previousState.Touches & (uint)rawTouch) != 0u)
- {
- result = true;
- }
- }
- }
- return result;
- }
- public static bool Get(OVRInput.NearTouch virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedNearTouch(virtualMask, OVRInput.RawNearTouch.None, controllerMask);
- }
- public static bool Get(OVRInput.RawNearTouch rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedNearTouch(OVRInput.NearTouch.None, rawMask, controllerMask);
- }
- private static bool GetResolvedNearTouch(OVRInput.NearTouch virtualMask, OVRInput.RawNearTouch rawMask, OVRInput.Controller controllerMask)
- {
- if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
- {
- controllerMask |= OVRInput.activeControllerType;
- }
- for (int i = 0; i < OVRInput.controllers.Count; i++)
- {
- OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
- if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
- {
- OVRInput.RawNearTouch rawNearTouch = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
- if ((ovrcontrollerBase.currentState.NearTouches & (uint)rawNearTouch) != 0u)
- {
- return true;
- }
- }
- }
- return false;
- }
- public static bool GetDown(OVRInput.NearTouch virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedNearTouchDown(virtualMask, OVRInput.RawNearTouch.None, controllerMask);
- }
- public static bool GetDown(OVRInput.RawNearTouch rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedNearTouchDown(OVRInput.NearTouch.None, rawMask, controllerMask);
- }
- private static bool GetResolvedNearTouchDown(OVRInput.NearTouch virtualMask, OVRInput.RawNearTouch rawMask, OVRInput.Controller controllerMask)
- {
- bool result = false;
- if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
- {
- controllerMask |= OVRInput.activeControllerType;
- }
- for (int i = 0; i < OVRInput.controllers.Count; i++)
- {
- OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
- if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
- {
- OVRInput.RawNearTouch rawNearTouch = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
- if ((ovrcontrollerBase.previousState.NearTouches & (uint)rawNearTouch) != 0u)
- {
- return false;
- }
- if ((ovrcontrollerBase.currentState.NearTouches & (uint)rawNearTouch) != 0u && (ovrcontrollerBase.previousState.NearTouches & (uint)rawNearTouch) == 0u)
- {
- result = true;
- }
- }
- }
- return result;
- }
- public static bool GetUp(OVRInput.NearTouch virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedNearTouchUp(virtualMask, OVRInput.RawNearTouch.None, controllerMask);
- }
- public static bool GetUp(OVRInput.RawNearTouch rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedNearTouchUp(OVRInput.NearTouch.None, rawMask, controllerMask);
- }
- private static bool GetResolvedNearTouchUp(OVRInput.NearTouch virtualMask, OVRInput.RawNearTouch rawMask, OVRInput.Controller controllerMask)
- {
- bool result = false;
- if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
- {
- controllerMask |= OVRInput.activeControllerType;
- }
- for (int i = 0; i < OVRInput.controllers.Count; i++)
- {
- OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
- if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
- {
- OVRInput.RawNearTouch rawNearTouch = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
- if ((ovrcontrollerBase.currentState.NearTouches & (uint)rawNearTouch) != 0u)
- {
- return false;
- }
- if ((ovrcontrollerBase.currentState.NearTouches & (uint)rawNearTouch) == 0u && (ovrcontrollerBase.previousState.NearTouches & (uint)rawNearTouch) != 0u)
- {
- result = true;
- }
- }
- }
- return result;
- }
- public static float Get(OVRInput.Axis1D virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedAxis1D(virtualMask, OVRInput.RawAxis1D.None, controllerMask);
- }
- public static float Get(OVRInput.RawAxis1D rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedAxis1D(OVRInput.Axis1D.None, rawMask, controllerMask);
- }
- private static float GetResolvedAxis1D(OVRInput.Axis1D virtualMask, OVRInput.RawAxis1D rawMask, OVRInput.Controller controllerMask)
- {
- float a = 0f;
- if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
- {
- controllerMask |= OVRInput.activeControllerType;
- }
- for (int i = 0; i < OVRInput.controllers.Count; i++)
- {
- OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
- if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
- {
- OVRInput.RawAxis1D rawAxis1D = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
- if ((OVRInput.RawAxis1D.LIndexTrigger & rawAxis1D) != OVRInput.RawAxis1D.None)
- {
- a = OVRInput.CalculateAbsMax(a, ovrcontrollerBase.currentState.LIndexTrigger);
- }
- if ((OVRInput.RawAxis1D.RIndexTrigger & rawAxis1D) != OVRInput.RawAxis1D.None)
- {
- a = OVRInput.CalculateAbsMax(a, ovrcontrollerBase.currentState.RIndexTrigger);
- }
- if ((OVRInput.RawAxis1D.LHandTrigger & rawAxis1D) != OVRInput.RawAxis1D.None)
- {
- a = OVRInput.CalculateAbsMax(a, ovrcontrollerBase.currentState.LHandTrigger);
- }
- if ((OVRInput.RawAxis1D.RHandTrigger & rawAxis1D) != OVRInput.RawAxis1D.None)
- {
- a = OVRInput.CalculateAbsMax(a, ovrcontrollerBase.currentState.RHandTrigger);
- }
- }
- }
- return OVRInput.CalculateDeadzone(a, OVRInput.AXIS_DEADZONE_THRESHOLD);
- }
- public static Vector2 Get(OVRInput.Axis2D virtualMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedAxis2D(virtualMask, OVRInput.RawAxis2D.None, controllerMask);
- }
- public static Vector2 Get(OVRInput.RawAxis2D rawMask, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- return OVRInput.GetResolvedAxis2D(OVRInput.Axis2D.None, rawMask, controllerMask);
- }
- private static Vector2 GetResolvedAxis2D(OVRInput.Axis2D virtualMask, OVRInput.RawAxis2D rawMask, OVRInput.Controller controllerMask)
- {
- Vector2 a = Vector2.zero;
- if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
- {
- controllerMask |= OVRInput.activeControllerType;
- }
- for (int i = 0; i < OVRInput.controllers.Count; i++)
- {
- OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
- if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
- {
- OVRInput.RawAxis2D rawAxis2D = rawMask | ovrcontrollerBase.ResolveToRawMask(virtualMask);
- if ((OVRInput.RawAxis2D.LThumbstick & rawAxis2D) != OVRInput.RawAxis2D.None)
- {
- Vector2 b = new Vector2(ovrcontrollerBase.currentState.LThumbstick.x, ovrcontrollerBase.currentState.LThumbstick.y);
- a = OVRInput.CalculateAbsMax(a, b);
- }
- if ((OVRInput.RawAxis2D.RThumbstick & rawAxis2D) != OVRInput.RawAxis2D.None)
- {
- Vector2 b2 = new Vector2(ovrcontrollerBase.currentState.RThumbstick.x, ovrcontrollerBase.currentState.RThumbstick.y);
- a = OVRInput.CalculateAbsMax(a, b2);
- }
- }
- }
- return OVRInput.CalculateDeadzone(a, OVRInput.AXIS_DEADZONE_THRESHOLD);
- }
- public static OVRInput.Controller GetConnectedControllers()
- {
- return OVRInput.connectedControllerTypes;
- }
- public static OVRInput.Controller GetActiveController()
- {
- return OVRInput.activeControllerType;
- }
- public static void SetControllerVibration(float frequency, float amplitude, OVRInput.Controller controllerMask = OVRInput.Controller.Active)
- {
- if ((controllerMask & OVRInput.Controller.Active) != OVRInput.Controller.None)
- {
- controllerMask |= OVRInput.activeControllerType;
- }
- for (int i = 0; i < OVRInput.controllers.Count; i++)
- {
- OVRInput.OVRControllerBase ovrcontrollerBase = OVRInput.controllers[i];
- if (OVRInput.ShouldResolveController(ovrcontrollerBase.controllerType, controllerMask))
- {
- ovrcontrollerBase.SetControllerVibration(frequency, amplitude);
- }
- }
- }
- private static Vector2 CalculateAbsMax(Vector2 a, Vector2 b)
- {
- float sqrMagnitude = a.sqrMagnitude;
- float sqrMagnitude2 = b.sqrMagnitude;
- if (sqrMagnitude >= sqrMagnitude2)
- {
- return a;
- }
- return b;
- }
- private static float CalculateAbsMax(float a, float b)
- {
- float num = (a < 0f) ? (-a) : a;
- float num2 = (b < 0f) ? (-b) : b;
- if (num >= num2)
- {
- return a;
- }
- return b;
- }
- private static Vector2 CalculateDeadzone(Vector2 a, float deadzone)
- {
- if (a.sqrMagnitude <= deadzone * deadzone)
- {
- return Vector2.zero;
- }
- a *= (a.magnitude - deadzone) / (1f - deadzone);
- if (a.sqrMagnitude > 1f)
- {
- return a.normalized;
- }
- return a;
- }
- private static float CalculateDeadzone(float a, float deadzone)
- {
- float num = (a < 0f) ? (-a) : a;
- if (num <= deadzone)
- {
- return 0f;
- }
- a *= (num - deadzone) / (1f - deadzone);
- if (a * a > 1f)
- {
- return (a < 0f) ? -1f : 1f;
- }
- return a;
- }
- private static bool ShouldResolveController(OVRInput.Controller controllerType, OVRInput.Controller controllerMask)
- {
- bool result = false;
- if ((controllerType & controllerMask) == controllerType)
- {
- result = true;
- }
- if ((controllerMask & OVRInput.Controller.Touch) == OVRInput.Controller.Touch && (controllerType & OVRInput.Controller.Touch) != OVRInput.Controller.None && (controllerType & OVRInput.Controller.Touch) != OVRInput.Controller.Touch)
- {
- result = false;
- }
- return result;
- }
- private static readonly float AXIS_AS_BUTTON_THRESHOLD = 0.5f;
- private static readonly float AXIS_DEADZONE_THRESHOLD = 0.2f;
- private static List<OVRInput.OVRControllerBase> controllers;
- private static OVRInput.Controller activeControllerType = OVRInput.Controller.None;
- private static OVRInput.Controller connectedControllerTypes = OVRInput.Controller.None;
- private static bool useFixedPoses = false;
- private static int fixedUpdateCount = 0;
- private static bool _pluginSupportsActiveController = false;
- private static bool _pluginSupportsActiveControllerCached = false;
- private static Version _pluginSupportsActiveControllerMinVersion = new Version(1, 9, 0);
- [Flags]
- public enum Button
- {
- None = 0,
- One = 1,
- Two = 2,
- Three = 4,
- Four = 8,
- Start = 256,
- Back = 512,
- PrimaryShoulder = 4096,
- PrimaryIndexTrigger = 8192,
- PrimaryHandTrigger = 16384,
- PrimaryThumbstick = 32768,
- PrimaryThumbstickUp = 65536,
- PrimaryThumbstickDown = 131072,
- PrimaryThumbstickLeft = 262144,
- PrimaryThumbstickRight = 524288,
- SecondaryShoulder = 1048576,
- SecondaryIndexTrigger = 2097152,
- SecondaryHandTrigger = 4194304,
- SecondaryThumbstick = 8388608,
- SecondaryThumbstickUp = 16777216,
- SecondaryThumbstickDown = 33554432,
- SecondaryThumbstickLeft = 67108864,
- SecondaryThumbstickRight = 134217728,
- DpadUp = 16,
- DpadDown = 32,
- DpadLeft = 64,
- DpadRight = 128,
- Up = 268435456,
- Down = 536870912,
- Left = 1073741824,
- Right = -2147483648,
- Any = -1
- }
- [Flags]
- public enum RawButton
- {
- None = 0,
- A = 1,
- B = 2,
- X = 256,
- Y = 512,
- Start = 1048576,
- Back = 2097152,
- LShoulder = 2048,
- LIndexTrigger = 268435456,
- LHandTrigger = 536870912,
- LThumbstick = 1024,
- LThumbstickUp = 16,
- LThumbstickDown = 32,
- LThumbstickLeft = 64,
- LThumbstickRight = 128,
- RShoulder = 8,
- RIndexTrigger = 67108864,
- RHandTrigger = 134217728,
- RThumbstick = 4,
- RThumbstickUp = 4096,
- RThumbstickDown = 8192,
- RThumbstickLeft = 16384,
- RThumbstickRight = 32768,
- DpadUp = 65536,
- DpadDown = 131072,
- DpadLeft = 262144,
- DpadRight = 524288,
- Any = -1
- }
- [Flags]
- public enum Touch
- {
- None = 0,
- One = 1,
- Two = 2,
- Three = 4,
- Four = 8,
- PrimaryIndexTrigger = 8192,
- PrimaryThumbstick = 32768,
- PrimaryThumbRest = 4096,
- SecondaryIndexTrigger = 2097152,
- SecondaryThumbstick = 8388608,
- SecondaryThumbRest = 1048576,
- Any = -1
- }
- [Flags]
- public enum RawTouch
- {
- None = 0,
- A = 1,
- B = 2,
- X = 256,
- Y = 512,
- LIndexTrigger = 4096,
- LThumbstick = 1024,
- LThumbRest = 2048,
- RIndexTrigger = 16,
- RThumbstick = 4,
- RThumbRest = 8,
- Any = -1
- }
- [Flags]
- public enum NearTouch
- {
- None = 0,
- PrimaryIndexTrigger = 1,
- PrimaryThumbButtons = 2,
- SecondaryIndexTrigger = 4,
- SecondaryThumbButtons = 8,
- Any = -1
- }
- [Flags]
- public enum RawNearTouch
- {
- None = 0,
- LIndexTrigger = 1,
- LThumbButtons = 2,
- RIndexTrigger = 4,
- RThumbButtons = 8,
- Any = -1
- }
- [Flags]
- public enum Axis1D
- {
- None = 0,
- PrimaryIndexTrigger = 1,
- PrimaryHandTrigger = 4,
- SecondaryIndexTrigger = 2,
- SecondaryHandTrigger = 8,
- Any = -1
- }
- [Flags]
- public enum RawAxis1D
- {
- None = 0,
- LIndexTrigger = 1,
- LHandTrigger = 4,
- RIndexTrigger = 2,
- RHandTrigger = 8,
- Any = -1
- }
- [Flags]
- public enum Axis2D
- {
- None = 0,
- PrimaryThumbstick = 1,
- SecondaryThumbstick = 2,
- Any = -1
- }
- [Flags]
- public enum RawAxis2D
- {
- None = 0,
- LThumbstick = 1,
- RThumbstick = 2,
- Any = -1
- }
- [Flags]
- public enum Controller
- {
- None = 0,
- LTouch = 1,
- RTouch = 2,
- Touch = 3,
- Remote = 4,
- Gamepad = 16,
- Touchpad = 134217728,
- Active = -2147483648,
- All = -1
- }
- private abstract class OVRControllerBase
- {
- public OVRControllerBase()
- {
- this.ConfigureButtonMap();
- this.ConfigureTouchMap();
- this.ConfigureNearTouchMap();
- this.ConfigureAxis1DMap();
- this.ConfigureAxis2DMap();
- }
- public virtual OVRInput.Controller Update()
- {
- OVRPlugin.ControllerState controllerState = OVRPlugin.GetControllerState((uint)this.controllerType);
- if (controllerState.LIndexTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- controllerState.Buttons |= 268435456u;
- }
- if (controllerState.LHandTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- controllerState.Buttons |= 536870912u;
- }
- if (controllerState.LThumbstick.y >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- controllerState.Buttons |= 16u;
- }
- if (controllerState.LThumbstick.y <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- controllerState.Buttons |= 32u;
- }
- if (controllerState.LThumbstick.x <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- controllerState.Buttons |= 64u;
- }
- if (controllerState.LThumbstick.x >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- controllerState.Buttons |= 128u;
- }
- if (controllerState.RIndexTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- controllerState.Buttons |= 67108864u;
- }
- if (controllerState.RHandTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- controllerState.Buttons |= 134217728u;
- }
- if (controllerState.RThumbstick.y >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- controllerState.Buttons |= 4096u;
- }
- if (controllerState.RThumbstick.y <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- controllerState.Buttons |= 8192u;
- }
- if (controllerState.RThumbstick.x <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- controllerState.Buttons |= 16384u;
- }
- if (controllerState.RThumbstick.x >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- controllerState.Buttons |= 32768u;
- }
- this.previousState = this.currentState;
- this.currentState = controllerState;
- return (OVRInput.Controller)(this.currentState.ConnectedControllers & (uint)this.controllerType);
- }
- public virtual void SetControllerVibration(float frequency, float amplitude)
- {
- OVRPlugin.SetControllerVibration((uint)this.controllerType, frequency, amplitude);
- }
- public abstract void ConfigureButtonMap();
- public abstract void ConfigureTouchMap();
- public abstract void ConfigureNearTouchMap();
- public abstract void ConfigureAxis1DMap();
- public abstract void ConfigureAxis2DMap();
- public OVRInput.RawButton ResolveToRawMask(OVRInput.Button virtualMask)
- {
- return this.buttonMap.ToRawMask(virtualMask);
- }
- public OVRInput.RawTouch ResolveToRawMask(OVRInput.Touch virtualMask)
- {
- return this.touchMap.ToRawMask(virtualMask);
- }
- public OVRInput.RawNearTouch ResolveToRawMask(OVRInput.NearTouch virtualMask)
- {
- return this.nearTouchMap.ToRawMask(virtualMask);
- }
- public OVRInput.RawAxis1D ResolveToRawMask(OVRInput.Axis1D virtualMask)
- {
- return this.axis1DMap.ToRawMask(virtualMask);
- }
- public OVRInput.RawAxis2D ResolveToRawMask(OVRInput.Axis2D virtualMask)
- {
- return this.axis2DMap.ToRawMask(virtualMask);
- }
- public OVRInput.Controller controllerType;
- public OVRInput.OVRControllerBase.VirtualButtonMap buttonMap = new OVRInput.OVRControllerBase.VirtualButtonMap();
- public OVRInput.OVRControllerBase.VirtualTouchMap touchMap = new OVRInput.OVRControllerBase.VirtualTouchMap();
- public OVRInput.OVRControllerBase.VirtualNearTouchMap nearTouchMap = new OVRInput.OVRControllerBase.VirtualNearTouchMap();
- public OVRInput.OVRControllerBase.VirtualAxis1DMap axis1DMap = new OVRInput.OVRControllerBase.VirtualAxis1DMap();
- public OVRInput.OVRControllerBase.VirtualAxis2DMap axis2DMap = new OVRInput.OVRControllerBase.VirtualAxis2DMap();
- public OVRPlugin.ControllerState previousState = default(OVRPlugin.ControllerState);
- public OVRPlugin.ControllerState currentState = default(OVRPlugin.ControllerState);
- public class VirtualButtonMap
- {
- public OVRInput.RawButton ToRawMask(OVRInput.Button virtualMask)
- {
- OVRInput.RawButton rawButton = OVRInput.RawButton.None;
- if (virtualMask == OVRInput.Button.None)
- {
- return OVRInput.RawButton.None;
- }
- if ((virtualMask & OVRInput.Button.One) != OVRInput.Button.None)
- {
- rawButton |= this.One;
- }
- if ((virtualMask & OVRInput.Button.Two) != OVRInput.Button.None)
- {
- rawButton |= this.Two;
- }
- if ((virtualMask & OVRInput.Button.Three) != OVRInput.Button.None)
- {
- rawButton |= this.Three;
- }
- if ((virtualMask & OVRInput.Button.Four) != OVRInput.Button.None)
- {
- rawButton |= this.Four;
- }
- if ((virtualMask & OVRInput.Button.Start) != OVRInput.Button.None)
- {
- rawButton |= this.Start;
- }
- if ((virtualMask & OVRInput.Button.Back) != OVRInput.Button.None)
- {
- rawButton |= this.Back;
- }
- if ((virtualMask & OVRInput.Button.PrimaryShoulder) != OVRInput.Button.None)
- {
- rawButton |= this.PrimaryShoulder;
- }
- if ((virtualMask & OVRInput.Button.PrimaryIndexTrigger) != OVRInput.Button.None)
- {
- rawButton |= this.PrimaryIndexTrigger;
- }
- if ((virtualMask & OVRInput.Button.PrimaryHandTrigger) != OVRInput.Button.None)
- {
- rawButton |= this.PrimaryHandTrigger;
- }
- if ((virtualMask & OVRInput.Button.PrimaryThumbstick) != OVRInput.Button.None)
- {
- rawButton |= this.PrimaryThumbstick;
- }
- if ((virtualMask & OVRInput.Button.PrimaryThumbstickUp) != OVRInput.Button.None)
- {
- rawButton |= this.PrimaryThumbstickUp;
- }
- if ((virtualMask & OVRInput.Button.PrimaryThumbstickDown) != OVRInput.Button.None)
- {
- rawButton |= this.PrimaryThumbstickDown;
- }
- if ((virtualMask & OVRInput.Button.PrimaryThumbstickLeft) != OVRInput.Button.None)
- {
- rawButton |= this.PrimaryThumbstickLeft;
- }
- if ((virtualMask & OVRInput.Button.PrimaryThumbstickRight) != OVRInput.Button.None)
- {
- rawButton |= this.PrimaryThumbstickRight;
- }
- if ((virtualMask & OVRInput.Button.SecondaryShoulder) != OVRInput.Button.None)
- {
- rawButton |= this.SecondaryShoulder;
- }
- if ((virtualMask & OVRInput.Button.SecondaryIndexTrigger) != OVRInput.Button.None)
- {
- rawButton |= this.SecondaryIndexTrigger;
- }
- if ((virtualMask & OVRInput.Button.SecondaryHandTrigger) != OVRInput.Button.None)
- {
- rawButton |= this.SecondaryHandTrigger;
- }
- if ((virtualMask & OVRInput.Button.SecondaryThumbstick) != OVRInput.Button.None)
- {
- rawButton |= this.SecondaryThumbstick;
- }
- if ((virtualMask & OVRInput.Button.SecondaryThumbstickUp) != OVRInput.Button.None)
- {
- rawButton |= this.SecondaryThumbstickUp;
- }
- if ((virtualMask & OVRInput.Button.SecondaryThumbstickDown) != OVRInput.Button.None)
- {
- rawButton |= this.SecondaryThumbstickDown;
- }
- if ((virtualMask & OVRInput.Button.SecondaryThumbstickLeft) != OVRInput.Button.None)
- {
- rawButton |= this.SecondaryThumbstickLeft;
- }
- if ((virtualMask & OVRInput.Button.SecondaryThumbstickRight) != OVRInput.Button.None)
- {
- rawButton |= this.SecondaryThumbstickRight;
- }
- if ((virtualMask & OVRInput.Button.DpadUp) != OVRInput.Button.None)
- {
- rawButton |= this.DpadUp;
- }
- if ((virtualMask & OVRInput.Button.DpadDown) != OVRInput.Button.None)
- {
- rawButton |= this.DpadDown;
- }
- if ((virtualMask & OVRInput.Button.DpadLeft) != OVRInput.Button.None)
- {
- rawButton |= this.DpadLeft;
- }
- if ((virtualMask & OVRInput.Button.DpadRight) != OVRInput.Button.None)
- {
- rawButton |= this.DpadRight;
- }
- if ((virtualMask & OVRInput.Button.Up) != OVRInput.Button.None)
- {
- rawButton |= this.Up;
- }
- if ((virtualMask & OVRInput.Button.Down) != OVRInput.Button.None)
- {
- rawButton |= this.Down;
- }
- if ((virtualMask & OVRInput.Button.Left) != OVRInput.Button.None)
- {
- rawButton |= this.Left;
- }
- if ((virtualMask & OVRInput.Button.Right) != OVRInput.Button.None)
- {
- rawButton |= this.Right;
- }
- return rawButton;
- }
- public OVRInput.RawButton None;
- public OVRInput.RawButton One;
- public OVRInput.RawButton Two;
- public OVRInput.RawButton Three;
- public OVRInput.RawButton Four;
- public OVRInput.RawButton Start;
- public OVRInput.RawButton Back;
- public OVRInput.RawButton PrimaryShoulder;
- public OVRInput.RawButton PrimaryIndexTrigger;
- public OVRInput.RawButton PrimaryHandTrigger;
- public OVRInput.RawButton PrimaryThumbstick;
- public OVRInput.RawButton PrimaryThumbstickUp;
- public OVRInput.RawButton PrimaryThumbstickDown;
- public OVRInput.RawButton PrimaryThumbstickLeft;
- public OVRInput.RawButton PrimaryThumbstickRight;
- public OVRInput.RawButton SecondaryShoulder;
- public OVRInput.RawButton SecondaryIndexTrigger;
- public OVRInput.RawButton SecondaryHandTrigger;
- public OVRInput.RawButton SecondaryThumbstick;
- public OVRInput.RawButton SecondaryThumbstickUp;
- public OVRInput.RawButton SecondaryThumbstickDown;
- public OVRInput.RawButton SecondaryThumbstickLeft;
- public OVRInput.RawButton SecondaryThumbstickRight;
- public OVRInput.RawButton DpadUp;
- public OVRInput.RawButton DpadDown;
- public OVRInput.RawButton DpadLeft;
- public OVRInput.RawButton DpadRight;
- public OVRInput.RawButton Up;
- public OVRInput.RawButton Down;
- public OVRInput.RawButton Left;
- public OVRInput.RawButton Right;
- }
- public class VirtualTouchMap
- {
- public OVRInput.RawTouch ToRawMask(OVRInput.Touch virtualMask)
- {
- OVRInput.RawTouch rawTouch = OVRInput.RawTouch.None;
- if (virtualMask == OVRInput.Touch.None)
- {
- return OVRInput.RawTouch.None;
- }
- if ((virtualMask & OVRInput.Touch.One) != OVRInput.Touch.None)
- {
- rawTouch |= this.One;
- }
- if ((virtualMask & OVRInput.Touch.Two) != OVRInput.Touch.None)
- {
- rawTouch |= this.Two;
- }
- if ((virtualMask & OVRInput.Touch.Three) != OVRInput.Touch.None)
- {
- rawTouch |= this.Three;
- }
- if ((virtualMask & OVRInput.Touch.Four) != OVRInput.Touch.None)
- {
- rawTouch |= this.Four;
- }
- if ((virtualMask & OVRInput.Touch.PrimaryIndexTrigger) != OVRInput.Touch.None)
- {
- rawTouch |= this.PrimaryIndexTrigger;
- }
- if ((virtualMask & OVRInput.Touch.PrimaryThumbstick) != OVRInput.Touch.None)
- {
- rawTouch |= this.PrimaryThumbstick;
- }
- if ((virtualMask & OVRInput.Touch.PrimaryThumbRest) != OVRInput.Touch.None)
- {
- rawTouch |= this.PrimaryThumbRest;
- }
- if ((virtualMask & OVRInput.Touch.SecondaryIndexTrigger) != OVRInput.Touch.None)
- {
- rawTouch |= this.SecondaryIndexTrigger;
- }
- if ((virtualMask & OVRInput.Touch.SecondaryThumbstick) != OVRInput.Touch.None)
- {
- rawTouch |= this.SecondaryThumbstick;
- }
- if ((virtualMask & OVRInput.Touch.SecondaryThumbRest) != OVRInput.Touch.None)
- {
- rawTouch |= this.SecondaryThumbRest;
- }
- return rawTouch;
- }
- public OVRInput.RawTouch None;
- public OVRInput.RawTouch One;
- public OVRInput.RawTouch Two;
- public OVRInput.RawTouch Three;
- public OVRInput.RawTouch Four;
- public OVRInput.RawTouch PrimaryIndexTrigger;
- public OVRInput.RawTouch PrimaryThumbstick;
- public OVRInput.RawTouch PrimaryThumbRest;
- public OVRInput.RawTouch SecondaryIndexTrigger;
- public OVRInput.RawTouch SecondaryThumbstick;
- public OVRInput.RawTouch SecondaryThumbRest;
- }
- public class VirtualNearTouchMap
- {
- public OVRInput.RawNearTouch ToRawMask(OVRInput.NearTouch virtualMask)
- {
- OVRInput.RawNearTouch rawNearTouch = OVRInput.RawNearTouch.None;
- if (virtualMask == OVRInput.NearTouch.None)
- {
- return OVRInput.RawNearTouch.None;
- }
- if ((virtualMask & OVRInput.NearTouch.PrimaryIndexTrigger) != OVRInput.NearTouch.None)
- {
- rawNearTouch |= this.PrimaryIndexTrigger;
- }
- if ((virtualMask & OVRInput.NearTouch.PrimaryThumbButtons) != OVRInput.NearTouch.None)
- {
- rawNearTouch |= this.PrimaryThumbButtons;
- }
- if ((virtualMask & OVRInput.NearTouch.SecondaryIndexTrigger) != OVRInput.NearTouch.None)
- {
- rawNearTouch |= this.SecondaryIndexTrigger;
- }
- if ((virtualMask & OVRInput.NearTouch.SecondaryThumbButtons) != OVRInput.NearTouch.None)
- {
- rawNearTouch |= this.SecondaryThumbButtons;
- }
- return rawNearTouch;
- }
- public OVRInput.RawNearTouch None;
- public OVRInput.RawNearTouch PrimaryIndexTrigger;
- public OVRInput.RawNearTouch PrimaryThumbButtons;
- public OVRInput.RawNearTouch SecondaryIndexTrigger;
- public OVRInput.RawNearTouch SecondaryThumbButtons;
- }
- public class VirtualAxis1DMap
- {
- public OVRInput.RawAxis1D ToRawMask(OVRInput.Axis1D virtualMask)
- {
- OVRInput.RawAxis1D rawAxis1D = OVRInput.RawAxis1D.None;
- if (virtualMask == OVRInput.Axis1D.None)
- {
- return OVRInput.RawAxis1D.None;
- }
- if ((virtualMask & OVRInput.Axis1D.PrimaryIndexTrigger) != OVRInput.Axis1D.None)
- {
- rawAxis1D |= this.PrimaryIndexTrigger;
- }
- if ((virtualMask & OVRInput.Axis1D.PrimaryHandTrigger) != OVRInput.Axis1D.None)
- {
- rawAxis1D |= this.PrimaryHandTrigger;
- }
- if ((virtualMask & OVRInput.Axis1D.SecondaryIndexTrigger) != OVRInput.Axis1D.None)
- {
- rawAxis1D |= this.SecondaryIndexTrigger;
- }
- if ((virtualMask & OVRInput.Axis1D.SecondaryHandTrigger) != OVRInput.Axis1D.None)
- {
- rawAxis1D |= this.SecondaryHandTrigger;
- }
- return rawAxis1D;
- }
- public OVRInput.RawAxis1D None;
- public OVRInput.RawAxis1D PrimaryIndexTrigger;
- public OVRInput.RawAxis1D PrimaryHandTrigger;
- public OVRInput.RawAxis1D SecondaryIndexTrigger;
- public OVRInput.RawAxis1D SecondaryHandTrigger;
- }
- public class VirtualAxis2DMap
- {
- public OVRInput.RawAxis2D ToRawMask(OVRInput.Axis2D virtualMask)
- {
- OVRInput.RawAxis2D rawAxis2D = OVRInput.RawAxis2D.None;
- if (virtualMask == OVRInput.Axis2D.None)
- {
- return OVRInput.RawAxis2D.None;
- }
- if ((virtualMask & OVRInput.Axis2D.PrimaryThumbstick) != OVRInput.Axis2D.None)
- {
- rawAxis2D |= this.PrimaryThumbstick;
- }
- if ((virtualMask & OVRInput.Axis2D.SecondaryThumbstick) != OVRInput.Axis2D.None)
- {
- rawAxis2D |= this.SecondaryThumbstick;
- }
- return rawAxis2D;
- }
- public OVRInput.RawAxis2D None;
- public OVRInput.RawAxis2D PrimaryThumbstick;
- public OVRInput.RawAxis2D SecondaryThumbstick;
- }
- }
- private class OVRControllerTouch : OVRInput.OVRControllerBase
- {
- public OVRControllerTouch()
- {
- this.controllerType = OVRInput.Controller.Touch;
- }
- public override void ConfigureButtonMap()
- {
- this.buttonMap.None = OVRInput.RawButton.None;
- this.buttonMap.One = OVRInput.RawButton.A;
- this.buttonMap.Two = OVRInput.RawButton.B;
- this.buttonMap.Three = OVRInput.RawButton.X;
- this.buttonMap.Four = OVRInput.RawButton.Y;
- this.buttonMap.Start = OVRInput.RawButton.Start;
- this.buttonMap.Back = OVRInput.RawButton.None;
- this.buttonMap.PrimaryShoulder = OVRInput.RawButton.None;
- this.buttonMap.PrimaryIndexTrigger = OVRInput.RawButton.LIndexTrigger;
- this.buttonMap.PrimaryHandTrigger = OVRInput.RawButton.LHandTrigger;
- this.buttonMap.PrimaryThumbstick = OVRInput.RawButton.LThumbstick;
- this.buttonMap.PrimaryThumbstickUp = OVRInput.RawButton.LThumbstickUp;
- this.buttonMap.PrimaryThumbstickDown = OVRInput.RawButton.LThumbstickDown;
- this.buttonMap.PrimaryThumbstickLeft = OVRInput.RawButton.LThumbstickLeft;
- this.buttonMap.PrimaryThumbstickRight = OVRInput.RawButton.LThumbstickRight;
- this.buttonMap.SecondaryShoulder = OVRInput.RawButton.None;
- this.buttonMap.SecondaryIndexTrigger = OVRInput.RawButton.RIndexTrigger;
- this.buttonMap.SecondaryHandTrigger = OVRInput.RawButton.RHandTrigger;
- this.buttonMap.SecondaryThumbstick = OVRInput.RawButton.RThumbstick;
- this.buttonMap.SecondaryThumbstickUp = OVRInput.RawButton.RThumbstickUp;
- this.buttonMap.SecondaryThumbstickDown = OVRInput.RawButton.RThumbstickDown;
- this.buttonMap.SecondaryThumbstickLeft = OVRInput.RawButton.RThumbstickLeft;
- this.buttonMap.SecondaryThumbstickRight = OVRInput.RawButton.RThumbstickRight;
- this.buttonMap.DpadUp = OVRInput.RawButton.None;
- this.buttonMap.DpadDown = OVRInput.RawButton.None;
- this.buttonMap.DpadLeft = OVRInput.RawButton.None;
- this.buttonMap.DpadRight = OVRInput.RawButton.None;
- this.buttonMap.Up = OVRInput.RawButton.LThumbstickUp;
- this.buttonMap.Down = OVRInput.RawButton.LThumbstickDown;
- this.buttonMap.Left = OVRInput.RawButton.LThumbstickLeft;
- this.buttonMap.Right = OVRInput.RawButton.LThumbstickRight;
- }
- public override void ConfigureTouchMap()
- {
- this.touchMap.None = OVRInput.RawTouch.None;
- this.touchMap.One = OVRInput.RawTouch.A;
- this.touchMap.Two = OVRInput.RawTouch.B;
- this.touchMap.Three = OVRInput.RawTouch.X;
- this.touchMap.Four = OVRInput.RawTouch.Y;
- this.touchMap.PrimaryIndexTrigger = OVRInput.RawTouch.LIndexTrigger;
- this.touchMap.PrimaryThumbstick = OVRInput.RawTouch.LThumbstick;
- this.touchMap.PrimaryThumbRest = OVRInput.RawTouch.LThumbRest;
- this.touchMap.SecondaryIndexTrigger = OVRInput.RawTouch.RIndexTrigger;
- this.touchMap.SecondaryThumbstick = OVRInput.RawTouch.RThumbstick;
- this.touchMap.SecondaryThumbRest = OVRInput.RawTouch.RThumbRest;
- }
- public override void ConfigureNearTouchMap()
- {
- this.nearTouchMap.None = OVRInput.RawNearTouch.None;
- this.nearTouchMap.PrimaryIndexTrigger = OVRInput.RawNearTouch.LIndexTrigger;
- this.nearTouchMap.PrimaryThumbButtons = OVRInput.RawNearTouch.LThumbButtons;
- this.nearTouchMap.SecondaryIndexTrigger = OVRInput.RawNearTouch.RIndexTrigger;
- this.nearTouchMap.SecondaryThumbButtons = OVRInput.RawNearTouch.RThumbButtons;
- }
- public override void ConfigureAxis1DMap()
- {
- this.axis1DMap.None = OVRInput.RawAxis1D.None;
- this.axis1DMap.PrimaryIndexTrigger = OVRInput.RawAxis1D.LIndexTrigger;
- this.axis1DMap.PrimaryHandTrigger = OVRInput.RawAxis1D.LHandTrigger;
- this.axis1DMap.SecondaryIndexTrigger = OVRInput.RawAxis1D.RIndexTrigger;
- this.axis1DMap.SecondaryHandTrigger = OVRInput.RawAxis1D.RHandTrigger;
- }
- public override void ConfigureAxis2DMap()
- {
- this.axis2DMap.None = OVRInput.RawAxis2D.None;
- this.axis2DMap.PrimaryThumbstick = OVRInput.RawAxis2D.LThumbstick;
- this.axis2DMap.SecondaryThumbstick = OVRInput.RawAxis2D.RThumbstick;
- }
- }
- private class OVRControllerLTouch : OVRInput.OVRControllerBase
- {
- public OVRControllerLTouch()
- {
- this.controllerType = OVRInput.Controller.LTouch;
- }
- public override void ConfigureButtonMap()
- {
- this.buttonMap.None = OVRInput.RawButton.None;
- this.buttonMap.One = OVRInput.RawButton.X;
- this.buttonMap.Two = OVRInput.RawButton.Y;
- this.buttonMap.Three = OVRInput.RawButton.None;
- this.buttonMap.Four = OVRInput.RawButton.None;
- this.buttonMap.Start = OVRInput.RawButton.Start;
- this.buttonMap.Back = OVRInput.RawButton.None;
- this.buttonMap.PrimaryShoulder = OVRInput.RawButton.None;
- this.buttonMap.PrimaryIndexTrigger = OVRInput.RawButton.LIndexTrigger;
- this.buttonMap.PrimaryHandTrigger = OVRInput.RawButton.LHandTrigger;
- this.buttonMap.PrimaryThumbstick = OVRInput.RawButton.LThumbstick;
- this.buttonMap.PrimaryThumbstickUp = OVRInput.RawButton.LThumbstickUp;
- this.buttonMap.PrimaryThumbstickDown = OVRInput.RawButton.LThumbstickDown;
- this.buttonMap.PrimaryThumbstickLeft = OVRInput.RawButton.LThumbstickLeft;
- this.buttonMap.PrimaryThumbstickRight = OVRInput.RawButton.LThumbstickRight;
- this.buttonMap.SecondaryShoulder = OVRInput.RawButton.None;
- this.buttonMap.SecondaryIndexTrigger = OVRInput.RawButton.None;
- this.buttonMap.SecondaryHandTrigger = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstick = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstickUp = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstickDown = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstickLeft = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstickRight = OVRInput.RawButton.None;
- this.buttonMap.DpadUp = OVRInput.RawButton.None;
- this.buttonMap.DpadDown = OVRInput.RawButton.None;
- this.buttonMap.DpadLeft = OVRInput.RawButton.None;
- this.buttonMap.DpadRight = OVRInput.RawButton.None;
- this.buttonMap.Up = OVRInput.RawButton.LThumbstickUp;
- this.buttonMap.Down = OVRInput.RawButton.LThumbstickDown;
- this.buttonMap.Left = OVRInput.RawButton.LThumbstickLeft;
- this.buttonMap.Right = OVRInput.RawButton.LThumbstickRight;
- }
- public override void ConfigureTouchMap()
- {
- this.touchMap.None = OVRInput.RawTouch.None;
- this.touchMap.One = OVRInput.RawTouch.X;
- this.touchMap.Two = OVRInput.RawTouch.Y;
- this.touchMap.Three = OVRInput.RawTouch.None;
- this.touchMap.Four = OVRInput.RawTouch.None;
- this.touchMap.PrimaryIndexTrigger = OVRInput.RawTouch.LIndexTrigger;
- this.touchMap.PrimaryThumbstick = OVRInput.RawTouch.LThumbstick;
- this.touchMap.PrimaryThumbRest = OVRInput.RawTouch.LThumbRest;
- this.touchMap.SecondaryIndexTrigger = OVRInput.RawTouch.None;
- this.touchMap.SecondaryThumbstick = OVRInput.RawTouch.None;
- this.touchMap.SecondaryThumbRest = OVRInput.RawTouch.None;
- }
- public override void ConfigureNearTouchMap()
- {
- this.nearTouchMap.None = OVRInput.RawNearTouch.None;
- this.nearTouchMap.PrimaryIndexTrigger = OVRInput.RawNearTouch.LIndexTrigger;
- this.nearTouchMap.PrimaryThumbButtons = OVRInput.RawNearTouch.LThumbButtons;
- this.nearTouchMap.SecondaryIndexTrigger = OVRInput.RawNearTouch.None;
- this.nearTouchMap.SecondaryThumbButtons = OVRInput.RawNearTouch.None;
- }
- public override void ConfigureAxis1DMap()
- {
- this.axis1DMap.None = OVRInput.RawAxis1D.None;
- this.axis1DMap.PrimaryIndexTrigger = OVRInput.RawAxis1D.LIndexTrigger;
- this.axis1DMap.PrimaryHandTrigger = OVRInput.RawAxis1D.LHandTrigger;
- this.axis1DMap.SecondaryIndexTrigger = OVRInput.RawAxis1D.None;
- this.axis1DMap.SecondaryHandTrigger = OVRInput.RawAxis1D.None;
- }
- public override void ConfigureAxis2DMap()
- {
- this.axis2DMap.None = OVRInput.RawAxis2D.None;
- this.axis2DMap.PrimaryThumbstick = OVRInput.RawAxis2D.LThumbstick;
- this.axis2DMap.SecondaryThumbstick = OVRInput.RawAxis2D.None;
- }
- }
- private class OVRControllerRTouch : OVRInput.OVRControllerBase
- {
- public OVRControllerRTouch()
- {
- this.controllerType = OVRInput.Controller.RTouch;
- }
- public override void ConfigureButtonMap()
- {
- this.buttonMap.None = OVRInput.RawButton.None;
- this.buttonMap.One = OVRInput.RawButton.A;
- this.buttonMap.Two = OVRInput.RawButton.B;
- this.buttonMap.Three = OVRInput.RawButton.None;
- this.buttonMap.Four = OVRInput.RawButton.None;
- this.buttonMap.Start = OVRInput.RawButton.None;
- this.buttonMap.Back = OVRInput.RawButton.None;
- this.buttonMap.PrimaryShoulder = OVRInput.RawButton.None;
- this.buttonMap.PrimaryIndexTrigger = OVRInput.RawButton.RIndexTrigger;
- this.buttonMap.PrimaryHandTrigger = OVRInput.RawButton.RHandTrigger;
- this.buttonMap.PrimaryThumbstick = OVRInput.RawButton.RThumbstick;
- this.buttonMap.PrimaryThumbstickUp = OVRInput.RawButton.RThumbstickUp;
- this.buttonMap.PrimaryThumbstickDown = OVRInput.RawButton.RThumbstickDown;
- this.buttonMap.PrimaryThumbstickLeft = OVRInput.RawButton.RThumbstickLeft;
- this.buttonMap.PrimaryThumbstickRight = OVRInput.RawButton.RThumbstickRight;
- this.buttonMap.SecondaryShoulder = OVRInput.RawButton.None;
- this.buttonMap.SecondaryIndexTrigger = OVRInput.RawButton.None;
- this.buttonMap.SecondaryHandTrigger = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstick = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstickUp = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstickDown = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstickLeft = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstickRight = OVRInput.RawButton.None;
- this.buttonMap.DpadUp = OVRInput.RawButton.None;
- this.buttonMap.DpadDown = OVRInput.RawButton.None;
- this.buttonMap.DpadLeft = OVRInput.RawButton.None;
- this.buttonMap.DpadRight = OVRInput.RawButton.None;
- this.buttonMap.Up = OVRInput.RawButton.RThumbstickUp;
- this.buttonMap.Down = OVRInput.RawButton.RThumbstickDown;
- this.buttonMap.Left = OVRInput.RawButton.RThumbstickLeft;
- this.buttonMap.Right = OVRInput.RawButton.RThumbstickRight;
- }
- public override void ConfigureTouchMap()
- {
- this.touchMap.None = OVRInput.RawTouch.None;
- this.touchMap.One = OVRInput.RawTouch.A;
- this.touchMap.Two = OVRInput.RawTouch.B;
- this.touchMap.Three = OVRInput.RawTouch.None;
- this.touchMap.Four = OVRInput.RawTouch.None;
- this.touchMap.PrimaryIndexTrigger = OVRInput.RawTouch.RIndexTrigger;
- this.touchMap.PrimaryThumbstick = OVRInput.RawTouch.RThumbstick;
- this.touchMap.PrimaryThumbRest = OVRInput.RawTouch.RThumbRest;
- this.touchMap.SecondaryIndexTrigger = OVRInput.RawTouch.None;
- this.touchMap.SecondaryThumbstick = OVRInput.RawTouch.None;
- this.touchMap.SecondaryThumbRest = OVRInput.RawTouch.None;
- }
- public override void ConfigureNearTouchMap()
- {
- this.nearTouchMap.None = OVRInput.RawNearTouch.None;
- this.nearTouchMap.PrimaryIndexTrigger = OVRInput.RawNearTouch.RIndexTrigger;
- this.nearTouchMap.PrimaryThumbButtons = OVRInput.RawNearTouch.RThumbButtons;
- this.nearTouchMap.SecondaryIndexTrigger = OVRInput.RawNearTouch.None;
- this.nearTouchMap.SecondaryThumbButtons = OVRInput.RawNearTouch.None;
- }
- public override void ConfigureAxis1DMap()
- {
- this.axis1DMap.None = OVRInput.RawAxis1D.None;
- this.axis1DMap.PrimaryIndexTrigger = OVRInput.RawAxis1D.RIndexTrigger;
- this.axis1DMap.PrimaryHandTrigger = OVRInput.RawAxis1D.RHandTrigger;
- this.axis1DMap.SecondaryIndexTrigger = OVRInput.RawAxis1D.None;
- this.axis1DMap.SecondaryHandTrigger = OVRInput.RawAxis1D.None;
- }
- public override void ConfigureAxis2DMap()
- {
- this.axis2DMap.None = OVRInput.RawAxis2D.None;
- this.axis2DMap.PrimaryThumbstick = OVRInput.RawAxis2D.RThumbstick;
- this.axis2DMap.SecondaryThumbstick = OVRInput.RawAxis2D.None;
- }
- }
- private class OVRControllerRemote : OVRInput.OVRControllerBase
- {
- public OVRControllerRemote()
- {
- this.controllerType = OVRInput.Controller.Remote;
- }
- public override void ConfigureButtonMap()
- {
- this.buttonMap.None = OVRInput.RawButton.None;
- this.buttonMap.One = OVRInput.RawButton.Start;
- this.buttonMap.Two = OVRInput.RawButton.Back;
- this.buttonMap.Three = OVRInput.RawButton.None;
- this.buttonMap.Four = OVRInput.RawButton.None;
- this.buttonMap.Start = OVRInput.RawButton.Start;
- this.buttonMap.Back = OVRInput.RawButton.Back;
- this.buttonMap.PrimaryShoulder = OVRInput.RawButton.None;
- this.buttonMap.PrimaryIndexTrigger = OVRInput.RawButton.None;
- this.buttonMap.PrimaryHandTrigger = OVRInput.RawButton.None;
- this.buttonMap.PrimaryThumbstick = OVRInput.RawButton.None;
- this.buttonMap.PrimaryThumbstickUp = OVRInput.RawButton.None;
- this.buttonMap.PrimaryThumbstickDown = OVRInput.RawButton.None;
- this.buttonMap.PrimaryThumbstickLeft = OVRInput.RawButton.None;
- this.buttonMap.PrimaryThumbstickRight = OVRInput.RawButton.None;
- this.buttonMap.SecondaryShoulder = OVRInput.RawButton.None;
- this.buttonMap.SecondaryIndexTrigger = OVRInput.RawButton.None;
- this.buttonMap.SecondaryHandTrigger = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstick = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstickUp = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstickDown = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstickLeft = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstickRight = OVRInput.RawButton.None;
- this.buttonMap.DpadUp = OVRInput.RawButton.DpadUp;
- this.buttonMap.DpadDown = OVRInput.RawButton.DpadDown;
- this.buttonMap.DpadLeft = OVRInput.RawButton.DpadLeft;
- this.buttonMap.DpadRight = OVRInput.RawButton.DpadRight;
- this.buttonMap.Up = OVRInput.RawButton.DpadUp;
- this.buttonMap.Down = OVRInput.RawButton.DpadDown;
- this.buttonMap.Left = OVRInput.RawButton.DpadLeft;
- this.buttonMap.Right = OVRInput.RawButton.DpadRight;
- }
- public override void ConfigureTouchMap()
- {
- this.touchMap.None = OVRInput.RawTouch.None;
- this.touchMap.One = OVRInput.RawTouch.None;
- this.touchMap.Two = OVRInput.RawTouch.None;
- this.touchMap.Three = OVRInput.RawTouch.None;
- this.touchMap.Four = OVRInput.RawTouch.None;
- this.touchMap.PrimaryIndexTrigger = OVRInput.RawTouch.None;
- this.touchMap.PrimaryThumbstick = OVRInput.RawTouch.None;
- this.touchMap.PrimaryThumbRest = OVRInput.RawTouch.None;
- this.touchMap.SecondaryIndexTrigger = OVRInput.RawTouch.None;
- this.touchMap.SecondaryThumbstick = OVRInput.RawTouch.None;
- this.touchMap.SecondaryThumbRest = OVRInput.RawTouch.None;
- }
- public override void ConfigureNearTouchMap()
- {
- this.nearTouchMap.None = OVRInput.RawNearTouch.None;
- this.nearTouchMap.PrimaryIndexTrigger = OVRInput.RawNearTouch.None;
- this.nearTouchMap.PrimaryThumbButtons = OVRInput.RawNearTouch.None;
- this.nearTouchMap.SecondaryIndexTrigger = OVRInput.RawNearTouch.None;
- this.nearTouchMap.SecondaryThumbButtons = OVRInput.RawNearTouch.None;
- }
- public override void ConfigureAxis1DMap()
- {
- this.axis1DMap.None = OVRInput.RawAxis1D.None;
- this.axis1DMap.PrimaryIndexTrigger = OVRInput.RawAxis1D.None;
- this.axis1DMap.PrimaryHandTrigger = OVRInput.RawAxis1D.None;
- this.axis1DMap.SecondaryIndexTrigger = OVRInput.RawAxis1D.None;
- this.axis1DMap.SecondaryHandTrigger = OVRInput.RawAxis1D.None;
- }
- public override void ConfigureAxis2DMap()
- {
- this.axis2DMap.None = OVRInput.RawAxis2D.None;
- this.axis2DMap.PrimaryThumbstick = OVRInput.RawAxis2D.None;
- this.axis2DMap.SecondaryThumbstick = OVRInput.RawAxis2D.None;
- }
- }
- private class OVRControllerGamepadPC : OVRInput.OVRControllerBase
- {
- public OVRControllerGamepadPC()
- {
- this.controllerType = OVRInput.Controller.Gamepad;
- }
- public override void ConfigureButtonMap()
- {
- this.buttonMap.None = OVRInput.RawButton.None;
- this.buttonMap.One = OVRInput.RawButton.A;
- this.buttonMap.Two = OVRInput.RawButton.B;
- this.buttonMap.Three = OVRInput.RawButton.X;
- this.buttonMap.Four = OVRInput.RawButton.Y;
- this.buttonMap.Start = OVRInput.RawButton.Start;
- this.buttonMap.Back = OVRInput.RawButton.Back;
- this.buttonMap.PrimaryShoulder = OVRInput.RawButton.LShoulder;
- this.buttonMap.PrimaryIndexTrigger = OVRInput.RawButton.LIndexTrigger;
- this.buttonMap.PrimaryHandTrigger = OVRInput.RawButton.None;
- this.buttonMap.PrimaryThumbstick = OVRInput.RawButton.LThumbstick;
- this.buttonMap.PrimaryThumbstickUp = OVRInput.RawButton.LThumbstickUp;
- this.buttonMap.PrimaryThumbstickDown = OVRInput.RawButton.LThumbstickDown;
- this.buttonMap.PrimaryThumbstickLeft = OVRInput.RawButton.LThumbstickLeft;
- this.buttonMap.PrimaryThumbstickRight = OVRInput.RawButton.LThumbstickRight;
- this.buttonMap.SecondaryShoulder = OVRInput.RawButton.RShoulder;
- this.buttonMap.SecondaryIndexTrigger = OVRInput.RawButton.RIndexTrigger;
- this.buttonMap.SecondaryHandTrigger = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstick = OVRInput.RawButton.RThumbstick;
- this.buttonMap.SecondaryThumbstickUp = OVRInput.RawButton.RThumbstickUp;
- this.buttonMap.SecondaryThumbstickDown = OVRInput.RawButton.RThumbstickDown;
- this.buttonMap.SecondaryThumbstickLeft = OVRInput.RawButton.RThumbstickLeft;
- this.buttonMap.SecondaryThumbstickRight = OVRInput.RawButton.RThumbstickRight;
- this.buttonMap.DpadUp = OVRInput.RawButton.DpadUp;
- this.buttonMap.DpadDown = OVRInput.RawButton.DpadDown;
- this.buttonMap.DpadLeft = OVRInput.RawButton.DpadLeft;
- this.buttonMap.DpadRight = OVRInput.RawButton.DpadRight;
- this.buttonMap.Up = OVRInput.RawButton.LThumbstickUp;
- this.buttonMap.Down = OVRInput.RawButton.LThumbstickDown;
- this.buttonMap.Left = OVRInput.RawButton.LThumbstickLeft;
- this.buttonMap.Right = OVRInput.RawButton.LThumbstickRight;
- }
- public override void ConfigureTouchMap()
- {
- this.touchMap.None = OVRInput.RawTouch.None;
- this.touchMap.One = OVRInput.RawTouch.None;
- this.touchMap.Two = OVRInput.RawTouch.None;
- this.touchMap.Three = OVRInput.RawTouch.None;
- this.touchMap.Four = OVRInput.RawTouch.None;
- this.touchMap.PrimaryIndexTrigger = OVRInput.RawTouch.None;
- this.touchMap.PrimaryThumbstick = OVRInput.RawTouch.None;
- this.touchMap.PrimaryThumbRest = OVRInput.RawTouch.None;
- this.touchMap.SecondaryIndexTrigger = OVRInput.RawTouch.None;
- this.touchMap.SecondaryThumbstick = OVRInput.RawTouch.None;
- this.touchMap.SecondaryThumbRest = OVRInput.RawTouch.None;
- }
- public override void ConfigureNearTouchMap()
- {
- this.nearTouchMap.None = OVRInput.RawNearTouch.None;
- this.nearTouchMap.PrimaryIndexTrigger = OVRInput.RawNearTouch.None;
- this.nearTouchMap.PrimaryThumbButtons = OVRInput.RawNearTouch.None;
- this.nearTouchMap.SecondaryIndexTrigger = OVRInput.RawNearTouch.None;
- this.nearTouchMap.SecondaryThumbButtons = OVRInput.RawNearTouch.None;
- }
- public override void ConfigureAxis1DMap()
- {
- this.axis1DMap.None = OVRInput.RawAxis1D.None;
- this.axis1DMap.PrimaryIndexTrigger = OVRInput.RawAxis1D.LIndexTrigger;
- this.axis1DMap.PrimaryHandTrigger = OVRInput.RawAxis1D.None;
- this.axis1DMap.SecondaryIndexTrigger = OVRInput.RawAxis1D.RIndexTrigger;
- this.axis1DMap.SecondaryHandTrigger = OVRInput.RawAxis1D.None;
- }
- public override void ConfigureAxis2DMap()
- {
- this.axis2DMap.None = OVRInput.RawAxis2D.None;
- this.axis2DMap.PrimaryThumbstick = OVRInput.RawAxis2D.LThumbstick;
- this.axis2DMap.SecondaryThumbstick = OVRInput.RawAxis2D.RThumbstick;
- }
- }
- private class OVRControllerGamepadMac : OVRInput.OVRControllerBase
- {
- public OVRControllerGamepadMac()
- {
- this.controllerType = OVRInput.Controller.Gamepad;
- this.initialized = OVRInput.OVRControllerGamepadMac.OVR_GamepadController_Initialize();
- }
- ~OVRControllerGamepadMac()
- {
- if (this.initialized)
- {
- OVRInput.OVRControllerGamepadMac.OVR_GamepadController_Destroy();
- }
- }
- public override OVRInput.Controller Update()
- {
- if (!this.initialized)
- {
- return OVRInput.Controller.None;
- }
- OVRPlugin.ControllerState currentState = default(OVRPlugin.ControllerState);
- bool flag = OVRInput.OVRControllerGamepadMac.OVR_GamepadController_Update();
- if (flag)
- {
- currentState.ConnectedControllers = 16u;
- }
- if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(0))
- {
- currentState.Buttons |= 1u;
- }
- if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(1))
- {
- currentState.Buttons |= 2u;
- }
- if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(2))
- {
- currentState.Buttons |= 256u;
- }
- if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(3))
- {
- currentState.Buttons |= 512u;
- }
- if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(4))
- {
- currentState.Buttons |= 65536u;
- }
- if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(5))
- {
- currentState.Buttons |= 131072u;
- }
- if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(6))
- {
- currentState.Buttons |= 262144u;
- }
- if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(7))
- {
- currentState.Buttons |= 524288u;
- }
- if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(8))
- {
- currentState.Buttons |= 1048576u;
- }
- if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(9))
- {
- currentState.Buttons |= 2097152u;
- }
- if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(10))
- {
- currentState.Buttons |= 1024u;
- }
- if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(11))
- {
- currentState.Buttons |= 4u;
- }
- if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(12))
- {
- currentState.Buttons |= 2048u;
- }
- if (OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetButton(13))
- {
- currentState.Buttons |= 8u;
- }
- currentState.LThumbstick.x = OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetAxis(0);
- currentState.LThumbstick.y = OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetAxis(1);
- currentState.RThumbstick.x = OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetAxis(2);
- currentState.RThumbstick.y = OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetAxis(3);
- currentState.LIndexTrigger = OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetAxis(4);
- currentState.RIndexTrigger = OVRInput.OVRControllerGamepadMac.OVR_GamepadController_GetAxis(5);
- if (currentState.LIndexTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 268435456u;
- }
- if (currentState.LHandTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 536870912u;
- }
- if (currentState.LThumbstick.y >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 16u;
- }
- if (currentState.LThumbstick.y <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 32u;
- }
- if (currentState.LThumbstick.x <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 64u;
- }
- if (currentState.LThumbstick.x >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 128u;
- }
- if (currentState.RIndexTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 67108864u;
- }
- if (currentState.RHandTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 134217728u;
- }
- if (currentState.RThumbstick.y >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 4096u;
- }
- if (currentState.RThumbstick.y <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 8192u;
- }
- if (currentState.RThumbstick.x <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 16384u;
- }
- if (currentState.RThumbstick.x >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 32768u;
- }
- this.previousState = this.currentState;
- this.currentState = currentState;
- return (OVRInput.Controller)(this.currentState.ConnectedControllers & (uint)this.controllerType);
- }
- public override void ConfigureButtonMap()
- {
- this.buttonMap.None = OVRInput.RawButton.None;
- this.buttonMap.One = OVRInput.RawButton.A;
- this.buttonMap.Two = OVRInput.RawButton.B;
- this.buttonMap.Three = OVRInput.RawButton.X;
- this.buttonMap.Four = OVRInput.RawButton.Y;
- this.buttonMap.Start = OVRInput.RawButton.Start;
- this.buttonMap.Back = OVRInput.RawButton.Back;
- this.buttonMap.PrimaryShoulder = OVRInput.RawButton.LShoulder;
- this.buttonMap.PrimaryIndexTrigger = OVRInput.RawButton.LIndexTrigger;
- this.buttonMap.PrimaryHandTrigger = OVRInput.RawButton.None;
- this.buttonMap.PrimaryThumbstick = OVRInput.RawButton.LThumbstick;
- this.buttonMap.PrimaryThumbstickUp = OVRInput.RawButton.LThumbstickUp;
- this.buttonMap.PrimaryThumbstickDown = OVRInput.RawButton.LThumbstickDown;
- this.buttonMap.PrimaryThumbstickLeft = OVRInput.RawButton.LThumbstickLeft;
- this.buttonMap.PrimaryThumbstickRight = OVRInput.RawButton.LThumbstickRight;
- this.buttonMap.SecondaryShoulder = OVRInput.RawButton.RShoulder;
- this.buttonMap.SecondaryIndexTrigger = OVRInput.RawButton.RIndexTrigger;
- this.buttonMap.SecondaryHandTrigger = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstick = OVRInput.RawButton.RThumbstick;
- this.buttonMap.SecondaryThumbstickUp = OVRInput.RawButton.RThumbstickUp;
- this.buttonMap.SecondaryThumbstickDown = OVRInput.RawButton.RThumbstickDown;
- this.buttonMap.SecondaryThumbstickLeft = OVRInput.RawButton.RThumbstickLeft;
- this.buttonMap.SecondaryThumbstickRight = OVRInput.RawButton.RThumbstickRight;
- this.buttonMap.DpadUp = OVRInput.RawButton.DpadUp;
- this.buttonMap.DpadDown = OVRInput.RawButton.DpadDown;
- this.buttonMap.DpadLeft = OVRInput.RawButton.DpadLeft;
- this.buttonMap.DpadRight = OVRInput.RawButton.DpadRight;
- this.buttonMap.Up = OVRInput.RawButton.LThumbstickUp;
- this.buttonMap.Down = OVRInput.RawButton.LThumbstickDown;
- this.buttonMap.Left = OVRInput.RawButton.LThumbstickLeft;
- this.buttonMap.Right = OVRInput.RawButton.LThumbstickRight;
- }
- public override void ConfigureTouchMap()
- {
- this.touchMap.None = OVRInput.RawTouch.None;
- this.touchMap.One = OVRInput.RawTouch.None;
- this.touchMap.Two = OVRInput.RawTouch.None;
- this.touchMap.Three = OVRInput.RawTouch.None;
- this.touchMap.Four = OVRInput.RawTouch.None;
- this.touchMap.PrimaryIndexTrigger = OVRInput.RawTouch.None;
- this.touchMap.PrimaryThumbstick = OVRInput.RawTouch.None;
- this.touchMap.PrimaryThumbRest = OVRInput.RawTouch.None;
- this.touchMap.SecondaryIndexTrigger = OVRInput.RawTouch.None;
- this.touchMap.SecondaryThumbstick = OVRInput.RawTouch.None;
- this.touchMap.SecondaryThumbRest = OVRInput.RawTouch.None;
- }
- public override void ConfigureNearTouchMap()
- {
- this.nearTouchMap.None = OVRInput.RawNearTouch.None;
- this.nearTouchMap.PrimaryIndexTrigger = OVRInput.RawNearTouch.None;
- this.nearTouchMap.PrimaryThumbButtons = OVRInput.RawNearTouch.None;
- this.nearTouchMap.SecondaryIndexTrigger = OVRInput.RawNearTouch.None;
- this.nearTouchMap.SecondaryThumbButtons = OVRInput.RawNearTouch.None;
- }
- public override void ConfigureAxis1DMap()
- {
- this.axis1DMap.None = OVRInput.RawAxis1D.None;
- this.axis1DMap.PrimaryIndexTrigger = OVRInput.RawAxis1D.LIndexTrigger;
- this.axis1DMap.PrimaryHandTrigger = OVRInput.RawAxis1D.None;
- this.axis1DMap.SecondaryIndexTrigger = OVRInput.RawAxis1D.RIndexTrigger;
- this.axis1DMap.SecondaryHandTrigger = OVRInput.RawAxis1D.None;
- }
- public override void ConfigureAxis2DMap()
- {
- this.axis2DMap.None = OVRInput.RawAxis2D.None;
- this.axis2DMap.PrimaryThumbstick = OVRInput.RawAxis2D.LThumbstick;
- this.axis2DMap.SecondaryThumbstick = OVRInput.RawAxis2D.RThumbstick;
- }
- public override void SetControllerVibration(float frequency, float amplitude)
- {
- int node = 0;
- float frequency2 = frequency * 200f;
- OVRInput.OVRControllerGamepadMac.OVR_GamepadController_SetVibration(node, amplitude, frequency2);
- }
- [DllImport("OVRGamepad", CallingConvention = CallingConvention.Cdecl)]
- private static extern bool OVR_GamepadController_Initialize();
- [DllImport("OVRGamepad", CallingConvention = CallingConvention.Cdecl)]
- private static extern bool OVR_GamepadController_Destroy();
- [DllImport("OVRGamepad", CallingConvention = CallingConvention.Cdecl)]
- private static extern bool OVR_GamepadController_Update();
- [DllImport("OVRGamepad", CallingConvention = CallingConvention.Cdecl)]
- private static extern float OVR_GamepadController_GetAxis(int axis);
- [DllImport("OVRGamepad", CallingConvention = CallingConvention.Cdecl)]
- private static extern bool OVR_GamepadController_GetButton(int button);
- [DllImport("OVRGamepad", CallingConvention = CallingConvention.Cdecl)]
- private static extern bool OVR_GamepadController_SetVibration(int node, float strength, float frequency);
- private bool initialized;
- private const string DllName = "OVRGamepad";
- private enum AxisGPC
- {
- None = -1,
- LeftXAxis,
- LeftYAxis,
- RightXAxis,
- RightYAxis,
- LeftTrigger,
- RightTrigger,
- DPad_X_Axis,
- DPad_Y_Axis,
- Max
- }
- public enum ButtonGPC
- {
- None = -1,
- A,
- B,
- X,
- Y,
- Up,
- Down,
- Left,
- Right,
- Start,
- Back,
- LStick,
- RStick,
- LeftShoulder,
- RightShoulder,
- Max
- }
- }
- private class OVRControllerGamepadAndroid : OVRInput.OVRControllerBase
- {
- public OVRControllerGamepadAndroid()
- {
- this.controllerType = OVRInput.Controller.Gamepad;
- }
- private bool ShouldUpdate()
- {
- if (Time.realtimeSinceStartup - this.joystickCheckTime > this.joystickCheckInterval)
- {
- this.joystickCheckTime = Time.realtimeSinceStartup;
- this.joystickDetected = false;
- string[] joystickNames = Input.GetJoystickNames();
- for (int i = 0; i < joystickNames.Length; i++)
- {
- if (joystickNames[i] != string.Empty)
- {
- this.joystickDetected = true;
- break;
- }
- }
- }
- return this.joystickDetected;
- }
- public override OVRInput.Controller Update()
- {
- if (!this.ShouldUpdate())
- {
- return OVRInput.Controller.None;
- }
- OVRPlugin.ControllerState currentState = default(OVRPlugin.ControllerState);
- currentState.ConnectedControllers = 16u;
- if (Input.GetKey(OVRInput.OVRControllerGamepadAndroid.AndroidButtonNames.A))
- {
- currentState.Buttons |= 1u;
- }
- if (Input.GetKey(OVRInput.OVRControllerGamepadAndroid.AndroidButtonNames.B))
- {
- currentState.Buttons |= 2u;
- }
- if (Input.GetKey(OVRInput.OVRControllerGamepadAndroid.AndroidButtonNames.X))
- {
- currentState.Buttons |= 256u;
- }
- if (Input.GetKey(OVRInput.OVRControllerGamepadAndroid.AndroidButtonNames.Y))
- {
- currentState.Buttons |= 512u;
- }
- if (Input.GetKey(OVRInput.OVRControllerGamepadAndroid.AndroidButtonNames.Start))
- {
- currentState.Buttons |= 1048576u;
- }
- if (Input.GetKey(OVRInput.OVRControllerGamepadAndroid.AndroidButtonNames.Back) || Input.GetKey(KeyCode.Escape))
- {
- currentState.Buttons |= 2097152u;
- }
- if (Input.GetKey(OVRInput.OVRControllerGamepadAndroid.AndroidButtonNames.LThumbstick))
- {
- currentState.Buttons |= 1024u;
- }
- if (Input.GetKey(OVRInput.OVRControllerGamepadAndroid.AndroidButtonNames.RThumbstick))
- {
- currentState.Buttons |= 4u;
- }
- if (Input.GetKey(OVRInput.OVRControllerGamepadAndroid.AndroidButtonNames.LShoulder))
- {
- currentState.Buttons |= 2048u;
- }
- if (Input.GetKey(OVRInput.OVRControllerGamepadAndroid.AndroidButtonNames.RShoulder))
- {
- currentState.Buttons |= 8u;
- }
- currentState.LThumbstick.x = Input.GetAxisRaw(OVRInput.OVRControllerGamepadAndroid.AndroidAxisNames.LThumbstickX);
- currentState.LThumbstick.y = Input.GetAxisRaw(OVRInput.OVRControllerGamepadAndroid.AndroidAxisNames.LThumbstickY);
- currentState.RThumbstick.x = Input.GetAxisRaw(OVRInput.OVRControllerGamepadAndroid.AndroidAxisNames.RThumbstickX);
- currentState.RThumbstick.y = Input.GetAxisRaw(OVRInput.OVRControllerGamepadAndroid.AndroidAxisNames.RThumbstickY);
- currentState.LIndexTrigger = Input.GetAxisRaw(OVRInput.OVRControllerGamepadAndroid.AndroidAxisNames.LIndexTrigger);
- currentState.RIndexTrigger = Input.GetAxisRaw(OVRInput.OVRControllerGamepadAndroid.AndroidAxisNames.RIndexTrigger);
- if (currentState.LIndexTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 268435456u;
- }
- if (currentState.LHandTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 536870912u;
- }
- if (currentState.LThumbstick.y >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 16u;
- }
- if (currentState.LThumbstick.y <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 32u;
- }
- if (currentState.LThumbstick.x <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 64u;
- }
- if (currentState.LThumbstick.x >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 128u;
- }
- if (currentState.RIndexTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 67108864u;
- }
- if (currentState.RHandTrigger >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 134217728u;
- }
- if (currentState.RThumbstick.y >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 4096u;
- }
- if (currentState.RThumbstick.y <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 8192u;
- }
- if (currentState.RThumbstick.x <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 16384u;
- }
- if (currentState.RThumbstick.x >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 32768u;
- }
- float axisRaw = Input.GetAxisRaw(OVRInput.OVRControllerGamepadAndroid.AndroidAxisNames.DpadX);
- float axisRaw2 = Input.GetAxisRaw(OVRInput.OVRControllerGamepadAndroid.AndroidAxisNames.DpadY);
- if (axisRaw <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 262144u;
- }
- if (axisRaw >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 524288u;
- }
- if (axisRaw2 <= -OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 131072u;
- }
- if (axisRaw2 >= OVRInput.AXIS_AS_BUTTON_THRESHOLD)
- {
- currentState.Buttons |= 65536u;
- }
- this.previousState = this.currentState;
- this.currentState = currentState;
- return (OVRInput.Controller)(this.currentState.ConnectedControllers & (uint)this.controllerType);
- }
- public override void ConfigureButtonMap()
- {
- this.buttonMap.None = OVRInput.RawButton.None;
- this.buttonMap.One = OVRInput.RawButton.A;
- this.buttonMap.Two = OVRInput.RawButton.B;
- this.buttonMap.Three = OVRInput.RawButton.X;
- this.buttonMap.Four = OVRInput.RawButton.Y;
- this.buttonMap.Start = OVRInput.RawButton.Start;
- this.buttonMap.Back = OVRInput.RawButton.Back;
- this.buttonMap.PrimaryShoulder = OVRInput.RawButton.LShoulder;
- this.buttonMap.PrimaryIndexTrigger = OVRInput.RawButton.LIndexTrigger;
- this.buttonMap.PrimaryHandTrigger = OVRInput.RawButton.None;
- this.buttonMap.PrimaryThumbstick = OVRInput.RawButton.LThumbstick;
- this.buttonMap.PrimaryThumbstickUp = OVRInput.RawButton.LThumbstickUp;
- this.buttonMap.PrimaryThumbstickDown = OVRInput.RawButton.LThumbstickDown;
- this.buttonMap.PrimaryThumbstickLeft = OVRInput.RawButton.LThumbstickLeft;
- this.buttonMap.PrimaryThumbstickRight = OVRInput.RawButton.LThumbstickRight;
- this.buttonMap.SecondaryShoulder = OVRInput.RawButton.RShoulder;
- this.buttonMap.SecondaryIndexTrigger = OVRInput.RawButton.RIndexTrigger;
- this.buttonMap.SecondaryHandTrigger = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstick = OVRInput.RawButton.RThumbstick;
- this.buttonMap.SecondaryThumbstickUp = OVRInput.RawButton.RThumbstickUp;
- this.buttonMap.SecondaryThumbstickDown = OVRInput.RawButton.RThumbstickDown;
- this.buttonMap.SecondaryThumbstickLeft = OVRInput.RawButton.RThumbstickLeft;
- this.buttonMap.SecondaryThumbstickRight = OVRInput.RawButton.RThumbstickRight;
- this.buttonMap.DpadUp = OVRInput.RawButton.DpadUp;
- this.buttonMap.DpadDown = OVRInput.RawButton.DpadDown;
- this.buttonMap.DpadLeft = OVRInput.RawButton.DpadLeft;
- this.buttonMap.DpadRight = OVRInput.RawButton.DpadRight;
- this.buttonMap.Up = OVRInput.RawButton.LThumbstickUp;
- this.buttonMap.Down = OVRInput.RawButton.LThumbstickDown;
- this.buttonMap.Left = OVRInput.RawButton.LThumbstickLeft;
- this.buttonMap.Right = OVRInput.RawButton.LThumbstickRight;
- }
- public override void ConfigureTouchMap()
- {
- this.touchMap.None = OVRInput.RawTouch.None;
- this.touchMap.One = OVRInput.RawTouch.None;
- this.touchMap.Two = OVRInput.RawTouch.None;
- this.touchMap.Three = OVRInput.RawTouch.None;
- this.touchMap.Four = OVRInput.RawTouch.None;
- this.touchMap.PrimaryIndexTrigger = OVRInput.RawTouch.None;
- this.touchMap.PrimaryThumbstick = OVRInput.RawTouch.None;
- this.touchMap.PrimaryThumbRest = OVRInput.RawTouch.None;
- this.touchMap.SecondaryIndexTrigger = OVRInput.RawTouch.None;
- this.touchMap.SecondaryThumbstick = OVRInput.RawTouch.None;
- this.touchMap.SecondaryThumbRest = OVRInput.RawTouch.None;
- }
- public override void ConfigureNearTouchMap()
- {
- this.nearTouchMap.None = OVRInput.RawNearTouch.None;
- this.nearTouchMap.PrimaryIndexTrigger = OVRInput.RawNearTouch.None;
- this.nearTouchMap.PrimaryThumbButtons = OVRInput.RawNearTouch.None;
- this.nearTouchMap.SecondaryIndexTrigger = OVRInput.RawNearTouch.None;
- this.nearTouchMap.SecondaryThumbButtons = OVRInput.RawNearTouch.None;
- }
- public override void ConfigureAxis1DMap()
- {
- this.axis1DMap.None = OVRInput.RawAxis1D.None;
- this.axis1DMap.PrimaryIndexTrigger = OVRInput.RawAxis1D.LIndexTrigger;
- this.axis1DMap.PrimaryHandTrigger = OVRInput.RawAxis1D.None;
- this.axis1DMap.SecondaryIndexTrigger = OVRInput.RawAxis1D.RIndexTrigger;
- this.axis1DMap.SecondaryHandTrigger = OVRInput.RawAxis1D.None;
- }
- public override void ConfigureAxis2DMap()
- {
- this.axis2DMap.None = OVRInput.RawAxis2D.None;
- this.axis2DMap.PrimaryThumbstick = OVRInput.RawAxis2D.LThumbstick;
- this.axis2DMap.SecondaryThumbstick = OVRInput.RawAxis2D.RThumbstick;
- }
- public override void SetControllerVibration(float frequency, float amplitude)
- {
- }
- private bool joystickDetected;
- private float joystickCheckInterval = 1f;
- private float joystickCheckTime;
- private static class AndroidButtonNames
- {
- public static readonly KeyCode A = KeyCode.JoystickButton0;
- public static readonly KeyCode B = KeyCode.JoystickButton1;
- public static readonly KeyCode X = KeyCode.JoystickButton2;
- public static readonly KeyCode Y = KeyCode.JoystickButton3;
- public static readonly KeyCode Start = KeyCode.JoystickButton10;
- public static readonly KeyCode Back = KeyCode.JoystickButton11;
- public static readonly KeyCode LThumbstick = KeyCode.JoystickButton8;
- public static readonly KeyCode RThumbstick = KeyCode.JoystickButton9;
- public static readonly KeyCode LShoulder = KeyCode.JoystickButton4;
- public static readonly KeyCode RShoulder = KeyCode.JoystickButton5;
- }
- private static class AndroidAxisNames
- {
- public static readonly string LThumbstickX = "Oculus_GearVR_LThumbstickX";
- public static readonly string LThumbstickY = "Oculus_GearVR_LThumbstickY";
- public static readonly string RThumbstickX = "Oculus_GearVR_RThumbstickX";
- public static readonly string RThumbstickY = "Oculus_GearVR_RThumbstickY";
- public static readonly string LIndexTrigger = "Oculus_GearVR_LIndexTrigger";
- public static readonly string RIndexTrigger = "Oculus_GearVR_RIndexTrigger";
- public static readonly string DpadX = "Oculus_GearVR_DpadX";
- public static readonly string DpadY = "Oculus_GearVR_DpadY";
- }
- }
- private class OVRControllerTouchpad : OVRInput.OVRControllerBase
- {
- public OVRControllerTouchpad()
- {
- this.controllerType = OVRInput.Controller.Touchpad;
- }
- public override OVRInput.Controller Update()
- {
- OVRPlugin.ControllerState currentState = default(OVRPlugin.ControllerState);
- if (Input.mousePresent)
- {
- currentState.ConnectedControllers = 134217728u;
- }
- if (Input.GetMouseButtonDown(0))
- {
- this.moveAmountMouse = Input.mousePosition;
- }
- if (Input.GetMouseButtonUp(0))
- {
- this.moveAmountMouse -= Input.mousePosition;
- Vector3 vector = this.moveAmountMouse;
- if (vector.magnitude < this.minMovMagnitudeMouse)
- {
- currentState.Buttons |= 1u;
- }
- else
- {
- vector.Normalize();
- if (Mathf.Abs(vector.x) > Mathf.Abs(vector.y))
- {
- if (vector.x > 0f)
- {
- currentState.Buttons |= 524288u;
- }
- else
- {
- currentState.Buttons |= 262144u;
- }
- }
- else if (vector.y > 0f)
- {
- currentState.Buttons |= 131072u;
- }
- else
- {
- currentState.Buttons |= 65536u;
- }
- }
- }
- if (Input.GetKey(KeyCode.Escape))
- {
- currentState.Buttons |= 2u;
- }
- this.previousState = this.currentState;
- this.currentState = currentState;
- return (OVRInput.Controller)(this.currentState.ConnectedControllers & (uint)this.controllerType);
- }
- public override void ConfigureButtonMap()
- {
- this.buttonMap.None = OVRInput.RawButton.None;
- this.buttonMap.One = OVRInput.RawButton.A;
- this.buttonMap.Two = OVRInput.RawButton.B;
- this.buttonMap.Three = OVRInput.RawButton.None;
- this.buttonMap.Four = OVRInput.RawButton.None;
- this.buttonMap.Start = OVRInput.RawButton.None;
- this.buttonMap.Back = OVRInput.RawButton.None;
- this.buttonMap.PrimaryShoulder = OVRInput.RawButton.None;
- this.buttonMap.PrimaryIndexTrigger = OVRInput.RawButton.None;
- this.buttonMap.PrimaryHandTrigger = OVRInput.RawButton.None;
- this.buttonMap.PrimaryThumbstick = OVRInput.RawButton.None;
- this.buttonMap.PrimaryThumbstickUp = OVRInput.RawButton.None;
- this.buttonMap.PrimaryThumbstickDown = OVRInput.RawButton.None;
- this.buttonMap.PrimaryThumbstickLeft = OVRInput.RawButton.None;
- this.buttonMap.PrimaryThumbstickRight = OVRInput.RawButton.None;
- this.buttonMap.SecondaryShoulder = OVRInput.RawButton.None;
- this.buttonMap.SecondaryIndexTrigger = OVRInput.RawButton.None;
- this.buttonMap.SecondaryHandTrigger = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstick = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstickUp = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstickDown = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstickLeft = OVRInput.RawButton.None;
- this.buttonMap.SecondaryThumbstickRight = OVRInput.RawButton.None;
- this.buttonMap.DpadUp = OVRInput.RawButton.DpadUp;
- this.buttonMap.DpadDown = OVRInput.RawButton.DpadDown;
- this.buttonMap.DpadLeft = OVRInput.RawButton.DpadLeft;
- this.buttonMap.DpadRight = OVRInput.RawButton.DpadRight;
- this.buttonMap.Up = OVRInput.RawButton.DpadUp;
- this.buttonMap.Down = OVRInput.RawButton.DpadDown;
- this.buttonMap.Left = OVRInput.RawButton.DpadLeft;
- this.buttonMap.Right = OVRInput.RawButton.DpadRight;
- }
- public override void ConfigureTouchMap()
- {
- this.touchMap.None = OVRInput.RawTouch.None;
- this.touchMap.One = OVRInput.RawTouch.None;
- this.touchMap.Two = OVRInput.RawTouch.None;
- this.touchMap.Three = OVRInput.RawTouch.None;
- this.touchMap.Four = OVRInput.RawTouch.None;
- this.touchMap.PrimaryIndexTrigger = OVRInput.RawTouch.None;
- this.touchMap.PrimaryThumbstick = OVRInput.RawTouch.None;
- this.touchMap.PrimaryThumbRest = OVRInput.RawTouch.None;
- this.touchMap.SecondaryIndexTrigger = OVRInput.RawTouch.None;
- this.touchMap.SecondaryThumbstick = OVRInput.RawTouch.None;
- this.touchMap.SecondaryThumbRest = OVRInput.RawTouch.None;
- }
- public override void ConfigureNearTouchMap()
- {
- this.nearTouchMap.None = OVRInput.RawNearTouch.None;
- this.nearTouchMap.PrimaryIndexTrigger = OVRInput.RawNearTouch.None;
- this.nearTouchMap.PrimaryThumbButtons = OVRInput.RawNearTouch.None;
- this.nearTouchMap.SecondaryIndexTrigger = OVRInput.RawNearTouch.None;
- this.nearTouchMap.SecondaryThumbButtons = OVRInput.RawNearTouch.None;
- }
- public override void ConfigureAxis1DMap()
- {
- this.axis1DMap.None = OVRInput.RawAxis1D.None;
- this.axis1DMap.PrimaryIndexTrigger = OVRInput.RawAxis1D.None;
- this.axis1DMap.PrimaryHandTrigger = OVRInput.RawAxis1D.None;
- this.axis1DMap.SecondaryIndexTrigger = OVRInput.RawAxis1D.None;
- this.axis1DMap.SecondaryHandTrigger = OVRInput.RawAxis1D.None;
- }
- public override void ConfigureAxis2DMap()
- {
- this.axis2DMap.None = OVRInput.RawAxis2D.None;
- this.axis2DMap.PrimaryThumbstick = OVRInput.RawAxis2D.None;
- this.axis2DMap.SecondaryThumbstick = OVRInput.RawAxis2D.None;
- }
- private Vector3 moveAmountMouse;
- private float minMovMagnitudeMouse = 25f;
- }
- }
|