Add ability to use lua on cammus c12

This commit is contained in:
Paul Dino Jones 2025-03-22 19:16:54 -04:00
parent 367c6fed34
commit 5dc00eb4ce
17 changed files with 267 additions and 102 deletions

View File

@ -119,15 +119,14 @@ int arduino_customled_init(SerialDevice* serialdevice, const char* portdev, cons
}
lua_setglobal(L,"myFunc");
serialdevice->L = L;
serialdevice->m.L = L;
return serialdevice->id;
}
int arduino_simled_update(SimDevice* this, SimData* simdata)
int arduino_simled_update(SerialDevice* serialdevice, SimData* simdata)
{
SerialDevice* serialdevice = (void *) this->derived;
int result = 1;
int total_leds = serialdevice->numleds;
@ -211,9 +210,8 @@ int arduino_simled_update(SimDevice* this, SimData* simdata)
return result;
}
int arduino_customled_update(SimDevice* this, SimData* simdata)
int arduino_customled_update(SerialDevice* serialdevice, SimData* simdata)
{
SerialDevice* serialdevice = (void *) this->derived;
int result = 1;
int total_leds = serialdevice->numleds;
@ -240,7 +238,7 @@ int arduino_customled_update(SimDevice* this, SimData* simdata)
bytes[bufsize-3] = 0xff;
lua_State* L = serialdevice->L;
lua_State* L = serialdevice->m.L;
lua_pushstring(L, "buff");
lua_pushlightuserdata(L, &bytes);
@ -325,7 +323,7 @@ int arduino_customled_free(SerialDevice* serialdevice, bool lua)
if(lua == true)
{
lua_close(serialdevice->L);
lua_close(serialdevice->m.L);
}
return result;
}

View File

@ -5,10 +5,10 @@
#include "../serialdevice.h"
int arduino_simled_update(SimDevice* this, SimData* simdata);
int arduino_simled_update(SerialDevice* serialdevice, SimData* simdata);
int arduino_update(SerialDevice* serialdevice, void* data, size_t size);
int arduino_customled_init(SerialDevice* serialdevice, const char* portdev, const char* luafile);
int arduino_customled_update(SimDevice* this, SimData* simdata);
int arduino_customled_update(SerialDevice* serialdevice, SimData* simdata);
int arduino_init(SerialDevice* serialdevice, const char* portdev);
int arduino_free(SerialDevice* serialdevice);
int arduino_customled_free(SerialDevice* serialdevice, bool lua);

View File

