Initially adding support for SIMAGIC P1000 Pedals
This commit is contained in:
parent
6d0b027171
commit
052ee12178
|
|
@ -21,6 +21,8 @@ set(devices_source_files
|
|||
usb/revburner.c
|
||||
usb/cslelitev3.h
|
||||
usb/cslelitev3.c
|
||||
usb/simagicp1000.h
|
||||
usb/simagicp1000.c
|
||||
usb/wheels/cammusc5.h
|
||||
usb/wheels/cammusc5.c
|
||||
usb/wheels/cammusc12.h
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@ int cslelitev3_update(USBGenericHapticDevice* usbhapticdevice, int effecttype, i
|
|||
}
|
||||
|
||||
|
||||
fprintf(usbhapticdevice->handle, "%i\n", value);
|
||||
fflush(usbhapticdevice->handle);
|
||||
fprintf(usbhapticdevice->filehandle, "%i\n", value);
|
||||
fflush(usbhapticdevice->filehandle);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -46,8 +46,8 @@ int cslelitev3_free(USBGenericHapticDevice* usbhapticdevice)
|
|||
|
||||
free(usbhapticdevice->dev);
|
||||
|
||||
fflush(usbhapticdevice->handle);
|
||||
fclose(usbhapticdevice->handle);
|
||||
fflush(usbhapticdevice->filehandle);
|
||||
fclose(usbhapticdevice->filehandle);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -91,9 +91,9 @@ int cslelitev3_init(USBGenericHapticDevice* usbhapticdevice)
|
|||
return res;
|
||||
}
|
||||
|
||||
usbhapticdevice->handle = fopen(usbhapticdevice->dev, "w");
|
||||
usbhapticdevice->filehandle = fopen(usbhapticdevice->dev, "w");
|
||||
|
||||
if (!usbhapticdevice->handle)
|
||||
if (!usbhapticdevice->filehandle)
|
||||
{
|
||||
sloge("Could not open pedal device...");
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "tachdevice.h"
|
||||
#include "../slog/slog.h"
|
||||
|
||||
const int buf_size = 65;
|
||||
const size_t buf_size = 8;
|
||||
|
||||
|
||||
int revburner_update(TachDevice* tachdevice, int pulses)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,133 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#include "usbhapticdevice.h"
|
||||
|
||||
#include "../../helper/confighelper.h"
|
||||
#include "../slog/slog.h"
|
||||
|
||||
#define SIMAGIC_VENDOR_ID 0x0483
|
||||
#define SIMAGIC_PRODUCT_ID_P1000 0x0525
|
||||
|
||||
const size_t SIMAGIC_P1000_BUFSIZE = 49;
|
||||
const char* SIMAGICP1000DEVSTRING = "SIMAGIC P1000 Pedals";
|
||||
|
||||
int senddevreport(USBGenericHapticDevice* usbhapticdevice, unsigned char* buf, size_t bufsize)
|
||||
{
|
||||
int res = 0;
|
||||
if (usbhapticdevice->handle)
|
||||
{
|
||||
res = hid_write(usbhapticdevice->handle, buf, SIMAGIC_P1000_BUFSIZE);
|
||||
slogd("sent %i bytes to %s", bufsize, SIMAGICP1000DEVSTRING);
|
||||
slogt("sent bytes %02x %02x %02x %02x %02x %02x %02x", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
|
||||
}
|
||||
else
|
||||
{
|
||||
slogd("no handle");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
int simagicp1000_update(USBGenericHapticDevice* usbhapticdevice, int effecttype, int play)
|
||||
{
|
||||
|
||||
int res = 0;
|
||||
int value = 0;
|
||||
|
||||
unsigned char bytes[SIMAGIC_P1000_BUFSIZE];
|
||||
for (int x = 0; x < SIMAGIC_P1000_BUFSIZE; x++)
|
||||
{
|
||||
bytes[x] = 0x00;
|
||||
}
|
||||
|
||||
if (play > 0)
|
||||
{
|
||||
bytes[0] = 0xEC;
|
||||
// we can add config settings for these values
|
||||
bytes[2] = 0x01;
|
||||
bytes[3] = 0x0A;
|
||||
bytes[4] = 0xFF;
|
||||
switch (effecttype)
|
||||
{
|
||||
case (EFFECT_TYRESLIP):
|
||||
bytes[1] = 0x02;
|
||||
senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
|
||||
break;
|
||||
case (EFFECT_TYRELOCK):
|
||||
bytes[1] = 0x01;
|
||||
senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
|
||||
break;
|
||||
case (EFFECT_ABSBRAKES):
|
||||
bytes[1] = 0x02;
|
||||
senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
|
||||
bytes[1] = 0x01;
|
||||
senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes[1] = 0x01;
|
||||
senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
|
||||
bytes[1] = 0x02;
|
||||
senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int simagicp1000_free(USBGenericHapticDevice* usbhapticdevice)
|
||||
{
|
||||
int res = 0;
|
||||
|
||||
hid_close(usbhapticdevice->handle);
|
||||
res = hid_exit();
|
||||
|
||||
return res;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int simagicp1000_init(USBGenericHapticDevice* usbhapticdevice)
|
||||
{
|
||||
slogi("initializing %s...", SIMAGICP1000DEVSTRING);
|
||||
|
||||
int res = 0;
|
||||
|
||||
res = hid_init();
|
||||
|
||||
usbhapticdevice->handle = hid_open(SIMAGIC_VENDOR_ID, SIMAGIC_PRODUCT_ID_P1000, NULL);
|
||||
|
||||
if (!usbhapticdevice->handle)
|
||||
{
|
||||
sloge("Could not find attached %s", SIMAGICP1000DEVSTRING);
|
||||
res = hid_exit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char bytes[SIMAGIC_P1000_BUFSIZE];
|
||||
for (int x = 0; x < SIMAGIC_P1000_BUFSIZE; x++)
|
||||
{
|
||||
bytes[x] = 0x00;
|
||||
}
|
||||
bytes[0] = 0xF1;
|
||||
bytes[1] = 0x17;
|
||||
bytes[2] = 0x00;
|
||||
bytes[3] = 0x00;
|
||||
bytes[4] = 0x00;
|
||||
bytes[5] = 0x01;
|
||||
bytes[6] = 0x02;
|
||||
res = senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
|
||||
slogd("Initialization returned %i", res);
|
||||
if(res != 0)
|
||||
{
|
||||
slogw("Problem with initialization of %s", SIMAGICP1000DEVSTRING);
|
||||
}
|
||||
}
|
||||
|
||||
slogd("Found %s...", SIMAGICP1000DEVSTRING);
|
||||
return res;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef _SIMAGICP1000_H
|
||||
#define _SIMAGICP1000_H
|
||||
|
||||
int simagicp1000_update(USBGenericHapticDevice* usbhapticdevice, int effecttype, int play);
|
||||
int simagicp1000_init(USBGenericHapticDevice* usbhapticdevice);
|
||||
int simagicp1000_free(USBGenericHapticDevice* usbhapticdevice);
|
||||
|
||||
#endif
|
||||
|
|
@ -6,6 +6,8 @@
|
|||
#include "usbhapticdevice.h"
|
||||
#include "hapticeffect.h"
|
||||
#include "usb/cslelitev3.h"
|
||||
#include "usb/simagicp1000.h"
|
||||
|
||||
#include "../../helper/confighelper.h"
|
||||
#include "../../simulatorapi/simapi/simapi/simdata.h"
|
||||
#include "../../slog/slog.h"
|
||||
|
|
@ -22,11 +24,27 @@ int usbhapticdev_update(USBGenericHapticDevice* usbhapticdevice, SimData* simdat
|
|||
if(play > 0)
|
||||
{
|
||||
rplay = 1;
|
||||
cslelitev3_update(usbhapticdevice, usbhapticdevice->effecttype, rplay);
|
||||
switch ( usbhapticdevice->type )
|
||||
{
|
||||
case USBHAPTIC_CSLELITEV3PEDALS:
|
||||
cslelitev3_update(usbhapticdevice, usbhapticdevice->effecttype, rplay);
|
||||
break;
|
||||
case USBHAPTIC_SIMAGICP1000PEDALS:
|
||||
simagicp1000_update(usbhapticdevice, usbhapticdevice->effecttype, rplay);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cslelitev3_update(usbhapticdevice, usbhapticdevice->effecttype, rplay);
|
||||
switch ( usbhapticdevice->type )
|
||||
{
|
||||
case USBHAPTIC_CSLELITEV3PEDALS:
|
||||
cslelitev3_update(usbhapticdevice, usbhapticdevice->effecttype, rplay);
|
||||
break;
|
||||
case USBHAPTIC_SIMAGICP1000PEDALS:
|
||||
simagicp1000_update(usbhapticdevice, usbhapticdevice->effecttype, rplay);
|
||||
break;
|
||||
}
|
||||
}
|
||||
usbhapticdevice->state = play;
|
||||
}
|
||||
|
|
@ -36,7 +54,16 @@ int usbhapticdev_update(USBGenericHapticDevice* usbhapticdevice, SimData* simdat
|
|||
int usbhapticdev_free(USBGenericHapticDevice* usbhapticdevice)
|
||||
{
|
||||
slogt("closing usb haptic device");
|
||||
cslelitev3_free(usbhapticdevice);
|
||||
switch ( usbhapticdevice->type )
|
||||
{
|
||||
case USBHAPTIC_CSLELITEV3PEDALS:
|
||||
cslelitev3_free(usbhapticdevice);
|
||||
break;
|
||||
case USBHAPTIC_SIMAGICP1000PEDALS:
|
||||
simagicp1000_free(usbhapticdevice);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -65,9 +92,18 @@ int usbhapticdev_init(USBGenericHapticDevice* usbhapticdevice, DeviceSettings* d
|
|||
|
||||
slogi("initializing standalone usb haptic device...");
|
||||
// detection of usb device model
|
||||
usbhapticdevice->type = HAPTIC_UNKNOWN;
|
||||
usbhapticdevice->type = HAPTIC_CSLELITEV3;
|
||||
error = cslelitev3_init(usbhapticdevice);
|
||||
switch (ds->dev_subsubtype) {
|
||||
case (SIMDEVSUBTYPE_SIMAGICP1000PEDALS):
|
||||
usbhapticdevice->type = USBHAPTIC_SIMAGICP1000PEDALS;
|
||||
error = simagicp1000_init(usbhapticdevice);
|
||||
break;
|
||||
case (SIMDEVSUBTYPE_CSLELITEV3PEDALS):
|
||||
usbhapticdevice->type = USBHAPTIC_CSLELITEV3PEDALS;
|
||||
error = cslelitev3_init(usbhapticdevice);
|
||||
break;
|
||||
default:
|
||||
slogw("Possibly unknown device");
|
||||
}
|
||||
|
||||
if(usbhapticdevice->handle == 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@
|
|||
|
||||
typedef enum
|
||||
{
|
||||
HAPTIC_UNKNOWN = 0,
|
||||
HAPTIC_CSLELITEV3 = 1
|
||||
USBHAPTIC_UNKNOWN = 0,
|
||||
USBHAPTIC_CSLELITEV3PEDALS = 1,
|
||||
USBHAPTIC_SIMAGICP1000PEDALS = 2
|
||||
}
|
||||
HapticType;
|
||||
|
||||
|
|
@ -22,7 +23,8 @@ typedef struct
|
|||
int value0;
|
||||
int value1;
|
||||
VibrationEffectType effecttype;
|
||||
FILE* handle;
|
||||
FILE* filehandle;
|
||||
hid_device* handle;
|
||||
char* dev;
|
||||
}
|
||||
USBGenericHapticDevice;
|
||||
|
|
|
|||
|
|
@ -99,22 +99,44 @@ int strtodevsubsubtype(const char* device_subsubtype, DeviceSettings* ds)
|
|||
{
|
||||
ds->dev_subsubtype = SIMDEVSUBTYPE_UNKNOWN;
|
||||
|
||||
if (strcicmp(device_subsubtype, "CammusC5") == 0)
|
||||
{
|
||||
ds->dev_subsubtype = SIMDEVSUBTYPE_CAMMUSC5;
|
||||
}
|
||||
if (strcicmp(device_subsubtype, "CammusC12") == 0)
|
||||
{
|
||||
ds->dev_subsubtype = SIMDEVSUBTYPE_CAMMUSC12;
|
||||
}
|
||||
if (strcicmp(device_subsubtype, "MozaR5") == 0)
|
||||
{
|
||||
ds->dev_subsubtype = SIMDEVSUBTYPE_MOZAR5;
|
||||
}
|
||||
if (strcicmp(device_subsubtype, "MozaR8") == 0)
|
||||
{
|
||||
ds->dev_subsubtype = SIMDEVSUBTYPE_MOZAR5;
|
||||
}
|
||||
|
||||
bool devfound = false;
|
||||
if (strcicmp(device_subsubtype, "CammusC5") == 0)
|
||||
{
|
||||
ds->dev_subsubtype = SIMDEVSUBTYPE_CAMMUSC5;
|
||||
bool devfound = true;
|
||||
}
|
||||
if (strcicmp(device_subsubtype, "CammusC12") == 0)
|
||||
{
|
||||
ds->dev_subsubtype = SIMDEVSUBTYPE_CAMMUSC12;
|
||||
bool devfound = true;
|
||||
}
|
||||
if (strcicmp(device_subsubtype, "MozaR5") == 0)
|
||||
{
|
||||
ds->dev_subsubtype = SIMDEVSUBTYPE_MOZAR5;
|
||||
bool devfound = true;
|
||||
}
|
||||
if (strcicmp(device_subsubtype, "MozaR8") == 0)
|
||||
{
|
||||
ds->dev_subsubtype = SIMDEVSUBTYPE_MOZAR5;
|
||||
bool devfound = true;
|
||||
}
|
||||
if (strcicmp(device_subsubtype, "CSLELITEV3PEDALS") == 0)
|
||||
{
|
||||
ds->dev_subsubtype = SIMDEVSUBTYPE_CSLELITEV3PEDALS;
|
||||
bool devfound = true;
|
||||
}
|
||||
if (strcicmp(device_subsubtype, "SIMAGICP1000PEDALS") == 0)
|
||||
{
|
||||
ds->dev_subsubtype = SIMDEVSUBTYPE_SIMAGICP1000PEDALS;
|
||||
bool devfound = true;
|
||||
}
|
||||
|
||||
if(devfound == false)
|
||||
{
|
||||
slogw("%s does not appear to be a valid device sub sub type, but attempting to continue with other devices", device_subsubtype);
|
||||
return MONOCOQUE_ERROR_INVALID_DEV;
|
||||
}
|
||||
return MONOCOQUE_ERROR_NONE;
|
||||
}
|
||||
|
||||
|
|
@ -618,12 +640,7 @@ int devsetup(const char* device_type, const char* device_subtype, const char* co
|
|||
}
|
||||
}
|
||||
|
||||
if (ds->dev_subtype == SIMDEVTYPE_USBHAPTIC)
|
||||
{
|
||||
// logic for different devices
|
||||
}
|
||||
|
||||
if (ds->dev_subtype == SIMDEVTYPE_USBWHEEL)
|
||||
if (ds->dev_subtype == SIMDEVTYPE_USBHAPTIC || ds->dev_subtype == SIMDEVTYPE_USBWHEEL)
|
||||
{
|
||||
// logic for different devices
|
||||
int b = 0;
|
||||
|
|
|
|||
|
|
@ -33,10 +33,12 @@ DeviceSubType;
|
|||
|
||||
typedef enum
|
||||
{
|
||||
SIMDEVSUBTYPE_UNKNOWN = 0,
|
||||
SIMDEVSUBTYPE_CAMMUSC5 = 1,
|
||||
SIMDEVSUBTYPE_CAMMUSC12 = 2,
|
||||
SIMDEVSUBTYPE_MOZAR5 = 3,
|
||||
SIMDEVSUBTYPE_UNKNOWN = 0,
|
||||
SIMDEVSUBTYPE_CAMMUSC5 = 1,
|
||||
SIMDEVSUBTYPE_CAMMUSC12 = 2,
|
||||
SIMDEVSUBTYPE_MOZAR5 = 3,
|
||||
SIMDEVSUBTYPE_CSLELITEV3PEDALS = 4,
|
||||
SIMDEVSUBTYPE_SIMAGICP1000PEDALS =5
|
||||
}
|
||||
DeviceSubSubType;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue