Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2aee847d7c | ||
|
|
9712396c6f | ||
|
|
6a36c2825f | ||
|
|
2b787cba00 | ||
|
|
3c81f749b8 | ||
|
|
3c1b1948fd |
@@ -1 +0,0 @@
|
||||
../../monocoque/simulatorapi/simapi/simapi/simdata.h
|
||||
@@ -25,6 +25,8 @@ set(devices_source_files
|
||||
usb/cslelitev3.c
|
||||
usb/simagicp1000.h
|
||||
usb/simagicp1000.c
|
||||
usb/simnetpedals.h
|
||||
usb/simnetpedals.c
|
||||
usb/wheels/logitechg29.h
|
||||
usb/wheels/logitechg29.c
|
||||
usb/wheels/cammusc5.h
|
||||
|
||||
@@ -128,21 +128,20 @@ int GetNumberOfLeds(SerialDevice* serialdevice, int* numlights)
|
||||
|
||||
int arduino_init(SerialDevice* serialdevice, const char* portdev)
|
||||
{
|
||||
serialdevice->id = monocoque_serial_open(serialdevice, portdev);
|
||||
return serialdevice->id;
|
||||
int id = monocoque_serial_open(serialdevice, portdev);
|
||||
if (id < 0) return id;
|
||||
serialdevice->id = id;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int arduino_custom_init(SerialDevice* serialdevice, const char* portdev, const char* luafile, bool uselights)
|
||||
{
|
||||
serialdevice->id = monocoque_serial_open(serialdevice, portdev);
|
||||
|
||||
int error = arduino_init(serialdevice, portdev);
|
||||
|
||||
int numlights = 0;
|
||||
|
||||
monocoque_serial_device serialdev = monocoque_serial_devices[serialdevice->id];
|
||||
int error = 0;
|
||||
if(uselights == true)
|
||||
{
|
||||
error = GetNumberOfLeds(serialdevice, &numlights);
|
||||
@@ -179,7 +178,7 @@ int arduino_custom_init(SerialDevice* serialdevice, const char* portdev, const c
|
||||
|
||||
slogi("LUA config setup successful.");
|
||||
|
||||
return serialdevice->id;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -140,6 +140,10 @@ int arduino_simhaptic_update(SimDevice* this, SimData* simdata)
|
||||
int result = 1;
|
||||
|
||||
slogt("arduino haptic device updating");
|
||||
serialdevice->u.simhapticdata.motor1 = 0;
|
||||
serialdevice->u.simhapticdata.motor2 = 0;
|
||||
serialdevice->u.simhapticdata.motor3 = 0;
|
||||
serialdevice->u.simhapticdata.motor4 = 0;
|
||||
|
||||
double play = slipeffect(simdata, this->hapticeffect.effecttype, this->hapticeffect.tyre, this->hapticeffect.threshold, this->hapticeffect.useconfig, this->hapticeffect.configcheck, this->hapticeffect.tyrediameterconfig);
|
||||
|
||||
@@ -149,23 +153,25 @@ int arduino_simhaptic_update(SimDevice* this, SimData* simdata)
|
||||
{
|
||||
play = 1.0;
|
||||
}
|
||||
int effectspeed = ceil(255 * play);
|
||||
uint8_t effectspeed = ceil(255 * play);
|
||||
|
||||
int motor = serialdevice->motorsposition;
|
||||
uint8_t motor = serialdevice->motorsposition;
|
||||
|
||||
if (play != serialdevice->state)
|
||||
{
|
||||
// motor 1
|
||||
if (motor == 0 || motor == 4 || motor == 7 || motor == 8 || motor == 10 || motor == 11 || motor == 13 || motor == 14)
|
||||
{
|
||||
serialdevice->u.simhapticdata.effect1 = effectspeed;
|
||||
serialdevice->u.simhapticdata.motor1 = 1;
|
||||
slogt("Updating arduino haptic device with effect type %i speed motor speed %i on motor %i from original effect %f with ampfactor %f", this->hapticeffect.effecttype, serialdevice->u.simhapticdata.effect3, serialdevice->motorsposition, rplay, serialdevice->ampfactor);
|
||||
slogt("Updating arduino haptic device with effect type %i speed motor speed %i on motor %i from original effect %f with ampfactor %f", this->hapticeffect.effecttype, serialdevice->u.simhapticdata.effect1, 1, rplay, serialdevice->ampfactor);
|
||||
}
|
||||
// motor 3
|
||||
if (motor == 2 || motor == 6 || motor == 8 || motor == 9 || motor == 10 || motor == 11 || motor == 12 || motor == 14)
|
||||
{
|
||||
serialdevice->u.simhapticdata.effect3 = effectspeed;
|
||||
serialdevice->u.simhapticdata.motor3 = 1;
|
||||
slogt("Updating arduino haptic device with effect type %i speed motor speed %i on motor %i from original effect %f with ampfactor %f", this->hapticeffect.effecttype, serialdevice->u.simhapticdata.effect3, serialdevice->motorsposition, rplay, serialdevice->ampfactor);
|
||||
slogt("Updating arduino haptic device with effect type %i speed motor speed %i on motor %i from original effect %f with ampfactor %f", this->hapticeffect.effecttype, serialdevice->u.simhapticdata.effect3, 3, rplay, serialdevice->ampfactor);
|
||||
}
|
||||
serialdevice->state = play;
|
||||
}
|
||||
@@ -399,7 +405,7 @@ SerialDevice* new_serial_device(DeviceSettings* ds, MonocoqueSettings* ms, SimIn
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
slogw("Did not initialize usb device due to error code %i", error);
|
||||
slogw("Did not initialize serial device due to error code %i", error);
|
||||
free(this);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -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 "usb/cslelitev3.h"
|
||||
#include "usb/simagicp1000.h"
|
||||
#include "usb/simnetpedals.h"
|
||||
|
||||
#include "../../helper/confighelper.h"
|
||||
#include "../../simulatorapi/simapi/simapi/simdata.h"
|
||||
@@ -32,6 +33,9 @@ int usbhapticdev_update(USBGenericHapticDevice* usbhapticdevice, SimData* simdat
|
||||
case USBHAPTIC_SIMAGICP1000PEDALS:
|
||||
simagicp1000_update(usbhapticdevice, usbhapticdevice->effecttype, rplay);
|
||||
break;
|
||||
case USBHAPTIC_SIMNETPEDALS:
|
||||
simnetpedals_update(usbhapticdevice, usbhapticdevice->effecttype, rplay);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -44,6 +48,9 @@ int usbhapticdev_update(USBGenericHapticDevice* usbhapticdevice, SimData* simdat
|
||||
case USBHAPTIC_SIMAGICP1000PEDALS:
|
||||
simagicp1000_update(usbhapticdevice, usbhapticdevice->effecttype, rplay);
|
||||
break;
|
||||
case USBHAPTIC_SIMNETPEDALS:
|
||||
simnetpedals_update(usbhapticdevice, usbhapticdevice->effecttype, rplay);
|
||||
break;
|
||||
}
|
||||
}
|
||||
usbhapticdevice->state = play;
|
||||
@@ -62,6 +69,9 @@ int usbhapticdev_free(USBGenericHapticDevice* usbhapticdevice)
|
||||
case USBHAPTIC_SIMAGICP1000PEDALS:
|
||||
simagicp1000_free(usbhapticdevice);
|
||||
break;
|
||||
case USBHAPTIC_SIMNETPEDALS:
|
||||
simnetpedals_free(usbhapticdevice);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -107,6 +117,13 @@ int usbhapticdev_init(USBGenericHapticDevice* usbhapticdevice, DeviceSettings* d
|
||||
usbhapticdevice->type = USBHAPTIC_CSLELITEV3PEDALS;
|
||||
error = cslelitev3_init(usbhapticdevice);
|
||||
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:
|
||||
slogw("Possibly unknown device");
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ typedef enum
|
||||
{
|
||||
USBHAPTIC_UNKNOWN = 0,
|
||||
USBHAPTIC_CSLELITEV3PEDALS = 1,
|
||||
USBHAPTIC_SIMAGICP1000PEDALS = 2
|
||||
USBHAPTIC_SIMAGICP1000PEDALS = 2,
|
||||
USBHAPTIC_SIMNETPEDALS = 3
|
||||
}
|
||||
HapticType;
|
||||
|
||||
@@ -22,6 +23,9 @@ typedef struct
|
||||
double threshold;
|
||||
int value0;
|
||||
int value1;
|
||||
uint32_t frequency;
|
||||
uint32_t amplitude;
|
||||
uint32_t motorposition;
|
||||
VibrationEffectType effecttype;
|
||||
FILE* filehandle;
|
||||
hid_device* handle;
|
||||
|
||||
@@ -737,6 +737,10 @@ int tester(SimDevice* devices, int numdevices)
|
||||
simdata->tyrediameter[1] = -1;
|
||||
simdata->tyrediameter[2] = -1;
|
||||
simdata->tyrediameter[3] = -1;
|
||||
simdata->tyreslipratio[0] = 0;
|
||||
simdata->tyreslipratio[1] = 0;
|
||||
simdata->tyreslipratio[2] = 0;
|
||||
simdata->tyreslipratio[3] = 0;
|
||||
simdata->Xvelocity = 0;
|
||||
simdata->Yvelocity = 100;
|
||||
simdata->Zvelocity = 0;
|
||||
|
||||
@@ -128,6 +128,11 @@ int strtodevsubsubtype(const char* device_subsubtype, DeviceSettings* ds)
|
||||
ds->dev_subsubtype = SIMDEVSUBTYPE_CSLELITEV3PEDALS;
|
||||
devfound = true;
|
||||
}
|
||||
if (strcicmp(device_subsubtype, "SIMNETPEDALS") == 0)
|
||||
{
|
||||
ds->dev_subsubtype = SIMDEVSUBTYPE_SIMNETPEDALS;
|
||||
devfound = true;
|
||||
}
|
||||
if (strcicmp(device_subsubtype, "SIMAGICP1000PEDALS") == 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
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)
|
||||
|
||||
@@ -46,7 +46,8 @@ typedef enum
|
||||
SIMDEVSUBTYPE_SIMAGICGTNEO = 6,
|
||||
SIMDEVSUBTYPE_MOZA_NEW = 7,
|
||||
SIMDEVSUBTYPE_LOGITECH_G29 = 8,
|
||||
SIMDEVSUBTYPE_MOZA_KS_PRO_WHEEL = 9
|
||||
SIMDEVSUBTYPE_MOZA_KS_PRO_WHEEL = 9,
|
||||
SIMDEVSUBTYPE_SIMNETPEDALS = 10
|
||||
}
|
||||
DeviceSubSubType;
|
||||
|
||||
@@ -196,6 +197,9 @@ typedef struct
|
||||
{
|
||||
int value0;
|
||||
int value1;
|
||||
uint32_t frequency;
|
||||
uint32_t amplitude;
|
||||
MotorPosition motorsposition;
|
||||
char* dev;
|
||||
}
|
||||
USBDeviceSettings;
|
||||
|
||||
Submodule src/monocoque/simulatorapi/simapi updated: ea44d0e57f...50fd181681
@@ -122,6 +122,8 @@ if ! distrobox list 2>/dev/null | grep -q "$CONTAINER"; then
|
||||
distrobox create \
|
||||
--image docker.io/library/archlinux:latest \
|
||||
--name "$CONTAINER" \
|
||||
--root \
|
||||
--additional-flags "--privileged --security-opt seccomp=unconfined" \
|
||||
--pre-init-hooks "sed -i 's/^SigLevel.*/SigLevel = Never/' /etc/pacman.conf && pacman -Sy --noconfirm archlinux-keyring && pacman-key --init && pacman-key --populate archlinux && sed -i 's/^SigLevel.*/SigLevel = Required DatabaseOptional/' /etc/pacman.conf"
|
||||
log_success "Container '$CONTAINER' created"
|
||||
else
|
||||
@@ -130,7 +132,7 @@ fi
|
||||
|
||||
# Install packages inside the container
|
||||
log_info "Installing packages inside container (this may take a few minutes)..."
|
||||
distrobox enter "$CONTAINER" -- bash -c '
|
||||
distrobox enter --root "$CONTAINER" -- bash -c '
|
||||
set -euo pipefail
|
||||
|
||||
# Install build dependencies
|
||||
@@ -181,19 +183,19 @@ mkdir -p "$BIN_DIR"
|
||||
|
||||
cat > "$BIN_DIR/start-simd" << 'EOF'
|
||||
#!/usr/bin/env bash
|
||||
exec distrobox enter simracing -- simd "$@"
|
||||
exec distrobox enter --root simracing -- simd "$@"
|
||||
EOF
|
||||
chmod +x "$BIN_DIR/start-simd"
|
||||
|
||||
cat > "$BIN_DIR/start-monocoque" << 'EOF'
|
||||
#!/usr/bin/env bash
|
||||
exec distrobox enter simracing -- monocoque play "$@"
|
||||
exec distrobox enter --root simracing -- monocoque play "$@"
|
||||
EOF
|
||||
chmod +x "$BIN_DIR/start-monocoque"
|
||||
|
||||
cat > "$BIN_DIR/test-monocoque" << 'EOF'
|
||||
#!/usr/bin/env bash
|
||||
exec distrobox enter simracing -- monocoque test -vv "$@"
|
||||
exec distrobox enter --root simracing -- monocoque test -vv "$@"
|
||||
EOF
|
||||
chmod +x "$BIN_DIR/test-monocoque"
|
||||
|
||||
|
||||
@@ -72,9 +72,9 @@ if [ -d "$INSTALL_DIR" ]; then
|
||||
fi
|
||||
|
||||
# Remove distrobox container
|
||||
if distrobox list 2>/dev/null | grep -q "$CONTAINER"; then
|
||||
if distrobox list --root 2>/dev/null | grep -q "$CONTAINER"; then
|
||||
log_info "Removing distrobox container '$CONTAINER'..."
|
||||
distrobox rm --force "$CONTAINER"
|
||||
distrobox rm --root --force "$CONTAINER"
|
||||
log_success "Container '$CONTAINER' removed"
|
||||
else
|
||||
log_info "Container '$CONTAINER' not found, skipping"
|
||||
|
||||
Reference in New Issue
Block a user