David ScottandClaude Opus 5 cd67cb1689 fix: three crashes found while packaging (#54)
* fix: zero the settings structs so --help does not free garbage

`monocoque --help` aborted with `free(): invalid pointer` on Debian forky --
found by installing the released debian-latest .deb on the distro it is built
for. gdb put it in monocoquesettingsfree() called straight from main().

The early-exit paths (`--help`, `--version`, bad parameters) jump to
cleanup_final before any field of Parameters or MonocoqueSettings is
assigned, and cleanup_final calls monocoquesettingsfree() and freeparams(),
which free every pointer in both. malloc leaves those pointing at whatever
was in the heap block. It is undefined behaviour everywhere; forky's glibc is
simply the first to check, which is why the same source looked healthy on
Debian stable and both Fedoras.

calloc in all three entry points -- monocoque.c, monocoque-cli.c (the `monocoque`
binary) and monocoque-gui.c.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(sound): return from sounddev_init so shaker devices survive setup

Only 2 of 24 configured sound devices came up -- "Could not initialize Sound
Device" for the other 22 -- and no shaker fired, on a rig whose PipeWire graph
looked perfect: monocoque streams connected into all six filter chains, every
node running.

sounddev_init() is declared int and fell off its end without returning, so
new_sound_device() read whatever was left in the return register and treated
that as the error code. The PulseAudio streams had already connected by then;
the device objects were simply freed and never fed telemetry again, which is
why the graph looked right and nothing shook.

Undefined behaviour, so it varies by build: the same config drives shakers
from a locally compiled monocoque and not from the packaged one. Now returns
usb_generic_shaker_init()'s own result.

Verified against a live Assetto Corsa session on real hardware: 26 devices
initialised, no failures, shakers working.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(gui): stop gmonocoque segfaulting on a config without an api key

gmonocoque died before drawing a window, in libconfig:

  #0 config_setting_get_member () from libconfig.so.9
  #1 config_setting_lookup ()
  #2 populate_device_list ()

find_default_config() required sim, api and car to all be present on an
entry and skipped the entry if any lookup failed, so it returned -1;
populate_device_list passed that -1 straight to config_setting_get_elem,
got NULL back, and config_setting_lookup dereferenced it.

No real config has all three. conf/monocoque.config -- the example this
project's own README points at -- sets sim and car and never mentions api,
so this crashed for anyone following the documentation. It stayed hidden in
the Flatpak build only until that manifest was given access to the real
~/.config/monocoque; against an empty config there was nothing to look up.

A key that isn't there no longer disqualifies a match, a -1 falls back to
the first entry (which is what a single-entry config means anyway), and both
NULL paths now return with a message instead of dereferencing. Verified by
rebuilding the Flatpak and launching gmonocoque against the real config that
crashed it: the window opens and stays up.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 16:26:53 -04:00
2026-08-21 15:26:52 -04:00
2025-07-14 00:15:47 -04:00
2024-09-19 18:53:04 -04:00
2026-08-18 16:39:24 -04:00
2026-05-25 19:54:08 -04:00
2022-12-23 22:42:37 +00:00

Monocoque

___   |/  /____________________________________ ____  ______ 
__  /|_/ /_  __ \_  __ \  __ \  ___/  __ \  __ `/  / / /  _ \
_  /  / / / /_/ /  / / / /_/ / /__ / /_/ / /_/ // /_/ //  __/
/_/  /_/  \____//_/ /_/\____/\___/ \____/\__, / \__,_/ \___/ 
                                           /_/

Cross Platform device manager for driving and flight simulators, for use with common simulator software titles.

📚 Usage Documentation: spacefreak18.github.io/simapi/

Features

  • Updates at 60 frames per seconds.
  • Modular design for support with various titles and devices.
  • Supports bass shakers, tachometers, several wheels and pedals, simlights, simwind etc, through usb and arduino serial.
  • Tachometer support is currently limited to the Revburner model. Supports existing revburner xml configuration files.
  • Includes utility to configure revburner tachometer
  • Can send data to any serial device. So far only tested with arduino. and ESP32. Includes sample arduino sketch for sim lights, simwind, and simhaptic effects for motors.
  • Support for custom arduino (or any serial) device, with a custom lua format for sending data
  • Convincing shaker effects for noise tranducers for wheel slip, wheel lock, and abs, as well as engine rpm and gear shifts.
  • Support for many wheels and pedals including Clubsport Elite V3, Logitech G29, and Moza R5.

Adding More Devices

Quick Install

One-Line Installation:

curl -fsSL https://raw.githubusercontent.com/Spacefreak18/monocoque/master/install.sh | bash

AUR Package following git master: https://aur.archlinux.org/packages/monocoque-git

Or download and review first:

wget https://raw.githubusercontent.com/Spacefreak18/monocoque/master/install.sh
chmod +x install.sh
./install.sh

Installation on Immutable Distros (Bazzite, Silverblue, etc.)

On immutable distributions where native package managers are unavailable, monocoque can be installed inside a distrobox container:

bash tools/distro/distrobox/install-distrobox.sh

This creates an Arch Linux container, installs all packages via AUR, and sets up wrapper scripts (start-simd, start-monocoque, test-monocoque) in ~/.local/bin/.

To uninstall: bash tools/distro/distrobox/uninstall-distrobox.sh

TUI Manager: After installation, use the interactive manager:

monocoque-manager

Supported Games Supported Sims please note on Linux some titles will require a compatibility exe from simshmbridge to be setup. Please follow the linked Documentation for installation instructions

Building

  • libserialport - arduino serial devices
  • hidapi - usb hid devices (hidraw)
  • portaudio - sound devices (haptic bass shakers)
  • libpulse - sound devices (haptic bass shakers)
  • libuv base event loop
  • libxml2
  • argtable2
  • libconfig
  • xdg-basedir
  • lua
  • libproc2
  • libcurl4
  • libgtk3
  • libglu1-mesa
  • simapi
  • slog (static)
  • nappgui (static) (for GUI) (sorta optional)
  • simshmbridge - for sims that need shared memory mapping like AC and Project Cars related.
pacman -Syu git cmake pulse-native-provider libxdg-basedir libserialport libconfig libuv argtable hidapi lua libproc2

This code depends on the shared memory data headers in the simapi repo. When pulling lastest if the submodule does not download run:

git submodule sync --recursive
git submodule update --init --recursive

Then to compile simply:

mkdir build; cd build
cmake ..
make

User Setup Guide

See the dedicated How To for detailed instructions to set up and run 'monocoque`

Testing

./monocoque test -vv # Make sure that ~/.config/monocque/monocoque.config only contains the devices you have connected.

Logs file location

~/.cache/monocoque/*.log

Static Analysis

    mkdir build; cd build
    make clean
    cmake -Danalyze=on ..
    make

Valgrind

    cd build
    valgrind -v --leak-check=full --show-leak-kinds=all --suppressions=../.valgrindrc ./monocoque play

Join the Discussion

Sim Racing Matrix Space

ToDo

  • add frequency cap (low pass filter) to sound haptic effects
  • add road and kerb sound haptic effects
  • windows port
  • more memory testing
  • cleanup tests which are basically just copies of the example from their respective projects
  • much, much more
S
Description
No description provided
Readme
1.5 MiB
Languages
C 77.9%
Shell 7%
Makefile 5.2%
Python 5.1%
CMake 2.2%
Other 2.6%