@ -34,6 +34,24 @@ int serialdev_update(SimDevice* this, SimData* simdata)
return 0;
}
int arduino_customled_updater(SimDevice* this, SimData* simdata)
{
SerialDevice* serialdevice = (void *) this->derived;
arduino_customled_update(serialdevice, simdata);
return 0;
}
int arduino_simled_updater(SimDevice* this, SimData* simdata)
{
SerialDevice* serialdevice = (void *) this->derived;
arduino_simled_update(serialdevice, simdata);
return 0;
}
int arduino_shiftlights_update(SimDevice* this, SimData* simdata)
{
SerialDevice* serialdevice = (void *) this->derived;
@ -149,7 +167,7 @@ int serialdev_free(SimDevice* this)
serialdevice->u.simhapticdata.effect4 = 0;
serialdevice->u.simhapticdata.motor4 = 1;
serialdevice->state = 0;
size_t size = sizeof(SimHapticData);
monocoque_serial_write_block(serialdevice->id, &serialdevice->u.simhapticdata, size, 9000);
slogi("set zero to arduino device");
@ -199,7 +217,7 @@ int serialdev_init(SerialDevice* serialdevice, DeviceSettings* ds)
error = moza_init(serialdevice, ds->serialdevsettings.portdev);
break;
case ARDUINODEV__SIMLED__CUSTOM:
error = arduino_customled_init(serialdevice, ds->serialdevsettings.portdev, ds->serialdevsettings.config_file);
error = arduino_customled_init(serialdevice, ds->serialdevsettings.portdev, ds->specific_config_file);
break;
case ARDUINODEV__SIMLED:
error = arduino_customled_init(serialdevice, ds->serialdevsettings.portdev, NULL);
@ -215,8 +233,8 @@ int serialdev_init(SerialDevice* serialdevice, DeviceSettings* ds)
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_simled_vtable = { &arduino_simled_update, &serialdev_free };
static const vtable arduino_simled_custom_vtable = { &arduino_customled_update, &serialdev_free };
static const vtable arduino_simled_vtable = { &arduino_simled_updater, &serialdev_free };
static const vtable arduino_simled_custom_vtable = { &arduino_customled_updater, &serialdev_free };
static const vtable arduino_simwind_vtable = { &arduino_simwind_update, &serialdev_free };
static const vtable arduino_simhaptic_vtable = { &arduino_simhaptic_update, &serialdev_free };
static const vtable serialwheel_vtable = { &serial_wheel_update, &serial_wheel_free };

View File

@ -2,13 +2,16 @@
#define _SIMDEVICE_H
#include <stdbool.h>
#include <hidapi/hidapi.h>
#include "lua.h"
#include "usbdevice.h"
#include "sounddevice.h"
#include "serialdevice.h"
#include "hapticeffect.h"
#include "../helper/confighelper.h"
#include "../simulatorapi/simapi/simapi/simdata.h"
@ -27,6 +30,7 @@ struct SimDevice
int id;
int fps;
bool initialized;
lua_State* L;
DeviceType type;
HapticEffect hapticeffect;
};
@ -51,7 +55,7 @@ typedef struct
int id;
SerialType type;
struct sp_port* port;
lua_State* L;
SerialDeviceType devicetype;
// move these two they only apply to the haptic device
int motorsposition;
@ -93,6 +97,7 @@ typedef struct
{
SimDevice m;
int id;
hid_device* handle;
USBType type;
union
{
@ -145,4 +150,16 @@ int devfree(SimDevice* simdevices, int numdevices);
int simdevfree(SimDevice* this);
/****** USB SubTypes ****************/
int wheeldev_update(USBDevice* usbdevice, SimData* simdata);
int wheeldev_init(USBDevice* usbdevice, DeviceSettings* ds);
int wheeldev_free(USBDevice* usbdevice);
int tachdev_update(USBDevice* tachdevice, SimData* simdata);
int tachdev_init(USBDevice* tachdevice, DeviceSettings* ds);
int tachdev_free(USBDevice* tachdevice);
#endif

View File

@ -2,14 +2,16 @@
#include <stdlib.h>
#include <string.h>
#include "tachdevice.h"
#include "revburner.h"
#include "../../helper/confighelper.h"
#include "../../simulatorapi/simapi/simapi/simdata.h"
#include "../../slog/slog.h"
//#include "tachdevice.h"
#include "simdevice.h"
#include "usb/revburner.h"
#include "../helper/confighelper.h"
#include "../simulatorapi/simapi/simapi/simdata.h"
#include "../slog/slog.h"
int tachdev_update(TachDevice* tachdevice, SimData* simdata)
int tachdev_update(USBDevice* usbdevice, SimData* simdata)
{
TachDevice* tachdevice = &usbdevice->u.tachdevice;
// current plan is to just use the revburner xml format for other possible tachometer devices
// with that assumption this same logic is assumed the same for other tachometer devices
// the only difference then being in communication to the physical device
@ -43,30 +45,33 @@ int tachdev_update(TachDevice* tachdevice, SimData* simdata)
}
}
slogt("Settings tachometer pulses to %i", pulses);
revburner_update(tachdevice, pulses);
revburner_update(usbdevice, pulses);
break;
}
return 0;
}
int tachdev_free(TachDevice* tachdevice)
int tachdev_free(USBDevice* usbdevice)
{
TachDevice* tachdevice = &usbdevice->u.tachdevice;
switch ( tachdevice->type )
{
case TACHDEV_UNKNOWN :
case TACHDEV_REVBURNER :
revburner_update(tachdevice, 0);
revburner_free(tachdevice);
revburner_update(usbdevice, 0);
revburner_free(usbdevice);
break;
}
return 0;
}
int tachdev_init(TachDevice* tachdevice, DeviceSettings* ds)
int tachdev_init(USBDevice* usbdevice, DeviceSettings* ds)
{
slogi("initializing tachometer device...");
TachDevice* tachdevice = &usbdevice->u.tachdevice;
int error = 0;
// detection of tach device model
tachdevice->type = TACHDEV_UNKNOWN;
@ -74,7 +79,7 @@ int tachdev_init(TachDevice* tachdevice, DeviceSettings* ds)
tachdevice->tachsettings = ds->tachsettings;
error = revburner_init(tachdevice);
error = revburner_init(usbdevice);
return error;
}

