Cleanup tyre locking implementation
This commit is contained in:
parent
557269c9f5
commit
95a7b40184
|
|
@ -80,32 +80,45 @@ int sounddev_tyrelock_update(SimDevice* this, SimData* simdata)
|
||||||
{
|
{
|
||||||
if (this->tyre == FRONTLEFT || this->tyre == FRONTS || this->tyre == ALLFOUR)
|
if (this->tyre == FRONTLEFT || this->tyre == FRONTS || this->tyre == ALLFOUR)
|
||||||
{
|
{
|
||||||
play += simdata->wheelspeed[0];
|
if(simdata->wheelspeed[0])
|
||||||
|
{
|
||||||
|
play++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (this->tyre == FRONTRIGHT || this->tyre == FRONTS || this->tyre == ALLFOUR)
|
if (this->tyre == FRONTRIGHT || this->tyre == FRONTS || this->tyre == ALLFOUR)
|
||||||
{
|
{
|
||||||
|
if(simdata->wheelspeed[1])
|
||||||
|
{
|
||||||
|
play++;
|
||||||
|
}
|
||||||
play += simdata->wheelspeed[1];
|
play += simdata->wheelspeed[1];
|
||||||
}
|
}
|
||||||
if (this->tyre == REARLEFT || this->tyre == REARS || this->tyre == ALLFOUR)
|
if (this->tyre == REARLEFT || this->tyre == REARS || this->tyre == ALLFOUR)
|
||||||
{
|
{
|
||||||
|
if(simdata->wheelspeed[2])
|
||||||
|
{
|
||||||
|
play++;
|
||||||
|
}
|
||||||
play += simdata->wheelspeed[2];
|
play += simdata->wheelspeed[2];
|
||||||
}
|
}
|
||||||
if (this->tyre == REARRIGHT || this->tyre == REARS || this->tyre == ALLFOUR)
|
if (this->tyre == REARRIGHT || this->tyre == REARS || this->tyre == ALLFOUR)
|
||||||
{
|
{
|
||||||
play += simdata->wheelspeed[3];
|
if(simdata->wheelspeed[3])
|
||||||
|
{
|
||||||
|
play++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (play > 0)
|
if (play > 0)
|
||||||
{
|
{
|
||||||
sounddevice->sounddata.curr_frequency = 0;
|
sounddevice->sounddata.curr_frequency = sounddevice->sounddata.frequency * play;
|
||||||
sounddevice->sounddata.curr_duration = 0;
|
sounddevice->sounddata.curr_duration = sounddevice->sounddata.duration;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sounddevice->sounddata.curr_frequency = sounddevice->sounddata.frequency * play;
|
sounddevice->sounddata.curr_frequency = 0;
|
||||||
sounddevice->sounddata.curr_duration = sounddevice->sounddata.duration;
|
sounddevice->sounddata.curr_duration = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,24 +16,21 @@ int usbhapticdev_update(USBGenericHapticDevice* usbhapticdevice, SimData* simdat
|
||||||
{
|
{
|
||||||
case (EFFECT_TYRESLIP):
|
case (EFFECT_TYRESLIP):
|
||||||
playthreshhold = .4;
|
playthreshhold = .4;
|
||||||
if (usbhapticdevice->effecttype == EFFECT_TYRESLIP)
|
if (usbhapticdevice->tyre == FRONTLEFT || usbhapticdevice->tyre == FRONTS || usbhapticdevice->tyre == ALLFOUR)
|
||||||
{
|
{
|
||||||
if (usbhapticdevice->tyre == FRONTLEFT || usbhapticdevice->tyre == FRONTS || usbhapticdevice->tyre == ALLFOUR)
|
play += (1.0 - simdata->wheelslip[0]);
|
||||||
{
|
}
|
||||||
play += (1.0 - simdata->wheelslip[0]);
|
if (usbhapticdevice->tyre == FRONTRIGHT || usbhapticdevice->tyre == FRONTS || usbhapticdevice->tyre == ALLFOUR)
|
||||||
}
|
{
|
||||||
if (usbhapticdevice->tyre == FRONTRIGHT || usbhapticdevice->tyre == FRONTS || usbhapticdevice->tyre == ALLFOUR)
|
play += (1.0 - simdata->wheelslip[1]);
|
||||||
{
|
}
|
||||||
play += (1.0 - simdata->wheelslip[1]);
|
if (usbhapticdevice->tyre == REARLEFT || usbhapticdevice->tyre == REARS || usbhapticdevice->tyre == ALLFOUR)
|
||||||
}
|
{
|
||||||
if (usbhapticdevice->tyre == REARLEFT || usbhapticdevice->tyre == REARS || usbhapticdevice->tyre == ALLFOUR)
|
play += (1.0 - simdata->wheelslip[2]);
|
||||||
{
|
}
|
||||||
play += (1.0 - simdata->wheelslip[2]);
|
if (usbhapticdevice->tyre == REARRIGHT || usbhapticdevice->tyre == REARS || usbhapticdevice->tyre == ALLFOUR)
|
||||||
}
|
{
|
||||||
if (usbhapticdevice->tyre == REARRIGHT || usbhapticdevice->tyre == REARS || usbhapticdevice->tyre == ALLFOUR)
|
play += (1.0 - simdata->wheelslip[3]);
|
||||||
{
|
|
||||||
play += (1.0 - simdata->wheelslip[3]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case (EFFECT_TYRELOCK):
|
case (EFFECT_TYRELOCK):
|
||||||
|
|
@ -42,38 +39,31 @@ int usbhapticdev_update(USBGenericHapticDevice* usbhapticdevice, SimData* simdat
|
||||||
{
|
{
|
||||||
if (usbhapticdevice->tyre == FRONTLEFT || usbhapticdevice->tyre == FRONTS || usbhapticdevice->tyre == ALLFOUR)
|
if (usbhapticdevice->tyre == FRONTLEFT || usbhapticdevice->tyre == FRONTS || usbhapticdevice->tyre == ALLFOUR)
|
||||||
{
|
{
|
||||||
play += simdata->wheelspeed[0];
|
if(simdata->wheelspeed[0])
|
||||||
|
{
|
||||||
|
play++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (usbhapticdevice->tyre == FRONTRIGHT || usbhapticdevice->tyre == FRONTS || usbhapticdevice->tyre == ALLFOUR)
|
if (usbhapticdevice->tyre == FRONTRIGHT || usbhapticdevice->tyre == FRONTS || usbhapticdevice->tyre == ALLFOUR)
|
||||||
{
|
{
|
||||||
play += simdata->wheelspeed[1];
|
if(simdata->wheelspeed[1])
|
||||||
|
{
|
||||||
|
play++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (usbhapticdevice->tyre == REARLEFT || usbhapticdevice->tyre == REARS || usbhapticdevice->tyre == ALLFOUR)
|
if (usbhapticdevice->tyre == REARLEFT || usbhapticdevice->tyre == REARS || usbhapticdevice->tyre == ALLFOUR)
|
||||||
{
|
{
|
||||||
play += simdata->wheelspeed[2];
|
if(simdata->wheelspeed[2])
|
||||||
|
{
|
||||||
|
play++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (usbhapticdevice->tyre == REARRIGHT || usbhapticdevice->tyre == REARS || usbhapticdevice->tyre == ALLFOUR)
|
if (usbhapticdevice->tyre == REARRIGHT || usbhapticdevice->tyre == REARS || usbhapticdevice->tyre == ALLFOUR)
|
||||||
{
|
{
|
||||||
play += simdata->wheelspeed[3];
|
if(simdata->wheelspeed[3])
|
||||||
}
|
{
|
||||||
}
|
play++;
|
||||||
if (usbhapticdevice->effecttype == EFFECT_TYRELOCK)
|
}
|
||||||
{
|
|
||||||
if (usbhapticdevice->tyre == FRONTLEFT || usbhapticdevice->tyre == FRONTS || usbhapticdevice->tyre == ALLFOUR)
|
|
||||||
{
|
|
||||||
play += (1.0 - simdata->wheelslip[0]);
|
|
||||||
}
|
|
||||||
if (usbhapticdevice->tyre == FRONTRIGHT || usbhapticdevice->tyre == FRONTS || usbhapticdevice->tyre == ALLFOUR)
|
|
||||||
{
|
|
||||||
play += (1.0 - simdata->wheelslip[1]);
|
|
||||||
}
|
|
||||||
if (usbhapticdevice->tyre == REARLEFT || usbhapticdevice->tyre == REARS || usbhapticdevice->tyre == ALLFOUR)
|
|
||||||
{
|
|
||||||
play += (1.0 - simdata->wheelslip[2]);
|
|
||||||
}
|
|
||||||
if (usbhapticdevice->tyre == REARRIGHT || usbhapticdevice->tyre == REARS || usbhapticdevice->tyre == ALLFOUR)
|
|
||||||
{
|
|
||||||
play += (1.0 - simdata->wheelslip[3]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,10 @@ int strtoeffecttype(const char* effect, DeviceSettings* ds)
|
||||||
{
|
{
|
||||||
ds->effect_type = EFFECT_TYRESLIP;
|
ds->effect_type = EFFECT_TYRESLIP;
|
||||||
}
|
}
|
||||||
|
if ((strcicmp(effect, "LOCK") == 0) || (strcicmp(effect, "TYRELOCK") == 0) || (strcicmp(effect, "TIRELOCK") == 0))
|
||||||
|
{
|
||||||
|
ds->effect_type = EFFECT_TYRELOCK;
|
||||||
|
}
|
||||||
|
|
||||||
ds->is_valid = true;
|
ds->is_valid = true;
|
||||||
return MONOCOQUE_ERROR_NONE;
|
return MONOCOQUE_ERROR_NONE;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue