Added preliminary support for tyre slip and abs vibrations
This commit is contained in:
parent
46adafd5f0
commit
d2e0bebc4e
|
|
@ -78,6 +78,7 @@ int devinit(SimDevice* simdevices, int numdevices, DeviceSettings* ds)
|
|||
simdevices[j] = sim->m;
|
||||
simdevices[j].initialized = true;
|
||||
simdevices[j].type = SIMDEV_SOUND;
|
||||
simdevices[j].tyre = ds[j].tyre;
|
||||
devices++;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ struct SimDevice
|
|||
int id;
|
||||
bool initialized;
|
||||
DeviceType type;
|
||||
|
||||
MonocoqueTyreIdentifier tyre;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
|
@ -96,6 +96,7 @@ SoundDevice;
|
|||
|
||||
int sounddev_engine_update(SimDevice* this, SimData* simdata);
|
||||
int sounddev_gearshift_update(SimDevice* this, SimData* simdata);
|
||||
int sounddev_tyreslip_update(SimDevice* this, SimData* simdata);
|
||||
int sounddev_free(SimDevice* this);
|
||||
|
||||
SoundDevice* new_sound_device(DeviceSettings* ds);
|
||||
|
|
|
|||
|
|
@ -38,6 +38,55 @@ int sounddev_engine_update(SimDevice* this, SimData* simdata)
|
|||
slogt("set engine frequency to %i", sounddevice->sounddata.frequency);
|
||||
}
|
||||
|
||||
int sounddev_tyreslip_update(SimDevice* this, SimData* simdata)
|
||||
{
|
||||
SoundDevice* sounddevice = (void *) this->derived;
|
||||
|
||||
double play = 0;
|
||||
if (this->tyre == FRONTLEFT || this->tyre == FRONTS || this->tyre == ALLFOUR)
|
||||
{
|
||||
play += simdata->wheelslip[0];
|
||||
}
|
||||
if (this->tyre == FRONTRIGHT || this->tyre == FRONTS || this->tyre == ALLFOUR)
|
||||
{
|
||||
play += simdata->wheelslip[1];
|
||||
}
|
||||
if (this->tyre == REARLEFT || this->tyre == REARS || this->tyre == ALLFOUR)
|
||||
{
|
||||
play += simdata->wheelslip[2];
|
||||
}
|
||||
if (this->tyre == REARRIGHT || this->tyre == REARS || this->tyre == ALLFOUR)
|
||||
{
|
||||
play += simdata->wheelslip[3];
|
||||
}
|
||||
if (play > 0)
|
||||
{
|
||||
sounddevice->sounddata.curr_frequency = sounddevice->sounddata.frequency * play;
|
||||
sounddevice->sounddata.curr_duration = sounddevice->sounddata.duration;
|
||||
}
|
||||
else
|
||||
{
|
||||
sounddevice->sounddata.curr_frequency = 0;
|
||||
sounddevice->sounddata.curr_duration = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int sounddev_absbrakes_update(SimDevice* this, SimData* simdata)
|
||||
{
|
||||
SoundDevice* sounddevice = (void *) this->derived;
|
||||
|
||||
if (simdata->abs > 0)
|
||||
{
|
||||
sounddevice->sounddata.curr_frequency = sounddevice->sounddata.frequency;
|
||||
sounddevice->sounddata.curr_duration = sounddevice->sounddata.duration;
|
||||
}
|
||||
else
|
||||
{
|
||||
sounddevice->sounddata.curr_frequency = 0;
|
||||
sounddevice->sounddata.curr_duration = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int sounddev_gearshift_update(SimDevice* this, SimData* simdata)
|
||||
{
|
||||
SoundDevice* sounddevice = (void *) this->derived;
|
||||
|
|
@ -90,6 +139,16 @@ int sounddev_init(SoundDevice* sounddevice, const char* devname, int volume, int
|
|||
sounddevice->sounddata.curr_duration = duration;
|
||||
streamname = "Gear";
|
||||
break;
|
||||
case (SOUNDEFFECT_TYRESLIP):
|
||||
sounddevice->sounddata.duration = duration;
|
||||
sounddevice->sounddata.curr_duration = duration;
|
||||
streamname = "TyreSlip";
|
||||
break;
|
||||
case (SOUNDEFFECT_ABSBRAKES):
|
||||
sounddevice->sounddata.duration = duration;
|
||||
sounddevice->sounddata.curr_duration = duration;
|
||||
streamname = "ABS";
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef USE_PULSEAUDIO
|
||||
|
|
@ -105,6 +164,8 @@ int sounddev_init(SoundDevice* sounddevice, const char* devname, int volume, int
|
|||
|
||||
static const vtable engine_sound_simdevice_vtable = { &sounddev_engine_update, &sounddev_free };
|
||||
static const vtable gear_sound_simdevice_vtable = { &sounddev_gearshift_update, &sounddev_free };
|
||||
static const vtable tyreslip_sound_simdevice_vtable = { &sounddev_tyreslip_update, &sounddev_free };
|
||||
static const vtable absbrakes_sound_simdevice_vtable = { &sounddev_absbrakes_update, &sounddev_free };
|
||||
|
||||
SoundDevice* new_sound_device(DeviceSettings* ds) {
|
||||
|
||||
|
|
@ -126,6 +187,16 @@ SoundDevice* new_sound_device(DeviceSettings* ds) {
|
|||
this->m.vtable = &gear_sound_simdevice_vtable;
|
||||
slogi("Initializing sound device for gear shift vibrations.");
|
||||
break;
|
||||
case (SIMDEVTYPE_TYRESLIP):
|
||||
this->effecttype = SOUNDEFFECT_TYRESLIP;
|
||||
this->m.vtable = &tyreslip_sound_simdevice_vtable;
|
||||
slogi("Initializing sound device for tyre slip vibrations.");
|
||||
break;
|
||||
case (SIMDEVTYPE_ABSBRAKES):
|
||||
this->effecttype = SOUNDEFFECT_ABSBRAKES;
|
||||
this->m.vtable = &absbrakes_sound_simdevice_vtable;
|
||||
slogi("Initializing sound device for abs vibrations.");
|
||||
break;
|
||||
}
|
||||
|
||||
slogt("Attempting to use device %s", ds->sounddevsettings.dev);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ SoundType;
|
|||
typedef enum
|
||||
{
|
||||
SOUNDEFFECT_ENGINERPM = 0,
|
||||
SOUNDEFFECT_GEARSHIFT = 1
|
||||
SOUNDEFFECT_GEARSHIFT = 1,
|
||||
SOUNDEFFECT_ABSBRAKES = 2,
|
||||
SOUNDEFFECT_TYRESLIP = 3
|
||||
}
|
||||
VibrationEffectType;
|
||||
|
||||
|
|
|
|||
|
|
@ -91,6 +91,11 @@ int strtodevsubtype(const char* device_subtype, DeviceSettings* ds, int simdev)
|
|||
ds->dev_subtype = SIMDEVTYPE_ABSBRAKES;
|
||||
break;
|
||||
}
|
||||
if ((strcicmp(device_subtype, "SLIP") == 0) || (strcicmp(device_subtype, "TYRESLIP") == 0))
|
||||
{
|
||||
ds->dev_subtype = SIMDEVTYPE_TYRESLIP;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ds->is_valid = false;
|
||||
slogw("%s does not appear to be a valid device sub type, but attempting to continue with other devices", device_subtype);
|
||||
|
|
@ -274,6 +279,8 @@ int devsetup(const char* device_type, const char* device_subtype, const char* co
|
|||
config_setting_lookup_int(device_settings, "pan", &ds->sounddevsettings.pan);
|
||||
config_setting_lookup_float(device_settings, "duration", &ds->sounddevsettings.duration);
|
||||
|
||||
|
||||
|
||||
const char* temp;
|
||||
int found = 0;
|
||||
found = config_setting_lookup_string(device_settings, "devid", &temp);
|
||||
|
|
@ -285,6 +292,38 @@ int devsetup(const char* device_type, const char* device_subtype, const char* co
|
|||
{
|
||||
ds->sounddevsettings.dev = strdup(temp);
|
||||
}
|
||||
if (ds->dev_subtype == SIMDEVTYPE_TYRESLIP)
|
||||
{
|
||||
|
||||
found = config_setting_lookup_string(device_settings, "tyre", &temp);
|
||||
|
||||
ds->tyre = ALLFOUR;
|
||||
|
||||
if (strcicmp(temp, "FRONTS") == 0)
|
||||
{
|
||||
ds->tyre = FRONTS;
|
||||
}
|
||||
if (strcicmp(temp, "REARS") == 0)
|
||||
{
|
||||
ds->tyre = REARS;
|
||||
}
|
||||
if (strcicmp(temp, "FRONTLEFT") == 0)
|
||||
{
|
||||
ds->tyre = FRONTLEFT;
|
||||
}
|
||||
if (strcicmp(temp, "FRONTRIGHT") == 0)
|
||||
{
|
||||
ds->tyre = FRONTRIGHT;
|
||||
}
|
||||
if (strcicmp(temp, "REARLEFT") == 0)
|
||||
{
|
||||
ds->tyre = REARLEFT;
|
||||
}
|
||||
if (strcicmp(temp, "REARRIGHT") == 0)
|
||||
{
|
||||
ds->tyre = REARRIGHT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef _CONFIGHELPER_H
|
||||
#define _CONFIGHELPER_H
|
||||
|
||||
#include <pulse/channelmap.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
@ -25,7 +26,8 @@ typedef enum
|
|||
SIMDEVTYPE_SIMWIND = 3,
|
||||
SIMDEVTYPE_ENGINESOUND = 4,
|
||||
SIMDEVTYPE_GEARSOUND = 5,
|
||||
SIMDEVTYPE_ABSBRAKES = 6
|
||||
SIMDEVTYPE_ABSBRAKES = 6,
|
||||
SIMDEVTYPE_TYRESLIP = 7
|
||||
}
|
||||
DeviceSubType;
|
||||
|
||||
|
|
@ -52,6 +54,18 @@ typedef enum
|
|||
}
|
||||
MonocoqueError;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FRONTLEFT = 0,
|
||||
FRONTRIGHT = 1,
|
||||
REARLEFT = 2,
|
||||
REARRIGHT = 3,
|
||||
FRONTS = 4,
|
||||
REARS = 5,
|
||||
ALLFOUR = 6
|
||||
}
|
||||
MonocoqueTyreIdentifier;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ProgramAction program_action;
|
||||
|
|
@ -95,6 +109,7 @@ typedef struct
|
|||
TachometerSettings tachsettings;
|
||||
SerialDeviceSettings serialdevsettings;
|
||||
SoundDeviceSettings sounddevsettings;
|
||||
MonocoqueTyreIdentifier tyre;
|
||||
}
|
||||
DeviceSettings;
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 618c6d043d88a2d9d04d66c845de2bdbd64b80ca
|
||||
Subproject commit 0c9fdd01595293984638dbe51519dae08d50949e
|
||||
Loading…
Reference in New Issue