Remove need to specify values for usb pedal rumble effects.

This commit is contained in:
Paul Dino Jones 2024-06-07 17:40:53 +00:00
parent 8cbc21b1a0
commit e211b35c9d
4 changed files with 24 additions and 30 deletions

View File

@ -5,15 +5,34 @@
#include "usbhapticdevice.h"
#include "../../helper/confighelper.h"
#include "../slog/slog.h"
const char* SYSFSRUMBLEPATH = "/sys/module/hid_fanatec/drivers/hid:ftec_csl_elite/0003:0EB7:183B.*/rumble";
int cslelitev3_update(USBGenericHapticDevice* usbhapticdevice, int value)
int cslelitev3_update(USBGenericHapticDevice* usbhapticdevice, int effecttype, int play)
{
int res = 0;
int value = 0;
if (play > 0)
{
switch (effecttype)
{
case (EFFECT_TYRESLIP):
value = 0xff0000;
break;
case (EFFECT_TYRELOCK):
value = 0xff00;
break;
case (EFFECT_ABSBRAKES):
value = 0xffff00;
break;
}
}
fprintf(usbhapticdevice->handle, "%i\n", value);
fflush(usbhapticdevice->handle);

View File

@ -1,7 +1,7 @@
#ifndef _CSLELITEV3_H
#define _CSLELITEV3_H
int cslelitev3_update(USBGenericHapticDevice* usbhapticdevice, int value);
int cslelitev3_update(USBGenericHapticDevice* usbhapticdevice, int effecttype, int play);
int cslelitev3_init(USBGenericHapticDevice* usbhapticdevice);
int cslelitev3_free(USBGenericHapticDevice* usbhapticdevice);

View File

@ -20,11 +20,11 @@ int usbhapticdev_update(USBGenericHapticDevice* usbhapticdevice, SimData* simdat
{
if(play > 0)
{
cslelitev3_update(usbhapticdevice, usbhapticdevice->value1);
cslelitev3_update(usbhapticdevice, usbhapticdevice->effecttype, play);
}
else
{
cslelitev3_update(usbhapticdevice, usbhapticdevice->value0);
cslelitev3_update(usbhapticdevice, usbhapticdevice->effecttype, play);
}
usbhapticdevice->state = play;
}

View File

@ -333,25 +333,7 @@ int devsetup(const char* device_type, const char* device_subtype, const char* co
if (ds->dev_subtype == SIMDEVTYPE_USBHAPTIC)
{
if (device_settings != NULL)
{
ds->usbdevsettings.value0 = 0;
ds->usbdevsettings.value1 = 1;
const char* temp;
int found = config_setting_lookup_string(device_settings, "devpath", &temp);
if (found == 0)
{
ds->usbdevsettings.dev = NULL;
}
else
{
ds->usbdevsettings.dev = strdup(temp);
}
config_setting_lookup_int(device_settings, "value0", &ds->usbdevsettings.value0);
config_setting_lookup_int(device_settings, "value1", &ds->usbdevsettings.value1);
}
// logic for different devices
}
if (ds->dev_subtype == SIMDEVTYPE_USBHAPTIC || ds->dev_type == SIMDEV_SOUND) {
@ -433,12 +415,5 @@ int settingsfree(DeviceSettings ds)
}
}
if (ds.dev_type == SIMDEV_USB)
{
if (ds.usbdevsettings.dev != NULL )
{
free(ds.usbdevsettings.dev);
}
}
return 0;
}