Skip to content

Commit 2ee8100

Browse files
committed
Allow calling LeapC on iOS
1 parent cdcb109 commit 2ee8100

File tree

1 file changed

+79
-73
lines changed
  • Packages/Tracking/Core/Runtime/Plugins/LeapCSharp

1 file changed

+79
-73
lines changed

Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/LeapC.cs

Lines changed: 79 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,170 +1012,175 @@ public class LeapC
10121012
private LeapC() { }
10131013
public static int DistortionSize = 64;
10141014

1015-
[DllImport("LeapC", EntryPoint = "LeapSetTrackingMode")]
1015+
#if UNITY_IOS && !UNITY_EDITOR
1016+
private const string DllName = "__Internal";
1017+
#else
1018+
private const string DllName = "LeapC";
1019+
#endif
1020+
[DllImport(DllName, EntryPoint = "LeapSetTrackingMode")]
10161021
public static extern eLeapRS SetTrackingMode(IntPtr hConnection, eLeapTrackingMode mode);
10171022

1018-
[DllImport("LeapC", EntryPoint = "LeapSetTrackingModeEx")]
1023+
[DllImport(DllName, EntryPoint = "LeapSetTrackingModeEx")]
10191024
public static extern eLeapRS SetTrackingModeEx(IntPtr hConnection, IntPtr hDevice, eLeapTrackingMode mode);
10201025

1021-
[DllImport("LeapC", EntryPoint = "LeapGetTrackingMode")]
1026+
[DllImport(DllName, EntryPoint = "LeapGetTrackingMode")]
10221027
public static extern eLeapRS LeapGetTrackingMode(IntPtr hConnection);
10231028

1024-
[DllImport("LeapC", EntryPoint = "LeapGetTrackingModeEx")]
1029+
[DllImport(DllName, EntryPoint = "LeapGetTrackingModeEx")]
10251030
public static extern eLeapRS LeapGetTrackingModeEx(IntPtr hConnection, IntPtr hDevice);
10261031

1027-
[DllImport("LeapC", EntryPoint = "LeapGetNow")]
1032+
[DllImport(DllName, EntryPoint = "LeapGetNow")]
10281033
public static extern long GetNow();
10291034

1030-
[DllImport("LeapC", EntryPoint = "LeapCreateClockRebaser")]
1035+
[DllImport(DllName, EntryPoint = "LeapCreateClockRebaser")]
10311036
public static extern eLeapRS CreateClockRebaser(out IntPtr phClockRebaser);
10321037

1033-
[DllImport("LeapC", EntryPoint = "LeapDestroyClockRebaser")]
1038+
[DllImport(DllName, EntryPoint = "LeapDestroyClockRebaser")]
10341039
public static extern eLeapRS DestroyClockRebaser(IntPtr hClockRebaser);
10351040

1036-
[DllImport("LeapC", EntryPoint = "LeapUpdateRebase")]
1041+
[DllImport(DllName, EntryPoint = "LeapUpdateRebase")]
10371042
public static extern eLeapRS UpdateRebase(IntPtr hClockRebaser, Int64 userClock, Int64 leapClock);
10381043

1039-
[DllImport("LeapC", EntryPoint = "LeapRebaseClock")]
1044+
[DllImport(DllName, EntryPoint = "LeapRebaseClock")]
10401045
public static extern eLeapRS RebaseClock(IntPtr hClockRebaser, Int64 userClock, out Int64 leapClock);
10411046

1042-
[DllImport("LeapC", EntryPoint = "LeapCreateConnection")]
1047+
[DllImport(DllName, EntryPoint = "LeapCreateConnection")]
10431048
public static extern eLeapRS CreateConnection(ref LEAP_CONNECTION_CONFIG pConfig, out IntPtr pConnection);
10441049

10451050
//Overrides to allow config to be set to null to use default config
1046-
[DllImport("LeapC", EntryPoint = "LeapCreateConnection")]
1051+
[DllImport(DllName, EntryPoint = "LeapCreateConnection")]
10471052
private static extern eLeapRS CreateConnection(IntPtr nulled, out IntPtr pConnection);
10481053
public static eLeapRS CreateConnection(out IntPtr pConnection)
10491054
{
10501055
return CreateConnection(IntPtr.Zero, out pConnection);
10511056
}
10521057

1053-
[DllImport("LeapC", EntryPoint = "LeapGetConnectionInfo")]
1058+
[DllImport(DllName, EntryPoint = "LeapGetConnectionInfo")]
10541059
public static extern eLeapRS GetConnectionInfo(IntPtr hConnection, ref LEAP_CONNECTION_INFO pInfo);
10551060

1056-
[DllImport("LeapC", EntryPoint = "LeapOpenConnection")]
1061+
[DllImport(DllName, EntryPoint = "LeapOpenConnection")]
10571062
public static extern eLeapRS OpenConnection(IntPtr hConnection);
10581063

1059-
[DllImport("LeapC", EntryPoint = "LeapSetConnectionMetadata")]
1064+
[DllImport(DllName, EntryPoint = "LeapSetConnectionMetadata")]
10601065
public static extern eLeapRS SetConnectionMetadata(IntPtr hConnection, string metadata, UIntPtr len);
10611066

1062-
[DllImport("LeapC", EntryPoint = "LeapSetAllocator")]
1067+
[DllImport(DllName, EntryPoint = "LeapSetAllocator")]
10631068
public static extern eLeapRS SetAllocator(IntPtr hConnection, ref LEAP_ALLOCATOR pAllocator);
10641069

1065-
[DllImport("LeapC", EntryPoint = "LeapGetDeviceList")]
1070+
[DllImport(DllName, EntryPoint = "LeapGetDeviceList")]
10661071
public static extern eLeapRS GetDeviceList(IntPtr hConnection, [In, Out] LEAP_DEVICE_REF[] pArray, out UInt32 pnArray);
10671072

1068-
[DllImport("LeapC", EntryPoint = "LeapGetDeviceList")]
1073+
[DllImport(DllName, EntryPoint = "LeapGetDeviceList")]
10691074
private static extern eLeapRS GetDeviceList(IntPtr hConnection, [In, Out] IntPtr pArray, out UInt32 pnArray);
10701075
//Override to allow pArray argument to be set to null (IntPtr.Zero) in order to get the device count
10711076
public static eLeapRS GetDeviceCount(IntPtr hConnection, out UInt32 deviceCount)
10721077
{
10731078
return GetDeviceList(hConnection, IntPtr.Zero, out deviceCount);
10741079
}
10751080

1076-
[DllImport("LeapC", EntryPoint = "LeapOpenDevice")]
1081+
[DllImport(DllName, EntryPoint = "LeapOpenDevice")]
10771082
public static extern eLeapRS OpenDevice(LEAP_DEVICE_REF rDevice, out IntPtr pDevice);
10781083

1079-
[DllImport("LeapC", EntryPoint = "LeapSetPrimaryDevice")]
1084+
[DllImport(DllName, EntryPoint = "LeapSetPrimaryDevice")]
10801085
public static extern eLeapRS LeapSetPrimaryDevice(IntPtr hConnection, IntPtr hDevice, bool unsubscribeOthers);
10811086

1082-
[DllImport("LeapC", EntryPoint = "LeapSubscribeEvents")]
1087+
[DllImport(DllName, EntryPoint = "LeapSubscribeEvents")]
10831088
public static extern eLeapRS LeapSubscribeEvents(IntPtr hConnection, IntPtr hDevice);
10841089

1085-
[DllImport("LeapC", EntryPoint = "LeapUnsubscribeEvents")]
1090+
[DllImport(DllName, EntryPoint = "LeapUnsubscribeEvents")]
10861091
public static extern eLeapRS LeapUnsubscribeEvents(IntPtr hConnection, IntPtr hDevice);
10871092

1088-
[DllImport("LeapC", EntryPoint = "LeapGetDeviceInfo", CharSet = CharSet.Ansi)]
1093+
[DllImport(DllName, EntryPoint = "LeapGetDeviceInfo", CharSet = CharSet.Ansi)]
10891094
public static extern eLeapRS GetDeviceInfo(IntPtr hDevice, ref LEAP_DEVICE_INFO info);
10901095

