PXR_EnterprisePlugin.cs 55 KB

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