| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686 |
- /*******************************************************************************
- 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;
- using UnityEngine;
- using UnityEngine.XR;
- namespace Unity.XR.PXR
- {
- 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);
- [DllImport("pxr_api", CallingConvention = CallingConvention.Cdecl)]
- public static extern int Pxr_GetPredictedDisplayTime(ref double predictedDisplayTime);
- [DllImport("pxr_api", CallingConvention = CallingConvention.Cdecl)]
- 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.PXR.", ".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_WriteConfigFileToDataLocal(string path, string content, Action<bool> callback)
- {
- #if PICO_PLATFORM
- tobHelper.Call("pbsWriteConfigFileToDataLocal", path, content, new BoolCallback(callback));
- #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 (IToBService == null)
- {
- return value;
- }
- num = IToBService.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.pose.x;
- frame.pose.position.y = (float)antiDistortionFrameItemExt.six_dof_pose.pose.y;
- frame.pose.position.z = (float)antiDistortionFrameItemExt.six_dof_pose.pose.z;
- frame.pose.rotation.w = (float)antiDistortionFrameItemExt.six_dof_pose.pose.rw;
- frame.pose.rotation.x = (float)antiDistortionFrameItemExt.six_dof_pose.pose.rx;
- frame.pose.rotation.y = (float)antiDistortionFrameItemExt.six_dof_pose.pose.ry;
- frame.pose.rotation.z = (float)antiDistortionFrameItemExt.six_dof_pose.pose.rz;
- }
- frame.status = antiDistortionFrameItemExt.six_dof_pose.pose.confidence;
- 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.globalPose.position.x;
- sensorState.pose.position.y = sensorState2.globalPose.position.y;
- sensorState.pose.position.z = sensorState2.globalPose.position.z;
- sensorState.pose.rotation.x = sensorState2.globalPose.orientation.x;
- sensorState.pose.rotation.y = sensorState2.globalPose.orientation.y;
- sensorState.pose.rotation.z = sensorState2.globalPose.orientation.z;
- sensorState.pose.rotation.w = sensorState2.globalPose.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
- }
- }
- }
|