1091-
[DllImport("LeapC", EntryPoint = "LeapDeviceTransformAvailable")]
1096+
[DllImport(DllName, EntryPoint = "LeapDeviceTransformAvailable")]
10921097
public static extern bool GetDeviceTransformAvailable(IntPtr hDevice);
10931098

1094-
[DllImport("LeapC", EntryPoint = "LeapGetDeviceTransform")]
1099+
[DllImport(DllName, EntryPoint = "LeapGetDeviceTransform")]
10951100
public static extern eLeapRS GetDeviceTransform(IntPtr hDevice, [MarshalAs(UnmanagedType.LPArray, SizeConst = 16)] float[] transform);
10961101

1097-
[DllImport("LeapC", EntryPoint = "LeapSetPolicyFlags")]
1102+
[DllImport(DllName, EntryPoint = "LeapSetPolicyFlags")]
10981103
public static extern eLeapRS SetPolicyFlags(IntPtr hConnection, UInt64 set, UInt64 clear);
10991104

1100-
[DllImport("LeapC", EntryPoint = "LeapSetPolicyFlagsEx")]
1105+
[DllImport(DllName, EntryPoint = "LeapSetPolicyFlagsEx")]
11011106
public static extern eLeapRS SetPolicyFlagsEx(IntPtr hConnection, IntPtr hDevice, UInt64 set, UInt64 clear);
11021107

1103-
[DllImport("LeapC", EntryPoint = "LeapSetPause")]
1108+
[DllImport(DllName, EntryPoint = "LeapSetPause")]
11041109
public static extern eLeapRS LeapSetPause(IntPtr hConnection, bool pause);
11051110

1106-
[DllImport("LeapC", EntryPoint = "LeapSetDeviceFlags")]
1107-
public static extern eLeapRS SetDeviceFlags(IntPtr hDevice, UInt64 set, UInt64 clear, out UInt64 prior);
1111+
// [DllImport(DllName, EntryPoint = "LeapSetDeviceFlags")]
1112+
// public static extern eLeapRS SetDeviceFlags(IntPtr hDevice, UInt64 set, UInt64 clear, out UInt64 prior);
11081113

1109-
[DllImport("LeapC", EntryPoint = "LeapPollConnection")]
1114+
[DllImport(DllName, EntryPoint = "LeapPollConnection")]
11101115
public static extern eLeapRS PollConnection(IntPtr hConnection, UInt32 timeout, ref LEAP_CONNECTION_MESSAGE msg);
11111116

1112-
[DllImport("LeapC", EntryPoint = "LeapGetFrameSize")]
1117+
[DllImport(DllName, EntryPoint = "LeapGetFrameSize")]
11131118
public static extern eLeapRS GetFrameSize(IntPtr hConnection, Int64 timestamp, out UInt64 pncbEvent);
11141119

1115-
[DllImport("LeapC", EntryPoint = "LeapGetFrameSizeEx")]
1120+
[DllImport(DllName, EntryPoint = "LeapGetFrameSizeEx")]
11161121
public static extern eLeapRS GetFrameSizeEx(IntPtr hConnection, IntPtr hDevice, Int64 timestamp, out UInt64 pncbEvent);
11171122

1118-
[DllImport("LeapC", EntryPoint = "LeapInterpolateFrame")]
1123+
[DllImport(DllName, EntryPoint = "LeapInterpolateFrame")]
11191124
public static extern eLeapRS InterpolateFrame(IntPtr hConnection, Int64 timestamp, IntPtr pEvent, UInt64 ncbEvent);
11201125

1121-
[DllImport("LeapC", EntryPoint = "LeapInterpolateFrameEx")]
1126+
[DllImport(DllName, EntryPoint = "LeapInterpolateFrameEx")]
11221127
public static extern eLeapRS InterpolateFrameEx(IntPtr hConnection, IntPtr hDevice, Int64 timestamp, IntPtr pEvent, UInt64 ncbEvent);
11231128

1124-
[DllImport("LeapC", EntryPoint = "LeapInterpolateFrameFromTime")]
1129+
[DllImport(DllName, EntryPoint = "LeapInterpolateFrameFromTime")]
11251130
public static extern eLeapRS InterpolateFrameFromTime(IntPtr hConnection, Int64 timestamp, Int64 sourceTimestamp, IntPtr pEvent, UInt64 ncbEvent);
11261131

