Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2aee847d7c | ||
|
|
9712396c6f |
@@ -25,6 +25,8 @@ set(devices_source_files
|
|||||||
usb/cslelitev3.c
|
usb/cslelitev3.c
|
||||||
usb/simagicp1000.h
|
usb/simagicp1000.h
|
||||||
usb/simagicp1000.c
|
usb/simagicp1000.c
|
||||||
|
usb/simnetpedals.h
|
||||||
|
usb/simnetpedals.c
|
||||||
usb/wheels/logitechg29.h
|
usb/wheels/logitechg29.h
|
||||||
usb/wheels/logitechg29.c
|
usb/wheels/logitechg29.c
|
||||||
usb/wheels/cammusc5.h
|
usb/wheels/cammusc5.h
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <glob.h>
|
||||||
|
|
||||||
|
#include "usbhapticdevice.h"
|
||||||
|
|
||||||
|
#include "../../helper/confighelper.h"
|
||||||
|
#include "../slog/slog.h"
|
||||||
|
|
||||||
|
#define SIMNETPEDALS_BUFSIZE 9
|
||||||
|
|
||||||
|
//Byte[0] : 0x01 (fixed) = Report ID
|
||||||
|
//Byte[1] : 0x00 (fixed)
|
||||||
|
//Byte[2] : motor number (0x01, 0x2 or 0x4)
|
||||||
|
//Byte[3]: motor 1 frequency in hz
|
||||||
|
//Byte[4] : motor 1 amplitude (0 to 100%)
|
||||||
|
//Byte[5] : motor 2 frequency in hz
|
||||||
|
//Byte[6]: motor 2 amplitude (0 to 100%)
|
||||||
|
//Byte[7]: motor 3 frequency in hz
|
||||||
|
//Byte[8]: motor 3 amplitude (0 to 100%)
|
||||||
|
|
||||||
|
|
||||||
|
int simnetpedals_update(USBGenericHapticDevice* usbhapticdevice, int effecttype, int play)
|
||||||
|
{
|
||||||
|
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
unsigned char bytes[SIMNETPEDALS_BUFSIZE];
|
||||||
|
for (int x = 0; x < SIMNETPEDALS_BUFSIZE; x++)
|
||||||
|
{
|
||||||
|
bytes[x] = 0x00;
|
||||||
|
}
|
||||||
|
bytes[0] = 0x01;
|
||||||
|
bytes[1] = 0x00;
|
||||||
|
bytes[2] = usbhapticdevice->motorposition;
|
||||||
|
uint8_t motormultiple = usbhapticdevice->motorposition - 1;
|
||||||
|
if(usbhapticdevice->motorposition == 0x04)
|
||||||
|
{
|
||||||
|
motormultiple = 2;
|
||||||
|
}
|
||||||
|
bytes[3 + (motormultiple * 2)] = usbhapticdevice->frequency;
|
||||||
|
bytes[4 + (motormultiple * 2)] = usbhapticdevice->amplitude;
|
||||||
|
|
||||||
|
|
||||||
|
if (usbhapticdevice->handle)
|
||||||
|
{
|
||||||
|
slogt("writing bytes x%02xx%02xx%02xx%02xx%02xx%02xx%02xx%02xx%02x", bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], bytes[8]);
|
||||||
|
res = hid_write(usbhapticdevice->handle, bytes, SIMNETPEDALS_BUFSIZE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
slogd("no handle");
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int simnetpedals_free(USBGenericHapticDevice* usbhapticdevice)
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
hid_close(usbhapticdevice->handle);
|
||||||
|
res = hid_exit();
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int simnetpedals_init(USBGenericHapticDevice* usbhapticdevice)
|
||||||
|
{
|
||||||
|
slogi("initializing simnet pedals...");
|
||||||
|
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
res = hid_init();
|
||||||
|
|
||||||
|
usbhapticdevice->handle = hid_open(0xcafe, 0xa301, NULL);
|
||||||
|
|
||||||
|
if (!usbhapticdevice->handle)
|
||||||
|
{
|
||||||
|
sloge("Could not find attached Simnet Pedals");
|
||||||
|
res = hid_exit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
slogd("Found Simnet Pedals handle %i...", usbhapticdevice->handle);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#ifndef _SIMNETPEDALS_H
|
||||||
|
#define _SIMNETPEDALS_H
|
||||||
|
|
||||||
|
int simnetpedals_update(USBGenericHapticDevice* usbhapticdevice, int effecttype, int play);
|
||||||
|
int simnetpedals_init(USBGenericHapticDevice* usbhapticdevice);
|
||||||
|
int simnetpedals_free(USBGenericHapticDevice* usbhapticdevice);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "hapticeffect.h"
|
#include "hapticeffect.h"
|
||||||
#include "usb/cslelitev3.h"
|
#include "usb/cslelitev3.h"
|
||||||
#include "usb/simagicp1000.h"
|
#include "usb/simagicp1000.h"
|
||||||
|
#include "usb/simnetpedals.h"
|
||||||
|
|
||||||
#include "../../helper/confighelper.h"
|
#include "../../helper/confighelper.h"
|
||||||
#include "../../simulatorapi/simapi/simapi/simdata.h"
|
#include "../../simulatorapi/simapi/simapi/simdata.h"
|
||||||
@@ -32,6 +33,9 @@ int usbhapticdev_update(USBGenericHapticDevice* usbhapticdevice, SimData* simdat
|
|||||||
case USBHAPTIC_SIMAGICP1000PEDALS:
|
case USBHAPTIC_SIMAGICP1000PEDALS:
|
||||||
simagicp1000_update(usbhapticdevice, usbhapticdevice->effecttype, rplay);
|
simagicp1000_update(usbhapticdevice, usbhapticdevice->effecttype, rplay);
|
||||||
break;
|
break;
|
||||||
|
case USBHAPTIC_SIMNETPEDALS:
|
||||||
|
simnetpedals_update(usbhapticdevice, usbhapticdevice->effecttype, rplay);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -44,6 +48,9 @@ int usbhapticdev_update(USBGenericHapticDevice* usbhapticdevice, SimData* simdat
|
|||||||
case USBHAPTIC_SIMAGICP1000PEDALS:
|
case USBHAPTIC_SIMAGICP1000PEDALS:
|
||||||
simagicp1000_update(usbhapticdevice, usbhapticdevice->effecttype, rplay);
|
simagicp1000_update(usbhapticdevice, usbhapticdevice->effecttype, rplay);
|
||||||
break;
|
break;
|
||||||
|
case USBHAPTIC_SIMNETPEDALS:
|
||||||
|
simnetpedals_update(usbhapticdevice, usbhapticdevice->effecttype, rplay);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
usbhapticdevice->state = play;
|
usbhapticdevice->state = play;
|
||||||
@@ -62,6 +69,9 @@ int usbhapticdev_free(USBGenericHapticDevice* usbhapticdevice)
|
|||||||
case USBHAPTIC_SIMAGICP1000PEDALS:
|
case USBHAPTIC_SIMAGICP1000PEDALS:
|
||||||
simagicp1000_free(usbhapticdevice);
|
simagicp1000_free(usbhapticdevice);
|
||||||
break;
|
break;
|
||||||
|
case USBHAPTIC_SIMNETPEDALS:
|
||||||
|
simnetpedals_free(usbhapticdevice);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -107,6 +117,13 @@ int usbhapticdev_init(USBGenericHapticDevice* usbhapticdevice, DeviceSettings* d
|
|||||||
usbhapticdevice->type = USBHAPTIC_CSLELITEV3PEDALS;
|
usbhapticdevice->type = USBHAPTIC_CSLELITEV3PEDALS;
|
||||||
error = cslelitev3_init(usbhapticdevice);
|
error = cslelitev3_init(usbhapticdevice);
|
||||||
break;
|
break;
|
||||||
|
case (SIMDEVSUBTYPE_SIMNETPEDALS):
|
||||||
|
usbhapticdevice->type = USBHAPTIC_SIMNETPEDALS;
|
||||||
|
usbhapticdevice->motorposition = ds->usbdevsettings.motorsposition;
|
||||||
|
usbhapticdevice->frequency = ds->usbdevsettings.frequency;
|
||||||
|
usbhapticdevice->amplitude = ds->usbdevsettings.amplitude;
|
||||||
|
error = simnetpedals_init(usbhapticdevice);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
slogw("Possibly unknown device");
|
slogw("Possibly unknown device");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ typedef enum
|
|||||||
{
|
{
|
||||||
USBHAPTIC_UNKNOWN = 0,
|
USBHAPTIC_UNKNOWN = 0,
|
||||||
USBHAPTIC_CSLELITEV3PEDALS = 1,
|
USBHAPTIC_CSLELITEV3PEDALS = 1,
|
||||||
USBHAPTIC_SIMAGICP1000PEDALS = 2
|
USBHAPTIC_SIMAGICP1000PEDALS = 2,
|
||||||
|
USBHAPTIC_SIMNETPEDALS = 3
|
||||||
}
|
}
|
||||||
HapticType;
|
HapticType;
|
||||||
|
|
||||||
@@ -22,6 +23,9 @@ typedef struct
|
|||||||
double threshold;
|
double threshold;
|
||||||
int value0;
|
int value0;
|
||||||
int value1;
|
int value1;
|
||||||
|
uint32_t frequency;
|
||||||
|
uint32_t amplitude;
|
||||||
|
uint32_t motorposition;
|
||||||
VibrationEffectType effecttype;
|
VibrationEffectType effecttype;
|
||||||
FILE* filehandle;
|
FILE* filehandle;
|
||||||
hid_device* handle;
|
hid_device* handle;
|
||||||
|
|||||||
@@ -128,6 +128,11 @@ int strtodevsubsubtype(const char* device_subsubtype, DeviceSettings* ds)
|
|||||||
ds->dev_subsubtype = SIMDEVSUBTYPE_CSLELITEV3PEDALS;
|
ds->dev_subsubtype = SIMDEVSUBTYPE_CSLELITEV3PEDALS;
|
||||||
devfound = true;
|
devfound = true;
|
||||||
}
|
}
|
||||||
|
if (strcicmp(device_subsubtype, "SIMNETPEDALS") == 0)
|
||||||
|
{
|
||||||
|
ds->dev_subsubtype = SIMDEVSUBTYPE_SIMNETPEDALS;
|
||||||
|
devfound = true;
|
||||||
|
}
|
||||||
if (strcicmp(device_subsubtype, "SIMAGICP1000PEDALS") == 0)
|
if (strcicmp(device_subsubtype, "SIMAGICP1000PEDALS") == 0)
|
||||||
{
|
{
|
||||||
ds->dev_subsubtype = SIMDEVSUBTYPE_SIMAGICP1000PEDALS;
|
ds->dev_subsubtype = SIMDEVSUBTYPE_SIMAGICP1000PEDALS;
|
||||||
@@ -731,6 +736,15 @@ int devsetup(const char* device_type, const char* device_subtype, const char* co
|
|||||||
{
|
{
|
||||||
b = strtodevsubsubtype(temp, ds);
|
b = strtodevsubsubtype(temp, ds);
|
||||||
}
|
}
|
||||||
|
ds->usbdevsettings.frequency = 0;
|
||||||
|
ds->usbdevsettings.amplitude = 0;
|
||||||
|
ds->usbdevsettings.motorsposition = 0;
|
||||||
|
config_setting_lookup_int(device_settings, "frequency", &ds->usbdevsettings.frequency);
|
||||||
|
config_setting_lookup_int(device_settings, "amplitude", &ds->usbdevsettings.amplitude);
|
||||||
|
|
||||||
|
int motorposition = 1;
|
||||||
|
config_setting_lookup_int(device_settings, "motors", &motorposition);
|
||||||
|
ds->usbdevsettings.motorsposition = motorposition;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ds->dev_subtype == SIMDEVTYPE_USBHAPTIC || ds->dev_type == SIMDEV_SOUND || ds->dev_subtype == SIMDEVTYPE_SERIALHAPTIC)
|
if (ds->dev_subtype == SIMDEVTYPE_USBHAPTIC || ds->dev_type == SIMDEV_SOUND || ds->dev_subtype == SIMDEVTYPE_SERIALHAPTIC)
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ typedef enum
|
|||||||
SIMDEVSUBTYPE_SIMAGICGTNEO = 6,
|
SIMDEVSUBTYPE_SIMAGICGTNEO = 6,
|
||||||
SIMDEVSUBTYPE_MOZA_NEW = 7,
|
SIMDEVSUBTYPE_MOZA_NEW = 7,
|
||||||
SIMDEVSUBTYPE_LOGITECH_G29 = 8,
|
SIMDEVSUBTYPE_LOGITECH_G29 = 8,
|
||||||
SIMDEVSUBTYPE_MOZA_KS_PRO_WHEEL = 9
|
SIMDEVSUBTYPE_MOZA_KS_PRO_WHEEL = 9,
|
||||||
|
SIMDEVSUBTYPE_SIMNETPEDALS = 10
|
||||||
}
|
}
|
||||||
DeviceSubSubType;
|
DeviceSubSubType;
|
||||||
|
|
||||||
@@ -196,6 +197,9 @@ typedef struct
|
|||||||
{
|
{
|
||||||
int value0;
|
int value0;
|
||||||
int value1;
|
int value1;
|
||||||
|
uint32_t frequency;
|
||||||
|
uint32_t amplitude;
|
||||||
|
MotorPosition motorsposition;
|
||||||
char* dev;
|
char* dev;
|
||||||
}
|
}
|
||||||
USBDeviceSettings;
|
USBDeviceSettings;
|
||||||
|
|||||||
Submodule src/monocoque/simulatorapi/simapi updated: ea44d0e57f...50fd181681
Reference in New Issue
Block a user