@@ -231,88 +231,112 @@ static const vtable tyrelock_sound_simdevice_vtable = { &sounddev_tyrelock_updat
231231static const vtable absbrakes_sound_simdevice_vtable = { & sounddev_absbrakes_update , & sounddev_free };
232232static const vtable suspension_sound_simdevice_vtable = { & sounddev_suspension_update , & sounddev_free };
233233
234- SoundDevice * new_sound_device (DeviceSettings * ds , MonocoqueSettings * ms ) {
234+ SoundDevice * new_sound_device (DeviceSettings * ds , MonocoqueSettings * ms , SimInfo * siminfo ) {
235235
236236 SoundDevice * this = (SoundDevice * ) malloc (sizeof (SoundDevice ));
237237
238238 this -> m .update = & update ;
239239 this -> m .free = & simdevfree ;
240240 this -> m .derived = this ;
241+ int error = 0 ;
241242
242- slogt ("Attempting to configure sound device with subtype: %i" , ds -> effect_type );
243- switch (ds -> effect_type ) {
244- case (EFFECT_ENGINERPM ):
245- this -> m .hapticeffect .effecttype = EFFECT_ENGINERPM ;
246- this -> m .vtable = & engine_sound_simdevice_vtable ;
247- slogi ("Initializing sound device for engine vibrations." );
248- break ;
249- case (EFFECT_GEARSHIFT ):
250- this -> m .hapticeffect .effecttype = EFFECT_GEARSHIFT ;
251- this -> m .vtable = & gear_sound_simdevice_vtable ;
252- slogi ("Initializing sound device for gear shift vibrations." );
253- break ;
243+ switch (ds -> effect_type )
244+ {
254245 case (EFFECT_TYRESLIP ):
255- this -> m .hapticeffect .effecttype = EFFECT_TYRESLIP ;
256- this -> m .hapticeffect .threshold = ds -> threshold ;
257-
258- this -> m .hapticeffect .threshold = ds -> threshold ;
259- slogt ("Haptic effect: %i %i" , this -> m .hapticeffect .effecttype , ds -> effect_type );
260- this -> m .hapticeffect .tyre = ds -> tyre ;
261- this -> m .hapticeffect .useconfig = ms -> useconfig ;
262- this -> m .hapticeffect .configcheck = & ms -> configcheck ;
263- this -> m .hapticeffect .tyrediameterconfig = ms -> tyre_diameter_config ;
264-
265- this -> m .vtable = & tyreslip_sound_simdevice_vtable ;
266- slogi ("Initializing sound device for tyre slip vibrations." );
267- break ;
268246 case (EFFECT_TYRELOCK ):
269- this -> m .hapticeffect .effecttype = EFFECT_TYRELOCK ;
270- this -> m .hapticeffect .threshold = ds -> threshold ;
271-
272- this -> m .hapticeffect .threshold = ds -> threshold ;
273- slogt ("Haptic effect: %i %i" , this -> m .hapticeffect .effecttype , ds -> effect_type );
274- this -> m .hapticeffect .tyre = ds -> tyre ;
275- this -> m .hapticeffect .useconfig = ms -> useconfig ;
276- this -> m .hapticeffect .configcheck = & ms -> configcheck ;
277- this -> m .hapticeffect .tyrediameterconfig = ms -> tyre_diameter_config ;
278-
279- this -> m .vtable = & tyrelock_sound_simdevice_vtable ;
280- slogi ("Initializing sound device for tyre slip vibrations." );
281- break ;
282247 case (EFFECT_ABSBRAKES ):
283- this -> m .hapticeffect .effecttype = EFFECT_ABSBRAKES ;
284- this -> m .hapticeffect .threshold = ds -> threshold ;
285-
286- this -> m .hapticeffect .threshold = ds -> threshold ;
287- slogt ("Haptic effect: %i %i" , this -> m .hapticeffect .effecttype , ds -> effect_type );
288- this -> m .hapticeffect .tyre = ds -> tyre ;
289- this -> m .hapticeffect .useconfig = ms -> useconfig ;
290- this -> m .hapticeffect .configcheck = & ms -> configcheck ;
291- this -> m .hapticeffect .tyrediameterconfig = ms -> tyre_diameter_config ;
292-
293- this -> m .vtable = & absbrakes_sound_simdevice_vtable ;
294- slogi ("Initializing sound device for abs vibrations." );
295- break ;
296-
297248 case (EFFECT_SUSPENSION ):
298- this -> m .hapticeffect .effecttype = EFFECT_SUSPENSION ;
299- this -> m .hapticeffect .threshold = ds -> threshold ;
300-
301- this -> m .hapticeffect .threshold = ds -> threshold ;
302- slogt ("Haptic effect: %i %i on tyre %i" , this -> m .hapticeffect .effecttype , ds -> effect_type , ds -> tyre );
303- this -> m .hapticeffect .tyre = ds -> tyre ;
304- this -> m .hapticeffect .useconfig = ms -> useconfig ;
305- this -> m .hapticeffect .configcheck = & ms -> configcheck ;
306- this -> m .hapticeffect .tyrediameterconfig = ms -> tyre_diameter_config ;
307-
308- this -> m .vtable = & suspension_sound_simdevice_vtable ;
309- slogi ("Initializing sound device for suspension vibrations." );
310- break ;
249+ if (siminfo -> SimSupportsHapticEffects == false)
250+ {
251+ slogw ("Skipping sound effect setup because sim does not support haptic effects" );
252+ error = MONOCOQUE_ERROR_UNSUPPORTED_SIM_FEATURE ;
253+ }
254+ defaut :
255+ error = 0 ;
256+ }
257+
258+
259+ if (error == 0 )
260+ {
261+ slogt ("Attempting to configure sound device with subtype: %i" , ds -> effect_type );
262+ switch (ds -> effect_type )
263+ {
264+ case (EFFECT_ENGINERPM ):
265+ this -> m .hapticeffect .effecttype = EFFECT_ENGINERPM ;
266+ this -> m .vtable = & engine_sound_simdevice_vtable ;
267+ slogi ("Initializing sound device for engine vibrations." );
268+ break ;
269+ case (EFFECT_GEARSHIFT ):
270+ this -> m .hapticeffect .effecttype = EFFECT_GEARSHIFT ;
271+ this -> m .vtable = & gear_sound_simdevice_vtable ;
272+ slogi ("Initializing sound device for gear shift vibrations." );
273+ break ;
274+ case (EFFECT_TYRESLIP ):
275+ this -> m .hapticeffect .effecttype = EFFECT_TYRESLIP ;
276+ this -> m .hapticeffect .threshold = ds -> threshold ;
277+
278+ this -> m .hapticeffect .threshold = ds -> threshold ;
279+ slogt ("Haptic effect: %i %i" , this -> m .hapticeffect .effecttype , ds -> effect_type );
280+ this -> m .hapticeffect .tyre = ds -> tyre ;
281+ this -> m .hapticeffect .useconfig = ms -> useconfig ;
282+ this -> m .hapticeffect .configcheck = & ms -> configcheck ;
283+ this -> m .hapticeffect .tyrediameterconfig = ms -> tyre_diameter_config ;
284+
285+ this -> m .vtable = & tyreslip_sound_simdevice_vtable ;
286+ slogi ("Initializing sound device for tyre slip vibrations." );
287+ break ;
288+ case (EFFECT_TYRELOCK ):
289+ this -> m .hapticeffect .effecttype = EFFECT_TYRELOCK ;
290+ this -> m .hapticeffect .threshold = ds -> threshold ;
291+
292+ this -> m .hapticeffect .threshold = ds -> threshold ;
293+ slogt ("Haptic effect: %i %i" , this -> m .hapticeffect .effecttype , ds -> effect_type );
294+ this -> m .hapticeffect .tyre = ds -> tyre ;
295+ this -> m .hapticeffect .useconfig = ms -> useconfig ;
296+ this -> m .hapticeffect .configcheck = & ms -> configcheck ;
297+ this -> m .hapticeffect .tyrediameterconfig = ms -> tyre_diameter_config ;
298+
299+ this -> m .vtable = & tyrelock_sound_simdevice_vtable ;
300+ slogi ("Initializing sound device for tyre slip vibrations." );
301+ break ;
302+ case (EFFECT_ABSBRAKES ):
303+ this -> m .hapticeffect .effecttype = EFFECT_ABSBRAKES ;
304+ this -> m .hapticeffect .threshold = ds -> threshold ;
305+
306+ this -> m .hapticeffect .threshold = ds -> threshold ;
307+ slogt ("Haptic effect: %i %i" , this -> m .hapticeffect .effecttype , ds -> effect_type );
308+ this -> m .hapticeffect .tyre = ds -> tyre ;
309+ this -> m .hapticeffect .useconfig = ms -> useconfig ;
310+ this -> m .hapticeffect .configcheck = & ms -> configcheck ;
311+ this -> m .hapticeffect .tyrediameterconfig = ms -> tyre_diameter_config ;
312+
313+ this -> m .vtable = & absbrakes_sound_simdevice_vtable ;
314+ slogi ("Initializing sound device for abs vibrations." );
315+ break ;
316+
317+ case (EFFECT_SUSPENSION ):
318+ this -> m .hapticeffect .effecttype = EFFECT_SUSPENSION ;
319+ this -> m .hapticeffect .threshold = ds -> threshold ;
320+
321+ this -> m .hapticeffect .threshold = ds -> threshold ;
322+ slogt ("Haptic effect: %i %i on tyre %i" , this -> m .hapticeffect .effecttype , ds -> effect_type , ds -> tyre );
323+ this -> m .hapticeffect .tyre = ds -> tyre ;
324+ this -> m .hapticeffect .useconfig = ms -> useconfig ;
325+ this -> m .hapticeffect .configcheck = & ms -> configcheck ;
326+ this -> m .hapticeffect .tyrediameterconfig = ms -> tyre_diameter_config ;
327+
328+ this -> m .vtable = & suspension_sound_simdevice_vtable ;
329+ slogi ("Initializing sound device for suspension vibrations." );
330+ break ;
331+ }
311332 }
312333
313- slogt ("Attempting to use sound device %s" , ds -> sounddevsettings .dev );
334+ if (error == 0 )
335+ {
336+ slogt ("Attempting to use sound device %s" , ds -> sounddevsettings .dev );
337+ error = sounddev_init (this , ds -> sounddevsettings .dev , ds -> tyre , ds -> sounddevsettings );
338+ }
314339
315- int error = sounddev_init (this , ds -> sounddevsettings .dev , ds -> tyre , ds -> sounddevsettings );
316340 if (error != 0 )
317341 {
318342 free (this );
0 commit comments