Interhaptics SDK for Unity 1.6
Loading...
Searching...
No Matches
HAR.Native.cs
Go to the documentation of this file.
1/* ​
2* Copyright (c) 2024 Go Touch VR SAS. All rights reserved. ​
3* ​
4*/
5
6using System.Runtime.InteropServices;
7
8
9namespace Interhaptics.Core
10{
11 public static partial class HAR
12 {
13#if UNITY_EDITOR_OSX
14 // Implementation for UNITY_EDITOR_OSX
15 // Methods will have dummy or macOS-specific implementations
16
17 public static bool Init()
18 {
19 UnityEngine.Debug.LogWarning("Unity Editor in iOS will have dummy implementation of the Interhaptics Engine. To correctly debug in editor use a Windows version of the Editor.");
20 // Dummy implementation for macOS Unity Editor
21 return false;
22 }
23
24 public static void Quit()
25 {
26 // Dummy implementation for macOS Unity Editor
27 }
28
29 public static void SetGlobalIntensity(double _intensity)
30 {
31 // Dummy implementation for macOS Unity Editor
32 }
33
34 public static double GetGlobalIntensity()
35 {
36 // Dummy implementation for macOS Unity Editor
37 return 1.0;
38 }
39
40 public static int AddParametricEffect([In] double[] _amplitude, int _amplitudeSize, [In] double[] _pitch, int _pitchSize, double _freqMin, double _freqMax, [In] double[] _transient, int _transientSize, bool _isLooping)
41 {
42 // Dummy implementation for macOS Unity Editor
43 return -1;
44 }
45
46 public static void SetEventIntensity(int _hMaterialId, double _intensity)
47 {
48 // Dummy implementation for macOS Unity Editor
49 }
50
51 public static void SetEventLoop(int _hMaterialId, int _loops)
52 {
53 // Dummy implementation for macOS Unity Editor
54 }
55
56 public static void SetTargetIntensityMarshal(int _hMaterialId, Interhaptics.HapticBodyMapping.CommandData[] _target, int _size, double _intensity)
57 {
58 // Dummy implementation for macOS Unity Editor
59 }
60
61 private static int AddHM(string _content)
62 {
63 // Dummy implementation for macOS Unity Editor
64 return -1;
65 }
66
67 private static bool UpdateHM(int _id, string _content)
68 {
69 // Dummy implementation for macOS Unity Editor
70 return false;
71 }
72
73 public static double GetVibrationAmp(int _id, double _step, int _mode = 0)
74 {
75 // Dummy implementation for macOS Unity Editor
76 return -1;
77 }
78
79 public static double GetVibrationFreq(int _id, double _step)
80 {
81 // Dummy implementation for macOS Unity Editor
82 return -1;
83 }
84
85 public static double GetVibrationLength(int _id)
86 {
87 // Dummy implementation for macOS Unity Editor
88 return -1;
89 }
90
91 public static double GetTextureAmp(int _id, double _step, int _mode = 0)
92 {
93 // Dummy implementation for macOS Unity Editor
94 return -1;
95 }
96
97 public static double GetTextureFreq(int _id, double _step)
98 {
99 // Dummy implementation for macOS Unity Editor
100 return -1;
101 }
102
103 public static double GetTextureLength(int _id)
104 {
105 // Dummy implementation for macOS Unity Editor
106 return -1;
107 }
108
109 public static double GetStiffnessAmp(int _id, double _step)
110 {
111 // Dummy implementation for macOS Unity Editor
112 return -1;
113 }
114
115 public static double GetStiffnessFreq(int _id, double _step)
116 {
117 // Dummy implementation for macOS Unity Editor
118 return -1;
119 }
120
121 public static void ClearOutputBuffers(bool _resetClips)
122 {
123 // Dummy implementation for macOS Unity Editor
124 }
125
126 public static int GetOutputBufferSize(Interhaptics.HapticBodyMapping.Perception _perception, Interhaptics.HapticBodyMapping.BodyPartID _bodyPartID, int _x, int _y, int _z, Interhaptics.HapticBodyMapping.BufferDataType _dataType)
127 {
128 // Dummy implementation for macOS Unity Editor
129 return -1;
130 }
131
132 public static void GetOutputBuffer(double[] _outputBuffer, int _bufferSize, Interhaptics.HapticBodyMapping.Perception _perception, Interhaptics.HapticBodyMapping.BodyPartID _bodyPartID, int _x, int _y, int _z, Interhaptics.HapticBodyMapping.BufferDataType _dataType)
133 {
134 // Dummy implementation for macOS Unity Editor
135 }
136
137 public static ulong GetVectorStartingTime(Interhaptics.HapticBodyMapping.Perception _perception, Interhaptics.HapticBodyMapping.BodyPartID _bodyPartID, int _xDimension, int _yDimension, int _zDimension)
138 {
139 // Dummy implementation for macOS Unity Editor
140 return 0;
141 }
142
143 public static void AddBodyPart(Interhaptics.HapticBodyMapping.Perception _perception, Interhaptics.HapticBodyMapping.BodyPartID _bodyPartID, int _xDimension, int _yDimension, int _zDimension, double _sampleRate, bool _hd, bool _splitFrequency, bool _splitTransient, bool realTime)
144 {
145 // Dummy implementation for macOS Unity Editor
146 }
147
148 public static void DeleteBodyPart(Interhaptics.HapticBodyMapping.Perception _perception, Interhaptics.HapticBodyMapping.BodyPartID _bodyPartID)
149 {
150 // Dummy implementation for macOS Unity Editor
151 }
152
153 public static void PlayEvent(int _hMaterialId, double _vibrationOffset, double _textureOffset, double _stiffnessOffset)
154 {
155 // Dummy implementation for macOS Unity Editor
156 }
157
158 public static void StopEvent(int _hMaterialId)
159 {
160 // Dummy implementation for macOS Unity Editor
161 }
162
163 public static void StopAllEvents()
164 {
165 // Dummy implementation for macOS Unity Editor
166 }
167
168 public static void ClearActiveEvents()
169 {
170 // Dummy implementation for macOS Unity Editor
171 }
172
173 public static void ClearInactiveEvents()
174 {
175 // Dummy implementation for macOS Unity Editor
176 }
177
178 public static void ClearEvent(int _hMaterialId)
179 {
180 // Dummy implementation for macOS Unity Editor
181 }
182
183 public static void SetEventOffsets(int _hMaterialId, double _vibrationOffset, double _textureOffset, double _stiffnessOffset)
184 {
185 // Dummy implementation for macOS Unity Editor
186 }
187
188 private static void UpdateEventPositionsMarshal(int _hMaterialId, Interhaptics.HapticBodyMapping.CommandData[] _target, int _size, double _texturePosition, double _stiffnessPosition)
189 {
190 // Dummy implementation for macOS Unity Editor
191 }
192
193 public static void ComputeAllEvents(double _curTime)
194 {
195 // Dummy implementation for macOS Unity Editor
196 }
197
198 private static void AddTargetToEventMarshal(int _hMaterialId, Interhaptics.HapticBodyMapping.CommandData[] _target, int _size)
199 {
200 // Dummy implementation for macOS Unity Editor
201 }
202
203 private static void RemoveTargetFromEventMarshal(int _hMaterialId, Interhaptics.HapticBodyMapping.CommandData[] _target, int _size)
204 {
205 // Dummy implementation for macOS Unity Editor
206 }
207
208 public static void RemoveAllTargetsFromEvent(int _hMaterialId)
209 {
210 // Dummy implementation for macOS Unity Editor
211 }
212
213 // ... other methods if needed
214
215#else
216
217
218#if (UNITY_IOS || UNITY_SWITCH) && !UNITY_EDITOR
219 const string DLL_NAME = "__Internal";
220#else
221 const string DLL_NAME = "HAR";
222#endif
223
231 [DllImport(DLL_NAME)]
232 public static extern bool Init();
237 [DllImport(DLL_NAME)]
238 public static extern void Quit();
243 [DllImport(DLL_NAME)]
244 public static extern void SetGlobalIntensity(double _intensity);
249 [DllImport(DLL_NAME)]
250 public static extern double GetGlobalIntensity();
264 [DllImport(DLL_NAME)]
265 public static extern int AddParametricEffect([In] double[] _amplitude, int _amplitudeSize, [In] double[] _pitch, int _pitchSize, double _freqMin, double _freqMax, [In] double[] _transient, int _transientSize, bool _isLooping);
271 [DllImport(DLL_NAME)]
272 public static extern void SetEventIntensity(int _hMaterialId, double _intensity);
279 [DllImport(DLL_NAME)]
280 public static extern void SetEventLoop(int _hMaterialID, int _numberOfLoops);
288 [DllImport(DLL_NAME)]
289 public static extern void SetTargetIntensityMarshal(int _hMaterialId, Interhaptics.HapticBodyMapping.CommandData[] _target, int _size, double _intensity);
295 [DllImport(DLL_NAME)]
296 private static extern int AddHM(string _content);
304 [DllImport(DLL_NAME)]
305 private static extern bool UpdateHM(int _id, string _content);
306
307 [DllImport(DLL_NAME)]
308 public static extern double GetVibrationAmp(int _id, double _step, int _mode = 0);
309
310 [DllImport(DLL_NAME)]
311 public static extern double GetVibrationFreq(int _id, double _step);
317 [DllImport(DLL_NAME)]
318 public static extern double GetVibrationLength(int _id);
319 [DllImport(DLL_NAME)]
320 public static extern double GetTextureAmp(int _id, double _step, int _mode = 0);
321 [DllImport(DLL_NAME)]
322 public static extern double GetTextureFreq(int _id, double _step);
323 [DllImport(DLL_NAME)]
324 public static extern double GetTextureLength(int _id);
325 [DllImport(DLL_NAME)]
326 public static extern double GetStiffnessAmp(int _id, double _step);
327 [DllImport(DLL_NAME)]
328 public static extern double GetStiffnessFreq(int _id, double _step);
333 [DllImport(DLL_NAME)]
334 public static extern void ClearOutputBuffers(bool _resetClips = false);
335 [DllImport(DLL_NAME)]
336 public static extern int GetOutputBufferSize(Interhaptics.HapticBodyMapping.Perception _perception, Interhaptics.HapticBodyMapping.BodyPartID _bodyPartID, int _x, int _y, int _z, Interhaptics.HapticBodyMapping.BufferDataType _dataType);
337 [DllImport(DLL_NAME)]
338 public static extern void GetOutputBuffer(double[] _outputBuffer, int _bufferSize, Interhaptics.HapticBodyMapping.Perception _perception, Interhaptics.HapticBodyMapping.BodyPartID _bodyPartID, int _x, int _y, int _z, Interhaptics.HapticBodyMapping.BufferDataType _dataType);
339 [DllImport(DLL_NAME)]
340 public static extern ulong GetVectorStartingTime(Interhaptics.HapticBodyMapping.Perception _perception, Interhaptics.HapticBodyMapping.BodyPartID _bodyPartID, int _xDimension, int _yDimension, int _zDimension);
341 [DllImport(DLL_NAME)]
342 public static extern void AddBodyPart(Interhaptics.HapticBodyMapping.Perception _perception, Interhaptics.HapticBodyMapping.BodyPartID _bodyPartID, int _xDimension, int _yDimension, int _zDimension, double _sampleRate, bool _hd, bool _splitFrequency, bool _splitTransient, bool realTime);
343 [DllImport(DLL_NAME)]
344 public static extern void DeleteBodyPart(Interhaptics.HapticBodyMapping.Perception _perception, Interhaptics.HapticBodyMapping.BodyPartID _bodyPartID);
345
356 [DllImport(DLL_NAME)]
357 public static extern void PlayEvent(int _hMaterialId, double _vibrationOffset, double _textureOffset, double _stiffnessOffset);
362 [DllImport(DLL_NAME)]
363 public static extern void StopEvent(int _hMaterialId);
367 [DllImport(DLL_NAME)]
368 public static extern void StopAllEvents();
369 [DllImport(DLL_NAME)]
373 public static extern void ClearActiveEvents();
374 [DllImport(DLL_NAME)]
379 public static extern void ClearInactiveEvents();
384 [DllImport(DLL_NAME)]
385 public static extern void ClearEvent(int _hMaterialId);
393 [DllImport(DLL_NAME)]
394 public static extern void SetEventOffsets(int _hMaterialId, double _vibrationOffset, double _textureOffset, double _stiffnessOffset);
403 [DllImport(DLL_NAME)]
404 private static extern void UpdateEventPositionsMarshal(int _hMaterialId, Interhaptics.HapticBodyMapping.CommandData[] _target, int _size, double _texturePosition, double _stiffnessPosition);
413 [DllImport(DLL_NAME)]
414 public static extern void ComputeAllEvents(double _curTime);
422 [DllImport(DLL_NAME)]
423 private static extern void AddTargetToEventMarshal(int _hMaterialId, Interhaptics.HapticBodyMapping.CommandData[] _target, int _size);
431 [DllImport(DLL_NAME)]
432 private static extern void RemoveTargetFromEventMarshal(int _hMaterialId, Interhaptics.HapticBodyMapping.CommandData[] _target, int _size);
437 [DllImport(DLL_NAME)]
438 public static extern void RemoveAllTargetsFromEvent(int _hMaterialId);
439
440#endif
441
442 }
443
444}
Structure for command data in haptic systems.