View File

@ -1,7 +1,7 @@
#ifndef _TACHDEVICE_H
#define _TACHDEVICE_H
#include <hidapi/hidapi.h>
#include "../helper/confighelper.h"
#include "../simulatorapi/simapi/simapi/simdata.h"
@ -19,13 +19,10 @@ typedef struct
int id;
TachType type;
bool use_pulses;
hid_device* handle;
TachometerSettings tachsettings;
}
TachDevice;
int tachdev_update(TachDevice* tachdevice, SimData* simdata);
int tachdev_init(TachDevice* tachdevice, DeviceSettings* ds);
int tachdev_free(TachDevice* tachdevice);
#endif

View File

@ -2,13 +2,13 @@
#include <hidapi/hidapi.h>
#include "tachdevice.h"
#include "../slog/slog.h"
#include "../simdevice.h"
#include "../../slog/slog.h"
const size_t REVBURNER_BUFSIZE = 8;
int revburner_update(TachDevice* tachdevice, int pulses)
int revburner_update(USBDevice* tachdevice, int pulses)
{
int res = 0;
@ -37,7 +37,7 @@ int revburner_update(TachDevice* tachdevice, int pulses)
return res;
}
int revburner_free(TachDevice* tachdevice)
int revburner_free(USBDevice* tachdevice)
{
int res = 0;
@ -47,7 +47,7 @@ int revburner_free(TachDevice* tachdevice)
return res;
}
int revburner_init(TachDevice* tachdevice)
int revburner_init(USBDevice* tachdevice)
{
slogi("initializing revburner tachometer...");
//tachdevice->update_tachometer = revburner_device_update;

View File

@ -1,8 +1,10 @@
#ifndef _REVBURNER_H
#define _REVBURNER_H
int revburner_update(TachDevice* tachdevice, int pulses);
int revburner_init(TachDevice* tachdevice);
int revburner_free(TachDevice* tachdevice);
#include "../simdevice.h"
int revburner_update(USBDevice* tachdevice, int pulses);
int revburner_init(USBDevice* tachdevice);
int revburner_free(USBDevice* tachdevice);
#endif

View File

@ -4,17 +4,21 @@
#include <hidapi/hidapi.h>
#include "cammusc12.h"
#include "../../serial/arduinoledlua.h"
#include "../../../slog/slog.h"
const int cammusc12_hidupdate_buf_size = 16;
const int cammusc12_hidledupdate_buf_size = 7;
int cammusc12_update(WheelDevice* wheeldevice, int maxrpm, int rpm, int gear, int velocity)
const int cammusc12_total_leds = 15;
int cammusc12_update(USBDevice* usbdevice, int maxrpm, int rpm, int gear, int velocity)
{
int res = 0;
unsigned char bytes[cammusc12_hidupdate_buf_size];
for (int x = 0; x < cammusc12_hidupdate_buf_size; x++)
{
bytes[x] = 0x00;
@ -43,9 +47,9 @@ int cammusc12_update(WheelDevice* wheeldevice, int maxrpm, int rpm, int gear, in
bytes[6] = gear-1;
slogt("writing bytes x%02xx%02xx%02xx%02xx%02x%02x%02x from rpm %i velocity %i gear %i", bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], rpm, velocity, gear);
if (wheeldevice->handle)
if (usbdevice->handle)
{
res = hid_write(wheeldevice->handle, bytes, cammusc12_hidupdate_buf_size);
res = hid_write(usbdevice->handle, bytes, cammusc12_hidupdate_buf_size);
}
else
{
@ -55,7 +59,7 @@ int cammusc12_update(WheelDevice* wheeldevice, int maxrpm, int rpm, int gear, in
return res;
}
int cammusc12_free(WheelDevice* wheeldevice)
int cammusc12_free(USBDevice* wheeldevice)
{
int res = 0;
@ -65,7 +69,7 @@ int cammusc12_free(WheelDevice* wheeldevice)
return res;
}
int cammusc12_init(WheelDevice* wheeldevice)
int cammusc12_init_(USBDevice* wheeldevice)
{
slogi("initializing cammus c12 wheel...");
@ -84,3 +88,119 @@ int cammusc12_init(WheelDevice* wheeldevice)
slogd("Found Cammus C12 Wheel...");
return res;
}
int cammusc12_init(USBDevice* wheeldevice, const char* luafile)
{
int res = cammusc12_init_(wheeldevice);
if(luafile == NULL)
{
return res;
}
lua_State* L = luaL_newstate();
luaL_openlibs(L);
int top=lua_gettop(L);
int status = luaL_loadfile(L, luafile);
if (status) {
/* If something went wrong, error message is at the top of */
/* the stack */
sloge("There is an issue with your lua script");
fprintf(stderr, "Couldn't load file: %s\n", lua_tostring(L, -1));
//exit(1);
}
lua_setglobal(L,"myFunc");
wheeldevice->m.L = L;
return res;
}
int cammusc12_customled_update(USBDevice* usbdevice, SimData* simdata)
{
int result = 1;
size_t bufsize = (cammusc12_total_leds * 3);
char ledbytes[bufsize];
lua_State* L = usbdevice->m.L;
lua_pushstring(L, "buff");
lua_pushlightuserdata(L, &ledbytes);
lua_settable(L, LUA_REGISTRYINDEX);
simdata_to_lua(L, simdata);
lua_setglobal(L, "simdata");
lua_pushinteger(L, cammusc12_total_leds);
lua_setglobal(L, "TotalLeds");
lua_register(L, "set_led_to_color", set_led_to_color);
lua_register(L, "set_led_range_to_color", set_led_range_to_color);
lua_register(L, "set_led_to_rgb_color", set_led_to_rgb_color);
lua_register(L, "set_led_range_to_rgb_color", set_led_range_to_rgb_color);
lua_register(L, "led_clear_all", led_clear_all);
lua_pushinteger(L, LUALEDCOLOR_RED);
lua_setglobal(L, "RED");
lua_pushinteger(L, LUALEDCOLOR_GREEN);
lua_setglobal(L, "GREEN");
lua_pushinteger(L, LUALEDCOLOR_BLUE);
lua_setglobal(L, "BLUE");
lua_pushinteger(L, LUALEDCOLOR_YELLOW);
lua_setglobal(L, "YELLOW");
lua_pushinteger(L, LUALEDCOLOR_ORANGE);
lua_setglobal(L, "ORANGE");
lua_getglobal(L,"myFunc");
if (lua_pcall(L, 0, 0, 0) != LUA_OK)
{
fprintf(stderr, "Error calling Lua script: %s\n", lua_tostring(L, -1));
}
int res = 0;
unsigned char bytes[cammusc12_hidledupdate_buf_size];
for(int x = 0; x < cammusc12_hidledupdate_buf_size; x++)
{
bytes[x] = 0x00;
}
bytes[0] = 0xFA;
bytes[1] = 0xFB;
bytes[2] = 0x02;
for(int i = 0; i < cammusc12_total_leds; i++)
{
for (int x = 3; x < cammusc12_hidledupdate_buf_size; x++)
{
bytes[x] = 0x00;
}
uint8_t led = i;
uint8_t red = ledbytes[(i * 3) + 0];
uint8_t green = ledbytes[(i * 3) + 1];
uint8_t blue = ledbytes[(i * 3) + 2];
bytes[3] = led;
bytes[4] = red;
bytes[5] = green;
bytes[6] = blue;
slogt("writing bytes x%02xx%02xx%02xx%02xx%02x%02x%02x from red %i green %i blue %i", bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], red, green, blue);
if (usbdevice->handle)
{
res = hid_write(usbdevice->handle, bytes, cammusc12_hidupdate_buf_size);
}
else
{
slogd("no handle");
}
}
return res;
}

View File

@ -3,8 +3,10 @@
#include "../../wheeldevice.h"
int cammusc12_update(WheelDevice* wheeldevice, int maxrpm, int rpm, int gear, int velocity);
int cammusc12_init(WheelDevice* wheeldevice);
int cammusc12_free(WheelDevice* wheeldevice);
#include "../../simdevice.h"
int cammusc12_update(USBDevice* wheeldevice, int maxrpm, int rpm, int gear, int velocity);
int cammusc12_init(USBDevice* wheeldevice, const char* luafile);
int cammusc12_free(USBDevice* wheeldevice);
#endif

View File

@ -9,13 +9,13 @@
const int cammusc5_hidupdate_buf_size = 14;
const int num_avail_leds = 9;
int cammusc5_update(WheelDevice* wheeldevice, int maxrpm, int rpm, int gear, int velocity)
int cammusc5_update(USBDevice* usbdevice, int maxrpm, int rpm, int gear, int velocity)
{
int res = 0;
unsigned char bytes[cammusc5_hidupdate_buf_size];
for (int x = 0; x < cammusc5_hidupdate_buf_size; x++)
{
bytes[x] = 0x00;
@ -56,9 +56,9 @@ int cammusc5_update(WheelDevice* wheeldevice, int maxrpm, int rpm, int gear, int
bytes[4] = gear-1;
slogt("writing bytes x%02xx%02xx%02xx%02xx%02x from rpm %i velocity %i gear %i", bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], rpm, velocity, gear);
if (wheeldevice->handle)
if (usbdevice->handle)
{
res = hid_write(wheeldevice->handle, bytes, cammusc5_hidupdate_buf_size);
res = hid_write(usbdevice->handle, bytes, cammusc5_hidupdate_buf_size);
}
else
{
@ -68,17 +68,17 @@ int cammusc5_update(WheelDevice* wheeldevice, int maxrpm, int rpm, int gear, int
return res;
}
int cammusc5_free(WheelDevice* wheeldevice)
int cammusc5_free(USBDevice* usbdevice)
{
int res = 0;
hid_close(wheeldevice->handle);
hid_close(usbdevice->handle);
res = hid_exit();
return res;
}
int cammusc5_init(WheelDevice* wheeldevice)
int cammusc5_init(USBDevice* usbdevice)
{
slogi("initializing cammus c5 wheel...");
@ -86,9 +86,9 @@ int cammusc5_init(WheelDevice* wheeldevice)
res = hid_init();
wheeldevice->handle = hid_open(0x3416, 0x1021, NULL);
usbdevice->handle = hid_open(0x3416, 0x1021, NULL);
if (!wheeldevice->handle)
if (!usbdevice->handle)
{
sloge("Could not find attached Cammus C5 Wheel");
res = hid_exit();

View File

@ -1,10 +1,10 @@
#ifndef _CAMMUSC5_H
#define _CAMMUSC5_H
#include "../../wheeldevice.h"
#include "../../simdevice.h"
int cammusc5_update(WheelDevice* wheeldevice, int maxrpm, int rpm, int gear, int velocity);
int cammusc5_init(WheelDevice* wheeldevice);
int cammusc5_free(WheelDevice* wheeldevice);
int cammusc5_update(USBDevice* wheeldevice, int maxrpm, int rpm, int gear, int velocity);
int cammusc5_init(USBDevice* wheeldevice);
int cammusc5_free(USBDevice* wheeldevice);
#endif

View File

@ -17,10 +17,10 @@ int usbdev_update(SimDevice* this, SimData* simdata)
{
case USBDEV_UNKNOWN :
case USBDEV_TACHOMETER :
tachdev_update(&usbdevice->u.tachdevice, simdata);
tachdev_update(usbdevice, simdata);
break;
case USBDEV_WHEEL :
wheeldev_update(&usbdevice->u.wheeldevice, simdata);
wheeldev_update(usbdevice, simdata);
break;
case USBDEV_GENERICHAPTIC :
usbhapticdev_update(&usbdevice->u.hapticdevice, simdata, this->hapticeffect.tyre, this->hapticeffect.useconfig, this->hapticeffect.configcheck, this->hapticeffect.tyrediameterconfig);
@ -39,10 +39,10 @@ int usbdev_free(SimDevice* this)
{
case USBDEV_UNKNOWN :
case USBDEV_TACHOMETER :
tachdev_free(&usbdevice->u.tachdevice);
tachdev_free(usbdevice);
break;
case USBDEV_WHEEL :
wheeldev_free(&usbdevice->u.wheeldevice);
wheeldev_free(usbdevice);
break;
case USBDEV_GENERICHAPTIC :
usbhapticdev_free(&usbdevice->u.hapticdevice);
@ -64,10 +64,10 @@ int usbdev_init(USBDevice* usbdevice, DeviceSettings* ds)
{
case USBDEV_UNKNOWN :
case USBDEV_TACHOMETER :
error = tachdev_init(&usbdevice->u.tachdevice, ds);
error = tachdev_init(usbdevice, ds);
break;
case USBDEV_WHEEL :
error = wheeldev_init(&usbdevice->u.wheeldevice, ds);
error = wheeldev_init(usbdevice, ds);
break;
case USBDEV_GENERICHAPTIC :
error = usbhapticdev_init(&usbdevice->u.hapticdevice, ds);

View File

@ -5,21 +5,23 @@
#include "usb/wheels/cammusc5.h"
#include "usb/wheels/cammusc12.h"
#include "serial/moza.h"
#include "wheeldevice.h"
#include "simdevice.h"
#include "../helper/confighelper.h"
#include "../simulatorapi/simapi/simapi/simdata.h"
#include "../slog/slog.h"
int wheeldev_update(WheelDevice* wheeldevice, SimData* simdata)
int wheeldev_update(USBDevice* usbdevice, SimData* simdata)
{
WheelDevice* wheeldevice = &usbdevice->u.wheeldevice;
switch ( wheeldevice->type )
{
case WHEELDEV_UNKNOWN :
case WHEELDEV_CAMMUSC5 :
cammusc5_update(wheeldevice, simdata->maxrpm, simdata->rpms, simdata->gear, simdata->velocity);
cammusc5_update(usbdevice, simdata->maxrpm, simdata->rpms, simdata->gear, simdata->velocity);
break;
case WHEELDEV_CAMMUSC12 :
cammusc12_update(wheeldevice, simdata->maxrpm, simdata->rpms, simdata->gear, simdata->velocity);
cammusc12_update(usbdevice, simdata->maxrpm, simdata->rpms, simdata->gear, simdata->velocity);
break;
}
@ -27,46 +29,55 @@ int wheeldev_update(WheelDevice* wheeldevice, SimData* simdata)
return 0;
}
int wheeldev_free(WheelDevice* wheeldevice)
int wheeldev_free(USBDevice* usbdevice)
{
WheelDevice* wheeldevice = &usbdevice->u.wheeldevice;
switch ( wheeldevice->type )
{
case WHEELDEV_UNKNOWN :
case WHEELDEV_CAMMUSC5 :
cammusc5_update(wheeldevice, 0, 0, 0, 0);
cammusc5_free(wheeldevice);
cammusc5_update(usbdevice, 0, 0, 0, 0);
cammusc5_free(usbdevice);
break;
case WHEELDEV_CAMMUSC12 :
cammusc12_update(wheeldevice, 0, 0, 0, 0);
cammusc12_free(wheeldevice);
cammusc12_update(usbdevice, 0, 0, 0, 0);
cammusc12_free(usbdevice);
break;
}
return 0;
}
int wheeldev_init(WheelDevice* wheeldevice, DeviceSettings* ds)
int wheeldev_init(USBDevice* usbdevice, DeviceSettings* ds)
{
slogi("initializing wheel device...");
int error = 0;
// detection of wheel model
WheelDevice* wheeldevice = &usbdevice->u.wheeldevice;
switch (ds->dev_subsubtype) {
case SIMDEVSUBTYPE_CAMMUSC5:
wheeldevice->type = WHEELDEV_CAMMUSC5;
slogi("Attempting to initialize cammus C5");
error = cammusc5_init(wheeldevice);
error = cammusc5_init(usbdevice);
break;
case SIMDEVSUBTYPE_CAMMUSC12:
wheeldevice->type = WHEELDEV_CAMMUSC12;
slogi("Attempting to initialize cammus C12");
error = cammusc12_init(wheeldevice);
if(ds->has_config == true)
{
error = cammusc12_init(usbdevice, ds->specific_config_file);
}
else
{
error = cammusc12_init(usbdevice, NULL);
}
break;
default:
wheeldevice->type = WHEELDEV_UNKNOWN;
slogw("Unknown cammus wheel detected, trying C5");
error = cammusc5_init(wheeldevice);
error = cammusc5_init(usbdevice);
break;
}

View File

@ -1,7 +1,6 @@
#ifndef _WHEELDEVICE_H
#define _WHEELDEVICE_H
#include <hidapi/hidapi.h>
#include "../helper/confighelper.h"
#include "../simulatorapi/simapi/simapi/simdata.h"
@ -20,13 +19,9 @@ typedef struct
{
int id;
WheelType type;
hid_device* handle;
char* port;
}
WheelDevice;
int wheeldev_update(WheelDevice* wheeldevice, SimData* simdata);
int wheeldev_init(WheelDevice* wheeldevice, DeviceSettings* ds);
int wheeldev_free(WheelDevice* wheeldevice);
#endif

View File

@ -801,24 +801,24 @@ int devsetup(const char* device_type, const char* device_subtype, const char* co
slogt("set port baud rate to %i, ampfactor %f", baud, ampfactor);
ds->has_config = false;
const char* temp2;
found = config_setting_lookup_string(device_settings, "config", &temp2);
slogt("config is %s found is %i", temp2, found);
if(strcicmp(temp2, "none") == 0)
{
slogt("config set to none");
}
else
{
ds->has_config = true;
ds->serialdevsettings.config_file = strdup(temp2);
slogt("will try to load config file at %s", ds->serialdevsettings.config_file);
}
}
}
ds->has_config = false;
const char* temp2;
int found = config_setting_lookup_string(device_settings, "config", &temp2);
if(strcicmp(temp2, "none") == 0)
{
slogt("config set to none");
}
else
{
ds->has_config = true;
ds->specific_config_file = strdup(temp2);
slogt("will try to load config file at %s", ds->specific_config_file);
}
return error;
}

View File

@ -155,7 +155,7 @@ TachometerSettings;
typedef struct
{
char* portdev;
char* config_file;
MotorPosition motorsposition;
int numlights;
int numleds;
@ -204,12 +204,12 @@ typedef struct
MonocoqueTyreIdentifier tyre;
double threshold;
bool has_config;
char* specific_config_file;
// union?
TachometerSettings tachsettings;
SerialDeviceSettings serialdevsettings;
SoundDeviceSettings sounddevsettings;
USBDeviceSettings usbdevsettings;
}
DeviceSettings;