PXR_EnterprisePlugin.cs 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686
  1. /*******************************************************************************
  2. Copyright © 2015-2022 PICO Technology Co., Ltd.All rights reserved.
  3. NOTICE:All information contained herein is, and remains the property of
  4. PICO Technology Co., Ltd. The intellectual and technical concepts
  5. contained herein are proprietary to PICO Technology Co., Ltd. and may be
  6. covered by patents, patents in process, and are protected by trade secret or
  7. copyright law. Dissemination of this information or reproduction of this
  8. material is strictly forbidden unless prior written permission is obtained from
  9. PICO Technology Co., Ltd.
  10. *******************************************************************************/
  11. #if (UNITY_ANDROID && !UNITY_EDITOR)
  12. #define PICO_PLATFORM
  13. #endif
  14. using System;
  15. using System.Collections.Generic;
  16. using System.Runtime.InteropServices;
  17. using UnityEngine;
  18. using UnityEngine.XR;
  19. namespace Unity.XR.PXR
  20. {
  21. public partial class PXR_EnterprisePlugin
  22. {
  23. private const string TAG = "[PXR_EnterprisePlugin]";
  24. public const int MAX_SIZE = 12208032;
  25. public static string token;
  26. private static int curSize = 0;
  27. private static bool camOpenned = false;
  28. private static FrameItemExt antiDistortionFrameItemExt;
  29. private static FrameItemExt distortionFrameItemExt;
  30. private static bool initDistortionFrame;
  31. [DllImport("libpxr_xrsdk_native", CallingConvention = CallingConvention.Cdecl)]
  32. public static extern int getHeadTrackingConfidence();
  33. [DllImport("libpxr_xrsdk_native", CallingConvention = CallingConvention.Cdecl)]
  34. public static extern int openVSTCamera();
  35. [DllImport("libpxr_xrsdk_native", CallingConvention = CallingConvention.Cdecl)]
  36. public static extern int closeVSTCamera();
  37. [DllImport("libpxr_xrsdk_native", CallingConvention = CallingConvention.Cdecl)]
  38. public static extern int getHeadTrackingData(Int64 predictTime, ref SixDof data, int type);
  39. [DllImport("libpxr_xrsdk_native", CallingConvention = CallingConvention.Cdecl)]
  40. public static extern int acquireVSTCameraFrame(ref FrameItemExt frame);
  41. [DllImport("libpxr_xrsdk_native", CallingConvention = CallingConvention.Cdecl)]
  42. public static extern int acquireVSTCameraFrameAntiDistortion(string token, Int32 width, Int32 height, ref FrameItemExt frame);
  43. [DllImport("libpxr_xrsdk_native", CallingConvention = CallingConvention.Cdecl)]
  44. public static extern int getCameraParameters(string token, out RGBCameraParams rgb_Camera_Params);
  45. [DllImport("pxr_api", CallingConvention = CallingConvention.Cdecl)]
  46. public static extern int Pxr_GetPredictedDisplayTime(ref double predictedDisplayTime);
  47. [DllImport("pxr_api", CallingConvention = CallingConvention.Cdecl)]
  48. public static extern int Pxr_GetPredictedMainSensorState2(double predictTimeMs, ref PxrSensorState2 sensorState, ref int sensorFrameIndex);
  49. #if PICO_PLATFORM
  50. private static AndroidJavaClass unityPlayer;
  51. private static AndroidJavaObject currentActivity;
  52. private static AndroidJavaObject tobHelper;
  53. private static AndroidJavaClass tobHelperClass;
  54. private static AndroidJavaObject IToBService;
  55. private static AndroidJavaClass BAuthLib;
  56. #endif
  57. public static Action<bool> BoolCallback;
  58. public static Action<int> IntCallback;
  59. public static Action<long> LongCallback;
  60. public static Action<string> StringCallback;
  61. private static AndroidJavaObject GetEnumType(Enum enumType)
  62. {
  63. AndroidJavaClass enumjs =
  64. new AndroidJavaClass("com.pvr.tobservice.enums" + enumType.GetType().ToString().Replace("Unity.XR.PXR.", ".PBS_"));
  65. AndroidJavaObject enumjo = enumjs.GetStatic<AndroidJavaObject>(enumType.ToString());
  66. return enumjo;
  67. }
  68. public static bool UPxr_InitEnterpriseService()
  69. {
  70. #if PICO_PLATFORM
  71. tobHelperClass = new AndroidJavaClass("com.picoxr.tobservice.ToBServiceUtils");
  72. tobHelper = tobHelperClass.CallStatic<AndroidJavaObject>("getInstance");
  73. unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
  74. currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
  75. BAuthLib = new AndroidJavaClass("com.pvr.tobauthlib.AuthCheckServer");
  76. #endif
  77. return UPxr_GetToken();
  78. }
  79. public static void UPxr_SetBindCallBack(BindCallback mBoolCallback)
  80. {
  81. #if PICO_PLATFORM
  82. tobHelper.Call("setBindCallBack", mBoolCallback);
  83. #endif
  84. }
  85. public static void UPxr_BindEnterpriseService(Action<bool> callback = null)
  86. {
  87. #if PICO_PLATFORM
  88. UPxr_SetBindCallBack(new BindCallback(callback));
  89. tobHelper.Call("bindTobService", currentActivity);
  90. #endif
  91. }
  92. public static void UPxr_UnBindEnterpriseService()
  93. {
  94. #if PICO_PLATFORM
  95. tobHelper.Call("unBindTobService");
  96. #endif
  97. }
  98. public static void GetServiceBinder()
  99. {
  100. #if PICO_PLATFORM
  101. IToBService = tobHelper.Call<AndroidJavaObject>("getServiceBinder");
  102. #endif
  103. }
  104. public static string UPxr_StateGetDeviceInfo(SystemInfoEnum type)
  105. {
  106. string result = "";
  107. #if PICO_PLATFORM
  108. if (IToBService == null)
  109. {
  110. return result;
  111. }
  112. result = IToBService.Call<string>("pbsStateGetDeviceInfo", GetEnumType(type), 0);
  113. #endif
  114. return result;
  115. }
  116. public static void UPxr_ControlSetDeviceAction(DeviceControlEnum deviceControl, Action<int> callback)
  117. {
  118. #if PICO_PLATFORM
  119. tobHelper.Call("pbsControlSetDeviceAction", GetEnumType(deviceControl), new IntCallback(callback));
  120. #endif
  121. }
  122. public static void UPxr_ControlAPPManager(PackageControlEnum packageControl, string path, Action<int> callback)
  123. {
  124. #if PICO_PLATFORM
  125. tobHelper.Call("pbsControlAPPManger", GetEnumType(packageControl), path, 0, new IntCallback(callback));
  126. #endif
  127. }
  128. public static void UPxr_ControlSetAutoConnectWIFI(string ssid, string pwd, Action<bool> callback)
  129. {
  130. #if PICO_PLATFORM
  131. tobHelper.Call("pbsControlSetAutoConnectWIFI", ssid, pwd, 0, new BoolCallback(callback));
  132. #endif
  133. }
  134. public static void UPxr_ControlClearAutoConnectWIFI(Action<bool> callback)
  135. {
  136. #if PICO_PLATFORM
  137. tobHelper.Call("pbsControlClearAutoConnectWIFI", new BoolCallback(callback));
  138. #endif
  139. }
  140. public static void UPxr_PropertySetHomeKey(HomeEventEnum eventEnum, HomeFunctionEnum function, Action<bool> callback)
  141. {
  142. #if PICO_PLATFORM
  143. tobHelper.Call("pbsPropertySetHomeKey", GetEnumType(eventEnum), GetEnumType(function), new BoolCallback(callback));
  144. #endif
  145. }
  146. public static void UPxr_PropertySetHomeKeyAll(HomeEventEnum eventEnum, HomeFunctionEnum function, int timesetup, string pkg, string className, Action<bool> callback)
  147. {
  148. #if PICO_PLATFORM
  149. tobHelper.Call("pbsPropertySetHomeKeyAll", GetEnumType(eventEnum), GetEnumType(function), timesetup, pkg,
  150. className, new BoolCallback(callback));
  151. #endif
  152. }
  153. public static void UPxr_PropertyDisablePowerKey(bool isSingleTap, bool enable, Action<int> callback)
  154. {
  155. #if PICO_PLATFORM
  156. tobHelper.Call("pbsPropertyDisablePowerKey", isSingleTap, enable, new IntCallback(callback));
  157. #endif
  158. }
  159. public static void UPxr_PropertySetScreenOffDelay(ScreenOffDelayTimeEnum timeEnum, Action<int> callback)
  160. {
  161. #if PICO_PLATFORM
  162. tobHelper.Call("pbsPropertySetScreenOffDelay", GetEnumType(timeEnum), new IntCallback(callback));
  163. #endif
  164. }
  165. public static void UPxr_PropertySetSleepDelay(SleepDelayTimeEnum timeEnum)
  166. {
  167. #if PICO_PLATFORM
  168. if (IToBService == null)
  169. {
  170. return;
  171. }
  172. IToBService.Call("pbsPropertySetSleepDelay", GetEnumType(timeEnum));
  173. #endif
  174. }
  175. public static void UPxr_SwitchSystemFunction(SystemFunctionSwitchEnum systemFunction, SwitchEnum switchEnum)
  176. {
  177. #if PICO_PLATFORM
  178. if (IToBService == null)
  179. {
  180. return;
  181. }
  182. IToBService.Call("pbsSwitchSystemFunction", GetEnumType(systemFunction), GetEnumType(switchEnum), 0);
  183. #endif
  184. }
  185. public static void UPxr_SwitchSetUsbConfigurationOption(USBConfigModeEnum uSBConfigModeEnum)
  186. {
  187. #if PICO_PLATFORM
  188. if (IToBService == null)
  189. {
  190. return;
  191. }
  192. IToBService.Call("pbsSwitchSetUsbConfigurationOption", GetEnumType(uSBConfigModeEnum), 0);
  193. #endif
  194. }
  195. public static void UPxr_SetControllerPairTime(ControllerPairTimeEnum timeEnum, Action<int> callback)
  196. {
  197. #if PICO_PLATFORM
  198. tobHelper.Call("pbsSetControllerPairTime", GetEnumType(timeEnum),new IntCallback(callback), 0);
  199. #endif
  200. }
  201. public static void UPxr_GetControllerPairTime(Action<int> callback)
  202. {
  203. #if PICO_PLATFORM
  204. tobHelper.Call("pbsGetControllerPairTime",new IntCallback(callback), 0);
  205. #endif
  206. }
  207. public static void UPxr_ScreenOn()
  208. {
  209. #if PICO_PLATFORM
  210. if (IToBService == null)
  211. {
  212. return;
  213. }
  214. IToBService.Call("pbsScreenOn");
  215. #endif
  216. }
  217. public static void UPxr_ScreenOff()
  218. {
  219. #if PICO_PLATFORM
  220. if (IToBService == null)
  221. {
  222. return;
  223. }
  224. IToBService.Call("pbsScreenOff");
  225. #endif
  226. }
  227. public static void UPxr_AcquireWakeLock()
  228. {
  229. #if PICO_PLATFORM
  230. if (IToBService == null)
  231. {
  232. return;
  233. }
  234. IToBService.Call("pbsAcquireWakeLock");
  235. #endif
  236. }
  237. public static void UPxr_ReleaseWakeLock()
  238. {
  239. #if PICO_PLATFORM
  240. if (IToBService == null)
  241. {
  242. return;
  243. }
  244. IToBService.Call("pbsReleaseWakeLock");
  245. #endif
  246. }
  247. public static void UPxr_EnableEnterKey()
  248. {
  249. #if PICO_PLATFORM
  250. if (IToBService == null)
  251. {
  252. return;
  253. }
  254. IToBService.Call("pbsEnableEnterKey");
  255. #endif
  256. }
  257. public static void UPxr_DisableEnterKey()
  258. {
  259. #if PICO_PLATFORM
  260. if (IToBService == null)
  261. {
  262. return;
  263. }
  264. IToBService.Call("pbsDisableEnterKey");
  265. #endif
  266. }
  267. public static void UPxr_EnableVolumeKey()
  268. {
  269. #if PICO_PLATFORM
  270. if (IToBService == null)
  271. {
  272. return;
  273. }
  274. IToBService.Call("pbsEnableVolumeKey");
  275. #endif
  276. }
  277. public static void UPxr_DisableVolumeKey()
  278. {
  279. #if PICO_PLATFORM
  280. if (IToBService == null)
  281. {
  282. return;
  283. }
  284. IToBService.Call("pbsDisableVolumeKey");
  285. #endif
  286. }
  287. public static void UPxr_EnableBackKey()
  288. {
  289. #if PICO_PLATFORM
  290. if (IToBService == null)
  291. {
  292. return;
  293. }
  294. IToBService.Call("pbsEnableBackKey");
  295. #endif
  296. }
  297. public static void UPxr_DisableBackKey()
  298. {
  299. #if PICO_PLATFORM
  300. if (IToBService == null)
  301. {
  302. return;
  303. }
  304. IToBService.Call("pbsDisableBackKey");
  305. #endif
  306. }
  307. public static void UPxr_WriteConfigFileToDataLocal(string path, string content, Action<bool> callback)
  308. {
  309. #if PICO_PLATFORM
  310. tobHelper.Call("pbsWriteConfigFileToDataLocal", path, content, new BoolCallback(callback));
  311. #endif
  312. }
  313. public static void UPxr_ResetAllKeyToDefault(Action<bool> callback)
  314. {
  315. #if PICO_PLATFORM
  316. tobHelper.Call("pbsResetAllKeyToDefault", new BoolCallback(callback));
  317. #endif
  318. }
  319. public static void UPxr_SetAPPAsHome(SwitchEnum switchEnum, string packageName)
  320. {
  321. #if PICO_PLATFORM
  322. if (IToBService == null)
  323. {
  324. return;
  325. }
  326. IToBService.Call("pbsAppSetAPPAsHomeTwo", GetEnumType(switchEnum), packageName);
  327. #endif
  328. }
  329. public static void UPxr_KillAppsByPidOrPackageName(int[] pids, string[] packageNames)
  330. {
  331. #if PICO_PLATFORM
  332. if (IToBService == null)
  333. {
  334. return;
  335. }
  336. IToBService.Call("pbsKillAppsByPidOrPackageName", pids, packageNames, 0);
  337. #endif
  338. }
  339. public static void UPxr_KillBackgroundAppsWithWhiteList(string[] packageNames)
  340. {
  341. #if PICO_PLATFORM
  342. if (IToBService == null)
  343. {
  344. return;
  345. }
  346. IToBService.Call("pbsKillBackgroundAppsWithWhiteList",packageNames, 0);
  347. #endif
  348. }
  349. public static void UPxr_FreezeScreen(bool freeze)
  350. {
  351. #if PICO_PLATFORM
  352. if (IToBService == null)
  353. {
  354. return;
  355. }
  356. IToBService.Call("pbsFreezeScreen", freeze);
  357. #endif
  358. }
  359. public static void UPxr_OpenMiracast()
  360. {
  361. #if PICO_PLATFORM
  362. if (IToBService == null)
  363. {
  364. return;
  365. }
  366. IToBService.Call("pbsOpenMiracast");
  367. #endif
  368. }
  369. public static bool UPxr_IsMiracastOn()
  370. {
  371. bool value = false;
  372. #if PICO_PLATFORM
  373. if (IToBService == null)
  374. {
  375. return value;
  376. }
  377. value = IToBService.Call<bool>("pbsIsMiracastOn");
  378. #endif
  379. return value;
  380. }
  381. public static void UPxr_CloseMiracast()
  382. {
  383. #if PICO_PLATFORM
  384. if (IToBService == null)
  385. {
  386. return;
  387. }
  388. IToBService.Call("pbsCloseMiracast");
  389. #endif
  390. }
  391. public static void UPxr_StartScan()
  392. {
  393. #if PICO_PLATFORM
  394. if (IToBService == null)
  395. {
  396. return;
  397. }
  398. IToBService.Call("pbsStartScan");
  399. #endif
  400. }
  401. public static void UPxr_StopScan()
  402. {
  403. #if PICO_PLATFORM
  404. if (IToBService == null)
  405. {
  406. return;
  407. }
  408. IToBService.Call("pbsStopScan");
  409. #endif
  410. }
  411. public static void UPxr_ConnectWifiDisplay(string modelJson)
  412. {
  413. #if PICO_PLATFORM
  414. tobHelper.Call("pbsConnectWifiDisplay", modelJson);
  415. #endif
  416. }
  417. public static void UPxr_DisConnectWifiDisplay()
  418. {
  419. #if PICO_PLATFORM
  420. if (IToBService == null)
  421. {
  422. return;
  423. }
  424. IToBService.Call("pbsDisConnectWifiDisplay");
  425. #endif
  426. }
  427. public static void UPxr_ForgetWifiDisplay(string address)
  428. {
  429. #if PICO_PLATFORM
  430. if (IToBService == null)
  431. {
  432. return;
  433. }
  434. IToBService.Call("pbsForgetWifiDisplay", address);
  435. #endif
  436. }
  437. public static void UPxr_RenameWifiDisplay(string address, string newName)
  438. {
  439. #if PICO_PLATFORM
  440. if (IToBService == null)
  441. {
  442. return;
  443. }
  444. IToBService.Call("pbsRenameWifiDisplay", address, newName);
  445. #endif
  446. }
  447. public static void UPxr_SetWDModelsCallback(Action<List<WifiDisplayModel>> callback)
  448. {
  449. #if PICO_PLATFORM
  450. tobHelper.Call("pbsSetWDModelsCallback", new WifiDisplayModelCallback(callback));
  451. #endif
  452. }
  453. public static void UPxr_SetWDJsonCallback(Action<string> callback)
  454. {
  455. #if PICO_PLATFORM
  456. tobHelper.Call("pbsSetWDJsonCallback", new StringCallback(callback));
  457. #endif
  458. }
  459. public static void UPxr_UpdateWifiDisplays()
  460. {
  461. #if PICO_PLATFORM
  462. if (IToBService == null)
  463. {
  464. return;
  465. }
  466. IToBService.Call("pbsUpdateWifiDisplays");
  467. #endif
  468. }
  469. public static string UPxr_GetConnectedWD()
  470. {
  471. string result = "";
  472. #if PICO_PLATFORM
  473. result = tobHelper.Call<string>("pbsGetConnectedWD");
  474. #endif
  475. return result;
  476. }
  477. public static void UPxr_SwitchLargeSpaceScene(bool open, Action<bool> callback)
  478. {
  479. #if PICO_PLATFORM
  480. tobHelper.Call("pbsSwitchLargeSpaceScene", new BoolCallback(callback), open, 0);
  481. #endif
  482. }
  483. public static void UPxr_GetSwitchLargeSpaceStatus(Action<string> callback)
  484. {
  485. #if PICO_PLATFORM
  486. tobHelper.Call("pbsGetSwitchLargeSpaceStatus",new StringCallback(callback), 0);
  487. #endif
  488. }
  489. public static bool UPxr_SaveLargeSpaceMaps()
  490. {
  491. bool value = false;
  492. #if PICO_PLATFORM
  493. if (IToBService == null)
  494. {
  495. return value;
  496. }
  497. value = IToBService.Call<bool>("pbsSaveLargeSpaceMaps", 0);
  498. #endif
  499. return value;
  500. }
  501. public static void UPxr_ExportMaps(Action<bool> callback)
  502. {
  503. #if PICO_PLATFORM
  504. tobHelper.Call("pbsExportMaps", new BoolCallback(callback), 0);
  505. #endif
  506. }
  507. public static void UPxr_ImportMaps(Action<bool> callback)
  508. {
  509. #if PICO_PLATFORM
  510. tobHelper.Call("pbsImportMaps", new BoolCallback(callback), 0);
  511. #endif
  512. }
  513. public static float[] UPxr_GetCpuUsages()
  514. {
  515. float[] data = null;
  516. #if PICO_PLATFORM
  517. data = tobHelper.Call<float[]>("pbsGetCpuUsages");
  518. #endif
  519. return data;
  520. }
  521. public static float[] UPxr_GetDeviceTemperatures(int type, int source)
  522. {
  523. float[] data = null;
  524. #if PICO_PLATFORM
  525. if (IToBService == null)
  526. {
  527. return null;
  528. }
  529. data = IToBService.Call<float[]>("pbsGetDeviceTemperatures", type, source);
  530. #endif
  531. return data;
  532. }
  533. public static void UPxr_Capture()
  534. {
  535. #if PICO_PLATFORM
  536. IToBService.Call("pbsCapture");
  537. #endif
  538. }
  539. public static void UPxr_Record()
  540. {
  541. #if PICO_PLATFORM
  542. IToBService.Call("pbsRecord");
  543. #endif
  544. }
  545. public static void UPxr_ControlSetAutoConnectWIFIWithErrorCodeCallback(String ssid, String pwd, int ext, Action<int> callback)
  546. {
  547. #if PICO_PLATFORM
  548. tobHelper.Call("pbsControlSetAutoConnectWIFIWithErrorCodeCallback",ssid,pwd,ext,new IntCallback(callback));
  549. #endif
  550. }
  551. public static void UPxr_AppKeepAlive(String appPackageName, bool keepAlive, int ext)
  552. {
  553. #if PICO_PLATFORM
  554. if (IToBService == null)
  555. {
  556. return ;
  557. }
  558. IToBService.Call("pbsAppKeepAlive",appPackageName,keepAlive,ext);
  559. #endif
  560. }
  561. public static void UPxr_TimingStartup(int year, int month, int day, int hour, int minute, bool open)
  562. {
  563. #if PICO_PLATFORM
  564. if (IToBService == null)
  565. {
  566. return ;
  567. }
  568. IToBService.Call("pbsTimingStartup", year, month, day, hour, minute, open);
  569. #endif
  570. }
  571. public static void UPxr_TimingShutdown(int year, int month, int day, int hour, int minute, bool open)
  572. {
  573. #if PICO_PLATFORM
  574. if (IToBService == null)
  575. {
  576. return ;
  577. }
  578. IToBService.Call("pbsTimingShutdown", year, month, day, hour, minute, open);
  579. #endif
  580. }
  581. public static void UPxr_StartVrSettingsItem(StartVRSettingsEnum settingsEnum, bool hideOtherItem, int ext)
  582. {
  583. #if PICO_PLATFORM
  584. if (IToBService == null)
  585. {
  586. return ;
  587. }
  588. IToBService.Call("pbsStartVrSettingsItem", GetEnumType(settingsEnum), hideOtherItem, ext);
  589. #endif
  590. }
  591. public static void UPxr_SwitchVolumeToHomeAndEnter(SwitchEnum switchEnum, int ext)
  592. {
  593. #if PICO_PLATFORM
  594. if (IToBService == null)
  595. {
  596. return ;
  597. }
  598. IToBService.Call("pbsSwitchVolumeToHomeAndEnter", GetEnumType(switchEnum), ext);
  599. #endif
  600. }
  601. public static SwitchEnum UPxr_IsVolumeChangeToHomeAndEnter()
  602. {
  603. SwitchEnum switchEnum = SwitchEnum.S_OFF;
  604. #if PICO_PLATFORM
  605. int num = 0;
  606. num = tobHelper.Call<int>("pbsIsVolumeChangeToHomeAndEnter");
  607. if (num == 0)
  608. {
  609. switchEnum = SwitchEnum.S_ON;
  610. }
  611. else if (num == 1) {
  612. switchEnum = SwitchEnum.S_OFF;
  613. }
  614. #endif
  615. return switchEnum;
  616. }
  617. public static int UPxr_InstallOTAPackage(String otaPackagePath)
  618. {
  619. int value = 0;
  620. #if PICO_PLATFORM
  621. if (IToBService == null)
  622. {
  623. return value;
  624. }
  625. value = IToBService.Call<int>("pbsInstallOTAPackage",otaPackagePath, 0);
  626. #endif
  627. return value;
  628. }
  629. public static string UPxr_GetAutoConnectWiFiConfig()
  630. {
  631. string value= "";
  632. #if PICO_PLATFORM
  633. if (IToBService == null)
  634. {
  635. return value;
  636. }
  637. value = IToBService.Call<string>("pbsGetAutoConnectWiFiConfig", 0);
  638. #endif
  639. return value;
  640. }
  641. public static string UPxr_GetTimingStartupStatus()
  642. {
  643. string value = "";
  644. #if PICO_PLATFORM
  645. if (IToBService == null)
  646. {
  647. return value;
  648. }
  649. value = IToBService.Call<string>("pbsGetTimingStartupStatus", 0);
  650. #endif
  651. return value;
  652. }
  653. public static string UPxr_GetTimingShutdownStatus()
  654. {
  655. string value = "";
  656. #if PICO_PLATFORM
  657. if (IToBService == null)
  658. {
  659. return value;
  660. }
  661. value = IToBService.Call<string>("pbsGetTimingShutdownStatus", 0);
  662. #endif
  663. return value;
  664. }
  665. public static int UPxr_GetControllerKeyState(ControllerKeyEnum pxrControllerKey)
  666. {
  667. int value = 1;
  668. #if PICO_PLATFORM
  669. if (IToBService == null)
  670. {
  671. return value;
  672. }
  673. value = IToBService.Call<int>("pbsGetControllerKeyState", GetEnumType(pxrControllerKey),0);
  674. #endif
  675. return value;
  676. }
  677. public static int UPxr_SetControllerKeyState(ControllerKeyEnum controllerKeyEnum, SwitchEnum status)
  678. {
  679. int value = 1;
  680. #if PICO_PLATFORM
  681. if (IToBService == null)
  682. {
  683. return value;
  684. }
  685. value = IToBService.Call<int>("pbsSetControllerKeyState", GetEnumType(controllerKeyEnum),GetEnumType(status),0);
  686. #endif
  687. return value;
  688. }
  689. public static SwitchEnum UPxr_ControlGetPowerOffWithUSBCable()
  690. {
  691. SwitchEnum switchEnum = SwitchEnum.S_OFF;
  692. #if PICO_PLATFORM
  693. int num = 0;
  694. num = tobHelper.Call<int>("pbsControlGetPowerOffWithUSBCable",0);
  695. if (num == 0)
  696. {
  697. switchEnum = SwitchEnum.S_ON;
  698. }
  699. else if (num == 1) {
  700. switchEnum = SwitchEnum.S_OFF;
  701. }
  702. #endif
  703. return switchEnum;
  704. }
  705. public static ScreenOffDelayTimeEnum UPxr_PropertyGetScreenOffDelay()
  706. {
  707. ScreenOffDelayTimeEnum screenOffDelayTimeEnum = ScreenOffDelayTimeEnum.NEVER;
  708. #if PICO_PLATFORM
  709. int num = 0;
  710. num = tobHelper.Call<int>("pbsPropertyGetScreenOffDelay", 0);
  711. switch (num) {
  712. case 0:
  713. screenOffDelayTimeEnum = ScreenOffDelayTimeEnum.THREE;
  714. break;
  715. case 1:
  716. screenOffDelayTimeEnum = ScreenOffDelayTimeEnum.TEN;
  717. break;
  718. case 2:
  719. screenOffDelayTimeEnum = ScreenOffDelayTimeEnum.THIRTY;
  720. break;
  721. case 3:
  722. screenOffDelayTimeEnum = ScreenOffDelayTimeEnum.SIXTY;
  723. break;
  724. case 4:
  725. screenOffDelayTimeEnum = ScreenOffDelayTimeEnum.THREE_HUNDRED;
  726. break;
  727. case 5:
  728. screenOffDelayTimeEnum = ScreenOffDelayTimeEnum.SIX_HUNDRED;
  729. break;
  730. case 6:
  731. screenOffDelayTimeEnum = ScreenOffDelayTimeEnum.NEVER;
  732. break;
  733. }
  734. #endif
  735. return screenOffDelayTimeEnum;
  736. }
  737. public static SleepDelayTimeEnum UPxr_PropertyGetSleepDelay()
  738. {
  739. SleepDelayTimeEnum sleepDelayTime = SleepDelayTimeEnum.NEVER;
  740. #if PICO_PLATFORM
  741. int num = 0;
  742. num = tobHelper.Call<int>("pbsPropertyGetSleepDelay", 0);
  743. switch (num)
  744. {
  745. case 0:
  746. sleepDelayTime = SleepDelayTimeEnum.FIFTEEN;
  747. break;
  748. case 1:
  749. sleepDelayTime = SleepDelayTimeEnum.THIRTY;
  750. break;
  751. case 2:
  752. sleepDelayTime = SleepDelayTimeEnum.SIXTY;
  753. break;
  754. case 3:
  755. sleepDelayTime = SleepDelayTimeEnum.THREE_HUNDRED;
  756. break;
  757. case 4:
  758. sleepDelayTime = SleepDelayTimeEnum.SIX_HUNDRED;
  759. break;
  760. case 5:
  761. sleepDelayTime = SleepDelayTimeEnum.ONE_THOUSAND_AND_EIGHT_HUNDRED;
  762. break;
  763. case 6:
  764. sleepDelayTime = SleepDelayTimeEnum.NEVER;
  765. break;
  766. }
  767. #endif
  768. return sleepDelayTime;
  769. }
  770. public static string UPxr_PropertyGetPowerKeyStatus()
  771. {
  772. string value = "";
  773. #if PICO_PLATFORM
  774. if (IToBService == null)
  775. {
  776. return value;
  777. }
  778. value = IToBService.Call<string>("pbsPropertyGetPowerKeyStatus", 0);
  779. #endif
  780. return value;
  781. }
  782. public static int UPxr_GetEnterKeyStatus()
  783. {
  784. int value = 1;
  785. #if PICO_PLATFORM
  786. if (IToBService == null)
  787. {
  788. return value;
  789. }
  790. value = IToBService.Call<int>("pbsGetEnterKeyStatus",0);
  791. #endif
  792. return value;
  793. }
  794. public static int UPxr_GetVolumeKeyStatus()
  795. {
  796. int value = 1;
  797. #if PICO_PLATFORM
  798. if (IToBService == null)
  799. {
  800. return value;
  801. }
  802. value = IToBService.Call<int>("pbsGetVolumeKeyStatus",0);
  803. #endif
  804. return value;
  805. }
  806. public static int UPxr_GetBackKeyStatus()
  807. {
  808. int value = 1;
  809. #if PICO_PLATFORM
  810. if (IToBService == null)
  811. {
  812. return value;
  813. }
  814. value = IToBService.Call<int>("pbsGetBackKeyStatus",0);
  815. #endif
  816. return value;
  817. }
  818. public static string UPxr_PropertyGetHomeKeyStatus(HomeEventEnum homeEvent)
  819. {
  820. string value = "";
  821. #if PICO_PLATFORM
  822. if (IToBService == null)
  823. {
  824. return value;
  825. }
  826. value = IToBService.Call<string>("pbsPropertyGetHomKeyStatus", GetEnumType(homeEvent),0);
  827. #endif
  828. return value;
  829. }
  830. public static void UPxr_GetSwitchSystemFunctionStatus(SystemFunctionSwitchEnum systemFunction, Action<int> callback)
  831. {
  832. #if PICO_PLATFORM
  833. tobHelper.Call("pbsGetSwitchSystemFunctionStatus", GetEnumType(systemFunction), new IntCallback(callback),
  834. 0);
  835. #endif
  836. }
  837. public static string UPxr_SwitchGetUsbConfigurationOption()
  838. {
  839. string value = "";
  840. #if PICO_PLATFORM
  841. if (IToBService == null)
  842. {
  843. return value;
  844. }
  845. value = IToBService.Call<string>("pbsSwitchGetUsbConfigurationOption", 0);
  846. #endif
  847. return value;
  848. }
  849. public static string UPxr_GetCurrentLauncher()
  850. {
  851. string value = "";
  852. #if PICO_PLATFORM
  853. if (IToBService == null)
  854. {
  855. return value;
  856. }
  857. value = IToBService.Call<string>("pbsGetCurrentLauncher", 0);
  858. #endif
  859. return value;
  860. }
  861. public static int UPxr_PICOCastInit(Action<int> callback)
  862. {
  863. int value = 0;
  864. #if PICO_PLATFORM
  865. value = tobHelper.Call<int>("pbsPicoCastInit", new IntCallback(callback), 0);
  866. #endif
  867. return value;
  868. }
  869. public static int UPxr_PICOCastSetShowAuthorization(int authZ)
  870. {
  871. int value = 0;
  872. #if PICO_PLATFORM
  873. if (IToBService == null)
  874. {
  875. return value;
  876. }
  877. value = IToBService.Call<int>("pbsPicoCastSetShowAuthorization",authZ,0);
  878. #endif
  879. return value;
  880. }
  881. public static int UPxr_PICOCastGetShowAuthorization()
  882. {
  883. int value = 0;
  884. #if PICO_PLATFORM
  885. if (IToBService == null)
  886. {
  887. return value;
  888. }
  889. value = IToBService.Call<int>("pbsPicoCastGetShowAuthorization",0);
  890. #endif
  891. return value;
  892. }
  893. public static string UPxr_PICOCastGetUrl(PICOCastUrlTypeEnum urlType)
  894. {
  895. string value = "";
  896. #if PICO_PLATFORM
  897. if (IToBService == null)
  898. {
  899. return value;
  900. }
  901. value = IToBService.Call<string>("pbsPicoCastGetUrl",GetEnumType(urlType), 0);
  902. #endif
  903. return value;
  904. }
  905. public static int UPxr_PICOCastStopCast()
  906. {
  907. int value = 0;
  908. #if PICO_PLATFORM
  909. if (IToBService == null)
  910. {
  911. return value;
  912. }
  913. value = IToBService.Call<int>("pbsPicoCastStopCast",0);
  914. #endif
  915. return value;
  916. }
  917. public static int UPxr_PICOCastSetOption(PICOCastOptionOrStatusEnum castOptionOrStatus, PICOCastOptionValueEnum castOptionValue)
  918. {
  919. int value = 0;
  920. #if PICO_PLATFORM
  921. if (IToBService == null)
  922. {
  923. return value;
  924. }
  925. value = IToBService.Call<int>("pbsPicoCastSetOption",GetEnumType(castOptionOrStatus),GetEnumType(castOptionValue),0);
  926. #endif
  927. return value;
  928. }
  929. public static PICOCastOptionValueEnum UPxr_PICOCastGetOptionOrStatus(PICOCastOptionOrStatusEnum castOptionOrStatus)
  930. {
  931. PICOCastOptionValueEnum value = PICOCastOptionValueEnum.STATUS_VALUE_ERROR;
  932. #if PICO_PLATFORM
  933. int num = 0;
  934. if (IToBService == null)
  935. {
  936. return value;
  937. }
  938. num = IToBService.Call<int>("pbsPicoCastGetOptionOrStatus", GetEnumType(castOptionOrStatus), 0);
  939. switch (num)
  940. {
  941. case 0:
  942. value = PICOCastOptionValueEnum.OPTION_VALUE_RESOLUTION_HIGH;
  943. break;
  944. case 1:
  945. value = PICOCastOptionValueEnum.OPTION_VALUE_RESOLUTION_MIDDLE;
  946. break;
  947. case 2:
  948. value = PICOCastOptionValueEnum.OPTION_VALUE_RESOLUTION_AUTO;
  949. break;
  950. case 3:
  951. value = PICOCastOptionValueEnum.OPTION_VALUE_RESOLUTION_HIGH_2K;
  952. break;
  953. case 4:
  954. value = PICOCastOptionValueEnum.OPTION_VALUE_RESOLUTION_HIGH_4K;
  955. break;
  956. case 5:
  957. value = PICOCastOptionValueEnum.OPTION_VALUE_BITRATE_HIGH;
  958. break;
  959. case 6:
  960. value = PICOCastOptionValueEnum.OPTION_VALUE_BITRATE_MIDDLE;
  961. break;
  962. case 7:
  963. value = PICOCastOptionValueEnum.OPTION_VALUE_BITRATE_LOW;
  964. break;
  965. case 8:
  966. value = PICOCastOptionValueEnum.OPTION_VALUE_AUDIO_ON;
  967. break;
  968. case 9:
  969. value = PICOCastOptionValueEnum.OPTION_VALUE_AUDIO_OFF;
  970. break;
  971. case 10:
  972. value = PICOCastOptionValueEnum.STATUS_VALUE_STATE_STARTED;
  973. break;
  974. case 11:
  975. value = PICOCastOptionValueEnum.STATUS_VALUE_STATE_STOPPED;
  976. break;
  977. case 12:
  978. value = PICOCastOptionValueEnum.STATUS_VALUE_ERROR;
  979. break;
  980. }
  981. #endif
  982. return value;
  983. }
  984. public static int UPxr_SetSystemLanguage(String language)
  985. {
  986. int num = 0;
  987. #if PICO_PLATFORM
  988. num = IToBService.Call<int>("pbsSetSystemLanguage", language, 0);
  989. #endif
  990. return num;
  991. }
  992. public static String UPxr_GetSystemLanguage()
  993. {
  994. string value = "";
  995. #if PICO_PLATFORM
  996. value = IToBService.Call<string>("pbsGetSystemLanguage", 0);
  997. #endif
  998. return value;
  999. }
  1000. public static int UPxr_ConfigWifi(String ssid, String pwd)
  1001. {
  1002. int num = 0;
  1003. #if PICO_PLATFORM
  1004. num = IToBService.Call<int>("pbsConfigWifi",ssid,pwd, 0);
  1005. #endif
  1006. return num;
  1007. }
  1008. public static String[] UPxr_GetConfiguredWifi()
  1009. {
  1010. #if PICO_PLATFORM
  1011. return IToBService.Call<string[]>("pbsGetConfiguredWifi",0);
  1012. #endif
  1013. return null;
  1014. }
  1015. public static int UPxr_SetSystemCountryCode(String countryCode, Action<int> callback)
  1016. {
  1017. int num = 0;
  1018. #if PICO_PLATFORM
  1019. num = tobHelper.Call<int>("pbsSetSystemCountryCode",countryCode,new IntCallback(callback),0);
  1020. #endif
  1021. return num;
  1022. }
  1023. public static string UPxr_GetSystemCountryCode()
  1024. {
  1025. string value = "";
  1026. #if PICO_PLATFORM
  1027. value = IToBService.Call<string>("pbsGetSystemCountryCode",0);
  1028. #endif
  1029. return value;
  1030. }
  1031. public static int UPxr_SetSkipInitSettingPage(int flag)
  1032. {
  1033. int num = 0;
  1034. #if PICO_PLATFORM
  1035. num = IToBService.Call<int>("pbsSetSkipInitSettingPage",flag,0);
  1036. #endif
  1037. return num;
  1038. }
  1039. public static int UPxr_GetSkipInitSettingPage()
  1040. {
  1041. int num = 0;
  1042. #if PICO_PLATFORM
  1043. num = IToBService.Call<int>("pbsGetSkipInitSettingPage",0);
  1044. #endif
  1045. return num;
  1046. }
  1047. public static int UPxr_IsInitSettingComplete()
  1048. {
  1049. int num = 0;
  1050. #if PICO_PLATFORM
  1051. num = IToBService.Call<int>("pbsIsInitSettingComplete",0);
  1052. #endif
  1053. return num;
  1054. }
  1055. public static int UPxr_StartActivity(String packageName, String className, String action, String extra, String[] categories, int[] flags)
  1056. {
  1057. int num = 0;
  1058. #if PICO_PLATFORM
  1059. num = IToBService.Call<int>("pbsStartActivity", packageName, className, action, extra, categories, flags, 0);
  1060. #endif
  1061. return num;
  1062. }
  1063. public static int UPxr_CustomizeAppLibrary(String[] packageNames, SwitchEnum switchEnum)
  1064. {
  1065. int num = 0;
  1066. #if PICO_PLATFORM
  1067. if (IToBService == null)
  1068. {
  1069. return num;
  1070. }
  1071. num = IToBService.Call<int>("pbsCustomizeAppLibrary", packageNames,GetEnumType(switchEnum), 0);
  1072. #endif
  1073. return num;
  1074. }
  1075. public static int[] UPxr_GetControllerBattery()
  1076. {
  1077. #if PICO_PLATFORM
  1078. if (IToBService == null)
  1079. {
  1080. return null;
  1081. }
  1082. return IToBService.Call<int[]>("pbsGetControllerBattery", 0);
  1083. #endif
  1084. return null;
  1085. }
  1086. public static int UPxr_GetControllerConnectState()
  1087. {
  1088. int num = 0;
  1089. #if PICO_PLATFORM
  1090. if (IToBService == null)
  1091. {
  1092. return num;
  1093. }
  1094. num = IToBService.Call<int>("pbsGetControllerConnectState",0);
  1095. #endif
  1096. return num;
  1097. }
  1098. public static string UPxr_GetAppLibraryHideList()
  1099. {
  1100. string value = " ";
  1101. #if PICO_PLATFORM
  1102. if (IToBService == null)
  1103. {
  1104. return value;
  1105. }
  1106. value = IToBService.Call<string>("pbsGetAppLibraryHideList",0);
  1107. #endif
  1108. return value;
  1109. }
  1110. public static int UPxr_SetScreenCastAudioOutput(ScreencastAudioOutputEnum screencastAudioOutput)
  1111. {
  1112. int value = 0;
  1113. #if PICO_PLATFORM
  1114. if (IToBService == null)
  1115. {
  1116. return value;
  1117. }
  1118. value = IToBService.Call<int>("pbsSetScreenCastAudioOutput",GetEnumType(screencastAudioOutput),0);
  1119. #endif
  1120. return value;
  1121. }
  1122. public static ScreencastAudioOutputEnum UPxr_GetScreenCastAudioOutput()
  1123. {
  1124. ScreencastAudioOutputEnum value = ScreencastAudioOutputEnum.AUDIO_ERROR;
  1125. #if PICO_PLATFORM
  1126. int num = 0;
  1127. num = tobHelper.Call<int>("pbsGetScreenCastAudioOutput",0);
  1128. switch (num)
  1129. {
  1130. case 0:
  1131. value = ScreencastAudioOutputEnum.AUDIO_SINK;
  1132. break;
  1133. case 1:
  1134. value = ScreencastAudioOutputEnum.AUDIO_TARGET;
  1135. break;
  1136. case 2:
  1137. value = ScreencastAudioOutputEnum.AUDIO_SINK_TARGET;
  1138. break;
  1139. }
  1140. #endif
  1141. return value;
  1142. }
  1143. public static int UPxr_CustomizeSettingsTabStatus(CustomizeSettingsTabEnum customizeSettingsTabEnum, SwitchEnum switchEnum)
  1144. {
  1145. int value = 0;
  1146. #if PICO_PLATFORM
  1147. if (IToBService == null)
  1148. {
  1149. return value;
  1150. }
  1151. value = IToBService.Call<int>("pbsCustomizeSettingsTabStatus", GetEnumType(customizeSettingsTabEnum), GetEnumType(switchEnum), 0);
  1152. #endif
  1153. return value;
  1154. }
  1155. public static SwitchEnum UPxr_GetCustomizeSettingsTabStatus(CustomizeSettingsTabEnum customizeSettingsTabEnum)
  1156. {
  1157. SwitchEnum switchEnum = SwitchEnum.S_OFF;
  1158. #if PICO_PLATFORM
  1159. int num = 0;
  1160. num = tobHelper.Call<int>("pbsGetCustomizeSettingsTabStatus",GetEnumType(customizeSettingsTabEnum),0);
  1161. if (num == 0)
  1162. {
  1163. switchEnum = SwitchEnum.S_ON;
  1164. }
  1165. else if (num == 1) {
  1166. switchEnum = SwitchEnum.S_OFF;
  1167. }
  1168. #endif
  1169. return switchEnum;
  1170. }
  1171. public static void UPxr_SetPowerOffWithUSBCable(SwitchEnum switchEnum)
  1172. {
  1173. #if PICO_PLATFORM
  1174. if (IToBService==null)
  1175. {
  1176. return;
  1177. }
  1178. IToBService.Call("pbsControlSetPowerOffWithUSBCable", GetEnumType(switchEnum),0);
  1179. #endif
  1180. }
  1181. public static void UPxr_RemoveControllerHomeKey(HomeEventEnum EventEnum)
  1182. {
  1183. #if PICO_PLATFORM
  1184. if (IToBService==null)
  1185. {
  1186. return;
  1187. }
  1188. IToBService.Call("pbsRemoveControllerHomeKey", GetEnumType(EventEnum));
  1189. #endif
  1190. }
  1191. public static void UPxr_SetPowerOnOffLogo(PowerOnOffLogoEnum powerOnOffLogoEnum, String path, Action<bool> callback)
  1192. {
  1193. #if PICO_PLATFORM
  1194. tobHelper.Call("pbsPropertySetPowerOnOffLogo",GetEnumType(powerOnOffLogoEnum),path,0, new BoolCallback(callback));
  1195. #endif
  1196. }
  1197. public static void UPxr_SetIPD(float ipd, Action<int> callback)
  1198. {
  1199. #if PICO_PLATFORM
  1200. tobHelper.Call("pbsSetIPD",ipd, new IntCallback(callback));
  1201. #endif
  1202. }
  1203. public static string UPxr_GetAutoMiracastConfig()
  1204. {
  1205. string value = " ";
  1206. #if PICO_PLATFORM
  1207. if (IToBService == null)
  1208. {
  1209. return value;
  1210. }
  1211. value = IToBService.Call<string>("pbsGetAutoMiracastConfig",0);
  1212. #endif
  1213. return value;
  1214. }
  1215. public static int UPxr_SetPicoCastMediaFormat(PicoCastMediaFormat mediaFormat)
  1216. {
  1217. int value = -1;
  1218. #if PICO_PLATFORM
  1219. value = tobHelper.Call<int>("setPicoCastMediaFormat",mediaFormat.bitrate,0);
  1220. #endif
  1221. return value;
  1222. }
  1223. public static int UPxr_setMarkerInfoCallback(TrackingOriginModeFlags trackingMode,float cameraYOffset,Action<List<MarkerInfo>> mediaFormat)
  1224. {
  1225. int value = -1;
  1226. #if PICO_PLATFORM
  1227. value = tobHelper.Call<int>("setMarkerInfoCallback",new MarkerInfoCallback(trackingMode,cameraYOffset,mediaFormat));
  1228. #endif
  1229. return value;
  1230. }
  1231. private static bool UPxr_GetToken()
  1232. {
  1233. PLog.i(TAG, "GetToken Start");
  1234. #if PICO_PLATFORM
  1235. token = BAuthLib.CallStatic<string>("featureAuthByToken", currentActivity, "getCameraInfo");
  1236. #endif
  1237. if (string.IsNullOrEmpty(token))
  1238. {
  1239. PLog.e(TAG, "Failed to obtain token, camera data cannot be obtained!");
  1240. return false;
  1241. }
  1242. PLog.i(TAG, "GetToken End token :" + token);
  1243. return true;
  1244. }
  1245. public static int UPxr_GetHeadTrackingConfidence()
  1246. {
  1247. PLog.d(TAG, "GetHeadTrackingConfidence Start");
  1248. int result = -1;
  1249. #if PICO_PLATFORM
  1250. result = getHeadTrackingConfidence();
  1251. #endif
  1252. PLog.d(TAG, "GetToken End result :" + result);
  1253. return result;
  1254. }
  1255. public static bool UPxr_OpenVSTCamera()
  1256. {
  1257. PLog.d(TAG, "OpenVSTCamera Start");
  1258. if (camOpenned)
  1259. {
  1260. PLog.d(TAG, "Camera has Openned!");
  1261. return true;
  1262. }
  1263. int result = -1;
  1264. #if PICO_PLATFORM
  1265. result = openVSTCamera();
  1266. #endif
  1267. camOpenned = result == 0;
  1268. PLog.d(TAG, "OpenVSTCamera End result :" + result + ", camOpenned : " + camOpenned);
  1269. return result == 0;
  1270. }
  1271. public static bool UPxr_CloseVSTCamera()
  1272. {
  1273. PLog.d(TAG, "CloseVSTCamera Start");
  1274. if (!camOpenned)
  1275. {
  1276. PLog.d(TAG, "Camera has Closed!");
  1277. return true;
  1278. }
  1279. int result = -1;
  1280. #if PICO_PLATFORM
  1281. result = closeVSTCamera();
  1282. #endif
  1283. camOpenned = !(result == 0);
  1284. PLog.d(TAG, "CloseVSTCamera End result :" + result + ", camOpenned : " + camOpenned);
  1285. return result == 0;
  1286. }
  1287. public static int UPxr_GetHeadTrackingData(Int64 predictTime, ref SixDof data, int type)
  1288. {
  1289. PLog.d(TAG, "GetHeadTrackingData Start");
  1290. int result = -1;
  1291. #if PICO_PLATFORM
  1292. result = getHeadTrackingData(predictTime, ref data, type);
  1293. #endif
  1294. PLog.d(TAG, "GetHeadTrackingData End result :" + result);
  1295. return result;
  1296. }
  1297. public static int UPxr_AcquireVSTCameraFrame(out Frame frame)
  1298. {
  1299. PLog.d(TAG, "AcquireVSTCameraFrame Start");
  1300. frame = new Frame();
  1301. if (string.IsNullOrEmpty(token))
  1302. {
  1303. PLog.e(TAG, "Failed to obtain token, camera data cannot be obtained!");
  1304. return -1;
  1305. }
  1306. if (!camOpenned)
  1307. {
  1308. PLog.e(TAG, "Failed to obtain data due to camera not being turned on!");
  1309. return -1;
  1310. }
  1311. InitDistortionFrame();
  1312. int result = -1;
  1313. #if PICO_PLATFORM
  1314. result = acquireVSTCameraFrame(ref distortionFrameItemExt);
  1315. #endif
  1316. frame.width = distortionFrameItemExt.frame.width;
  1317. frame.height = distortionFrameItemExt.frame.height;
  1318. frame.timestamp = distortionFrameItemExt.frame.timestamp;
  1319. frame.datasize = distortionFrameItemExt.frame.datasize;
  1320. frame.data = distortionFrameItemExt.frame.data;
  1321. if (frame.pose != null)
  1322. {
  1323. frame.pose.position.x = (float)distortionFrameItemExt.six_dof_pose.pose.x;
  1324. frame.pose.position.y = (float)distortionFrameItemExt.six_dof_pose.pose.y;
  1325. frame.pose.position.z = (float)distortionFrameItemExt.six_dof_pose.pose.z;
  1326. frame.pose.rotation.w = (float)distortionFrameItemExt.six_dof_pose.pose.rw;
  1327. frame.pose.rotation.x = (float)distortionFrameItemExt.six_dof_pose.pose.rx;
  1328. frame.pose.rotation.y = (float)distortionFrameItemExt.six_dof_pose.pose.ry;
  1329. frame.pose.rotation.z = (float)distortionFrameItemExt.six_dof_pose.pose.rz;
  1330. }
  1331. frame.status = distortionFrameItemExt.six_dof_pose.pose.confidence;
  1332. PLog.d(TAG, "AcquireVSTCameraFrame End result :" + result);
  1333. return result;
  1334. }
  1335. public static int UPxr_AcquireVSTCameraFrameAntiDistortion(int width, int height, out Frame frame)
  1336. {
  1337. PLog.d(TAG, "AcquireVSTCameraFrameAntiDistortion Start width:" + width + ", height:" + height);
  1338. frame = new Frame();
  1339. if (string.IsNullOrEmpty(token))
  1340. {
  1341. PLog.e(TAG, "Failed to obtain token, camera data cannot be obtained!");
  1342. return -1;
  1343. }
  1344. if (!camOpenned)
  1345. {
  1346. PLog.e(TAG, "Failed to obtain data due to camera not being turned on!");
  1347. return -1;
  1348. }
  1349. int size = width * height * 3;
  1350. InitAntiDistortionFrame(size);
  1351. int result = -1;
  1352. #if PICO_PLATFORM
  1353. result = acquireVSTCameraFrameAntiDistortion(token, width, height, ref antiDistortionFrameItemExt);
  1354. #endif
  1355. PLog.d(TAG, "AcquireVSTCameraFrameAntiDistortion End result :" + result +
  1356. ", width : " + antiDistortionFrameItemExt.frame.width +
  1357. ", height : " + antiDistortionFrameItemExt.frame.height +
  1358. ", datasize : " + antiDistortionFrameItemExt.frame.datasize +
  1359. ", data : " + antiDistortionFrameItemExt.frame.data +
  1360. ", confidence : " + antiDistortionFrameItemExt.six_dof_pose.pose.confidence);
  1361. frame.width = antiDistortionFrameItemExt.frame.width;
  1362. frame.height = antiDistortionFrameItemExt.frame.height;
  1363. frame.timestamp = antiDistortionFrameItemExt.frame.timestamp;
  1364. frame.datasize = antiDistortionFrameItemExt.frame.datasize;
  1365. frame.data = antiDistortionFrameItemExt.frame.data;
  1366. if (frame.pose != null)
  1367. {
  1368. frame.pose.position.x = (float)antiDistortionFrameItemExt.six_dof_pose.pose.x;
  1369. frame.pose.position.y = (float)antiDistortionFrameItemExt.six_dof_pose.pose.y;
  1370. frame.pose.position.z = (float)antiDistortionFrameItemExt.six_dof_pose.pose.z;
  1371. frame.pose.rotation.w = (float)antiDistortionFrameItemExt.six_dof_pose.pose.rw;
  1372. frame.pose.rotation.x = (float)antiDistortionFrameItemExt.six_dof_pose.pose.rx;
  1373. frame.pose.rotation.y = (float)antiDistortionFrameItemExt.six_dof_pose.pose.ry;
  1374. frame.pose.rotation.z = (float)antiDistortionFrameItemExt.six_dof_pose.pose.rz;
  1375. }
  1376. frame.status = antiDistortionFrameItemExt.six_dof_pose.pose.confidence;
  1377. return result;
  1378. }
  1379. public static UnityEngine.Pose ToUnityPose(UnityEngine.Pose poseR)
  1380. {
  1381. UnityEngine.Pose poseL;
  1382. poseL.position.x = poseR.position.x;
  1383. poseL.position.y = poseR.position.y;
  1384. poseL.position.z = -poseR.position.z;
  1385. poseL.rotation.x = poseR.rotation.x;
  1386. poseL.rotation.y = poseR.rotation.y;
  1387. poseL.rotation.z = -poseR.rotation.z;
  1388. poseL.rotation.w = -poseR.rotation.w;
  1389. return poseL;
  1390. }
  1391. // RGB Camera pose (Left-handed coordinate system: X right, Y up, Z out)
  1392. public static UnityEngine.Pose ToRGBCameraPose(RGBCameraParams cameraParams, UnityEngine.Pose headPose)
  1393. {
  1394. Vector3 headToCameraPos = new Vector3((float)cameraParams.x, (float)cameraParams.y, (float)cameraParams.z);
  1395. Quaternion headToCameraRot = new Quaternion((float)cameraParams.rx, (float)cameraParams.ry, (float)cameraParams.rz, (float)cameraParams.rw);
  1396. Matrix4x4 headMx = Matrix4x4.TRS(headPose.position, headPose.rotation, Vector3.one);
  1397. Matrix4x4 cameraMx = Matrix4x4.TRS(headToCameraPos, headToCameraRot, Vector3.one);
  1398. Matrix4x4 rgbMx = headMx * cameraMx;
  1399. Matrix4x4 rotX180 = Matrix4x4.Rotate(Quaternion.Euler(180f, 0f, 0f));
  1400. rgbMx *= rotX180;
  1401. #if UNITY_2021_2_OR_NEWER
  1402. UnityEngine.Pose rgbCameraPose = ToUnityPose(new UnityEngine.Pose(rgbMx.GetPosition(), rgbMx.rotation));
  1403. #else
  1404. UnityEngine.Pose rgbCameraPose = ToUnityPose(new UnityEngine.Pose(new Vector3(rgbMx.m03, rgbMx.m13, rgbMx.m23), rgbMx.rotation));
  1405. #endif
  1406. return rgbCameraPose;
  1407. }
  1408. private static void InitDistortionFrame()
  1409. {
  1410. if (initDistortionFrame)
  1411. {
  1412. return;
  1413. }
  1414. distortionFrameItemExt = new FrameItemExt();
  1415. initDistortionFrame = true;
  1416. }
  1417. private static void InitAntiDistortionFrame(int size)
  1418. {
  1419. if (curSize == size)
  1420. {
  1421. return;
  1422. }
  1423. Debug.LogFormat("InitAntiDistortionFrame curSize={0}, size={1}", curSize, size);
  1424. antiDistortionFrameItemExt = new FrameItemExt();
  1425. if (antiDistortionFrameItemExt.frame.data != IntPtr.Zero)
  1426. {
  1427. Marshal.FreeHGlobal(antiDistortionFrameItemExt.frame.data);
  1428. antiDistortionFrameItemExt.frame.data = IntPtr.Zero;
  1429. }
  1430. antiDistortionFrameItemExt.frame.data = Marshal.AllocHGlobal(size);
  1431. curSize = size;
  1432. }
  1433. public static RGBCameraParams UPxr_GetCameraParameters()
  1434. {
  1435. PLog.d(TAG, "GetCameraParameters Start");
  1436. RGBCameraParams rgbCameraParams = new RGBCameraParams();
  1437. if (string.IsNullOrEmpty(token))
  1438. {
  1439. PLog.e(TAG, "Failed to obtain token, camera data cannot be obtained!");
  1440. return rgbCameraParams;
  1441. }
  1442. int result = getCameraParameters(token, out rgbCameraParams);
  1443. PLog.d(TAG, "GetCameraParameters End result :" + result);
  1444. return rgbCameraParams;
  1445. }
  1446. public static double UPxr_GetPredictedDisplayTime()
  1447. {
  1448. PLog.d(TAG, "UPxr_GetPredictedDisplayTime()");
  1449. double predictedDisplayTime = 0;
  1450. #if PICO_PLATFORM
  1451. Pxr_GetPredictedDisplayTime(ref predictedDisplayTime);
  1452. #endif
  1453. PLog.d(TAG, "UPxr_GetPredictedDisplayTime() predictedDisplayTime:" + predictedDisplayTime);
  1454. return predictedDisplayTime;
  1455. }
  1456. public static SensorState UPxr_GetPredictedMainSensorState(double predictTime)
  1457. {
  1458. SensorState sensorState = new SensorState();
  1459. PxrSensorState2 sensorState2 = new PxrSensorState2();
  1460. int sensorFrameIndex = 0;
  1461. #if PICO_PLATFORM
  1462. Pxr_GetPredictedMainSensorState2(predictTime, ref sensorState2, ref sensorFrameIndex);
  1463. #endif
  1464. sensorState.status = sensorState2.status == 3 ? 1 : 0;
  1465. sensorState.pose.position.x = sensorState2.globalPose.position.x;
  1466. sensorState.pose.position.y = sensorState2.globalPose.position.y;
  1467. sensorState.pose.position.z = sensorState2.globalPose.position.z;
  1468. sensorState.pose.rotation.x = sensorState2.globalPose.orientation.x;
  1469. sensorState.pose.rotation.y = sensorState2.globalPose.orientation.y;
  1470. sensorState.pose.rotation.z = sensorState2.globalPose.orientation.z;
  1471. sensorState.pose.rotation.w = sensorState2.globalPose.orientation.w;
  1472. return sensorState;
  1473. }
  1474. public static int UPxr_gotoSeeThroughFloorSetting()
  1475. {
  1476. int value = -1;
  1477. #if PICO_PLATFORM
  1478. value = IToBService.Call<int>("gotoSeeThroughFloorSetting",0);
  1479. #endif
  1480. return value;
  1481. }
  1482. public static int UPxr_fileCopy(String srcPath, String dstPath, FileCopyCallback callback)
  1483. {
  1484. int value = -1;
  1485. #if PICO_PLATFORM
  1486. value = tobHelper.Call<int>("FileCopy",srcPath,dstPath,callback);
  1487. #endif
  1488. return value;
  1489. }
  1490. public static void UPxr_IsMapInEffect(String path, Action<int> callback)
  1491. {
  1492. #if PICO_PLATFORM
  1493. tobHelper.Call("isMapInEffect",path,new IntCallback(callback),0);
  1494. #endif
  1495. }
  1496. public static void UPxr_ImportMapByPath(String path, Action<int> callback)
  1497. {
  1498. #if PICO_PLATFORM
  1499. tobHelper.Call("importMapByPath",path,new IntCallback(callback),0);
  1500. #endif
  1501. }
  1502. }
  1503. }
粤ICP备19079148号