1127-
[DllImport("LeapC", EntryPoint = "LeapInterpolateFrameFromTimeEx")]
1132+
[DllImport(DllName, EntryPoint = "LeapInterpolateFrameFromTimeEx")]
11281133
public static extern eLeapRS InterpolateFrameFromTimeEx(IntPtr hConnection, IntPtr hDevice, Int64 timestamp, Int64 sourceTimestamp, IntPtr pEvent, UInt64 ncbEvent);
11291134

1130-
[DllImport("LeapC", EntryPoint = "LeapInterpolateHeadPose")]
1135+
[DllImport(DllName, EntryPoint = "LeapInterpolateHeadPose")]
11311136
public static extern eLeapRS InterpolateHeadPose(IntPtr hConnection, Int64 timestamp, ref LEAP_HEAD_POSE_EVENT headPose);
11321137

1133-
[DllImport("LeapC", EntryPoint = "LeapInterpolateEyePositions")]
1138+
[DllImport(DllName, EntryPoint = "LeapInterpolateEyePositions")]
11341139
public static extern eLeapRS InterpolateEyePositions(IntPtr hConnection, Int64 timestamp, ref LEAP_EYE_EVENT eyes);
11351140

1136-
[DllImport("LeapC", EntryPoint = "LeapPixelToRectilinear")]
1141+
[DllImport(DllName, EntryPoint = "LeapPixelToRectilinear")]
11371142
public static extern LEAP_VECTOR LeapPixelToRectilinear(IntPtr hConnection,
11381143
eLeapPerspectiveType camera, LEAP_VECTOR pixel);
11391144

1140-
[Obsolete("Use of calibrationType is not valid. Use alternative LeapPixelToRectilinearEx method."), DllImport("LeapC", EntryPoint = "LeapPixelToRectilinearEx")]
1145+
[Obsolete("Use of calibrationType is not valid. Use alternative LeapPixelToRectilinearEx method."), DllImport(DllName, EntryPoint = "LeapPixelToRectilinearEx")]
11411146
public static extern LEAP_VECTOR LeapPixelToRectilinearEx(IntPtr hConnection,
11421147
IntPtr hDevice, eLeapPerspectiveType camera, eLeapCameraCalibrationType calibrationType, LEAP_VECTOR pixel);
11431148

1144-
[DllImport("LeapC", EntryPoint = "LeapPixelToRectilinearEx")]
1149+
[DllImport(DllName, EntryPoint = "LeapPixelToRectilinearEx")]
11451150
public static extern LEAP_VECTOR LeapPixelToRectilinearEx(IntPtr hConnection,
11461151
IntPtr hDevice, eLeapPerspectiveType camera, LEAP_VECTOR pixel);
11471152

1148-
[DllImport("LeapC", EntryPoint = "LeapRectilinearToPixel")]
1153+
[DllImport(DllName, EntryPoint = "LeapRectilinearToPixel")]
11491154
public static extern LEAP_VECTOR LeapRectilinearToPixel(IntPtr hConnection,
11501155
eLeapPerspectiveType camera, LEAP_VECTOR rectilinear);
11511156

1152-
[DllImport("LeapC", EntryPoint = "LeapRectilinearToPixelEx")]
1157+
[DllImport(DllName, EntryPoint = "LeapRectilinearToPixelEx")]
11531158
public static extern LEAP_VECTOR LeapRectilinearToPixelEx(IntPtr hConnection,
11541159
IntPtr hDevice, eLeapPerspectiveType camera, LEAP_VECTOR rectilinear);
11551160

1156-
[DllImport("LeapC", EntryPoint = "LeapExtrinsicCameraMatrix")]
1161+
[DllImport(DllName, EntryPoint = "LeapExtrinsicCameraMatrix")]
11571162
public static extern eLeapRS LeapExtrinsicCameraMatrix(IntPtr hConnection, eLeapPerspectiveType camera,
11581163
[MarshalAs(UnmanagedType.LPArray, SizeConst = 16)] float[] extrinsicMatrix);
11591164

