12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715 |
- /*******************************************************************************
- Copyright © 2015-2022 PICO Technology Co., Ltd.All rights reserved.
- NOTICE:All information contained herein is, and remains the property of
- PICO Technology Co., Ltd. The intellectual and technical concepts
- contained herein are proprietary to PICO Technology Co., Ltd. and may be
- covered by patents, patents in process, and are protected by trade secret or
- copyright law. Dissemination of this information or reproduction of this
- material is strictly forbidden unless prior written permission is obtained from
- PICO Technology Co., Ltd.
- *******************************************************************************/
- #if (UNITY_ANDROID && !UNITY_EDITOR)
- #define PICO_PLATFORM
- #endif
- using System;
- using System.Collections.Generic;
- using System.Runtime.InteropServices;
- #if PICO_XR
- using Unity.XR.PXR;
- #else
- using Unity.XR.OpenXR.Features.PICOSupport;
- #endif
- using UnityEngine;
- using UnityEngine.XR;
- namespace Unity.XR.PICO.TOBSupport
- {
- public partial class PXR_EnterprisePlugin
- {
- private const string TAG = "[PXR_EnterprisePlugin]";
- public const int MAX_SIZE = 12208032;
- public static string token;
- private static int curSize = 0;
- private static bool camOpenned = false;
- private static FrameItemExt antiDistortionFrameItemExt;
- private static FrameItemExt distortionFrameItemExt;
- private static bool initDistortionFrame;
- [DllImport("libpxr_xrsdk_native", CallingConvention = CallingConvention.Cdecl)]
- public static extern int getHeadTrackingConfidence();
- [DllImport("libpxr_xrsdk_native", CallingConvention = CallingConvention.Cdecl)]
- public static extern int openVSTCamera();
- [DllImport("libpxr_xrsdk_native", CallingConvention = CallingConvention.Cdecl)]
- public static extern int closeVSTCamera();
- [DllImport("libpxr_xrsdk_native", CallingConvention = CallingConvention.Cdecl)]
- public static extern int getHeadTrackingData(Int64 predictTime, ref SixDof data, int type);
- [DllImport("libpxr_xrsdk_native", CallingConvention = CallingConvention.Cdecl)]
- public static extern int acquireVSTCameraFrame(ref FrameItemExt frame);
- [DllImport("libpxr_xrsdk_native", CallingConvention = CallingConvention.Cdecl)]
- public static extern int acquireVSTCameraFrameAntiDistortion(string token, Int32 width, Int32 height, ref FrameItemExt frame);
- [DllImport("libpxr_xrsdk_native", CallingConvention = CallingConvention.Cdecl)]
- public static extern int getCameraParameters(string token, out RGBCameraParams rgb_Camera_Params);
- #if PICO_XR
- [DllImport("pxr_api", CallingConvention = CallingConvention.Cdecl)]
- #else
- [DllImport("openxr_pico", EntryPoint = "PICO_GetPredictedDisplayTime",
- CallingConvention = CallingConvention.Cdecl)]
- #endif
- public static extern int Pxr_GetPredictedDisplayTime(ref double predictedDisplayTime);
-
- #if PICO_XR
- [DllImport("pxr_api", CallingConvention = CallingConvention.Cdecl)]
- #else
- [DllImport("openxr_pico", EntryPoint = "PICO_GetPredictedMainSensorState2",
- CallingConvention = CallingConvention.Cdecl)]
- #endif
- public static extern int Pxr_GetPredictedMainSensorState2(double predictTimeMs, ref PxrSensorState2 sensorState, ref int sensorFrameIndex);
- #if PICO_PLATFORM
- private static AndroidJavaClass unityPlayer;
- private static AndroidJavaObject currentActivity;
- private static AndroidJavaObject tobHelper;
- private static AndroidJavaClass tobHelperClass;
- private static AndroidJavaObject IToBService;
- private static AndroidJavaClass BAuthLib;
- #endif
- public static Action<bool> BoolCallback;
- public static Action<int> IntCallback;
- public static Action<long> LongCallback;
- public static Action<string> StringCallback;
-
- private static AndroidJavaObject GetEnumType(Enum enumType)
- {
- AndroidJavaClass enumjs =
- new AndroidJavaClass("com.pvr.tobservice.enums" + enumType.GetType().ToString().Replace("Unity.XR.PICO.TOBSupport.", ".PBS_"));
- AndroidJavaObject enumjo = enumjs.GetStatic<AndroidJavaObject>(enumType.ToString());
- return enumjo;
- }
-
- public static bool UPxr_InitEnterpriseService()
- {
- #if PICO_PLATFORM
- tobHelperClass = new AndroidJavaClass("com.picoxr.tobservice.ToBServiceUtils");
- tobHelper = tobHelperClass.CallStatic<AndroidJavaObject>("getInstance");
- unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
- currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
- BAuthLib = new AndroidJavaClass("com.pvr.tobauthlib.AuthCheckServer");
- #endif
- return UPxr_GetToken();
- }
- public static void UPxr_SetBindCallBack(BindCallback mBoolCallback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("setBindCallBack", mBoolCallback);
- #endif
- }
- public static void UPxr_BindEnterpriseService(Action<bool> callback = null)
- {
- #if PICO_PLATFORM
- UPxr_SetBindCallBack(new BindCallback(callback));
- tobHelper.Call("bindTobService", currentActivity);
- #endif
- }
- public static void UPxr_UnBindEnterpriseService()
- {
- #if PICO_PLATFORM
- tobHelper.Call("unBindTobService");
- #endif
- }
- public static void GetServiceBinder()
- {
- #if PICO_PLATFORM
- IToBService = tobHelper.Call<AndroidJavaObject>("getServiceBinder");
- #endif
- }
- public static string UPxr_StateGetDeviceInfo(SystemInfoEnum type)
- {
- string result = "";
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return result;
- }
- result = IToBService.Call<string>("pbsStateGetDeviceInfo", GetEnumType(type), 0);
- #endif
- return result;
- }
- public static void UPxr_ControlSetDeviceAction(DeviceControlEnum deviceControl, Action<int> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsControlSetDeviceAction", GetEnumType(deviceControl), new IntCallback(callback));
- #endif
- }
- public static void UPxr_ControlAPPManager(PackageControlEnum packageControl, string path, Action<int> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsControlAPPManger", GetEnumType(packageControl), path, 0, new IntCallback(callback));
- #endif
- }
- public static void UPxr_ControlSetAutoConnectWIFI(string ssid, string pwd, Action<bool> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsControlSetAutoConnectWIFI", ssid, pwd, 0, new BoolCallback(callback));
- #endif
- }
- public static void UPxr_ControlClearAutoConnectWIFI(Action<bool> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsControlClearAutoConnectWIFI", new BoolCallback(callback));
- #endif
- }
- public static void UPxr_PropertySetHomeKey(HomeEventEnum eventEnum, HomeFunctionEnum function, Action<bool> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsPropertySetHomeKey", GetEnumType(eventEnum), GetEnumType(function), new BoolCallback(callback));
- #endif
- }
- public static void UPxr_PropertySetHomeKeyAll(HomeEventEnum eventEnum, HomeFunctionEnum function, int timesetup, string pkg, string className, Action<bool> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsPropertySetHomeKeyAll", GetEnumType(eventEnum), GetEnumType(function), timesetup, pkg,
- className, new BoolCallback(callback));
- #endif
- }
- public static void UPxr_PropertyDisablePowerKey(bool isSingleTap, bool enable, Action<int> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsPropertyDisablePowerKey", isSingleTap, enable, new IntCallback(callback));
- #endif
- }
- public static void UPxr_PropertySetScreenOffDelay(ScreenOffDelayTimeEnum timeEnum, Action<int> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsPropertySetScreenOffDelay", GetEnumType(timeEnum), new IntCallback(callback));
- #endif
- }
- public static void UPxr_PropertySetSleepDelay(SleepDelayTimeEnum timeEnum)
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsPropertySetSleepDelay", GetEnumType(timeEnum));
- #endif
- }
- public static void UPxr_SwitchSystemFunction(SystemFunctionSwitchEnum systemFunction, SwitchEnum switchEnum)
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsSwitchSystemFunction", GetEnumType(systemFunction), GetEnumType(switchEnum), 0);
- #endif
- }
- public static void UPxr_SwitchSetUsbConfigurationOption(USBConfigModeEnum uSBConfigModeEnum)
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsSwitchSetUsbConfigurationOption", GetEnumType(uSBConfigModeEnum), 0);
- #endif
- }
- public static void UPxr_SetControllerPairTime(ControllerPairTimeEnum timeEnum, Action<int> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsSetControllerPairTime", GetEnumType(timeEnum),new IntCallback(callback), 0);
- #endif
- }
- public static void UPxr_GetControllerPairTime(Action<int> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsGetControllerPairTime",new IntCallback(callback), 0);
- #endif
- }
- public static void UPxr_ScreenOn()
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsScreenOn");
- #endif
- }
- public static void UPxr_ScreenOff()
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsScreenOff");
- #endif
- }
- public static void UPxr_AcquireWakeLock()
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsAcquireWakeLock");
- #endif
- }
- public static void UPxr_ReleaseWakeLock()
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsReleaseWakeLock");
- #endif
- }
- public static void UPxr_EnableEnterKey()
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsEnableEnterKey");
- #endif
- }
- public static void UPxr_DisableEnterKey()
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsDisableEnterKey");
- #endif
- }
- public static void UPxr_EnableVolumeKey()
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsEnableVolumeKey");
- #endif
- }
- public static void UPxr_DisableVolumeKey()
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsDisableVolumeKey");
- #endif
- }
- public static void UPxr_EnableBackKey()
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsEnableBackKey");
- #endif
- }
- public static void UPxr_DisableBackKey()
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsDisableBackKey");
- #endif
- }
- public static void UPxr_ResetAllKeyToDefault(Action<bool> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsResetAllKeyToDefault", new BoolCallback(callback));
- #endif
- }
- public static void UPxr_SetAPPAsHome(SwitchEnum switchEnum, string packageName)
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsAppSetAPPAsHomeTwo", GetEnumType(switchEnum), packageName);
- #endif
- }
- public static void UPxr_KillAppsByPidOrPackageName(int[] pids, string[] packageNames)
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsKillAppsByPidOrPackageName", pids, packageNames, 0);
- #endif
- }
- public static void UPxr_KillBackgroundAppsWithWhiteList(string[] packageNames)
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsKillBackgroundAppsWithWhiteList",packageNames, 0);
- #endif
- }
- public static void UPxr_FreezeScreen(bool freeze)
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsFreezeScreen", freeze);
- #endif
- }
- public static void UPxr_OpenMiracast()
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsOpenMiracast");
- #endif
- }
- public static bool UPxr_IsMiracastOn()
- {
- bool value = false;
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<bool>("pbsIsMiracastOn");
- #endif
- return value;
- }
- public static void UPxr_CloseMiracast()
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsCloseMiracast");
- #endif
- }
- public static void UPxr_StartScan()
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsStartScan");
- #endif
- }
- public static void UPxr_StopScan()
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsStopScan");
- #endif
- }
- public static void UPxr_ConnectWifiDisplay(string modelJson)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsConnectWifiDisplay", modelJson);
- #endif
- }
- public static void UPxr_DisConnectWifiDisplay()
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsDisConnectWifiDisplay");
- #endif
- }
- public static void UPxr_ForgetWifiDisplay(string address)
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsForgetWifiDisplay", address);
- #endif
- }
- public static void UPxr_RenameWifiDisplay(string address, string newName)
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsRenameWifiDisplay", address, newName);
- #endif
- }
- public static void UPxr_SetWDModelsCallback(Action<List<WifiDisplayModel>> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsSetWDModelsCallback", new WifiDisplayModelCallback(callback));
- #endif
- }
- public static void UPxr_SetWDJsonCallback(Action<string> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsSetWDJsonCallback", new StringCallback(callback));
- #endif
- }
- public static void UPxr_UpdateWifiDisplays()
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return;
- }
- IToBService.Call("pbsUpdateWifiDisplays");
- #endif
- }
- public static string UPxr_GetConnectedWD()
- {
- string result = "";
- #if PICO_PLATFORM
- result = tobHelper.Call<string>("pbsGetConnectedWD");
- #endif
- return result;
- }
- public static void UPxr_SwitchLargeSpaceScene(bool open, Action<bool> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsSwitchLargeSpaceScene", new BoolCallback(callback), open, 0);
- #endif
- }
- public static void UPxr_GetSwitchLargeSpaceStatus(Action<string> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsGetSwitchLargeSpaceStatus",new StringCallback(callback), 0);
- #endif
- }
- public static bool UPxr_SaveLargeSpaceMaps()
- {
- bool value = false;
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<bool>("pbsSaveLargeSpaceMaps", 0);
- #endif
- return value;
- }
- public static void UPxr_ExportMaps(Action<bool> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsExportMaps", new BoolCallback(callback), 0);
- #endif
- }
- public static void UPxr_ImportMaps(Action<bool> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsImportMaps", new BoolCallback(callback), 0);
- #endif
- }
- public static float[] UPxr_GetCpuUsages()
- {
- float[] data = null;
- #if PICO_PLATFORM
- data = tobHelper.Call<float[]>("pbsGetCpuUsages");
- #endif
- return data;
- }
- public static float[] UPxr_GetDeviceTemperatures(int type, int source)
- {
- float[] data = null;
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return null;
- }
- data = IToBService.Call<float[]>("pbsGetDeviceTemperatures", type, source);
- #endif
- return data;
- }
- public static void UPxr_Capture()
- {
- #if PICO_PLATFORM
- IToBService.Call("pbsCapture");
- #endif
- }
- public static void UPxr_Record()
- {
- #if PICO_PLATFORM
- IToBService.Call("pbsRecord");
- #endif
- }
- public static void UPxr_ControlSetAutoConnectWIFIWithErrorCodeCallback(String ssid, String pwd, int ext, Action<int> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsControlSetAutoConnectWIFIWithErrorCodeCallback",ssid,pwd,ext,new IntCallback(callback));
- #endif
- }
- public static void UPxr_AppKeepAlive(String appPackageName, bool keepAlive, int ext)
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return ;
- }
- IToBService.Call("pbsAppKeepAlive",appPackageName,keepAlive,ext);
- #endif
- }
- public static void UPxr_TimingStartup(int year, int month, int day, int hour, int minute, bool open)
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return ;
- }
- IToBService.Call("pbsTimingStartup", year, month, day, hour, minute, open);
- #endif
- }
- public static void UPxr_TimingShutdown(int year, int month, int day, int hour, int minute, bool open)
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return ;
- }
- IToBService.Call("pbsTimingShutdown", year, month, day, hour, minute, open);
- #endif
- }
- public static void UPxr_StartVrSettingsItem(StartVRSettingsEnum settingsEnum, bool hideOtherItem, int ext)
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return ;
- }
- IToBService.Call("pbsStartVrSettingsItem", GetEnumType(settingsEnum), hideOtherItem, ext);
- #endif
- }
- public static void UPxr_SwitchVolumeToHomeAndEnter(SwitchEnum switchEnum, int ext)
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return ;
- }
- IToBService.Call("pbsSwitchVolumeToHomeAndEnter", GetEnumType(switchEnum), ext);
- #endif
- }
- public static SwitchEnum UPxr_IsVolumeChangeToHomeAndEnter()
- {
- SwitchEnum switchEnum = SwitchEnum.S_OFF;
- #if PICO_PLATFORM
- int num = 0;
- num = tobHelper.Call<int>("pbsIsVolumeChangeToHomeAndEnter");
- if (num == 0)
- {
- switchEnum = SwitchEnum.S_ON;
- }
- else if (num == 1) {
- switchEnum = SwitchEnum.S_OFF;
- }
- #endif
- return switchEnum;
- }
- public static int UPxr_InstallOTAPackage(String otaPackagePath)
- {
- int value = 0;
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
-
- value = IToBService.Call<int>("pbsInstallOTAPackage",otaPackagePath, 0);
- #endif
- return value;
- }
- public static string UPxr_GetAutoConnectWiFiConfig()
- {
- string value= "";
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<string>("pbsGetAutoConnectWiFiConfig", 0);
- #endif
- return value;
- }
- public static string UPxr_GetTimingStartupStatus()
- {
- string value = "";
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<string>("pbsGetTimingStartupStatus", 0);
- #endif
- return value;
- }
- public static string UPxr_GetTimingShutdownStatus()
- {
- string value = "";
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<string>("pbsGetTimingShutdownStatus", 0);
- #endif
- return value;
- }
- public static int UPxr_GetControllerKeyState(ControllerKeyEnum pxrControllerKey)
- {
- int value = 1;
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<int>("pbsGetControllerKeyState", GetEnumType(pxrControllerKey),0);
- #endif
- return value;
- }
- public static int UPxr_SetControllerKeyState(ControllerKeyEnum controllerKeyEnum, SwitchEnum status)
- {
- int value = 1;
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<int>("pbsSetControllerKeyState", GetEnumType(controllerKeyEnum),GetEnumType(status),0);
- #endif
- return value;
- }
- public static SwitchEnum UPxr_ControlGetPowerOffWithUSBCable()
- {
- SwitchEnum switchEnum = SwitchEnum.S_OFF;
- #if PICO_PLATFORM
- int num = 0;
- num = tobHelper.Call<int>("pbsControlGetPowerOffWithUSBCable",0);
- if (num == 0)
- {
- switchEnum = SwitchEnum.S_ON;
- }
- else if (num == 1) {
- switchEnum = SwitchEnum.S_OFF;
- }
- #endif
- return switchEnum;
- }
- public static ScreenOffDelayTimeEnum UPxr_PropertyGetScreenOffDelay()
- {
- ScreenOffDelayTimeEnum screenOffDelayTimeEnum = ScreenOffDelayTimeEnum.NEVER;
- #if PICO_PLATFORM
- int num = 0;
- num = tobHelper.Call<int>("pbsPropertyGetScreenOffDelay", 0);
- switch (num) {
- case 0:
- screenOffDelayTimeEnum = ScreenOffDelayTimeEnum.THREE;
- break;
- case 1:
- screenOffDelayTimeEnum = ScreenOffDelayTimeEnum.TEN;
- break;
- case 2:
- screenOffDelayTimeEnum = ScreenOffDelayTimeEnum.THIRTY;
- break;
- case 3:
- screenOffDelayTimeEnum = ScreenOffDelayTimeEnum.SIXTY;
- break;
- case 4:
- screenOffDelayTimeEnum = ScreenOffDelayTimeEnum.THREE_HUNDRED;
- break;
- case 5:
- screenOffDelayTimeEnum = ScreenOffDelayTimeEnum.SIX_HUNDRED;
- break;
- case 6:
- screenOffDelayTimeEnum = ScreenOffDelayTimeEnum.NEVER;
- break;
- }
- #endif
- return screenOffDelayTimeEnum;
- }
- public static SleepDelayTimeEnum UPxr_PropertyGetSleepDelay()
- {
- SleepDelayTimeEnum sleepDelayTime = SleepDelayTimeEnum.NEVER;
- #if PICO_PLATFORM
- int num = 0;
- num = tobHelper.Call<int>("pbsPropertyGetSleepDelay", 0);
- switch (num)
- {
- case 0:
- sleepDelayTime = SleepDelayTimeEnum.FIFTEEN;
- break;
- case 1:
- sleepDelayTime = SleepDelayTimeEnum.THIRTY;
- break;
- case 2:
- sleepDelayTime = SleepDelayTimeEnum.SIXTY;
- break;
- case 3:
- sleepDelayTime = SleepDelayTimeEnum.THREE_HUNDRED;
- break;
- case 4:
- sleepDelayTime = SleepDelayTimeEnum.SIX_HUNDRED;
- break;
- case 5:
- sleepDelayTime = SleepDelayTimeEnum.ONE_THOUSAND_AND_EIGHT_HUNDRED;
- break;
- case 6:
- sleepDelayTime = SleepDelayTimeEnum.NEVER;
- break;
- }
- #endif
- return sleepDelayTime;
- }
- public static string UPxr_PropertyGetPowerKeyStatus()
- {
- string value = "";
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<string>("pbsPropertyGetPowerKeyStatus", 0);
- #endif
- return value;
- }
- public static int UPxr_GetEnterKeyStatus()
- {
- int value = 1;
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<int>("pbsGetEnterKeyStatus",0);
- #endif
- return value;
- }
- public static int UPxr_GetVolumeKeyStatus()
- {
- int value = 1;
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<int>("pbsGetVolumeKeyStatus",0);
- #endif
- return value;
- }
- public static int UPxr_GetBackKeyStatus()
- {
- int value = 1;
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<int>("pbsGetBackKeyStatus",0);
- #endif
- return value;
- }
- public static string UPxr_PropertyGetHomeKeyStatus(HomeEventEnum homeEvent)
- {
- string value = "";
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<string>("pbsPropertyGetHomKeyStatus", GetEnumType(homeEvent),0);
- #endif
- return value;
- }
- public static void UPxr_GetSwitchSystemFunctionStatus(SystemFunctionSwitchEnum systemFunction, Action<int> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsGetSwitchSystemFunctionStatus", GetEnumType(systemFunction), new IntCallback(callback),
- 0);
- #endif
- }
- public static string UPxr_SwitchGetUsbConfigurationOption()
- {
- string value = "";
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<string>("pbsSwitchGetUsbConfigurationOption", 0);
- #endif
- return value;
- }
- public static string UPxr_GetCurrentLauncher()
- {
- string value = "";
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<string>("pbsGetCurrentLauncher", 0);
- #endif
- return value;
- }
- public static int UPxr_PICOCastInit(Action<int> callback)
- {
- int value = 0;
- #if PICO_PLATFORM
- value = tobHelper.Call<int>("pbsPicoCastInit", new IntCallback(callback), 0);
- #endif
- return value;
- }
- public static int UPxr_PICOCastSetShowAuthorization(int authZ)
- {
- int value = 0;
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<int>("pbsPicoCastSetShowAuthorization",authZ,0);
- #endif
- return value;
- }
- public static int UPxr_PICOCastGetShowAuthorization()
- {
- int value = 0;
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<int>("pbsPicoCastGetShowAuthorization",0);
- #endif
- return value;
- }
- public static string UPxr_PICOCastGetUrl(PICOCastUrlTypeEnum urlType)
- {
- string value = "";
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<string>("pbsPicoCastGetUrl",GetEnumType(urlType), 0);
- #endif
- return value;
- }
- public static int UPxr_PICOCastStopCast()
- {
- int value = 0;
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<int>("pbsPicoCastStopCast",0);
- #endif
- return value;
- }
- public static int UPxr_PICOCastSetOption(PICOCastOptionOrStatusEnum castOptionOrStatus, PICOCastOptionValueEnum castOptionValue)
- {
- int value = 0;
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<int>("pbsPicoCastSetOption",GetEnumType(castOptionOrStatus),GetEnumType(castOptionValue),0);
- #endif
- return value;
- }
- public static PICOCastOptionValueEnum UPxr_PICOCastGetOptionOrStatus(PICOCastOptionOrStatusEnum castOptionOrStatus)
- {
- PICOCastOptionValueEnum value = PICOCastOptionValueEnum.STATUS_VALUE_ERROR;
- #if PICO_PLATFORM
- int num = 0;
- if (tobHelper == null)
- {
- return value;
- }
- num = tobHelper.Call<int>("pbsPicoCastGetOptionOrStatus", GetEnumType(castOptionOrStatus), 0);
- switch (num)
- {
- case 0:
- value = PICOCastOptionValueEnum.OPTION_VALUE_RESOLUTION_HIGH;
- break;
- case 1:
- value = PICOCastOptionValueEnum.OPTION_VALUE_RESOLUTION_MIDDLE;
- break;
- case 2:
- value = PICOCastOptionValueEnum.OPTION_VALUE_RESOLUTION_AUTO;
- break;
- case 3:
- value = PICOCastOptionValueEnum.OPTION_VALUE_RESOLUTION_HIGH_2K;
- break;
- case 4:
- value = PICOCastOptionValueEnum.OPTION_VALUE_RESOLUTION_HIGH_4K;
- break;
- case 5:
- value = PICOCastOptionValueEnum.OPTION_VALUE_BITRATE_HIGH;
- break;
- case 6:
- value = PICOCastOptionValueEnum.OPTION_VALUE_BITRATE_MIDDLE;
- break;
- case 7:
- value = PICOCastOptionValueEnum.OPTION_VALUE_BITRATE_LOW;
- break;
- case 8:
- value = PICOCastOptionValueEnum.OPTION_VALUE_AUDIO_ON;
- break;
- case 9:
- value = PICOCastOptionValueEnum.OPTION_VALUE_AUDIO_OFF;
- break;
- case 10:
- value = PICOCastOptionValueEnum.STATUS_VALUE_STATE_STARTED;
- break;
- case 11:
- value = PICOCastOptionValueEnum.STATUS_VALUE_STATE_STOPPED;
- break;
- case 12:
- value = PICOCastOptionValueEnum.STATUS_VALUE_ERROR;
- break;
- }
- #endif
- return value;
- }
- public static int UPxr_SetSystemLanguage(String language)
- {
- int num = 0;
- #if PICO_PLATFORM
- num = IToBService.Call<int>("pbsSetSystemLanguage", language, 0);
- #endif
- return num;
- }
- public static String UPxr_GetSystemLanguage()
- {
- string value = "";
- #if PICO_PLATFORM
- value = IToBService.Call<string>("pbsGetSystemLanguage", 0);
- #endif
- return value;
- }
- public static int UPxr_ConfigWifi(String ssid, String pwd)
- {
- int num = 0;
- #if PICO_PLATFORM
- num = IToBService.Call<int>("pbsConfigWifi",ssid,pwd, 0);
- #endif
- return num;
- }
- public static String[] UPxr_GetConfiguredWifi()
- {
- #if PICO_PLATFORM
- return IToBService.Call<string[]>("pbsGetConfiguredWifi",0);
- #endif
- return null;
- }
- public static int UPxr_SetSystemCountryCode(String countryCode, Action<int> callback)
- {
- int num = 0;
- #if PICO_PLATFORM
- num = tobHelper.Call<int>("pbsSetSystemCountryCode",countryCode,new IntCallback(callback),0);
- #endif
- return num;
- }
- public static string UPxr_GetSystemCountryCode()
- {
- string value = "";
- #if PICO_PLATFORM
- value = IToBService.Call<string>("pbsGetSystemCountryCode",0);
- #endif
- return value;
- }
- public static int UPxr_SetSkipInitSettingPage(int flag)
- {
- int num = 0;
- #if PICO_PLATFORM
- num = IToBService.Call<int>("pbsSetSkipInitSettingPage",flag,0);
- #endif
- return num;
- }
- public static int UPxr_GetSkipInitSettingPage()
- {
- int num = 0;
- #if PICO_PLATFORM
- num = IToBService.Call<int>("pbsGetSkipInitSettingPage",0);
- #endif
- return num;
- }
- public static int UPxr_IsInitSettingComplete()
- {
- int num = 0;
- #if PICO_PLATFORM
- num = IToBService.Call<int>("pbsIsInitSettingComplete",0);
- #endif
- return num;
- }
- public static int UPxr_StartActivity(String packageName, String className, String action, String extra, String[] categories, int[] flags)
- {
- int num = 0;
- #if PICO_PLATFORM
- num = IToBService.Call<int>("pbsStartActivity", packageName, className, action, extra, categories, flags, 0);
- #endif
- return num;
- }
- public static int UPxr_CustomizeAppLibrary(String[] packageNames, SwitchEnum switchEnum)
- {
- int num = 0;
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return num;
- }
- num = IToBService.Call<int>("pbsCustomizeAppLibrary", packageNames,GetEnumType(switchEnum), 0);
- #endif
- return num;
- }
- public static int[] UPxr_GetControllerBattery()
- {
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return null;
- }
- return IToBService.Call<int[]>("pbsGetControllerBattery", 0);
- #endif
- return null;
- }
- public static int UPxr_GetControllerConnectState()
- {
- int num = 0;
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return num;
- }
- num = IToBService.Call<int>("pbsGetControllerConnectState",0);
- #endif
- return num;
- }
- public static string UPxr_GetAppLibraryHideList()
- {
- string value = " ";
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<string>("pbsGetAppLibraryHideList",0);
- #endif
- return value;
- }
- public static int UPxr_SetScreenCastAudioOutput(ScreencastAudioOutputEnum screencastAudioOutput)
- {
- int value = 0;
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<int>("pbsSetScreenCastAudioOutput",GetEnumType(screencastAudioOutput),0);
- #endif
- return value;
- }
- public static ScreencastAudioOutputEnum UPxr_GetScreenCastAudioOutput()
- {
- ScreencastAudioOutputEnum value = ScreencastAudioOutputEnum.AUDIO_ERROR;
- #if PICO_PLATFORM
- int num = 0;
- num = tobHelper.Call<int>("pbsGetScreenCastAudioOutput",0);
- switch (num)
- {
- case 0:
- value = ScreencastAudioOutputEnum.AUDIO_SINK;
- break;
- case 1:
- value = ScreencastAudioOutputEnum.AUDIO_TARGET;
- break;
- case 2:
- value = ScreencastAudioOutputEnum.AUDIO_SINK_TARGET;
- break;
- }
- #endif
- return value;
- }
- public static int UPxr_CustomizeSettingsTabStatus(CustomizeSettingsTabEnum customizeSettingsTabEnum, SwitchEnum switchEnum)
- {
- int value = 0;
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<int>("pbsCustomizeSettingsTabStatus", GetEnumType(customizeSettingsTabEnum), GetEnumType(switchEnum), 0);
- #endif
- return value;
- }
- public static SwitchEnum UPxr_GetCustomizeSettingsTabStatus(CustomizeSettingsTabEnum customizeSettingsTabEnum)
- {
- SwitchEnum switchEnum = SwitchEnum.S_OFF;
- #if PICO_PLATFORM
- int num = 0;
- num = tobHelper.Call<int>("pbsGetCustomizeSettingsTabStatus",GetEnumType(customizeSettingsTabEnum),0);
- if (num == 0)
- {
- switchEnum = SwitchEnum.S_ON;
- }
- else if (num == 1) {
- switchEnum = SwitchEnum.S_OFF;
- }
- #endif
- return switchEnum;
- }
-
- public static void UPxr_SetPowerOffWithUSBCable(SwitchEnum switchEnum)
- {
-
- #if PICO_PLATFORM
- if (IToBService==null)
- {
- return;
- }
- IToBService.Call("pbsControlSetPowerOffwithUSBCable", GetEnumType(switchEnum),0);
- #endif
- }
- public static void UPxr_RemoveControllerHomeKey(HomeEventEnum EventEnum)
- {
- #if PICO_PLATFORM
- if (IToBService==null)
- {
- return;
- }
- IToBService.Call("pbsRemoveControllerHomeKey", GetEnumType(EventEnum));
- #endif
- }
- public static void UPxr_SetPowerOnOffLogo(PowerOnOffLogoEnum powerOnOffLogoEnum, String path, Action<bool> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsPropertySetPowerOnOffLogo",GetEnumType(powerOnOffLogoEnum),path,0, new BoolCallback(callback));
- #endif
- }
- public static void UPxr_SetIPD(float ipd, Action<int> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsSetIPD",ipd, new IntCallback(callback));
- #endif
- }
-
- public static string UPxr_GetAutoMiracastConfig()
- {
- string value = " ";
- #if PICO_PLATFORM
- if (IToBService == null)
- {
- return value;
- }
- value = IToBService.Call<string>("pbsGetAutoMiracastConfig",0);
- #endif
- return value;
- }
- public static int UPxr_SetPicoCastMediaFormat(PicoCastMediaFormat mediaFormat)
- {
- int value = -1;
- #if PICO_PLATFORM
- value = tobHelper.Call<int>("setPicoCastMediaFormat",mediaFormat.bitrate,0);
- #endif
- return value;
- }
-
- public static int UPxr_setMarkerInfoCallback(TrackingOriginModeFlags trackingMode,float cameraYOffset,Action<List<MarkerInfo>> mediaFormat)
- {
- int value = -1;
- #if PICO_PLATFORM
- value = tobHelper.Call<int>("setMarkerInfoCallback",new MarkerInfoCallback(trackingMode,cameraYOffset,mediaFormat));
- #endif
- return value;
- }
- private static bool UPxr_GetToken()
- {
- PLog.i(TAG, "GetToken Start");
- #if PICO_PLATFORM
- token = BAuthLib.CallStatic<string>("featureAuthByToken", currentActivity, "getCameraInfo");
- #endif
- if (string.IsNullOrEmpty(token))
- {
- PLog.e(TAG, "Failed to obtain token, camera data cannot be obtained!");
- return false;
- }
- PLog.i(TAG, "GetToken End token :" + token);
- return true;
- }
- public static int UPxr_GetHeadTrackingConfidence()
- {
- PLog.d(TAG, "GetHeadTrackingConfidence Start");
- int result = -1;
- #if PICO_PLATFORM
- result = getHeadTrackingConfidence();
- #endif
- PLog.d(TAG, "GetToken End result :" + result);
- return result;
- }
- public static bool UPxr_OpenVSTCamera()
- {
- PLog.d(TAG, "OpenVSTCamera Start");
- if (camOpenned)
- {
- PLog.d(TAG, "Camera has Openned!");
- return true;
- }
- int result = -1;
- #if PICO_PLATFORM
- result = openVSTCamera();
- #endif
- camOpenned = result == 0;
- PLog.d(TAG, "OpenVSTCamera End result :" + result + ", camOpenned : " + camOpenned);
- return result == 0;
- }
- public static bool UPxr_CloseVSTCamera()
- {
- PLog.d(TAG, "CloseVSTCamera Start");
- if (!camOpenned)
- {
- PLog.d(TAG, "Camera has Closed!");
- return true;
- }
- int result = -1;
- #if PICO_PLATFORM
- result = closeVSTCamera();
- #endif
- camOpenned = !(result == 0);
- PLog.d(TAG, "CloseVSTCamera End result :" + result + ", camOpenned : " + camOpenned);
- return result == 0;
- }
- public static int UPxr_GetHeadTrackingData(Int64 predictTime, ref SixDof data, int type)
- {
- PLog.d(TAG, "GetHeadTrackingData Start");
- int result = -1;
- #if PICO_PLATFORM
- result = getHeadTrackingData(predictTime, ref data, type);
- #endif
- PLog.d(TAG, "GetHeadTrackingData End result :" + result);
- return result;
- }
- public static int UPxr_AcquireVSTCameraFrame(out Frame frame)
- {
- PLog.d(TAG, "AcquireVSTCameraFrame Start");
- frame = new Frame();
- if (string.IsNullOrEmpty(token))
- {
- PLog.e(TAG, "Failed to obtain token, camera data cannot be obtained!");
- return -1;
- }
- if (!camOpenned)
- {
- PLog.e(TAG, "Failed to obtain data due to camera not being turned on!");
- return -1;
- }
- InitDistortionFrame();
- int result = -1;
- #if PICO_PLATFORM
- result = acquireVSTCameraFrame(ref distortionFrameItemExt);
- #endif
- frame.width = distortionFrameItemExt.frame.width;
- frame.height = distortionFrameItemExt.frame.height;
- frame.timestamp = distortionFrameItemExt.frame.timestamp;
- frame.datasize = distortionFrameItemExt.frame.datasize;
- frame.data = distortionFrameItemExt.frame.data;
- if (frame.pose != null)
- {
- frame.pose.position.x = (float)distortionFrameItemExt.six_dof_pose.pose.x;
- frame.pose.position.y = (float)distortionFrameItemExt.six_dof_pose.pose.y;
- frame.pose.position.z = (float)distortionFrameItemExt.six_dof_pose.pose.z;
- frame.pose.rotation.w = (float)distortionFrameItemExt.six_dof_pose.pose.rw;
- frame.pose.rotation.x = (float)distortionFrameItemExt.six_dof_pose.pose.rx;
- frame.pose.rotation.y = (float)distortionFrameItemExt.six_dof_pose.pose.ry;
- frame.pose.rotation.z = (float)distortionFrameItemExt.six_dof_pose.pose.rz;
- }
- frame.status = distortionFrameItemExt.six_dof_pose.pose.confidence;
- PLog.d(TAG, "AcquireVSTCameraFrame End result :" + result);
- return result;
- }
- public static int UPxr_AcquireVSTCameraFrameAntiDistortion(int width, int height, out Frame frame)
- {
- PLog.d(TAG, "AcquireVSTCameraFrameAntiDistortion Start width:" + width + ", height:" + height);
- frame = new Frame();
- if (string.IsNullOrEmpty(token))
- {
- PLog.e(TAG, "Failed to obtain token, camera data cannot be obtained!");
- return -1;
- }
- if (!camOpenned)
- {
- PLog.e(TAG, "Failed to obtain data due to camera not being turned on!");
- return -1;
- }
- int size = width * height * 3;
- InitAntiDistortionFrame(size);
- int result = -1;
- #if PICO_PLATFORM
- result = acquireVSTCameraFrameAntiDistortion(token, width, height, ref antiDistortionFrameItemExt);
- #endif
- PLog.d(TAG, "AcquireVSTCameraFrameAntiDistortion End result :" + result +
- ", width : " + antiDistortionFrameItemExt.frame.width +
- ", height : " + antiDistortionFrameItemExt.frame.height +
- ", datasize : " + antiDistortionFrameItemExt.frame.datasize +
- ", data : " + antiDistortionFrameItemExt.frame.data +
- ", confidence : " + antiDistortionFrameItemExt.six_dof_pose.pose.confidence);
- frame.width = antiDistortionFrameItemExt.frame.width;
- frame.height = antiDistortionFrameItemExt.frame.height;
- frame.timestamp = antiDistortionFrameItemExt.frame.timestamp;
- frame.datasize = antiDistortionFrameItemExt.frame.datasize;
- frame.data = antiDistortionFrameItemExt.frame.data;
- if (frame.pose != null)
- {
- frame.pose.position.x = (float)antiDistortionFrameItemExt.six_dof_pose.relocation_pose.x;
- frame.pose.position.y = (float)antiDistortionFrameItemExt.six_dof_pose.relocation_pose.y;
- frame.pose.position.z = (float)antiDistortionFrameItemExt.six_dof_pose.relocation_pose.z;
- frame.pose.rotation.w = (float)antiDistortionFrameItemExt.six_dof_pose.relocation_pose.rw;
- frame.pose.rotation.x = (float)antiDistortionFrameItemExt.six_dof_pose.relocation_pose.rx;
- frame.pose.rotation.y = (float)antiDistortionFrameItemExt.six_dof_pose.relocation_pose.ry;
- frame.pose.rotation.z = (float)antiDistortionFrameItemExt.six_dof_pose.relocation_pose.rz;
- }
- frame.status = antiDistortionFrameItemExt.six_dof_pose.relocation_pose.confidence;
-
- PLog.d(TAG, "zzzzzz relocation_pose.x=" + (float)antiDistortionFrameItemExt.six_dof_pose.relocation_pose.x +
- ", relocation_pose.y=" + (float)antiDistortionFrameItemExt.six_dof_pose.relocation_pose.y +
- ", relocation_pose.z=: " + (float)antiDistortionFrameItemExt.six_dof_pose.relocation_pose.z +
- ", relocation_pose.rw=: " + (float)antiDistortionFrameItemExt.six_dof_pose.relocation_pose.rw +
- ", relocation_pose.rx = " + (float)antiDistortionFrameItemExt.six_dof_pose.relocation_pose.rx +
- ", relocation_pose.ry = " + (float)antiDistortionFrameItemExt.six_dof_pose.relocation_pose.ry +
- ", relocation_pose.rz = " + (float)antiDistortionFrameItemExt.six_dof_pose.relocation_pose.rz);
- PLog.d(TAG, "zzzzzz pose.x=" + (float)antiDistortionFrameItemExt.six_dof_pose.relocation_pose.x +
- ", pose.y=" + (float)antiDistortionFrameItemExt.six_dof_pose.pose.y +
- ", relocation_pose.z=: " + (float)antiDistortionFrameItemExt.six_dof_pose.pose.z +
- ", pose.rw=: " + (float)antiDistortionFrameItemExt.six_dof_pose.pose.rw +
- ", pose.rx = " + (float)antiDistortionFrameItemExt.six_dof_pose.pose.rx +
- ", pose.ry = " + (float)antiDistortionFrameItemExt.six_dof_pose.pose.ry +
- ", pose.rz = " + (float)antiDistortionFrameItemExt.six_dof_pose.pose.rz);
- return result;
- }
- public static UnityEngine.Pose ToUnityPose(UnityEngine.Pose poseR)
- {
- UnityEngine.Pose poseL;
- poseL.position.x = poseR.position.x;
- poseL.position.y = poseR.position.y;
- poseL.position.z = -poseR.position.z;
- poseL.rotation.x = poseR.rotation.x;
- poseL.rotation.y = poseR.rotation.y;
- poseL.rotation.z = -poseR.rotation.z;
- poseL.rotation.w = -poseR.rotation.w;
- return poseL;
- }
- // RGB Camera pose (Left-handed coordinate system: X right, Y up, Z out)
- public static UnityEngine.Pose ToRGBCameraPose(RGBCameraParams cameraParams, UnityEngine.Pose headPose)
- {
- Vector3 headToCameraPos = new Vector3((float)cameraParams.x, (float)cameraParams.y, (float)cameraParams.z);
- Quaternion headToCameraRot = new Quaternion((float)cameraParams.rx, (float)cameraParams.ry, (float)cameraParams.rz, (float)cameraParams.rw);
- Matrix4x4 headMx = Matrix4x4.TRS(headPose.position, headPose.rotation, Vector3.one);
- Matrix4x4 cameraMx = Matrix4x4.TRS(headToCameraPos, headToCameraRot, Vector3.one);
- Matrix4x4 rgbMx = headMx * cameraMx;
- Matrix4x4 rotX180 = Matrix4x4.Rotate(Quaternion.Euler(180f, 0f, 0f));
- rgbMx *= rotX180;
- #if UNITY_2021_2_OR_NEWER
- UnityEngine.Pose rgbCameraPose = ToUnityPose(new UnityEngine.Pose(rgbMx.GetPosition(), rgbMx.rotation));
- #else
- UnityEngine.Pose rgbCameraPose = ToUnityPose(new UnityEngine.Pose(new Vector3(rgbMx.m03, rgbMx.m13, rgbMx.m23), rgbMx.rotation));
- #endif
- return rgbCameraPose;
- }
- private static void InitDistortionFrame()
- {
- if (initDistortionFrame)
- {
- return;
- }
- distortionFrameItemExt = new FrameItemExt();
- initDistortionFrame = true;
- }
- private static void InitAntiDistortionFrame(int size)
- {
- if (curSize == size)
- {
- return;
- }
- Debug.LogFormat("InitAntiDistortionFrame curSize={0}, size={1}", curSize, size);
- antiDistortionFrameItemExt = new FrameItemExt();
- if (antiDistortionFrameItemExt.frame.data != IntPtr.Zero)
- {
- Marshal.FreeHGlobal(antiDistortionFrameItemExt.frame.data);
- antiDistortionFrameItemExt.frame.data = IntPtr.Zero;
- }
- antiDistortionFrameItemExt.frame.data = Marshal.AllocHGlobal(size);
- curSize = size;
- }
- public static RGBCameraParams UPxr_GetCameraParameters()
- {
- PLog.d(TAG, "GetCameraParameters Start");
- RGBCameraParams rgbCameraParams = new RGBCameraParams();
- if (string.IsNullOrEmpty(token))
- {
- PLog.e(TAG, "Failed to obtain token, camera data cannot be obtained!");
- return rgbCameraParams;
- }
- int result = getCameraParameters(token, out rgbCameraParams);
- PLog.d(TAG, "GetCameraParameters End result :" + result);
- return rgbCameraParams;
- }
- public static double UPxr_GetPredictedDisplayTime()
- {
- PLog.d(TAG, "UPxr_GetPredictedDisplayTime()");
- double predictedDisplayTime = 0;
- #if PICO_PLATFORM
- Pxr_GetPredictedDisplayTime(ref predictedDisplayTime);
- #endif
- PLog.d(TAG, "UPxr_GetPredictedDisplayTime() predictedDisplayTime:" + predictedDisplayTime);
- return predictedDisplayTime;
- }
- public static SensorState UPxr_GetPredictedMainSensorState(double predictTime)
- {
- SensorState sensorState = new SensorState();
- PxrSensorState2 sensorState2 = new PxrSensorState2();
- int sensorFrameIndex = 0;
- #if PICO_PLATFORM
- Pxr_GetPredictedMainSensorState2(predictTime, ref sensorState2, ref sensorFrameIndex);
- #endif
- sensorState.status = sensorState2.status == 3 ? 1 : 0;
- sensorState.pose.position.x = sensorState2.pose.position.x;
- sensorState.pose.position.y = sensorState2.pose.position.y;
- sensorState.pose.position.z = sensorState2.pose.position.z;
- sensorState.pose.rotation.x = sensorState2.pose.orientation.x;
- sensorState.pose.rotation.y = sensorState2.pose.orientation.y;
- sensorState.pose.rotation.z = sensorState2.pose.orientation.z;
- sensorState.pose.rotation.w = sensorState2.pose.orientation.w;
- return sensorState;
- }
-
- public static int UPxr_gotoSeeThroughFloorSetting()
- {
- int value = -1;
- #if PICO_PLATFORM
- value = IToBService.Call<int>("gotoSeeThroughFloorSetting",0);
- #endif
- return value;
- }
- public static int UPxr_fileCopy(String srcPath, String dstPath, FileCopyCallback callback)
- {
- int value = -1;
- #if PICO_PLATFORM
- value = tobHelper.Call<int>("FileCopy",srcPath,dstPath,callback);
- #endif
- return value;
- }
- public static void UPxr_IsMapInEffect(String path, Action<int> callback)
- {
-
- #if PICO_PLATFORM
- tobHelper.Call("isMapInEffect",path,new IntCallback(callback),0);
- #endif
- }
- public static void UPxr_ImportMapByPath(String path, Action<int> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("importMapByPath",path,new IntCallback(callback),0);
- #endif
- }
-
-
- private const string LibraryName = "PICO_TOBAPI";
- [DllImport(LibraryName, CallingConvention = CallingConvention.Cdecl)]
- public static extern float oxr_get_trackingorigin_height();
- }
- }
|