Add haptic effect to serial haptic device type
This commit is contained in:
parent
1ebffa9f63
commit
ea100ca2cf
|
|
@ -2,8 +2,16 @@
|
|||
#define _HAPTICEFFECT_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../helper/confighelper.h"
|
||||
#include "../simulatorapi/simapi/simapi/simdata.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
double threshold;
|
||||
VibrationEffectType effecttype;
|
||||
}
|
||||
HapticEffect;
|
||||
|
||||
int slipeffect(SimData* simdata, int effecttype, int tyre, double threshold, int useconfig, int* configcheck, char* configfile);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "simdevice.h"
|
||||
#include "serialdevice.h"
|
||||
#include "hapticeffect.h"
|
||||
#include "serial/arduino.h"
|
||||
#include "../helper/parameters.h"
|
||||
#include "../simulatorapi/simapi/simapi/simdata.h"
|
||||
|
|
@ -59,6 +60,8 @@ int arduino_haptic_update(SimDevice* this, SimData* simdata)
|
|||
SerialDevice* serialdevice = (void *) this->derived;
|
||||
int result = 1;
|
||||
|
||||
int play = slipeffect(simdata, serialdevice->hapticeffect.effecttype, this->tyre, serialdevice->hapticeffect.threshold, this->useconfig, this->configcheck, this->tyrediameterconfig);
|
||||
|
||||
slogt("Updating arduino haptic device");
|
||||
|
||||
arduino_update(serialdevice, simdata, sizeof(SimData));
|
||||
|
|
@ -122,6 +125,12 @@ SerialDevice* new_serial_device(DeviceSettings* ds) {
|
|||
break;
|
||||
}
|
||||
|
||||
if(this->devicetype == ARDUINODEV__HAPTIC)
|
||||
{
|
||||
this->hapticeffect.threshold = ds->threshold;
|
||||
this->hapticeffect.effecttype = ds->effect_type;
|
||||
}
|
||||
|
||||
int error = serialdev_init(this, ds->serialdevsettings.portdev);
|
||||
|
||||
if (error != 0)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include "usbdevice.h"
|
||||
#include "sounddevice.h"
|
||||
#include "serialdevice.h"
|
||||
#include "hapticeffect.h"
|
||||
#include "../helper/confighelper.h"
|
||||
#include "../simulatorapi/simapi/simapi/simdata.h"
|
||||
|
||||
|
|
@ -50,6 +51,7 @@ typedef struct
|
|||
SerialType type;
|
||||
struct sp_port* port;
|
||||
SerialDeviceType devicetype;
|
||||
HapticEffect hapticeffect;
|
||||
union
|
||||
{
|
||||
SimWindData simwinddata;
|
||||
|
|
|
|||
Loading…
Reference in New Issue