1160-
[DllImport("LeapC", EntryPoint = "LeapExtrinsicCameraMatrixEx")]
1165+
[DllImport(DllName, EntryPoint = "LeapExtrinsicCameraMatrixEx")]
11611166
public static extern eLeapRS LeapExtrinsicCameraMatrixEx(IntPtr hConnection, IntPtr hDevice, eLeapPerspectiveType camera,
11621167
[MarshalAs(UnmanagedType.LPArray, SizeConst = 16)] float[] extrinsicMatrix);
11631168

1164-
[DllImport("LeapC", EntryPoint = "LeapCloseDevice")]
1169+
[DllImport(DllName, EntryPoint = "LeapCloseDevice")]
11651170
public static extern void CloseDevice(IntPtr pDevice);
11661171

1167-
[DllImport("LeapC", EntryPoint = "LeapCloseConnection")]
1172+
[DllImport(DllName, EntryPoint = "LeapCloseConnection")]
11681173
public static extern eLeapRS CloseConnection(IntPtr hConnection);
11691174

1170-
[DllImport("LeapC", EntryPoint = "LeapDestroyConnection")]
1175+
[DllImport(DllName, EntryPoint = "LeapDestroyConnection")]
11711176
public static extern void DestroyConnection(IntPtr connection);
11721177

11731178
[Obsolete("Config is not used in Ultraleap's Tracking Service 5.X+. This will be removed in the next Major release")]
1174-
[DllImport("LeapC", EntryPoint = "LeapSaveConfigValue")]
1179+
[DllImport(DllName, EntryPoint = "LeapSaveConfigValue")]
11751180
private static extern eLeapRS SaveConfigValue(IntPtr hConnection, string key, IntPtr value, out UInt32 requestId);
11761181

11771182
[Obsolete("Config is not used in Ultraleap's Tracking Service 5.X+. This will be removed in the next Major release")]
1178-
[DllImport("LeapC", EntryPoint = "LeapRequestConfigValue")]
1183+
[DllImport(DllName, EntryPoint = "LeapRequestConfigValue")]
11791184
public static extern eLeapRS RequestConfigValue(IntPtr hConnection, string name, out UInt32 request_id);
11801185

11811186
[Obsolete("Config is not used in Ultraleap's Tracking Service 5.X+. This will be removed in the next Major release")]
@@ -1245,10 +1250,10 @@ private static eLeapRS SaveConfigWithRefType(IntPtr hConnection, string key, LEA
12451250
return callResult;
12461251
}
12471252

1248-
[DllImport("LeapC", EntryPoint = "LeapGetPointMappingSize")]
1253+
[DllImport(DllName, EntryPoint = "LeapGetPointMappingSize")]
12491254
public static extern eLeapRS GetPointMappingSize(IntPtr hConnection, ref ulong pSize);
12501255

1251-
[DllImport("LeapC", EntryPoint = "LeapGetPointMapping")]
1256+
[DllImport(DllName, EntryPoint = "LeapGetPointMapping")]
12521257
public static extern eLeapRS GetPointMapping(IntPtr hConnection, IntPtr pointMapping, ref ulong pSize);
12531258

12541259
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Ansi)]
@@ -1262,37 +1267,37 @@ public struct LEAP_RECORDING_STATUS
12621267
public UInt32 mode;
12631268
}
12641269

1265-
[DllImport("LeapC", EntryPoint = "LeapRecordingOpen")]
1270+
[DllImport(DllName, EntryPoint = "LeapRecordingOpen")]
12661271
public static extern eLeapRS RecordingOpen(ref IntPtr ppRecording, string userPath, LEAP_RECORDING_PARAMETERS parameters);
12671272

1268-
[DllImport("LeapC", EntryPoint = "LeapRecordingClose")]
1273+
[DllImport(DllName, EntryPoint = "LeapRecordingClose")]
12691274
public static extern eLeapRS RecordingClose(ref IntPtr ppRecording);
12701275

1271-
[DllImport("LeapC", EntryPoint = "LeapRecordingGetStatus")]
1276+
[DllImport(DllName, EntryPoint = "LeapRecordingGetStatus")]
12721277
public static extern eLeapRS LeapRecordingGetStatus(IntPtr pRecording, ref LEAP_RECORDING_STATUS status);
12731278

1274-
[DllImport("LeapC", EntryPoint = "LeapRecordingReadSize")]
1279+
[DllImport(DllName, EntryPoint = "LeapRecordingReadSize")]
12751280
public static extern eLeapRS RecordingReadSize(IntPtr pRecording, ref UInt64 pncbEvent);
12761281

1277-
[DllImport("LeapC", EntryPoint = "LeapRecordingRead")]
1282+
[DllImport(DllName, EntryPoint = "LeapRecordingRead")]
12781283
public static extern eLeapRS RecordingRead(IntPtr pRecording, ref LEAP_TRACKING_EVENT pEvent, UInt64 ncbEvent);
12791284

1280-
[DllImport("LeapC", EntryPoint = "LeapRecordingWrite")]
1285+
[DllImport(DllName, EntryPoint = "LeapRecordingWrite")]
12811286
public static extern eLeapRS RecordingWrite(IntPtr pRecording, ref LEAP_TRACKING_EVENT pEvent, ref UInt64 pnBytesWritten);
12821287

1283-
[DllImport("LeapC", EntryPoint = "LeapTelemetryProfiling")]
1288+
[DllImport(DllName, EntryPoint = "LeapTelemetryProfiling")]
12841289
public static extern eLeapRS LeapTelemetryProfiling(IntPtr hConnection, ref LEAP_TELEMETRY_DATA telemetryData);
12851290

1286-
[DllImport("LeapC", EntryPoint = "LeapTelemetryGetNow")]
1291+
[DllImport(DllName, EntryPoint = "LeapTelemetryGetNow")]
12871292
public static extern UInt64 TelemetryGetNow();
12881293

1289-
[DllImport("LeapC", EntryPoint = "LeapGetVersion")]
1294+
[DllImport(DllName, EntryPoint = "LeapGetVersion")]
12901295
public static extern eLeapRS GetVersion(IntPtr hConnection, eLeapVersionPart versionPart, ref LEAP_VERSION pVersion);
12911296

1292-
[DllImport("LeapC", EntryPoint = "LeapGetServerStatus")]
1297+
[DllImport(DllName, EntryPoint = "LeapGetServerStatus")]
12931298
public static extern eLeapRS GetServerStatus(UInt32 timeout, ref IntPtr status);
12941299

1295-
[DllImport("LeapC", EntryPoint = "LeapReleaseServerStatus")]
1300+
[DllImport(DllName, EntryPoint = "LeapReleaseServerStatus")]
12961301
public static extern eLeapRS ReleaseServerStatus(ref LEAP_SERVER_STATUS status);
12971302

12981303

@@ -1313,17 +1318,18 @@ public struct LEAP_SERVER_STATUS_DEVICE
13131318

13141319
public static eLeapRS SetDeviceHints(IntPtr hConnection, IntPtr hDevice, string[] hints)
13151320
{
1316-
// Ensure the final element of the array is null terminated.
1317-
if (hints.Length == 0 || hints[^1] != null)
1318-
{
1319-
Array.Resize(ref hints, hints.Length + 1);
1320-
hints[^1] = null;
1321-
}
1322-
1323-
return SetDeviceHintsInternal(hConnection, hDevice, hints);
1321+
return eLeapRS.eLeapRS_Success;
1322+
// // Ensure the final element of the array is null terminated.
1323+
// if (hints.Length == 0 || hints[^1] != null)
1324+
// {
1325+
// Array.Resize(ref hints, hints.Length + 1);
1326+
// hints[^1] = null;
1327+
// }
1328+
//
1329+
// return SetDeviceHintsInternal(hConnection, hDevice, hints);
13241330
}
13251331

1326-
[DllImport("LeapC", EntryPoint = "LeapSetDeviceHints")]
1327-
private static extern eLeapRS SetDeviceHintsInternal(IntPtr hConnection, IntPtr hDevice, string[] hints);
1332+
// [DllImport(DllName, EntryPoint = "LeapSetDeviceHints")]
1333+
// private static extern eLeapRS SetDeviceHintsInternal(IntPtr hConnection, IntPtr hDevice, string[] hints);
13281334
}
13291335
}

0 commit comments

Comments
 (0)