Add basic support for arduino haptic motors
This commit is contained in:
parent
62e619780f
commit
1ebffa9f63
|
|
@ -54,6 +54,18 @@ int arduino_simwind_update(SimDevice* this, SimData* simdata)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int arduino_haptic_update(SimDevice* this, SimData* simdata)
|
||||||
|
{
|
||||||
|
SerialDevice* serialdevice = (void *) this->derived;
|
||||||
|
int result = 1;
|
||||||
|
|
||||||
|
slogt("Updating arduino haptic device");
|
||||||
|
|
||||||
|
arduino_update(serialdevice, simdata, sizeof(SimData));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
int serialdev_free(SimDevice* this)
|
int serialdev_free(SimDevice* this)
|
||||||
{
|
{
|
||||||
SerialDevice* serialdevice = (void *) this->derived;
|
SerialDevice* serialdevice = (void *) this->derived;
|
||||||
|
|
@ -80,6 +92,7 @@ int serialdev_init(SerialDevice* serialdevice, const char* portdev)
|
||||||
static const vtable serial_simdevice_vtable = { &serialdev_update, &serialdev_free };
|
static const vtable serial_simdevice_vtable = { &serialdev_update, &serialdev_free };
|
||||||
static const vtable arduino_shiftlights_vtable = { &arduino_shiftlights_update, &serialdev_free };
|
static const vtable arduino_shiftlights_vtable = { &arduino_shiftlights_update, &serialdev_free };
|
||||||
static const vtable arduino_simwind_vtable = { &arduino_simwind_update, &serialdev_free };
|
static const vtable arduino_simwind_vtable = { &arduino_simwind_update, &serialdev_free };
|
||||||
|
static const vtable arduino_haptic_vtable = { &arduino_haptic_update, &serialdev_free };
|
||||||
|
|
||||||
SerialDevice* new_serial_device(DeviceSettings* ds) {
|
SerialDevice* new_serial_device(DeviceSettings* ds) {
|
||||||
|
|
||||||
|
|
@ -102,6 +115,11 @@ SerialDevice* new_serial_device(DeviceSettings* ds) {
|
||||||
this->m.vtable = &arduino_simwind_vtable;
|
this->m.vtable = &arduino_simwind_vtable;
|
||||||
slogi("Initializing arduino devices for sim wind.");
|
slogi("Initializing arduino devices for sim wind.");
|
||||||
break;
|
break;
|
||||||
|
case (SIMDEVTYPE_SERIALHAPTIC):
|
||||||
|
this->devicetype = ARDUINODEV__HAPTIC;
|
||||||
|
this->m.vtable = &arduino_haptic_vtable;
|
||||||
|
slogi("Initializing arduino device for haptic effects.");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int error = serialdev_init(this, ds->serialdevsettings.portdev);
|
int error = serialdev_init(this, ds->serialdevsettings.portdev);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ typedef enum
|
||||||
{
|
{
|
||||||
ARDUINODEV__SHIFTLIGHTS = 0,
|
ARDUINODEV__SHIFTLIGHTS = 0,
|
||||||
ARDUINODEV__SIMWIND = 1,
|
ARDUINODEV__SIMWIND = 1,
|
||||||
|
ARDUINODEV__HAPTIC = 2,
|
||||||
}
|
}
|
||||||
SerialDeviceType;
|
SerialDeviceType;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ SerialDevice;
|
||||||
|
|
||||||
int arduino_shiftlights_update(SimDevice* this, SimData* simdata);
|
int arduino_shiftlights_update(SimDevice* this, SimData* simdata);
|
||||||
int arduino_simwind_update(SimDevice* this, SimData* simdata);
|
int arduino_simwind_update(SimDevice* this, SimData* simdata);
|
||||||
|
int arduino_haptic_update(SimDevice* this, SimData* simdata);
|
||||||
int serialdev_free(SimDevice* this);
|
int serialdev_free(SimDevice* this);
|
||||||
|
|
||||||
SerialDevice* new_serial_device(DeviceSettings* ds);
|
SerialDevice* new_serial_device(DeviceSettings* ds);
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,11 @@ int strtodevsubtype(const char* device_subtype, DeviceSettings* ds, int simdev)
|
||||||
ds->dev_subtype = SIMDEVTYPE_SIMWIND;
|
ds->dev_subtype = SIMDEVTYPE_SIMWIND;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (strcicmp(device_subtype, "SerialHaptic") == 0 || strcicmp(device_subtype, "Haptic") == 0)
|
||||||
|
{
|
||||||
|
ds->dev_subtype = SIMDEVTYPE_SERIALHAPTIC;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case SIMDEV_SOUND:
|
case SIMDEV_SOUND:
|
||||||
ds->is_valid = true;
|
ds->is_valid = true;
|
||||||
break;
|
break;
|
||||||
|
|
@ -336,7 +341,7 @@ int devsetup(const char* device_type, const char* device_subtype, const char* co
|
||||||
// logic for different devices
|
// logic for different devices
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ds->dev_subtype == SIMDEVTYPE_USBHAPTIC || ds->dev_type == SIMDEV_SOUND) {
|
if (ds->dev_subtype == SIMDEVTYPE_USBHAPTIC || ds->dev_type == SIMDEV_SOUND || ds->dev_type == SIMDEVTYPE_SERIALHAPTIC ) {
|
||||||
const char* effect;
|
const char* effect;
|
||||||
config_setting_lookup_string(device_settings, "effect", &effect);
|
config_setting_lookup_string(device_settings, "effect", &effect);
|
||||||
strtoeffecttype(effect, ds);
|
strtoeffecttype(effect, ds);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@ typedef enum
|
||||||
SIMDEVTYPE_TACHOMETER = 1,
|
SIMDEVTYPE_TACHOMETER = 1,
|
||||||
SIMDEVTYPE_USBHAPTIC = 2,
|
SIMDEVTYPE_USBHAPTIC = 2,
|
||||||
SIMDEVTYPE_SHIFTLIGHTS = 3,
|
SIMDEVTYPE_SHIFTLIGHTS = 3,
|
||||||
SIMDEVTYPE_SIMWIND = 4
|
SIMDEVTYPE_SIMWIND = 4,
|
||||||
|
SIMDEVTYPE_SERIALHAPTIC = 5
|
||||||
}
|
}
|
||||||
DeviceSubType;
|
DeviceSubType;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue