Загрузка PICO Unity OpenXR Integration SDK

This commit is contained in:
2024-12-21 10:28:02 +03:00
parent b2ecc77b2a
commit a2c2504d48
628 changed files with 68895 additions and 2 deletions

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d10b07d0efa7915488f7ac6e32eb5eb6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,118 @@
/*******************************************************************************
Copyright © 2015-2022 PICO Technology Co., Ltd.All rights reserved.
NOTICEAll information contained herein is, and remains the property of
PICO Technology Co., Ltd. The intellectual and technical concepts
contained herein are proprietary to PICO Technology Co., Ltd. and may be
covered by patents, patents in process, and are protected by trade secret or
copyright law. Dissemination of this information or reproduction of this
material is strictly forbidden unless prior written permission is obtained from
PICO Technology Co., Ltd.
*******************************************************************************/
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace Pico.Platform
{
public partial class CLIB
{
public static ulong ppf_Achievements_GetProgressByName(string[] names)
{
var namesHandle = new PtrArray(names);
var result = ppf_Achievements_GetProgressByName(namesHandle.a, names.Length);
namesHandle.Free();
return result;
}
public static ulong ppf_Achievements_GetDefinitionsByName(string[] names)
{
var namesHandle = new PtrArray(names);
var result = ppf_Achievements_GetDefinitionsByName(namesHandle.a, names.Length);
namesHandle.Free();
return result;
}
public static ulong ppf_IAP_GetProductsBySKU(string[] names)
{
var namesHandle = new PtrArray(names);
var result = ppf_IAP_GetProductsBySKU(namesHandle.a, names.Length);
namesHandle.Free();
return result;
}
public static ulong ppf_Leaderboard_GetEntriesByIds(string leaderboardName, int pageSize, int pageIdx, LeaderboardStartAt startAt, string[] userIDs)
{
var userIds = new PtrArray(userIDs);
var result = ppf_Leaderboard_GetEntriesByIds(leaderboardName, pageSize, pageIdx, startAt, userIds.a, (uint) userIDs.Length);
userIds.Free();
return result;
}
public static ulong ppf_Challenges_GetEntriesByIds(ulong challengeID, LeaderboardStartAt startAt, string[] userIDs, int pageIdx, int pageSize)
{
var userIds = new PtrArray(userIDs);
var result = ppf_Challenges_GetEntriesByIds(challengeID, startAt, userIds.a, (uint) userIDs.Length, pageIdx, pageSize);
userIds.Free();
return result;
}
public static ulong ppf_Challenges_Invites(ulong challengeID, string[] userIDs)
{
var userIds = new PtrArray(userIDs);
var result = ppf_Challenges_Invites(challengeID, userIds.a, (uint) userIDs.Length);
userIds.Free();
return result;
}
public static ulong ppf_User_RequestUserPermissions(string[] permissions)
{
var ptrs = new PtrArray(permissions);
var result = ppf_User_RequestUserPermissions(ptrs.a, permissions.Length);
ptrs.Free();
return result;
}
public static ulong ppf_User_GetRelations(string[] userIds)
{
var ptrs = new PtrArray(userIds);
var result = ppf_User_GetRelations(ptrs.a, userIds.Length);
ptrs.Free();
return result;
}
public static ulong ppf_Presence_SendInvites(string[] userIDs)
{
var ptrs = new PtrArray(userIDs);
var result = ppf_Presence_SendInvites(ptrs.a, (uint) userIDs.Length);
ptrs.Free();
return result;
}
public static Dictionary<string, string> DataStoreFromNative(IntPtr ppfDataStore)
{
var map = new Dictionary<string, string>();
var size = (int) ppf_DataStore_GetNumKeys(ppfDataStore);
for (var i = 0; i < size; i++)
{
string key = ppf_DataStore_GetKey(ppfDataStore, i);
map[key] = ppf_DataStore_GetValue(ppfDataStore, key);
}
return map;
}
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int RtcProcessAudioFrameFunction(IntPtr audioFrameHandle);
[DllImport("pxrplatformloader", EntryPoint = "ppf_Rtc_RegisterLocalAudioProcessor", CallingConvention = CallingConvention.Cdecl)]
public static extern void ppf_Rtc_RegisterLocalAudioProcessor(RtcProcessAudioFrameFunction rtcProcessAudioFrameFunction, RtcAudioChannel channel, RtcAudioSampleRate sampleRate);
[DllImport("pxrplatformloader", EntryPoint = "ppf_InitializeAndroid", CallingConvention = CallingConvention.Cdecl)]
public static extern PlatformInitializeResult ppf_InitializeAndroid(string appId, IntPtr activityObj, IntPtr env);
[DllImport("pxrplatformloader", EntryPoint = "ppf_InitializeAndroidAsynchronous", CallingConvention = CallingConvention.Cdecl)]
public static extern ulong ppf_InitializeAndroidAsynchronous(string appId, IntPtr activityObj, IntPtr env);
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d8426d258c3f4a19950866175d24fdcf
timeCreated: 1660302689

View File

@ -0,0 +1,171 @@
/*******************************************************************************
Copyright © 2015-2022 PICO Technology Co., Ltd.All rights reserved.
NOTICEAll information contained herein is, and remains the property of
PICO Technology Co., Ltd. The intellectual and technical concepts
contained herein are proprietary to PICO Technology Co., Ltd. and may be
covered by patents, patents in process, and are protected by trade secret or
copyright law. Dissemination of this information or reproduction of this
material is strictly forbidden unless prior written permission is obtained from
PICO Technology Co., Ltd.
*******************************************************************************/
using System;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace Pico.Platform
{
public class UTF8Marshaller : ICustomMarshaler
{
public void CleanUpManagedData(object ManagedObj)
{
}
public void CleanUpNativeData(IntPtr pNativeData)
=> Marshal.FreeHGlobal(pNativeData);
public int GetNativeDataSize() => -1;
public IntPtr MarshalManagedToNative(object managedObj)
{
if (managedObj == null)
return IntPtr.Zero;
if (!(managedObj is string))
throw new MarshalDirectiveException("UTF8Marshaler must be used on a string.");
return MarshalUtil.StringToPtr((string) managedObj);
}
public object MarshalNativeToManaged(IntPtr str)
{
if (str == IntPtr.Zero)
return null;
return MarshalUtil.PtrToString(str);
}
public static ICustomMarshaler GetInstance(string pstrCookie)
{
if (marshaler == null)
marshaler = new UTF8Marshaller();
return marshaler;
}
private static UTF8Marshaller marshaler;
}
public class PtrManager
{
public IntPtr ptr;
private bool freed = false;
public PtrManager(byte[] a)
{
this.ptr = MarshalUtil.ByteArrayToNative(a);
}
public void Free()
{
if (freed) return;
freed = true;
Marshal.FreeHGlobal(ptr);
}
~PtrManager()
{
this.Free();
}
}
class PtrArray
{
public IntPtr[] a;
private bool freed = false;
public PtrArray(string[] a)
{
if (a == null)
{
a = Array.Empty<string>();
}
this.a = a.Select(x => MarshalUtil.StringToPtr(x)).ToArray();
}
public void Free()
{
if (freed) return;
freed = true;
foreach (var i in a)
{
Marshal.FreeHGlobal(i);
}
}
~PtrArray()
{
this.Free();
}
}
public static class MarshalUtil
{
public static IntPtr StringToPtr(string s)
{
if (s == null) return IntPtr.Zero;
// not null terminated
byte[] strbuf = Encoding.UTF8.GetBytes(s);
IntPtr buffer = Marshal.AllocHGlobal(strbuf.Length + 1);
Marshal.Copy(strbuf, 0, buffer, strbuf.Length);
// write the terminating null
Marshal.WriteByte(buffer + strbuf.Length, 0);
return buffer;
}
public static string PtrToString(IntPtr p)
{
return GetString(Encoding.UTF8, p);
}
public static string GetString(Encoding encoding, IntPtr str)
{
if (str == IntPtr.Zero)
return null;
int byteCount = 0;
if (Equals(encoding, Encoding.UTF32))
{
while (Marshal.ReadInt32(str, byteCount) != 0) byteCount += sizeof(int);
}
else if (Equals(encoding, Encoding.Unicode) || Equals(encoding, Encoding.BigEndianUnicode))
{
while (Marshal.ReadInt16(str, byteCount) != 0) byteCount += sizeof(short);
}
else
{
while (Marshal.ReadByte(str, byteCount) != 0) byteCount += sizeof(byte);
}
var bytes = new byte[byteCount];
Marshal.Copy(str, bytes, 0, byteCount);
return encoding.GetString(bytes);
}
public static byte[] ByteArrayFromNative(IntPtr ptr, uint length)
{
var ans = new byte[length];
Marshal.Copy(ptr, ans, 0, (int) length);
return ans;
}
public static IntPtr ByteArrayToNative(byte[] a)
{
var ptr = Marshal.AllocHGlobal(a.Length);
Marshal.Copy(a, 0, ptr, a.Length);
return ptr;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a97b494aeb644a0f9e1f1dc041b13a4e
timeCreated: 1660145702