Interhaptics SDK for Unity 1.6
Loading...
Searching...
No Matches
Interhaptics.Samples.HapticEffectCodeTester Class Reference

Class to test the different haptic effects in the Interhaptics SDK triggered by key presses on the code side (no Monobehaviour) More...

Inheritance diagram for Interhaptics.Samples.HapticEffectCodeTester:

Public Member Functions

void CodeTester ()
 
void TestConstant ()
 
void TestConstantLoop ()
 
void TestConstantRight ()
 
void TestParametricHapticEffect ()
 
void TestHapticEffect ()
 
void TestTransient ()
 
void TestTransients ()
 
void TestTransientsLoop ()
 
void TestAmplitude ()
 
void TestAmplitudesLoop ()
 
void TestAmplitudesTransients ()
 
void TestAmplitudesTransientsLoop ()
 
void TestFrequency ()
 
void TestFrequencyLoop ()
 
void TestFrequencyTransients ()
 
void TestFrequencyTransientsLoop ()
 
void TestLongHaptics ()
 
void PlayStockHaptics (int i)
 
void StopMobileHaptics ()
 
void StopHapticEffect ()
 

Public Attributes

HapticMaterial hapticMaterial
 
double intensity = 1.0
 

Detailed Description

Class to test the different haptic effects in the Interhaptics SDK triggered by key presses on the code side (no Monobehaviour)

Definition at line 13 of file HapticEffectCodeTester.cs.

Member Function Documentation

◆ CodeTester()

void Interhaptics.Samples.HapticEffectCodeTester.CodeTester ( )

Definition at line 85 of file HapticEffectCodeTester.cs.

86 {
87 HapticMaterial myHapticMaterial = null;
88 if (myHapticMaterial != null)
89 {
90 HAR.PlayHapticEffect(myHapticMaterial);
91 Debug.Log("Haptic effect played successfully!");
92 }
93 else
94 {
95 Debug.LogError("Haptic material is not assigned!");
96 }
97 }

◆ PlayStockHaptics()

void Interhaptics.Samples.HapticEffectCodeTester.PlayStockHaptics ( int i)

Definition at line 306 of file HapticEffectCodeTester.cs.

307 {
308 HapticPreset.Play((HapticPreset.PresetType)(i));
309 }

◆ StopHapticEffect()

void Interhaptics.Samples.HapticEffectCodeTester.StopHapticEffect ( )

Definition at line 321 of file HapticEffectCodeTester.cs.

322 {
323 HAR.StopAllEvents();
324 }

◆ StopMobileHaptics()

◆ TestAmplitude()

void Interhaptics.Samples.HapticEffectCodeTester.TestAmplitude ( )

Definition at line 163 of file HapticEffectCodeTester.cs.

164 {
165 // Define an array of time-amplitude pairs
166 HAR.Play(new double[] { 0, 1, 1, 0.0, 2, 1 }); // plays a vibrations starting at maximum amplitude, decrease at 0.5 at 1 second, and back to 1 at 2 seconds
167 }

◆ TestAmplitudesLoop()

void Interhaptics.Samples.HapticEffectCodeTester.TestAmplitudesLoop ( )

Definition at line 169 of file HapticEffectCodeTester.cs.

170 {
171 double[] amplitude = { 0, 1, 1, 0.0, 2, 1 };
172 // HAR.PlayParametricHapticEffectWithLoop(amplitude, null, 65, 300, null, 1.0, 2, LateralFlag.Global);
173 HAR.Play(amplitude, 1.0, 2, LateralFlag.Global);
174 }
LateralFlag
Enumeration for lateral flag in haptic command data.

◆ TestAmplitudesTransients()

void Interhaptics.Samples.HapticEffectCodeTester.TestAmplitudesTransients ( )

Definition at line 176 of file HapticEffectCodeTester.cs.

177 {
178 // Amplitude array as time amplitude pairs
179 double[] amplitude = {
180 0.0, 0.5,
181 2.0, 0.5,
182 };
183 // Transients expressed as time amplitude pitch triplets
184 double[] transient = {
185 0.5, 1, 0.5,
186 1.5, 0.75, 0.5
187 };
188 HAR.Play(amplitude, transient, 1.0, 1, LateralFlag.Global); //Plays the complex pattern described by the arrays 2 times at intensity one on the left side. See Intensity Controls
189 }

◆ TestAmplitudesTransientsLoop()

void Interhaptics.Samples.HapticEffectCodeTester.TestAmplitudesTransientsLoop ( )

Definition at line 191 of file HapticEffectCodeTester.cs.

192 {
193 // Amplitude array as time amplitude pairs
194 double[] amplitude = {
195 0.0, 0.5,
196 2.0, 0.5,
197 };
198 // Transients expressed as time amplitude pitch triplets
199 double[] transient = {
200 0.5, 1, 0.5,
201 1.5, 0.75, 0.5
202 };
203 HAR.Play(amplitude, transient, 1.0, 2, LateralFlag.Global);
204 }

◆ TestConstant()

void Interhaptics.Samples.HapticEffectCodeTester.TestConstant ( )

Definition at line 98 of file HapticEffectCodeTester.cs.

99 {
100 HAR.PlayConstant(0.5, 0.5); // Plays a constant haptic effect with 50% amplitude for 0.5s.
101 }

◆ TestConstantLoop()

void Interhaptics.Samples.HapticEffectCodeTester.TestConstantLoop ( )

Definition at line 103 of file HapticEffectCodeTester.cs.

104 {
105 double[] amplitude = { 0.0, 0.5, 0.5, 0.5 };
106 //HAR.PlayParametricHapticEffectWithLoop(amplitude, null, 65, 300, null, 1.0, 2, LateralFlag.Global);
107 HAR.PlayConstant(0.5, 0.5, 1, 2, LateralFlag.Global);
108 }

◆ TestConstantRight()

void Interhaptics.Samples.HapticEffectCodeTester.TestConstantRight ( )

Definition at line 110 of file HapticEffectCodeTester.cs.

111 {
112 HAR.PlayConstant(1.0, 5.0, _controllerSide: LateralFlag.Right);
113 }

◆ TestFrequency()

void Interhaptics.Samples.HapticEffectCodeTester.TestFrequency ( )

Definition at line 206 of file HapticEffectCodeTester.cs.

207 {
208 // Amplitude at 0.5 between 0 and 2 seconds
209 double[] amplitudes = {
210 1.0, 0.5,
211 3.0, 0.5
212 };
213 // pitch between 0 and 1
214 double[] pitch = {
215 1.0, 0.0,
216 3.0, 1.0
217 };
218 HAR.PlayAdvanced(amplitudes, pitch);
219 }

◆ TestFrequencyLoop()

void Interhaptics.Samples.HapticEffectCodeTester.TestFrequencyLoop ( )

Definition at line 221 of file HapticEffectCodeTester.cs.

222 {
223 // Amplitude at 0.5 between 0 and 2 seconds
224 double[] amplitudes = {
225 1.0, 0.5,
226 3.0, 0.5
227 };
228 // pitch between 0 and 1
229 double[] pitch = {
230 1.0, 0.0,
231 3.0, 1.0
232 };
233 HAR.PlayAdvanced(amplitudes, pitch, 65, 300, null, 1.0, 2, LateralFlag.Global);
234 }

◆ TestFrequencyTransients()

void Interhaptics.Samples.HapticEffectCodeTester.TestFrequencyTransients ( )

Definition at line 236 of file HapticEffectCodeTester.cs.

237 {
238 // Amplitude array
239 double[] amplitudes = {
240 0.0, 0.0,
241 1.0, 1.0,
242 2.0, 0.5,
243 3.0, 0.25,
244 4.0, 0.25
245 };
246 // pitch array
247 double[] pitch = {
248 0.0, 1,
249 2.0, 0,
250 4.0, 1
251 };
252 // transient array
253 double[] transients = {
254 0.5, 1, 0.5,
255 3.5, 0.5, 0.5
256 };
257 double _fmin = 65;
258 double _fmax = 300;
259 HAR.PlayAdvanced(amplitudes, pitch, _fmin, _fmax, transients);
260 }

◆ TestFrequencyTransientsLoop()

void Interhaptics.Samples.HapticEffectCodeTester.TestFrequencyTransientsLoop ( )

Definition at line 262 of file HapticEffectCodeTester.cs.

263 {
264 // Amplitude array
265 double[] amplitudes = {
266 0.0, 0.0,
267 1.0, 1.0,
268 2.0, 0.5,
269 3.0, 0.25,
270 4.0, 0.25
271 };
272 // pitch array
273 double[] pitch = {
274 0.0, 1,
275 2.0, 0,
276 4.0, 1
277 };
278 // transient array
279 double[] transients = {
280 0.5, 1, 0.5,
281 3.5, 0.5, 0.5
282 };
283 double _fmin = 65;
284 double _fmax = 300;
285 HAR.PlayAdvanced(amplitudes, pitch, _fmin, _fmax, transients, 1.0, 2, LateralFlag.Global);
286 //HAR.PlayParametricHapticEffectWithLoop(amplitudes, pitch, _fmin, _fmax, transients, 1.0, 2, LateralFlag.Global);
287 }

◆ TestHapticEffect()

void Interhaptics.Samples.HapticEffectCodeTester.TestHapticEffect ( )

Definition at line 118 of file HapticEffectCodeTester.cs.

119 {
120 HAR.PlayHapticEffect(hapticMaterial, 1.0, 1, 0f, LateralFlag.Global);
121 }

References Interhaptics.Samples.HapticEffectCodeTester.hapticMaterial.

◆ TestLongHaptics()

void Interhaptics.Samples.HapticEffectCodeTester.TestLongHaptics ( )

Definition at line 289 of file HapticEffectCodeTester.cs.

290 {
291 // Amplitude array
292 double[] amplitudes = {
293 0.0, 0.0,
294 4.0, 1.0
295 };
296 // pitch array
297 double[] pitch = {
298 0.0, 0,
299 4.0, 1
300 };
301 double _fmin = 65;
302 double _fmax = 300;
303 HAR.PlayAdvanced(amplitudes, pitch, _fmin, _fmax, null, 1.0, 1, LateralFlag.Global);
304 }

◆ TestParametricHapticEffect()

void Interhaptics.Samples.HapticEffectCodeTester.TestParametricHapticEffect ( )

Definition at line 114 of file HapticEffectCodeTester.cs.

115 {
116 HAR.PlayAdvanced(amplitude, pitch, HAR.DEFAULT_FREQ_MIN, HAR.DEFAULT_FREQ_MAX, transient, 1.0, 2); // Intensity set to 1.0
117 }

◆ TestTransient()

void Interhaptics.Samples.HapticEffectCodeTester.TestTransient ( )

Definition at line 122 of file HapticEffectCodeTester.cs.

123 {
124 // Set the time, amplitude, and pitch for the transient
125 double time = 0.0; // Half a second after being called
126 double amplitude = 1.0; // strong transient
127 double pitch = 1.0; // High pitch
128
129 // Optional parameters
130 double intensity = 1.0; // Full intensity
131 int loops = 1; // No looping
132 LateralFlag controllerSide = LateralFlag.Global; // Play on both sides
133
134 // Play the transient haptic effect
135 HAR.PlayTransient(time, amplitude, pitch, intensity, loops, controllerSide);
136 //HAR.PlayTransient(time, amplitude, pitch); same effect with default parameters
137 //HAR.PlayTransient(); // Plays a transient immediately with the default values 1.0 and 1.0 for amplitude and pitch
138 }

References Interhaptics.Samples.HapticEffectCodeTester.intensity.

◆ TestTransients()

void Interhaptics.Samples.HapticEffectCodeTester.TestTransients ( )

Definition at line 139 of file HapticEffectCodeTester.cs.

140 {
141 // Transients expressed as time amplitude pitch triplets
142 double[] transient = {
143 0.0, 1.0, 0.5,
144 0.25, 0.75, 0.5,
145 0.5, 0.5, 0.5,
146 0.75, 0.25, 0.5
147 };
148 HAR.PlayTransients(transient);
149 }

◆ TestTransientsLoop()

void Interhaptics.Samples.HapticEffectCodeTester.TestTransientsLoop ( )

Definition at line 151 of file HapticEffectCodeTester.cs.

152 {
153 // Transients expressed as time amplitude pitch triplets
154 double[] transient = {
155 0.0, 1.0, 0.5,
156 0.25, 0.75, 0.5,
157 0.5, 0.5, 0.5,
158 0.75, 0.25, 0.5
159 };
160 HAR.PlayTransients(transient, 1.0, 2, LateralFlag.Global);
161 //HAR.PlayParametricHapticEffectWithLoop(null, null, 65, 300, transient, 1.0, 2, LateralFlag.Global);
162 }

Member Data Documentation

◆ hapticMaterial

HapticMaterial Interhaptics.Samples.HapticEffectCodeTester.hapticMaterial

◆ intensity

double Interhaptics.Samples.HapticEffectCodeTester.intensity = 1.0

The documentation for this class was generated from the following file: