Compare commits

..
398 Commits
Author SHA1 Message Date
Paul Dino Jones e32cac5666 Allow to automatically spawn pulseaudio daemon 2026-03-03 23:08:00 -05:00
Paul Dino Jones 93a967ec15 Update to latest simapi for RaceRoom support 2026-02-28 16:04:31 -05:00
Paul Dino Jones db6b5b027c Add link to guide for reverse engineering 2026-02-14 13:45:02 -05:00
dafteran4 76b7d4dafc Noise for haptics (#31) 2026-02-14 12:32:14 -05:00
dafteran4 f7df9ab90e Low latency (#32) 2026-02-13 11:13:33 -05:00
dafteran4 5781518f44 sound: Fix frequency handling and add RPM rev test (#29)
- Change curr_frequency from uint32_t to double for precise frequency
  control
- Remove get_closest_frequency() and change phase calculation in engine
  sound to ensure continuous sine curve
- Add RPM revving test
2026-02-12 14:29:10 -05:00
Paul Dino Jones ce05f0d78b Update to latest simapi for Forza support 2026-02-11 10:52:13 -05:00
Paul Dino Jones 7415ecf85f use separate debian control for each build 2026-02-08 11:42:37 -05:00
Paul Dino Jones 6b84a85639 Added new files to build from new version of simapi 2026-02-07 10:57:21 -05:00
Paul Dino Jones 38e13be623 updated to lastest simapi for Wreckfest 2 Support 2026-02-07 10:47:57 -05:00
Paul Dino Jones 2433417cf6 restructure some libuv stuff 2026-02-06 17:54:17 -05:00
Paul Dino Jones 5b1ac7c74a Improve handling of shutdown when in udp mode 2026-01-27 01:43:01 -05:00
Paul Dino Jones 24a5811b07 update to latest simapi 2026-01-25 19:09:51 -05:00
Paul Dino Jones 00a177fd2f Improve verbiage around invalid config file 2026-01-20 18:11:55 -05:00
Paul Dino Jones acd52f78dd fix small issues with command line parameters 2026-01-20 18:11:55 -05:00
Paul Dino Jones 0b1014763e move tyre diameter calculations and diameters config saving out of haptic effect device specific logic 2026-01-15 18:18:29 -05:00
Paul Dino Jones 37c8fb94d4 move finished rpm to github workspace 2026-01-12 15:31:52 -05:00
Paul Dino Jones ec1690b49d hardcode directory of generated rpm file 2026-01-12 15:22:22 -05:00
Paul Dino Jones 7478e4e010 run on creation of any new tag 2026-01-12 15:14:50 -05:00
Paul Dino Jones bcb633e774 fix typo on file type 2026-01-12 15:11:58 -05:00
Paul Dino Jones ac6c996602 create rpm build dirs first 2026-01-12 15:08:22 -05:00
Paul Dino Jones fb0ab4b96b fix checkout command 2026-01-12 15:06:22 -05:00
Paul Dino Jones 7cde3b39fa Add rpm workflow 2026-01-12 15:04:37 -05:00
Paul Dino Jones 270bf256b7 add libxml2 dependency 2026-01-12 12:00:37 -05:00
Paul Dino Jones 70f0ca1b50 adding first attempt at rpm spec file 2026-01-12 11:47:43 -05:00
Paul Dino Jones 6091e5f9dc fix spelling error 2026-01-10 15:34:37 -05:00
Paul Dino Jones b968dccd28 matrix based package name 2026-01-10 15:33:54 -05:00
Paul Dino Jones fe644ea6bd added system info action 2026-01-10 15:15:19 -05:00
Paul Dino Jones d18a420449 update package release names 2026-01-10 15:09:05 -05:00
Paul Dino Jones 9983149d0e update to build latest ubuntu and debian packages 2026-01-10 15:02:33 -05:00
Paul Dino Jones e3fde9b71e update to build ubuntu and debian packages 2026-01-10 15:00:24 -05:00
Paul Dino Jones 59da0dd7e3 update to build ubuntu and debian packages 2026-01-10 14:59:33 -05:00
Paul Dino Jones 1f236737f2 update to build ubuntu and debian packages 2026-01-10 14:54:58 -05:00
Paul Dino Jones 4fd4654909 update to build ubuntu and debian packages 2026-01-10 14:51:10 -05:00
Paul Dino Jones 4ba6dec508 update to use self hosted runner debian-latest 2026-01-10 12:47:46 -05:00
Paul Dino Jones 3bea423613 update to use self hosted runner 2026-01-10 12:05:03 -05:00
Paul Dino Jones 1ee07edcc5 fix typo 2026-01-09 17:33:56 -05:00
Paul Dino Jones b09acd5bf0 use -p to create dirs 2026-01-09 17:23:39 -05:00
Paul Dino Jones 410e197723 try to apt update 2026-01-09 17:20:20 -05:00
Paul Dino Jones 4ed5ed50c4 try ubuntu 24 2026-01-09 17:16:41 -05:00
Paul Dino Jones 38120c0ea6 try ubuntu latest 2026-01-09 17:14:59 -05:00
Paul Dino Jones e738261512 Fix bad label 2026-01-09 17:12:14 -05:00
Paul Dino Jones d8d747a168 Add libpulse dependency 2026-01-09 17:03:18 -05:00
Paul Dino Jones cd084f183b Add step to checkout submodultes 2026-01-09 17:01:03 -05:00
Paul Dino Jones 30e704a6b1 Add step to install dependencies 2026-01-09 16:57:42 -05:00
Paul Dino Jones 49844dce11 fix indentation problem 2026-01-09 16:52:13 -05:00
Paul Dino Jones 2e4286233d fix indentation problem 2026-01-09 16:51:04 -05:00
Paul Dino Jones 4ba4dce451 fix indentation problem 2026-01-09 16:49:35 -05:00
Paul Dino Jones c8f2010c8e update README 2026-01-09 16:41:58 -05:00
Paul Dino Jones a379c32e7a monocoque debian package 2026-01-09 16:40:12 -05:00
Paul Dino Jones 46becd1cee Adding debian package control file 2026-01-09 12:47:32 -05:00
Paul Dino Jones 94968c3d4c updated readme 2026-01-07 01:01:08 -05:00
Paul Dino Jones 20ee6b7446 Adding support for Logitech G29 Wheel 2026-01-06 21:14:10 -05:00
Paul Dino Jones 1c4f20d7a7 updated readme to point to new supported sims chart 2026-01-05 13:05:11 -05:00
Paul Dino Jones 9fe8d0871d update to latest simapi for Dirt2 support 2025-12-30 11:40:40 -05:00
Paul Dino Jones 1f5823bce0 allow for non set cars to atleast use provided tyre diameters 2025-12-24 16:23:03 -05:00
M4X1K02 582c031755 feat: Add universal installer and TUI manager (#26)
* feat: Add universal installer and TUI manager

This vibe-coded project now includes a comprehensive installation system
that simplifies monocoque setup across all major Linux distributions.

Key Features:
- Universal installer (install.sh) with automatic distribution detection
- Installs binaries to ~/.local/share/monocoque (user-local, no root needed)
- Creates launcher scripts in ~/.local/bin (start-simd, start-monocoque, test-monocoque)
- Interactive TUI manager (monocoque-manager) for service management
- Complete uninstaller (tools/uninstall.sh) with selective removal
- Dynamic systemd service generation for auto-start capability

Installation Components:
- install.sh: One-command installation across Arch, Debian/Ubuntu, Fedora, openSUSE
- tools/monocoque-manager: Python TUI for real-time status monitoring
- tools/uninstall.sh: Clean removal with config/log preservation options
- Updated README.md with quick install instructions

Architecture:
- User-local installation (no system pollution)
- Binaries: ~/.local/share/monocoque/{monocoque,simapi,simshmbridge}/
- Configs: ~/.config/{monocoque,simd}/
- Launchers: ~/.local/bin/{start-*,test-*,monocoque-manager}
- Services: ~/.config/systemd/user/ (generated dynamically)

Distribution Support:
- AUR integration for Arch users (fastest installation path)
- Native package manager integration (pacman, apt, dnf, zypper)
- Comprehensive dependency handling and build automation

This reduces installation time from 30-60 minutes to 5-15 minutes while
providing better user experience and easier maintenance.

Tested on Garuda Linux (Arch-based) - successful installation, operation, and cleanup.

* refactor: address PR feedback and improve XDG compliance

- Consolidate installers: removed universal-install.sh in favor of install.sh
- Fix XDG compliance: updated install.sh, uninstall.sh, and monocoque-manager to respect XDG_DATA_HOME, XDG_CONFIG_HOME, and XDG_CACHE_HOME with proper fallbacks
- Remove --no-daemon flag from simd launcher and systemd service as requested
- Improve TUI compatibility: fixed popen execution for Kitty (confirmed working), xfce4-terminal, Alacritty, and xterm
- Add documentation: added references to spacefreak18.github.io/simapi/ in README and installer
2025-12-23 17:11:51 -05:00
Paul Dino Jones 9ce8a615a2 move duplicate loop release code to its own function 2025-12-22 22:44:47 -05:00
Paul Dino Jones 6bc921c955 update to latest simapi 2025-12-22 22:44:19 -05:00
Paul Dino Jones dc32dd2062 Update to latest simapi for car from outgauge 2025-12-18 00:23:45 -05:00
Paul Dino Jones 220646cfe5 update to latest simapi for ACEvo and ACRally support 2025-12-14 17:46:27 -05:00
Paul Dino Jones f7f4c00beb update to latest simapi for Assetto Corsa Rally support 2025-12-13 13:04:38 -05:00
Paul Dino Jones 7a91d3d0a1 fix flipped rpm and maxrpm in moza device update signature 2025-12-13 11:51:44 -05:00
Paul Dino Jones 9e2ed33bfb update to latest simapi to fix outgauge mapping 2025-12-12 15:39:57 -05:00
Paul Dino Jones 9ef8c5c1ee update to latest simapi for BeamNG workaround 2025-12-12 15:33:07 -05:00
Paul Dino Jones 187521a905 thread showstats so it does not go crazy 2025-12-12 15:26:50 -05:00
Paul Dino Jones 871a2b9a80 update to latest simapi to fix small issue using simd with udp sims 2025-12-12 12:22:59 -05:00
Paul Dino Jones 7687a95025 pull in simapi update to fix mapping issue with outgauge 2025-12-12 10:22:57 -05:00
Paul Dino Jones df49e8a3cc add support for BeamNG 2025-12-11 20:21:36 -05:00
Paul Dino Jones c5b4f872d3 Add basic support for Live For Speed through OutGauge and Outsim protocols 2025-12-11 17:49:39 -05:00
Paul Dino Jones 5ac70779d7 pull latest simapi to fix too many files bug 2025-11-27 19:12:32 -05:00
Paul Dino Jones 0b2685ac3f update to latest simapi to fix gear int value 2025-11-23 13:50:35 -05:00
Paul Dino Jones 42efd815df add lua dependency to README 2025-11-22 11:39:41 -05:00
Paul Dino Jones 8aadf53dc0 updated to latest simapi 2025-11-22 09:28:20 -05:00
Paul Dino Jones 09e200f16c update to latest simapi 2025-11-18 12:25:28 -05:00
Paul Dino Jones 7e0ce63e26 fix type for fourth gear 2025-11-10 13:02:15 -05:00
Paul Dino Jones 5bb1f1715c use new enums for flag and gear 2025-11-10 11:27:10 -05:00
Paul Dino Jones b96c6006ed fix issue with diameters.config not using gameid. Update to latest simapi 2025-10-28 12:18:59 -04:00
Olly Smith e32596d723 Initial support for latest Moza firmware LED controls (#25) 2025-10-28 01:39:33 -04:00
Paul Dino Jones ac04fd8e0a init and destroy logging with thread safety 2025-10-28 00:26:04 -04:00
Paul Dino Jones 2a86e3b2f9 add compilation targets for new mapping structure 2025-10-23 14:01:18 -04:00
Paul Dino Jones 989ccc5459 Updated to latest simapi 2025-10-23 13:52:24 -04:00
Paul Dino Jones 5fcb7f128d Add gearc to lua and to test sequence 2025-10-22 14:36:59 -04:00
Paul Dino Jones 90fb8969d4 working custom serial 2025-10-20 19:37:28 -04:00
Paul Dino Jones 4b94e68d6c consolidate cleanup gotos 2025-09-01 19:30:43 -04:00
Paul Dino Jones 7271a26e23 clean up argument parsing a little 2025-09-01 17:24:26 -04:00
Paul Dino Jones 6b5e16f59d fix freeing of xdg handle when help is specified 2025-09-01 11:52:52 -04:00
Paul Dino Jones e0337125d3 Add beginnings of custom arduino devices. 2025-09-01 11:38:36 -04:00
Paul Dino Jones 638c7d29c3 update to lastest simapi 2025-09-01 10:59:03 -04:00
Sebastian NoeandSebastian Noe edde4e2cad Provide instructions to set up monocoque (#24)
* add consolidated instructions on how to run monocoque

* reference config test

* reference user setup guide

---------

Co-authored-by: Sebastian Noe <sebastian.schneider@boxine.de>
2025-08-31 21:57:41 -04:00
Paul Dino Jones ae8904b7cf fix formatting of monocoque.config 2025-08-31 19:20:58 -04:00
Paul Dino Jones b484d7e5da add newer and better examples to monocoque.config 2025-08-31 19:14:33 -04:00
Paul Dino Jones 96a5e689ff Update to latest simapi 2025-08-29 19:15:15 -04:00
Paul Dino Jones 7926706ea1 Update to latest simapi to fix tyre diameters 2025-08-29 19:01:46 -04:00
Paul Dino Jones fce4d8e33c updated to latest simapi for tyre diameter and turbo boost 2025-08-28 17:00:08 -04:00
Paul Dino Jones 5fcea3ad88 Add led_clear_range lua function so leds can be cleared without clearing them all for certain effects 2025-08-26 18:05:09 -04:00
Paul Dino Jones e22a8911b8 updated to latest simapi 2025-08-25 20:28:16 -04:00
Paul Dino Jones 29c6ebe7a2 Update to latest simapi 2025-08-25 17:46:48 -04:00
Paul Dino Jones fc21669d81 Add disable_audio flag 2025-08-15 04:19:39 -04:00
Paul Dino Jones 03b1654112 Fix gear and engine effects remove some unnecessary code 2025-07-30 03:32:41 -04:00
Morgan Garcia 40bb0b2929 Update moza.c
Change MOZA_MAGIC_VALUE back to 0x0d from 13.
2025-07-29 20:43:49 -04:00
Morgan Garcia e13faeabc7 Update moza.c
Changed MOZA_TIMEOUT back to 1000.
2025-07-29 20:43:49 -04:00
Morgan Garcia f66af0d424 Update moza.c
moza_update function

Updated variable name to perctflt and changed the value to multiply the quotient of rpm/maxrpm by 100.

Made int perct variable to round perctflt to nearest whole number.

Updated LED activation ranges so that all 10 LEDs get activated when given rpm percentage is reached.
2025-07-29 20:43:49 -04:00
Morgan Garcia 477fcd9c6c Update gameloop.c
Reverted back to default from Spacefreak18 source now that I've tested and gotten the LEDs working.
2025-07-29 20:43:49 -04:00
Morgan Garcia f853cd9f79 Update gameloop.c
Text output update
2025-07-29 20:43:49 -04:00
Morgan Garcia 924354afa1 Update moza.c
Fixed error in BIT number increasing.
2025-07-29 20:43:49 -04:00
Morgan Garcia 409a6b7707 Update gameloop.c
Comment out normal LED test.

Added test for quicker push to the wheel for troubleshooting.
2025-07-29 20:43:49 -04:00
Morgan Garcia d59e46cc64 Update moza.c
moza_update values updated for LED test.

MOZA_PAYLOAD_SIZE added per update from Spacefreak18
2025-07-29 20:43:49 -04:00
Morgan Garcia ba4c96a3f0 Update moza.c
Updated MOZA_SERIAL_TEMPLATE[3] from 0x17 to 0x13 which fixed communication issues with the device.
2025-07-29 20:43:49 -04:00
Paul Dino Jones f5a2b38ee2 Bump to latest simapi for unix timestamp ticks. Push unix timestamp ticks to lua variable. Update test logic to test on 8000 rpms. Update example lua scripts with examples of led rpm blink. 2025-07-15 16:39:41 -04:00
Paul Dino Jones 59d2ff935f fix serial receiving 2025-07-14 00:15:47 -04:00
Paul Dino Jones 34b258ab1b fix misleading log message 2025-06-16 13:19:13 -04:00
Paul Dino Jones 9261123491 accept usbwheel for wheel on usb devices in config 2025-06-16 13:02:34 -04:00
Oleg Makarenko 73c59f5b29 Add Simagic GT Neo to the udev rules, opening hidraw 2025-06-15 22:59:41 -04:00
Oleg Makarenko aaf0e4b6bc Add lua config for Simagic GT Neo 2025-06-15 22:59:41 -04:00
Oleg Makarenko 6d5b34f4b9 Add GT Neo LED update feature 2025-06-15 22:59:41 -04:00
Paul Dino Jones e5cee3c228 update to latest simapi for lmu support 2025-06-14 19:11:44 -04:00
Paul Dino Jones 9edd275984 Update to latest simapi for improvements to tyre diameter detection 2025-04-30 19:07:05 -04:00
Paul Dino Jones af060ff574 update to latest simapi to fix detecting diameters while simd is running 2025-04-29 00:01:39 -04:00
Paul Dino Jones ab956af9cb fix code around generating diameters config 2025-04-29 00:00:58 -04:00
Paul Dino Jones f81588a2a5 Re-enable shared memory test prog 2025-04-28 20:38:34 -04:00
Mon ouïe 808be1aec0 Add udev rule for Simagic P1000 support 2025-04-21 14:09:46 -04:00
Mon ouïe 3733261647 Fix HID send report commands for Simagic P1000 Haptic modules 2025-04-21 14:09:46 -04:00
Paul Dino Jones 1a1ede9f4b add function to expand tilde and expand tilde on device specific config files 2025-04-07 10:56:38 -04:00
Paul Dino Jones a3d0cbcb43 small cleanup to fix memory leaks 2025-04-07 10:56:38 -04:00
Paul Dino Jones c0680515ae add -c for specified config file option 2025-04-07 10:56:38 -04:00
Paul Dino Jones cd5be23235 fix issue with freeing lua file on cammus c12 2025-03-27 17:12:23 -04:00
Paul Dino Jones af37299d25 Add extra log information on revburner 2025-03-27 15:52:51 -04:00
Paul Dino Jones 8a2ce50187 improvements for cammus c12 2025-03-27 15:38:35 -04:00
Paul Dino Jones dbe6908386 fix arduino lua device free 2025-03-27 14:47:34 -04:00
Paul Dino Jones 51cc376eb9 Temporarily remove feature to ignore reattempting to open a serial device after it had failed once. Increase number of allowed serial device blocks to 20. 2025-03-27 01:51:37 -04:00
Paul Dino Jones 415526c4d3 Move release of serial adapter to before underlying device is released 2025-03-26 18:25:26 -04:00
Paul Dino Jones 52f5c824f8 Fix some pulseaudio stuff 2025-03-26 17:35:05 -04:00
Paul Dino Jones ce200b8d21 Improve logging over device specific configs 2025-03-26 16:41:18 -04:00
Paul Dino Jones e110ac50d2 remove debug build hardcode 2025-03-26 15:20:43 -04:00
Paul Dino Jones d589147552 actually pass the config file around 2025-03-26 15:16:04 -04:00
Paul Dino Jones d9cdd18bf9 Move device specific config file test to more logical spot 2025-03-26 15:01:06 -04:00
Paul Dino Jones 4db0f6dff1 Fix tachometer config 2025-03-26 13:03:50 -04:00
Paul Dino Jones a290a346cb Fix leak in arduino lua 2025-03-26 12:35:16 -04:00
Paul Dino Jones 4fd2658a98 Remove log entries 2025-03-26 11:58:39 -04:00
Paul Dino Jones 79f0ceff28 Cleanup pulseaudio code 2025-03-26 11:58:05 -04:00
Paul Dino Jones fdd5f0b7ba Fix leak in xdglib 2025-03-26 11:57:40 -04:00
Paul Dino Jones 0d29fd7005 fix leak in config 2025-03-26 11:56:31 -04:00
Paul Dino Jones b68af9c8b9 fix leak in cammus c12 2025-03-26 11:56:04 -04:00
Paul Dino Jones 12570f5caf fix leak in wheel device 2025-03-26 11:55:43 -04:00
Paul Dino Jones 4a0c33d5a5 Fix leak in serial adapter 2025-03-26 11:55:18 -04:00
Paul Dino Jones 831a9d00e1 Fix segfault freeing cammus c12 2025-03-25 14:57:52 -04:00
Paul Dino Jones 2b2ae31907 Rename to car radar.lua 2025-03-25 14:03:58 -04:00
Paul Dino Jones 593a415cd9 fix colors 2025-03-25 13:54:16 -04:00
Paul Dino Jones a4acbf5cc7 Fix off by one on rgb math 2025-03-25 13:52:22 -04:00
Paul Dino Jones e92ba3dd25 Add example for cars alongside 2025-03-25 13:25:11 -04:00
Paul Dino Jones e78fa76e1b Add flags to test loop 2025-03-25 12:57:55 -04:00
Paul Dino Jones 22da3b405c Do not write to rpm leds on cammus c12 2025-03-25 12:31:00 -04:00
Paul Dino Jones 8c1298e7f3 Always write to led 2025-03-25 10:09:39 -04:00
Paul Dino Jones 988468d746 Huge refactor to improve memory efficiency mostly around pulseaudio 2025-03-25 10:04:39 -04:00
Paul Dino Jones 3b1f2e46f3 Remove some unnecessary variables from lua variable setup 2025-03-25 10:04:14 -04:00
Paul Dino Jones 97d935c037 Properly release lua if it is used on cammus 2025-03-25 10:03:38 -04:00
Paul Dino Jones 2660394ccf Fix logging spam 2025-03-24 16:43:09 -04:00
Paul Dino Jones 18f6dc290a Fix segfaults on device specific config files 2025-03-24 15:58:37 -04:00
Paul Dino Jones db081513db Fix issue with serial devices opening when they have already failed once 2025-03-24 15:57:50 -04:00
Paul Dino Jones 8157aa1258 Fix issue with not found configs 2025-03-24 14:22:20 -04:00
Paul Dino Jones 4d1d43821c Fix off by one error. Fix log format 2025-03-24 14:07:16 -04:00
Paul Dino Jones ab3152e9e4 Increase cammus c12 leds 2025-03-24 13:22:45 -04:00
Paul Dino Jones ac17b24cf6 Make sure leds clear each time 2025-03-24 12:13:39 -04:00
Paul Dino Jones 97d69bec9c Fix to use lua on c12 if lua script loads properly 2025-03-24 12:05:49 -04:00
Paul Dino Jones e4b32f1843 Fix issue with arduino leds not clearing 2025-03-24 11:44:44 -04:00
Paul Dino Jones a6353d3469 change buffer log to first byte, probably safe to assume there will be atleast 1 byte in the buffer. 2025-03-23 18:10:03 -04:00
Paul Dino Jones 5ef7b2f683 Fix led lua code so the buffer do not include device specific magic values 2025-03-23 18:05:58 -04:00
Paul Dino Jones 025f88f559 Fix some issues with sound device code 2025-03-22 19:24:15 -04:00
Paul Dino Jones 0fb2571848 Add ability to use lua on cammus c12 2025-03-22 19:16:54 -04:00
Paul Dino Jones d185314a31 Add Suspension travel effect 2025-03-21 19:45:34 -04:00
Paul Dino Jones 5bc02c012d Fix issues with config segfaults 2025-03-21 19:44:55 -04:00
Paul Dino Jones 6ed403e4d5 Add ability to use car proximity for lights 2025-03-21 13:55:56 -04:00
Paul Dino Jones 9a23eef998 Add more logging to config loading 2025-03-21 13:55:21 -04:00
Paul Dino Jones 4e0deaf695 Add AMPLIFY modulation 2025-03-15 23:42:15 -04:00
Paul Dino Jones fd0b28e66f Add lua include dir to cmake 2025-03-11 12:23:02 -04:00
Paul Dino Jones 34cefb5aa7 Fix lua cmake dependency. Use specified frequency as base frequency for engine effects 2025-03-11 12:01:24 -04:00
Paul Dino Jones d846305114 Updating configuration to reflect new simled code 2025-02-25 22:13:49 -05:00
Paul Dino Jones a35354be5b Add support for simhub protocol and custom lua scripts to control leds 2025-02-25 18:41:10 -05:00
Paul Dino Jones 5cc8a1fb1a Updated to latest simapi for getpid improvements 2025-02-19 15:46:44 -05:00
Paul Dino Jones 7711c1939b Update sketches to use 115200 baud 2025-02-12 15:04:38 -05:00
Paul Dino Jones 5d055fd1ad fix improper detecting of usb haptic device 2025-02-01 17:01:50 -05:00
Paul Dino Jones 29fbc7c798 Refactor serial devices so a single open handle is shared throughout 2025-01-25 09:52:38 -05:00
Paul Dino Jones f10540069c moved some confusing code 2025-01-25 09:51:20 -05:00
Paul Dino Jones 86a21d9c89 improve process of closing sound devices 2025-01-25 09:50:11 -05:00
Paul Dino Jones 84dc8a1753 pulling in latest simapi for improvements to pcars2 2025-01-21 17:23:28 -05:00
Paul Dino Jones ce53ff5da1 Adding max frequency and modulation to sound devices 2025-01-21 17:23:10 -05:00
Paul Dino Jones fa3bb6e80f Fix bug causing no tyre effects 2025-01-20 12:13:49 -05:00
Paul Dino Jones 2462dfd0c9 Update to latest simapi, allow sim strings in configs 2025-01-20 10:53:57 -05:00
Paul Dino Jones fefecd76df updated to latest simapi 2025-01-19 15:16:30 -05:00
Paul Dino Jones e9c7264b4e Updated to latest simapi for AC EVO support 2025-01-19 09:57:57 -05:00
Paul Dino Jones c7ee4bad32 fixed sound readme again 2025-01-19 09:57:23 -05:00
Paul Dino Jones 1c279e071f Removed calls to abort 2025-01-18 19:01:52 -05:00
Paul Dino Jones a6146f5644 moved to latest simapi 2025-01-18 13:36:03 -05:00
Paul Dino Jones 23db7cb4dc Add numlights setting 2025-01-18 13:20:56 -05:00
Paul Dino Jones 2676e31094 fix revburner typo 2025-01-18 12:26:23 -05:00
Paul Dino Jones d161eb19c4 Initially adding support for SIMAGIC P1000 Pedals 2025-01-18 03:30:11 -05:00
Paul Dino Jones 4aa7fe6391 lock pulseaudio mainloop while freeing sound devices 2025-01-17 19:41:12 -05:00
Paul Dino Jones 1e6d630be5 use more standard channel map 2025-01-17 18:22:51 -05:00
Paul Dino Jones 9a05458a84 more details in README 2025-01-17 10:41:18 -05:00
Paul Dino Jones 0c8c508dd8 added global refresh rate -f 2025-01-17 10:29:27 -05:00
Paul Dino Jones 7397491eb8 added a few commands to help with sound setup 2025-01-17 10:28:25 -05:00
Paul Dino Jones 637c5b8c6c move logging around to make output a little cleaner 2025-01-16 22:22:49 -05:00
Paul Dino Jones 164b0a1533 remove old commented code 2025-01-16 22:10:44 -05:00
Paul Dino Jones f5eae498ef I knew there was a reason it was commented out. It makes valgrind happy but causes the program to segfault on exit. 2025-01-16 17:00:15 -05:00
Paul Dino Jones 07a51011c6 fix more malloc complaints 2025-01-16 16:57:34 -05:00
Paul Dino Jones 08e2e971e7 fix bad memory management around device threading model 2025-01-16 16:45:37 -05:00
Paul Dino Jones 2cd57396ec updated readme for getting device name 2025-01-16 14:28:29 -05:00
Paul Dino Jones ac8fd3ce56 sound devices stay on main thread 2025-01-16 01:08:00 -05:00
Paul Dino Jones 598e8f9b3a fix some effects in test loop 2025-01-15 23:43:25 -05:00
Paul Dino Jones e3ba5c08ee add sim entry to diameters file 2025-01-15 23:42:57 -05:00
Paul Dino Jones 1c253975e5 add logging for haptic effects, fix consistency of test sequence 2025-01-15 18:16:07 -05:00
Paul Dino Jones 34ae67b788 fix bug in tyre effects and its test 2025-01-15 14:11:42 -05:00
Paul Dino Jones 160c98f46b fixed return of checkbyte for moza 2025-01-15 12:24:08 -05:00
Paul Dino Jones 5f526af1e3 Updated PKGBUILD files to use libpulse 2025-01-15 12:23:34 -05:00
Paul Dino Jones 90960dddda fix floating point issue on moza 2025-01-14 20:23:43 -05:00
Paul Dino Jones 7573583644 temporarily add another step with rpms at 7000 to assist in debugging some wheels 2025-01-14 20:23:11 -05:00
Paul Dino Jones 41c5ceefc7 updated to latest simapi 2025-01-14 18:25:42 -05:00
Paul Dino Jones 079dc9716c fix issues with serial wheel 2025-01-14 18:09:35 -05:00
Paul Dino Jones 3476959f98 Improve config handling 2025-01-14 17:40:07 -05:00
Paul Dino Jones bf4f1f0353 removed unused jansson header 2025-01-13 19:17:42 -05:00
Paul Dino Jones 4fcd4e3be1 Add support for per device fps settings. 2025-01-13 15:16:57 -05:00
Paul Dino Jones ca18f2ff10 updated monocoque PKGBUILDS 2025-01-11 03:19:19 -05:00
Paul Dino Jones 81b85c89f2 moved PKGBUILD to stable folder 2025-01-11 03:18:09 -05:00
Paul Dino Jones 73f3b7c6a9 add example pacman command for dependencies 2025-01-11 03:06:27 -05:00
Paul Dino Jones 27d4472440 Use STARTLED default of 1 2025-01-02 16:21:15 -05:00
Paul Dino Jones 82fa5a7087 Update simlight test 2025-01-02 15:57:13 -05:00
Paul Dino Jones 70da7cf0a3 Add start led 2025-01-02 15:54:46 -05:00
Paul Dino Jones 64229b5318 updated TODO 2024-12-04 14:44:09 -05:00
Paul Dino Jones a6683fd78f updated TODO 2024-12-04 14:42:37 -05:00
Paul Dino Jones ea9ec5b566 disable all tests for now 2024-12-04 12:34:21 -05:00
Paul Dino Jones c4e57b8db8 add code to smooth out frequencies between audio frames 2024-12-04 11:20:21 -05:00
Paul Dino Jones b5211a8ea4 persist phase to stop disjointed sine waves 2024-12-03 20:47:57 -05:00
Paul Dino Jones aa6963529e improve stability of config file loading when multiple configs are in use 2024-11-22 16:21:30 -05:00
Paul Dino Jones 71d1a4cd29 fix issues with simapi mapping correctly when using simd 2024-11-22 16:21:08 -05:00
Paul Dino Jones f57c51eca8 Use more generic sysfs path to find csl elite v3 pedals 2024-11-19 11:57:58 -05:00
Paul Dino Jones 91335c0802 Use latest simapi to improve tyre slip effects 2024-11-19 11:55:55 -05:00
Paul Dino Jones 3ea20310aa stable pkgbuild 2024-11-18 16:53:27 -05:00
Paul Dino Jones 0bec1e0050 Added ampfactor to serial haptic log message 2024-10-10 15:00:39 -04:00
Paul Dino Jones f6def08b01 Add xdg to dependencies 2024-10-06 00:52:17 -04:00
Paul Dino Jones cb2985071f upgraed to latest simapi 2024-10-06 00:49:08 -04:00
Paul Dino Jones 7a46e9daf8 various readme updates 2024-10-06 00:12:50 -04:00
Paul Dino Jones 68ab4f6d45 upgraded to new simapi 2024-10-05 17:10:00 -04:00
Paul Dino Jones ac2f8525e4 Updated to latest simapi 2024-10-05 08:32:01 -04:00
Paul Dino Jones c9b257dc80 Updated to latest simapi 2024-10-05 08:28:26 -04:00
Paul Dino Jones 06da8c2e2e UDP support and upgrade to latest simapi for udp and logging support 2024-10-01 12:46:41 -04:00
Paul Dino Jones 27b793f27e Fix issue not setting correct baud rate through to libserialport 2024-09-30 22:21:35 -04:00
Paul Dino Jones 82a8e79d2b set simhaptic baud to 9600 2024-09-30 20:34:29 -04:00
Paul Dino Jones e2d715ee49 forgot to add submodules 2024-09-19 21:44:22 -04:00
Paul Dino Jones b4801dabf2 Fixed overlook device settings in config processing 2024-09-19 21:22:00 -04:00
Paul Dino Jones 1453c522bf Updated pkgbuild to actually install 2024-09-19 21:21:30 -04:00
Paul Dino Jones d7d3c47d0e Fix a couple things i missed in the merge 2024-09-19 18:59:46 -04:00
Paul Dino Jones 89b2593a56 Reorganization and config updates for Moza wheel 2024-09-19 18:54:16 -04:00
Paul Dino Jones 2361599340 Add ability to specify baud rate in config file 2024-09-19 18:54:12 -04:00
Lawstorant 538ce54b44 Initial work 2024-09-19 18:53:04 -04:00
Paul Jones 232d39b19d Serial8 (#11)
* Using 8 bits per int for serial devices

* Refactor simwind code slightly to improve performance
2024-09-19 17:05:42 -04:00
Paul Dino Jones 08e12546ed Moved baud rate to serial device struct and fixed log message 2024-09-17 10:17:40 -04:00
Paul Dino Jones 9377188cf7 Fix velocity bytes on cammus c12 hid message 2024-09-16 16:48:17 -04:00
Paul Dino Jones d100d570be Support for cammus c12 2024-09-16 16:14:18 -04:00
Paul Dino Jones 5de6b1cb7f Add some robustness to diameters file and slip effect code 2024-09-16 14:08:58 -04:00
Paul Dino Jones c86a7509ad Fix issue with test not having a car set 2024-09-15 12:24:23 -04:00
Paul Dino Jones 56700c8018 Added more checks to make sure sims do not try to set tyre diameters without a car set 2024-09-08 18:49:01 -04:00
Paul Dino Jones edaa7e8b81 Do not compare car if it is null 2024-09-08 18:44:21 -04:00
Paul Dino Jones 5e61e32795 Added more robustness to config lookup 2024-09-06 14:50:00 -04:00
Paul Dino Jones 794f8fb0b0 Added more logging to config load 2024-09-06 14:30:12 -04:00
Paul Dino Jones 56e0d71893 Put default configs closer to the bottom 2024-09-04 16:22:36 -04:00
Paul Dino Jones f962bfa8ef Fix some issues with config loading 2024-09-04 16:15:34 -04:00
Paul Dino Jones c257222509 Add ability to specify baud rate in config file 2024-09-04 12:56:02 -04:00
Paul Dino Jones 723d2e6463 Update loop to 60fps. Update some arduino devices to 115200. Refactor shiftlights code for performance. 2024-09-04 12:16:21 -04:00
Paul Dino Jones 63fe5007b7 Updated config example to support profiles 2024-09-03 16:59:48 -04:00
Paul Dino Jones ce2049a552 Update CMake so project build 2024-09-02 13:24:34 -04:00
Paul Dino Jones 4913e6b8ae Updated to latest simapi 2024-09-02 13:20:28 -04:00
spikerguy 152431cb8b Add supported games list (#9)
* Add supported games list

* readme: get car tyre diameter

* typo
2024-09-02 12:53:22 -04:00
Paul Dino Jones b8df16dd67 Added link to Linux Sim Racing Matrix space 2024-09-02 12:50:06 -04:00
Paul Dino Jones ca17d84c0c Added arch linux PKGBUILD 2024-09-02 12:47:17 -04:00
Paul Dino Jones 820bdaa15a Update to latest simapi 2024-09-02 12:40:40 -04:00
Paul Dino Jones 644cc95ac2 Updated to latest simapi 2024-09-02 12:09:18 -04:00
Paul Dino Jones e25fa700d1 Initialize some data so tyre diameter detection works, and motors spin down. 2024-09-02 11:15:19 -04:00
Paul Dino Jones a1c26b4228 Set gameloop to 8fps for now to avoid issues 2024-09-02 11:13:19 -04:00
Paul Dino Jones c7b3607e33 Improving loop management to prevent double freeing. Fixing other memory issues 2024-09-02 10:43:36 -04:00
Paul Dino Jones 235d4257d4 making log statement more accurate 2024-08-31 16:14:33 -04:00
Paul Dino Jones 7c8273bcde Move some things around and add another indicator to prevent double frees 2024-08-31 16:02:34 -04:00
Paul Dino Jones 15d18bbe8f Fix log statement so it actual outputs the amount of slip 2024-08-31 16:02:04 -04:00
Paul Dino Jones 7c0e17342e Major overhault to add libuv event loop. Enhancements to config file to support profiles. 2024-08-30 13:46:56 -04:00
Paul Dino Jones 8f59254c67 update to latest simapi 2024-08-12 23:50:18 -04:00
Paul Dino Jones d97e919d7c Update to latest simapi to fix gear in truck sims 2024-08-11 23:48:00 -04:00
Paul Dino Jones 49b0d764c9 Add SCS Truck Sim support 2024-08-11 23:28:29 -04:00
Paul Dino Jones 7714c2cb8e Move from libusb to hidraw backend hid api 2024-08-11 20:12:27 -04:00
Paul Dino Jones cb39d17b22 Refactored wheel diameters config logic 2024-08-08 21:19:52 -04:00
Paul Dino Jones fedbf473bb Set useconfig before initializing devices 2024-08-08 15:02:55 -04:00
Paul Dino Jones d62e4c7d1b Fixing issue with diameters file. Disabling diameters config checking during monocoque test. Additonal logging 2024-08-08 00:28:54 -04:00
Paul Dino Jones 89e49353e4 setting uninitialized values on sound devices 2024-08-08 00:28:03 -04:00
Paul Dino Jones 007a786c14 No longer abort on one failed write to a serial device. Log error instead. 2024-08-06 16:45:29 -04:00
Paul Dino Jones e194642d6e Add Reverse for Cammus C5 2024-08-06 10:06:49 -04:00
Paul Dino Jones 9eb1cd75b0 Update gameloop so it sets gear to neutral on shutdown. Add enum for gears. 2024-08-06 10:06:24 -04:00
Paul Dino Jones ae9293ba08 Fix issue with bad data being send to cammus wheel on quit 2024-08-05 17:08:23 -04:00
Paul Dino Jones 5b24faa7f1 Fix include paths 2024-08-05 17:07:04 -04:00
Paul Dino Jones cf61b8a4e5 Add more logging for cammus 2024-08-05 16:43:47 -04:00
Paul Dino Jones df199b5f5c clear bytes on each update 2024-08-05 16:31:58 -04:00
Paul Dino Jones ca4f1654fa Fix gear 2024-08-05 16:18:51 -04:00
Paul Dino Jones 622e46a42f Using correct pid for cammus 2024-08-05 16:11:29 -04:00
Paul Dino Jones d5c0c485cf Small fixes for speed and gear 2024-08-05 16:10:15 -04:00
Paul Dino Jones c983cb2b4e rpm margin must return as an integer 2024-08-05 14:49:32 -04:00
Paul Dino Jones 8d04c3aa04 Initial attempt at adding support CammusC5 wheel with underlying code for future wheels. 2024-08-05 13:42:17 -04:00
Paul Dino Jones 270a075292 Reverse regression in previous commit 2024-08-04 17:07:09 -04:00
Paul Dino Jones c36658e0e1 Refactor motor haptic effect slightly. Add logging. 2024-08-04 14:58:01 -04:00
Paul Dino Jones e4634721a1 Pull in and use latest simapi 2024-07-28 19:02:40 -04:00
Paul Dino Jones 2129299f5f Start sound devices with frequency set to 0 to avoid loud start ups 2024-07-28 11:18:41 -04:00
Paul Dino Jones 3fc3ce3ea0 Fix small buffer overflow on the diameters file string 2024-07-28 11:00:26 -04:00
Paul Dino Jones 254c891528 Update to latest simapi to fix issues with file descriptors 2024-07-28 02:23:45 -04:00
Paul Dino Jones 0c74666409 Add more logging for mem freeing 2024-07-28 02:08:18 -04:00
Paul Dino Jones 82c45f1bca update to latest simapi to bypass wrong behavior 2024-07-28 02:06:44 -04:00
Paul Dino Jones bb5c2069c9 Added extra logging. Added code to free mapped memory and file descriptors 2024-07-27 20:32:09 -04:00
Paul Dino Jones ac749cebfa Fix issue with tyre effects on sound devices 2024-07-27 20:09:24 -04:00
Paul Dino Jones e125b33a85 update to latest simapi 2024-07-27 19:51:17 -04:00
Paul Dino Jones 6e041152a2 More support for beyond stereo 2024-07-22 21:45:57 -04:00
Paul Dino Jones 6945b026e9 Better handle volume math 2024-07-20 20:15:16 -04:00
Paul Dino Jones b7c5e1a9fa Updated readme with some instructions on bass shakers 2024-07-20 16:39:53 -04:00
Paul Dino Jones 178c16b0d7 Add ability to use sound cards with more than 2 channels. 2024-07-20 16:31:17 -04:00
Paul Dino Jones 5dcc69b2a2 Updated slog dependency 2024-07-17 17:30:00 -04:00
spikerguy f56bf19d17 Add Arduino upload, Test cmd and log location (#6)
* add log, arduino upload and Test

* use correct path

* add haptic nodes

* readme: add haptic and arduino motor connection
2024-07-17 10:14:28 -04:00
Paul Dino Jones dea445cafa Added log statement for ampfactor 2024-07-13 14:46:36 -04:00
Paul Dino Jones db83fc9aca Add ampfactor to control final motor power 2024-07-13 14:21:35 -04:00
Paul Dino Jones 234cf064a3 Add abs brake test 2024-07-13 12:48:05 -04:00
Paul Dino Jones b4742a2a8a Cleanup and fix issue that could cause abs to not work. 2024-07-13 11:36:21 -04:00
Paul Dino Jones befe49fd5c Set the fallback threshold for tyre slip effects to zero 2024-07-13 09:40:27 -04:00
Paul Dino Jones 67e04257ba Update so multiple defined serial haptic effects do not conflict with eachother. 2024-07-13 09:38:00 -04:00
Paul Dino Jones 813308c20f Fix issues with data not being correctly sent to motors for sim haptic. 2024-07-12 20:42:55 -04:00
Paul Dino Jones bfcb578bb1 Fix dumb issues with haptic arduino code. Add tyre slip vibrations to test script. 2024-07-09 17:14:40 -04:00
Paul Dino Jones 793d5b6f16 Add sim haptic arduino logic and config variables 2024-07-09 15:46:51 -04:00
Paul Dino Jones 411c8c5340 Move haptic effect data into it's own structure. 2024-07-03 19:18:39 +00:00
Paul Dino Jones f8237798a7 Add haptic effect to serial haptic device type 2024-07-01 22:45:54 +00:00
Paul Dino Jones dfbd2542b4 Add basic support for arduino haptic motors 2024-07-01 15:23:46 +00:00
Paul Dino Jones 8acd05f4c7 Improve handling of devices referenced in config but not actually able to be used for some reason 2024-06-27 20:20:13 +00:00
Paul Dino Jones 0df46cff76 Refactor diameter save file into libconfig to save a dependency. 2024-06-11 16:42:29 -04:00
Paul Dino Jones 1e1dbb9f2e Updated config file example 2024-06-11 10:53:26 -04:00
Paul Dino Jones 16b81fcc98 Send string around for diameters file 2024-06-11 14:41:30 +00:00
Paul Dino Jones 92f48d3bb0 Fix some issues with pulseaudio not stopping properly. 2024-06-11 14:29:09 +00:00
Paul Dino Jones 9a576ed19d Add support for save file for tyre diameters 2024-06-10 00:46:11 +00:00
Paul Dino Jones 424c691b2a Update to latest simapi 2024-06-10 00:45:21 +00:00
Paul Dino Jones 676fb8047f Initialize tyre diameters 2024-06-10 00:44:51 +00:00
Paul Dino Jones 1d49673804 Remove need to specify values for usb pedal rumble effects. 2024-06-07 17:40:53 +00:00
Paul Dino Jones c846e7517b Add attempt at ABS effect. Small refactorings 2024-06-07 04:21:08 +00:00
Paul Dino Jones 4c3318bfe8 Use correct sysfs path for csl elite v3 pedals 2024-06-07 03:02:53 +00:00
Paul Dino Jones fdf06503db Refactor implementation of CSL Elite V3 Pedals 2024-06-06 21:42:08 +00:00
Paul Dino Jones 0e4bac6885 Refactor tyre effects to take threshold input from config file. Spell threshold correctly. 2024-06-05 04:21:39 +00:00
Paul Dino Jones 5744276a94 Update valgrindrc to ignore libs outside project 2024-06-05 04:20:23 +00:00
Paul Dino Jones f393327a87 Refactor effects into separate module 2024-06-05 03:43:48 +00:00
Paul Dino Jones 2f8b40be9f Refactored tyre slip calculations 2024-06-03 18:42:16 -04:00
Paul Dino Jones 05da884e6b Update to latest simapi to support new tyre slip calculations. 2024-06-03 18:40:50 -04:00
Paul Dino Jones bd6176fbcb Cleanup tyre locking implementation 2024-06-01 18:07:37 +00:00
Paul Dino Jones 7ca5371bf2 Implement tyre locking. Cleanup test gameloop 2024-05-30 20:39:47 +00:00
Paul Dino Jones f62a67c778 Update to latest submodule 2024-05-30 18:27:41 +00:00
Paul Dino Jones 364d4be558 Fix tachometer config error handling 2024-05-30 18:25:47 +00:00
Paul Dino Jones d7498e86cb Fix wheel slip calculations 2024-05-30 18:03:26 +00:00
Paul Dino Jones e3a98b6284 Fix compilation error on portaudio codepath 2024-05-30 17:25:07 +00:00
Paul Dino Jones 1b2256abce Add usbhaptic support 2024-05-30 17:07:44 +00:00
Paul Dino Jones 30f34a5d8f Add wheelslip and abs to test loop 2024-05-28 16:12:48 +00:00
Paul Dino Jones d6ef631d06 Updated to latest simapi 2024-03-09 13:39:12 -05:00
Paul Dino Jones d4f32881ab Updated to latest simapi 2024-03-09 13:36:18 -05:00
Paul Dino Jones 3863acde71 Fix wrong data type for velocity 2024-03-05 17:23:29 -05:00
Paul Dino Jones fb1925be2d Fix compilation issue for wheel slip 2024-03-05 00:36:34 -05:00
Paul Dino Jones 83ffb32a2d Fix compilation issues for arduino devices 2024-03-05 00:34:29 -05:00
Paul Dino Jones 6963c377dc Refactored serial arduino devices. Created custom structs for sending data to arduino devices. 2024-03-05 04:51:49 +00:00
Paul Dino Jones 4cb5ecf4f4 Added preliminary support for tyre slip and abs vibrations 2024-02-29 19:19:57 +00:00
Paul Dino Jones 0ca123d027 Fixed simapi version 2024-02-28 14:10:13 -05:00
Paul Dino Jones 3acf5eb716 Add makefiles for arduino and related documentation 2024-02-27 17:36:02 -05:00
Paul Dino Jones 44d954ca2d Fixed signal handleing 2024-02-26 22:05:41 +00:00
Paul Dino Jones a2ede0d210 Add more user variables in arduino code 2024-02-17 18:50:57 +00:00
Paul Dino Jones eb28208eb1 Updated to latest simapi for wheel slip and abs 2024-02-16 16:16:26 +00:00
Paul Dino Jones b6bd2659d0 Slight refactor of detecting running sim 2024-01-02 19:25:11 +00:00
Paul Dino Jones c79e0a557f Fix latency on pulseaudio backend 2023-11-14 15:31:44 +00:00
Paul Dino Jones cd1e56f70e Add basic info for pulseaudio backend into readme 2023-11-13 07:50:10 +00:00
Paul Dino Jones 215a25df06 Updated config for new pulseaudio backend 2023-11-13 07:46:04 +00:00
Paul Dino Jones f81972fbb1 Fix possible causes of leaks and segfaults 2023-11-12 13:27:17 -05:00
Paul Dino Jones 22a72d4b0c Adding pulseaudio backend 2023-11-11 18:19:39 +00:00
Paul Dino Jones c673bb128d Improve game detection in gameloop 2023-10-12 05:26:55 +00:00
Paul Dino Jones 8705f76f61 Update to latest simapi to fix compilation issue 2023-10-11 15:57:55 +00:00
Paul Dino Jones 3e71340dd8 Updated to latest simapi for ACC Support and more RFactor2 support 2023-10-07 19:38:03 +00:00
Paul Dino Jones d2378eed35 Updating to latest simapi for RFactor2 fixes. 2023-10-01 15:03:19 +00:00
Paul Dino Jones ed0900024e Updating to latest simapi to support RFactor2 detection. 2023-09-29 21:26:03 +00:00
condaatje 2b2ca79875 Update README.md
remove workaround in favour of default success
2023-09-29 12:14:08 -04:00
condaatje d76df2f3d3 Update .gitmodules
ssh -> https gitmodule
2023-09-29 12:12:47 -04:00
condaatje 79bbfcc70e add workaround for microsoft ssh clone requirements 2023-09-21 10:06:48 -04:00
Paul Dino Jones 96f59417ab Updating to latest simapi. Updating arduino sketches. Creating simlinks to simdata accordingly. 2023-07-17 03:42:34 +00:00
Paul Dino Jones 0d904a30da Use new simapi to get sim automatically. Use light version of simapi 2023-07-14 22:11:01 +00:00
Paul Dino Jones 3a3e1f9932 Updated to simapi fix for simstatus 2023-07-14 20:36:27 +00:00
Paul Dino Jones 1c8417552a Updated to new release of simapi 2023-07-14 20:18:24 +00:00
Paul Dino Jones 87f83999f6 Updated README 2023-05-17 16:00:26 +00:00
Paul Dino Jones 62790e4a65 Major refactor. Adding sim wind 2023-05-17 15:56:57 +00:00
Paul Dino Jones 5baadb43e2 Added static analysis 2022-12-23 22:43:37 +00:00
Paul Dino Jones 87d7552779 Moved to GPLv3 2022-12-23 22:42:37 +00:00
Paul Dino Jones 0ae55221a5 Updated README 2022-12-19 15:02:41 -05:00
Paul Dino Jones fa91c97ae8 Removed memcpy calls for better performance 2022-12-19 15:01:55 -05:00
Paul Dino Jones 9c195c87ac Initial RFactor support 2022-12-01 21:36:55 +00:00
Paul Dino Jones 1a79c6b7b4 Updated readme 2022-12-01 21:27:57 +00:00
Paul Dino Jones 6335e6dbe1 Display zeros and cleanup gameloop output 2022-12-01 21:25:26 +00:00
Paul Dino Jones 1d8a23c491 monocoque initial commit 2022-10-31 15:11:02 +00:00
40 changed files with 296 additions and 1240 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ jobs:
- name: Update apt
run: sudo apt update
- name: Install Dependencies
run: sudo apt install -y libuv1-dev libargtable2-dev libserialport-dev libconfig-dev libhidapi-dev liblua5.4-dev libxdg-basedir-dev libxml2-dev libpulse-dev libproc2-dev
run: sudo apt install -y libuv1-dev libargtable2-dev libserialport-dev libconfig-dev libhidapi-dev liblua5.4-dev libxdg-basedir-dev libxml2-dev libpulse-dev
- name: Set build dir
id: strings
shell: bash
+6 -36
View File
@@ -1,4 +1,7 @@
# minimum CMake version required for C++20 support, among other things
cmake_minimum_required(VERSION 3.18)
# detect if Monocoque is being used as a sub-project of another CMake project
if(NOT DEFINED PROJECT_NAME)
set(MONOCOQUE_SUBPROJECT OFF)
@@ -17,25 +20,9 @@ set(CMAKE_EXE_LINKER_FLAGS "-Wl,--no-as-needed -ldl")
set(LIBUSB_INCLUDE_DIR /usr/include/libusb-1.0)
set(LIBXML_INCLUDE_DIR /usr/include/libxml2)
FIND_PACKAGE(Lua)
FIND_PACKAGE(Lua 5.3 REQUIRED)
set(INCLUDE_DIRS ${LUA_INCLUDE_DIR})
include_directories(${LUA_INCLUDE_DIR})
if(Lua_FOUND AND NOT TARGET Lua::Lua)
add_library(Lua::Lua INTERFACE IMPORTED)
set_target_properties(
Lua::Lua
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${LUA_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${LUA_LIBRARIES}"
)
endif()
message("Lua ${Lua_VERSION} found")
if (Lua_VERSION VERSION_GREATER_EQUAL "5.5.0")
add_compile_definitions(USE_LUA_55)
else()
remove_definitions(USE_LUA_55)
endif()
#FIND_PATH(LIBUSB_INCLUDE_DIR libusb.h
# HINTS $ENV{LIBUSB_ROOT}
@@ -52,31 +39,14 @@ set(BUILD_SHARED_LIBS TRUE) # HIDAPI as static library on all platforms
add_executable(monocoque src/monocoque/monocoque.c)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBPROCPS libprocps)
pkg_check_modules(LIBPROC2 libproc2)
if (LIBPROCPS_FOUND)
#add_compile_definitions(USE_OLD_PID_VAL=0)
elseif (LIBPROC2_FOUND)
if (LIBPROC2_VERSION VERSION_GREATER_EQUAL "4.0.5")
#add_compile_definitions(USE_OLD_PID_VAL=0)
else()
add_compile_definitions(USE_OLD_PID_VAL=1)
endif()
else()
message(FATAL_ERROR "Either libprocps or libproc2 is required")
endif()
#if(USE_PULSEAUDIO)
#else()
#endif()
message("Using pulseaudio backend...")
add_compile_definitions(USE_PULSEAUDIO=true)
target_link_libraries(monocoque m hidapi-hidraw pulse serialport xml2 argtable2 config gameloop helper devices slog simulatorapi uv xdg-basedir Lua::Lua proc2)
target_link_libraries(monocoque m hidapi-hidraw pulse serialport xml2 argtable2 config gameloop helper devices slog simulatorapi uv xdg-basedir ${LUA_LIBRARY})
target_include_directories(monocoque PUBLIC config ${LIBXML_INCLUDE_DIR} ${LUA_INCLUDE_DIR})
target_include_directories(monocoque PUBLIC config ${LIBXML_INCLUDE_DIR})
add_subdirectory(src/monocoque/gameloop)
add_subdirectory(src/monocoque/simulatorapi)
+1 -16
View File
@@ -41,20 +41,6 @@ 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
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:
```bash
@@ -80,12 +66,11 @@ for installation instructions***
- libconfig
- xdg-basedir
- lua
- libproc2
- [slog](https://github.com/kala13x/slog) (static)
- [simshmbridge](https://github.com/spacefreak18/simshmbridge) - for sims that need shared memory mapping like AC and Project Cars related.
- [simapi](https://github.com/spacefreak18/simapi)
```
pacman -Syu git cmake pulse-native-provider libxdg-basedir libserialport libconfig libuv argtable hidapi lua libproc2
pacman -Syu git cmake pulse-native-provider libxdg-basedir libserialport libconfig libuv argtable hidapi lua
```
This code depends on the shared memory data headers in the simapi [repo](https://github.com/spacefreak18/simapi). When pulling lastest if the submodule does not download run:
-2
View File
@@ -220,7 +220,6 @@ configs = (
config = "None";
baud = 115200;
devpath = "/dev/simdev1";
fanpower = 0.6;
},
{
@@ -229,7 +228,6 @@ configs = (
config = "None";
baud = 115200;
devpath = "/dev/simdev1";
fanpower = 0.6;
},
{
+2 -2
View File
@@ -95,7 +95,7 @@ install_dependencies() {
case $DISTRO in
arch|manjaro)
local deps="yder libuv argtable libserialport libconfig hidapi lua54 libpulse pkgconfig libxdg-basedir mingw-w64-gcc"
local deps="yder libuv argtable libserialport libconfig hidapi lua libxdg-basedir mingw-w64-gcc"
# Check if yay is available for AUR
if command -v yay &> /dev/null; then
@@ -223,7 +223,7 @@ build_simapi() {
mkdir -p build
cd build
cmake -DINSTALL_SYSTEMD_SERVICE=off ..
cmake ..
make -j$(nproc)
log_info "Installing simapi library..."
-166
View File
@@ -1,166 +0,0 @@
# Makefile for Arduino based scketches
#
# Copyright 2020 Valerio Di Giampietro http://va.ler.io v@ler.io
# MIT License - see License.txt file
#
# This Makefile uses the arduino-cli, the Arduino command line interface
# and has been designed and tested to run on Linux, not on Windows.
# Probably it will run on a Mac, but it has not been tested.
#
# Please note that:
#
# 1. each sketch must reside in his own folder with this Makefile
#
# 2. the main make targets are:
# - all compiles and upload
# - compile compiles only
# - upload upload via serial port, compile if the binary file is
# not available
# - ota upload Over The Air, automatically find the device
# IP address using the IOT_NAME (device hostname)
# - clean clean the build directory
# - find find OTA updatable devices on the local subnet
# - requirements it the file "requirements.txt" exists it will
# install the libraries listed in this file
#
# default is "all"
#
# 3. it gets the name of the sketch using the wildcard make command;
# the name is *.ino; this means that you must have ONLY a file
# with .ino extension, otherwise this makefile will break. This
# also means that you can use this Makefile, almost unmodified,
# for any sketch as long as you keep a single .ino file in each
# folder
#
# 4. you can split your project in multiple files, if you wish,
# using a single .ino file and multiple .h files, that you can
# include in the .ino file with an '#include "myfile.h"'
# directive
#
# Optionally some environment variables can be set:
#
# FQBN Fully Qualified Board Name; if not set in the environment
# it will be assigned a value in this makefile
#
# SERIAL_DEV Serial device to upload the sketch; if not set in the
# environment it will be assigned:
# /dev/ttyUSB0 if it exists, or
# /dev/ttyACM0 if it exists, or
# unknown
#
# IOT_NAME Name of the IOT device; if not set in the environment
# it will be assigned a value in this makefile. This is
# very useful for OTA update, the device will be searched
# on the local subnet using this name
#
# OTA_PORT Port used by OTA update; if not set in the environment
# it will be assigned the default value of 8266 in this
# makefile
#
# OTA_PASS Password used for OTA update; if not set in the environment
# it will be assigned the default value of an empty string
#
# V verbose flag; can be 0 (quiet) or 1 (verbose); if not set
# in the environment it will be assigned a default value
# in this makefile
MAKE_DIR := $(PWD)
#
# ----- setup wor Wemos D1 mini -----
#FQBN ?= esp8266:esp8266:d1_mini
#IOT_NAME ?= esp8266-meteo
#OTA_PORT ?= 8266
#OTA_PASS ?=
# ----- setup for Arduino Uno
FQBN ?= arduino:avr:uno
# ----- ---------------------
V ?= 0
VFLAG =
ifeq "$(V)" "1"
VFLAG =-v
endif
ifndef SERIAL_DEV
ifneq (,$(wildcard /dev/ttyUSB0))
SERIAL_DEV = /dev/ttyUSB0
else ifneq (,$(wildcard /dev/ttyACM0))
SERIAL_DEV = /dev/ttyACM0
else
SERIAL_DEV = unknown
endif
endif
BUILD_DIR := $(subst :,.,build/$(FQBN))
SRC := $(wildcard *.ino)
HDRS := $(wildcard *.h)
BIN := $(BUILD_DIR)/$(SRC).bin
ELF := $(BUILD_DIR)/$(SRC).elf
$(info FQBN is [${FQBN}])
$(info IOT_NAME is [${IOT_NAME}])
$(info OTA_PORT is [${OTA_PORT}])
$(info OTA_PASS is [${OTA_PASS}])
$(info V is [${V}])
$(info VFLAG is [${VFLAG}])
$(info MAKE_DIR is [${MAKE_DIR}])
$(info BUILD_DIR is [${BUILD_DIR}])
$(info SRC is [${SRC}])
$(info HDRS is [${HDRS}])
$(info BIN is [${BIN}])
$(info SERIAL_DEV is [${SERIAL_DEV}])
all: $(ELF) upload
.PHONY: all
compile: $(ELF)
.PHONY: compile
$(ELF): $(SRC) $(HDRS)
arduino-cli compile -b $(FQBN) $(VFLAG)
@if which arduino-manifest.pl; \
then echo "---> Generating manifest.txt"; \
arduino-manifest.pl -b $(FQBN) $(SRC) $(HDRS) > manifest.txt; \
else echo "---> If you want to generate manifest.txt, listing used libraries and their versions,"; \
echo "---> please install arduino-manifest, see https://github.com/digiampietro/arduino-manifest"; \
fi
upload:
@if [ ! -c $(SERIAL_DEV) ] ; \
then echo "---> ERROR: Serial Device not available, please set the SERIAL_DEV environment variable" ; \
else echo "---> Uploading sketch\n"; \
arduino-cli upload -b $(FQBN) -p $(SERIAL_DEV) $(VFLAG); \
fi
ota:
@PLAT_PATH=`arduino-cli compile -b $(FQBN) --show-properties | grep '^runtime.platform.path' | awk -F= '{print $$2}'` ; \
PY_PATH=`arduino-cli compile -b $(FQBN) --show-properties | grep '^runtime.tools.python3.path' | awk -F= '{print $$2}'` ; \
IOT_IP=`avahi-browse _arduino._tcp --resolve --parsable --terminate|grep -i ';$(IOT_NAME);'|grep ';$(OTA_PORT);'| awk -F\; '{print $$8}'|head -1`; \
BINFILE=$(wildcard $(BUILD_DIR)/$(SRC)*bin); \
echo "PLAT_PATH is [$$PLAT_PATH]" ; \
echo "PY_PATH: is [$$PY_PATH]" ; \
echo "IOT_IP: is [$$IOT_IP]" ; \
echo "BINFILE: is [$$BINFILE]" ; \
if [ "$$IOT_IP" = "" ] ; \
then echo "Unable to find device IP. Check that the IOT_NAME environment variable is correctly set. Use 'make find' to search devices"; \
else echo "---> Uploading Over The Air"; \
$$PY_PATH/python3 $$PLAT_PATH/tools/espota.py -i $$IOT_IP -p $(OTA_PORT) --auth=$(OTA_PASS) -f $$BINFILE ;\
fi
clean:
@echo "---> Cleaning the build directory"
rm -rf build
find:
avahi-browse _arduino._tcp --resolve --parsable --terminate
requirements:
@if [ -e requirements.txt ]; \
then while read -r i ; do echo ; \
echo "---> Installing " '"'$$i'"' ; \
arduino-cli lib install "$$i" ; \
done < requirements.txt ; \
else echo "---> MISSING requirements.txt file"; \
fi
-15
View File
@@ -1,15 +0,0 @@
#ifndef _SIMWINDDATA_H
#define _SIMWINDDATA_H
#include <stdint.h>
#include <stdbool.h>
typedef struct
{
uint8_t velocity;
uint8_t fanpower;
}
SimWindData;
#endif
-56
View File
@@ -1,56 +0,0 @@
#include "simwind.h"
// ============================================================
// Configuration
// ============================================================
#define BAUD_RATE 115200
#define PWM_PIN_1 9 // Fan PWM output pins
#define PWM_PIN_2 10 //
#define PWM_MAX 320 // Max PWM value for 25kHz (16MHz / 25kHz / 2)
#define SPEED_MIN 0 // Min speed (mph) — fans off below this
#define SPEED_MAX 100 // Max speed (mph) — full fan speed at this
#define SPEED_THRESHOLD 5 // Below this speed fans are off
// ============================================================
#define BYTE_SIZE sizeof(SimWindData)
int velocity = 0;
int fanpower = 0;
void setup() {
Serial.begin(BAUD_RATE);
// Configure Timer1 for Phase Correct PWM at 25kHz duty cycle
// Mode 10: Phase Correct PWM, TOP = ICR1
// WGM13:WGM12:WGM11:WGM10 = 1:0:1:0
TCCR1A = _BV(COM1A1) | _BV(COM1B1) | _BV(WGM11);
TCCR1B = _BV(WGM13) | _BV(CS10); // <-- WGM13 restored, no prescaler
ICR1 = PWM_MAX; // TOP = 320 → 16MHz / (2 * 320) = 25kHz
pinMode(PWM_PIN_1, OUTPUT);
pinMode(PWM_PIN_2, OUTPUT);
OCR1A = 0;
OCR1B = 0;
}
void loop() {
char buff[BYTE_SIZE];
if (Serial.available() >= BYTE_SIZE) {
if (Serial.readBytes(buff, BYTE_SIZE) != BYTE_SIZE) return;
union { SimWindData data; char bytes[BYTE_SIZE]; } u;
memcpy(u.bytes, buff, BYTE_SIZE);
velocity = u.data.velocity;
fanpower = u.data.fanpower;
}
int pwm = 0;
if (velocity > SPEED_THRESHOLD) {
// Square root scaling for slightly stronger sensation at lower speeds
// fanpower (0-255) scales the overall intensity
float powerScale = (float)fanpower / 255.0;
pwm = (int)(sqrt((float)velocity / SPEED_MAX) * PWM_MAX * powerScale);
pwm = constrain(pwm, 0, PWM_MAX);
}
OCR1A = pwm;
OCR1B = pwm;
}
-2
View File
@@ -42,8 +42,6 @@ set(devices_source_files
serial/moza.c
serial/moza_new.h
serial/moza_new.c
serial/moza_ks_pro_wheel.h
serial/moza_ks_pro_wheel.c
)
include_directories("." "usb" "sound" "serial")
+36 -53
View File
@@ -204,68 +204,51 @@ double slipeffect(SimData* simdata, int effecttype, int tyre, double threshold,
wheelslip[2] = 0;
wheelslip[3] = 0;
int sim_slip_ratio =0;
for (int i = 0; i < 4; i++)
slogt("wheel vibration calculation with wheel config set to %i configchecked %i configfile %s car %s sim %i", useconfig, *configcheck, configfile, simdata->car, simdata->simexe);
switch (effecttype)
{
sim_slip_ratio = abs(simdata->tyreslipratio[i]);
}
if(sim_slip_ratio == 0)
{
slogt("wheel vibration calculation with wheel config set to %i configchecked %i configfile %s car %s sim %i", useconfig, *configcheck, configfile, simdata->car, simdata->simexe);
switch (effecttype)
{
case (EFFECT_TYRESLIP):
case (EFFECT_TYRELOCK):
case (EFFECT_ABSBRAKES):
case (EFFECT_TYRESLIP):
case (EFFECT_TYRELOCK):
case (EFFECT_ABSBRAKES):
if(hasTyreDiameter(simdata)==true)
if(hasTyreDiameter(simdata)==true)
{
double Speedms = kmhtoms * simdata->velocity;
slogt("attempting wheel slip calculation");
if (Speedms > minspeedinms)
{
double Speedms = kmhtoms * simdata->velocity;
slogt("attempting wheel slip calculation");
if (Speedms > minspeedinms)
for(int i = 0; i < 4; i++)
{
for(int i = 0; i < 4; i++)
{
wheelslip[i] = (Speedms - simdata->tyrediameter[i] * simdata->tyreRPS[i] / 2) / Speedms;
}
wheelslip[i] = (Speedms - simdata->tyrediameter[i] * simdata->tyreRPS[i] / 2) / Speedms;
}
else
{
for(int i = 0; i < 4; i++)
{
wheelslip[i] = 0;
}
}
slogt("wheelslip values are %f %f %f %f", wheelslip[0], wheelslip[1], wheelslip[2], wheelslip[3]);
slogt("velocities (x,y,z) are %f %f %f", simdata->Xvelocity, simdata->Yvelocity, simdata->Zvelocity);
}
break;
case EFFECT_SUSPENSION:
break;
default:
slogd("Unknown effect type");
}
if(simdata->Yvelocity <= 0)
{
return 0;
}
if(simdata->Zvelocity > 1 || simdata->Zvelocity < -1)
{
return 0;
}
}
else
{
for (int i = 0; i < 4; i++)
{
wheelslip[i] = simdata->tyreslipratio[i];
}
slogt("wheelslip values from sim are %f %f %f %f", wheelslip[0], wheelslip[1], wheelslip[2], wheelslip[3]);
else
{
for(int i = 0; i < 4; i++)
{
wheelslip[i] = 0;
}
}
slogt("wheelslip values are %f %f %f %f", wheelslip[0], wheelslip[1], wheelslip[2], wheelslip[3]);
slogt("velocities (x,y,z) are %f %f %f", simdata->Xvelocity, simdata->Yvelocity, simdata->Zvelocity);
}
break;
case EFFECT_SUSPENSION:
break;
default:
slogd("Unknown effect type");
}
if(simdata->Yvelocity <= 0)
{
return 0;
}
if(simdata->Zvelocity > 1 || simdata->Zvelocity < -1)
{
return 0;
}
switch (effecttype)
{
@@ -64,39 +64,6 @@ int simdata_to_lua(lua_State *L, SimData* simdata) {
}
lua_setfield(L, -2, "pd");
lua_pushnumber(L, simdata->gas);
lua_setfield(L, -2, "gas");
lua_pushnumber(L, simdata->fuel);
lua_setfield(L, -2, "fuel");
lua_pushnumber(L, simdata->turboboost);
lua_setfield(L, -2, "turboboost");
lua_newtable(L);
for(int i = 0; i < 4; i++)
{
lua_pushnumber(L, simdata->tyreRPS[i]);
lua_rawseti(L, -2, i+1);
}
lua_setfield(L, -2, "tyreRPS");
lua_newtable(L);
for(int i = 0; i < 4; i++)
{
lua_pushnumber(L, simdata->tyrediameter[i]);
lua_rawseti(L, -2, i+1);
}
lua_setfield(L, -2, "tyrediameter");
lua_newtable(L);
for(int i = 0; i < 4; i++)
{
lua_pushnumber(L, simdata->tyretemp[i]);
lua_rawseti(L, -2, i+1);
}
lua_setfield(L, -2, "tyretemp");
return 0; // Return the table to Lua
}
+3 -8
View File
@@ -1,14 +1,9 @@
#ifndef _ARDUINOLEDLUA_H
#define _ARDUINOLEDLUA_H
//#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#ifdef USE_LUA_55
/* open all libraries */
#define luaL_openlibs(L) luaL_openselectedlibs(L, ~0, 0)
#endif
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
#include "../../simulatorapi/simapi/simapi/simdata.h"
+2 -4
View File
@@ -84,8 +84,6 @@ int moza_update(SerialDevice* serialdevice, unsigned short rpm, unsigned short m
int moza_init(SerialDevice* serialdevice, const char* portdev)
{
int id = monocoque_serial_open(serialdevice, portdev);
if (id < 0) return id;
serialdevice->id = id;
return 0;
serialdevice->id = monocoque_serial_open(serialdevice, portdev);
return serialdevice->id;
}
@@ -1,142 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <hidapi/hidapi.h>
#include "moza.h"
#include "moza_ks_pro_wheel.h"
#include "../serialadapter.h"
#include "../../slog/slog.h"
#define MOZA_TIMEOUT 1000
#define MOZA_MAGIC_VALUE 0x0d
#define MOZA_RPM_MASK_TEMPLATE {0x7e, 0x06, 0x3f, 0x17, 0x1a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
#define MOZA_RPM_MASK_PAYLOAD_SIZE 11
#define MOZA_RPM_COLOR_PAYLOAD_1 {0x7e, 0x16, 0x3f, 0x17, 0x19, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0xff, 0, 0, 4, 0xff, 0, 0, 0}
#define MOZA_RPM_COLOR_PAYLOAD_2 {0x7e, 0x16, 0x3f, 0x17, 0x19, 0, 5, 0xff, 0, 0, 6, 0xff, 0, 0, 7, 0xff, 0, 0, 8, 0xff, 0, 0, 9, 0xff, 0, 0, 0}
#define MOZA_RPM_COLOR_PAYLOAD_3 {0x7e, 0x16, 0x3f, 0x17, 0x19, 0, 10, 0xff, 0x7f, 0, 11, 0xff, 0x7f, 0, 12, 0xff, 0x7f, 0, 13, 0, 0, 0xff, 14, 0, 0, 0xff, 0}
#define MOZA_BTN_COLOR_PAYLOAD_1 {0x7e, 0x16, 0x3f, 0x17, 0x19, 1, 0, 0xff, 0, 0, 1, 0xff, 0, 0, 2, 0xff, 0, 0, 3, 0xff, 0, 0, 4, 0xff, 0, 0, 0}
#define MOZA_BTN_COLOR_PAYLOAD_2 {0x7e, 0x16, 0x3f, 0x17, 0x19, 1, 5, 0xff, 0, 0, 6, 0xff, 0, 0, 7, 0xff, 0, 0, 8, 0xff, 0, 0, 9, 0xff, 0, 0, 0}
#define MOZA_COLOR_PAYLOAD_SIZE 27
#define MOZA_FLAG_COLOR_YELLOW_LEFT {0x7e, 0x16, 0x3f, 0x17, 0x19, 0, 0, 0xff, 0xaa, 0, 1, 0xff, 0xaa, 0, 2, 0xff, 0xaa, 0, 0, 0xff, 0xaa, 0, 1, 0xff, 0xaa, 0, 0}
#define MOZA_FLAG_COLOR_YELLOW_RIGHT {0x7e, 0x16, 0x3f, 0x17, 0x19, 0, 15, 0xff, 0xaa, 0, 16, 0xff, 0xaa, 0, 17, 0xff, 0xaa, 0, 15, 0xff, 0xaa, 0, 16, 0xff, 0xaa, 0, 0}
#define MOZA_FLAG_COLOR_OFF_LEFT {0x7e, 0x16, 0x3f, 0x17, 0x19, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0}
#define MOZA_FLAG_COLOR_OFF_RIGHT {0x7e, 0x16, 0x3f, 0x17, 0x19, 0, 15, 0, 0, 0, 16, 0, 0, 0, 17, 0, 0, 0, 15, 0, 0, 0, 16, 0, 0, 0, 0}
#define BIT(nr) (1UL << (nr))
int moza_ks_pro_wheel_update(SerialDevice* serialdevice, SimData* simData)
{
static uint8_t last_flag = 0xff;
unsigned char bytes[] = MOZA_RPM_MASK_TEMPLATE;
int size = MOZA_RPM_MASK_PAYLOAD_SIZE;
float perctflt = ((float)simData->rpms/(float)simData->maxrpm)*100;
int perct = round(perctflt);
if (perct >= 98 && (simData->mtick >> 7) & 1 == 1) perct = 0;
if (perct >= 75)
bytes[6] |= BIT(3);
if (perct >= 77)
bytes[6] |= BIT(4);
if (perct >= 79)
bytes[6] |= BIT(5);
if (perct >= 81)
bytes[6] |= BIT(6);
if (perct >= 83)
bytes[6] |= BIT(7);
if (perct >= 85)
bytes[7] |= BIT(0);
if (perct >= 87)
bytes[7] |= BIT(1);
if (perct >= 89)
bytes[7] |= BIT(2);
if (perct >= 91)
bytes[7] |= BIT(3);
if (perct >= 93)
bytes[7] |= BIT(4);
if (perct >= 95)
bytes[7] |= BIT(5);
if (perct >= 97)
bytes[7] |= BIT(6);
if (simData->playerflag == SIMAPI_FLAG_YELLOW) {
bytes[6] |= BIT(0) | BIT(1) | BIT(2); // left 3 flag LEDs (indices 0, 1, 2)
bytes[7] |= BIT(7); // right flag LED (index 15)
bytes[8] |= BIT(0) | BIT(1); // right flag LEDs (indices 16, 17)
}
bytes[10] = moza_checksum(bytes, size);
int result = 1;
if (serialdevice->port)
{
if (simData->playerflag != last_flag) {
last_flag = simData->playerflag;
if (simData->playerflag == SIMAPI_FLAG_YELLOW) {
unsigned char fl[] = MOZA_FLAG_COLOR_YELLOW_LEFT;
unsigned char fr[] = MOZA_FLAG_COLOR_YELLOW_RIGHT;
fl[MOZA_COLOR_PAYLOAD_SIZE-1] = moza_checksum(fl, MOZA_COLOR_PAYLOAD_SIZE);
fr[MOZA_COLOR_PAYLOAD_SIZE-1] = moza_checksum(fr, MOZA_COLOR_PAYLOAD_SIZE);
monocoque_serial_write(serialdevice->id, fl, MOZA_COLOR_PAYLOAD_SIZE, MOZA_TIMEOUT);
monocoque_serial_write(serialdevice->id, fr, MOZA_COLOR_PAYLOAD_SIZE, MOZA_TIMEOUT);
} else {
unsigned char fl[] = MOZA_FLAG_COLOR_OFF_LEFT;
unsigned char fr[] = MOZA_FLAG_COLOR_OFF_RIGHT;
fl[MOZA_COLOR_PAYLOAD_SIZE-1] = moza_checksum(fl, MOZA_COLOR_PAYLOAD_SIZE);
fr[MOZA_COLOR_PAYLOAD_SIZE-1] = moza_checksum(fr, MOZA_COLOR_PAYLOAD_SIZE);
monocoque_serial_write(serialdevice->id, fl, MOZA_COLOR_PAYLOAD_SIZE, MOZA_TIMEOUT);
monocoque_serial_write(serialdevice->id, fr, MOZA_COLOR_PAYLOAD_SIZE, MOZA_TIMEOUT);
}
}
slogd("copying %i bytes to moza device", MOZA_RPM_MASK_PAYLOAD_SIZE);
slogt("writing bytes %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x from rpm %i maxrpm %i", bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], bytes[8], bytes[9], bytes[10], simData->rpms, simData->maxrpm);
result = monocoque_serial_write(serialdevice->id, bytes, size, MOZA_TIMEOUT);
}
return result;
}
int moza_ks_pro_wheel_init(SerialDevice* serialdevice, const char* portdev)
{
serialdevice->id = monocoque_serial_open(serialdevice, portdev);
if (serialdevice->id == -1) return serialdevice->id;
unsigned char p1[] = MOZA_RPM_COLOR_PAYLOAD_1;
unsigned char p2[] = MOZA_RPM_COLOR_PAYLOAD_2;
unsigned char p3[] = MOZA_RPM_COLOR_PAYLOAD_3;
unsigned char p4[] = MOZA_BTN_COLOR_PAYLOAD_1;
unsigned char p5[] = MOZA_BTN_COLOR_PAYLOAD_2;
p1[MOZA_COLOR_PAYLOAD_SIZE-1] = moza_checksum(p1, MOZA_COLOR_PAYLOAD_SIZE);
p2[MOZA_COLOR_PAYLOAD_SIZE-1] = moza_checksum(p2, MOZA_COLOR_PAYLOAD_SIZE);
p3[MOZA_COLOR_PAYLOAD_SIZE-1] = moza_checksum(p3, MOZA_COLOR_PAYLOAD_SIZE);
p4[MOZA_COLOR_PAYLOAD_SIZE-1] = moza_checksum(p4, MOZA_COLOR_PAYLOAD_SIZE);
p5[MOZA_COLOR_PAYLOAD_SIZE-1] = moza_checksum(p5, MOZA_COLOR_PAYLOAD_SIZE);
monocoque_serial_write(serialdevice->id, p1, MOZA_COLOR_PAYLOAD_SIZE, MOZA_TIMEOUT);
monocoque_serial_write(serialdevice->id, p2, MOZA_COLOR_PAYLOAD_SIZE, MOZA_TIMEOUT);
monocoque_serial_write(serialdevice->id, p3, MOZA_COLOR_PAYLOAD_SIZE, MOZA_TIMEOUT);
monocoque_serial_write(serialdevice->id, p4, MOZA_COLOR_PAYLOAD_SIZE, MOZA_TIMEOUT);
monocoque_serial_write(serialdevice->id, p5, MOZA_COLOR_PAYLOAD_SIZE, MOZA_TIMEOUT);
unsigned char p6[] = MOZA_FLAG_COLOR_OFF_RIGHT;
p6[MOZA_COLOR_PAYLOAD_SIZE-1] = moza_checksum(p6, MOZA_COLOR_PAYLOAD_SIZE);
monocoque_serial_write(serialdevice->id, p6, MOZA_COLOR_PAYLOAD_SIZE, MOZA_TIMEOUT);
return serialdevice->id;
}
@@ -1,10 +0,0 @@
#ifndef _MOZA_KS_PRO_WHEEL_H
#define _MOZA_KS_PRO_WHEEL_H
#include "../serialdevice.h"
#include "../simdevice.h"
int moza_ks_pro_wheel_update(SerialDevice* serialdevice, SimData* simData);
int moza_ks_pro_wheel_init(SerialDevice* serialdevice, const char* portdev);
#endif
+7 -9
View File
@@ -74,9 +74,8 @@ int moza_new_update(SerialDevice* serialdevice, SimData* simData)
int moza_new_init(SerialDevice* serialdevice, const char* portdev)
{
int id = monocoque_serial_open(serialdevice, portdev);
if (id < 0) return id;
serialdevice->id = id;
serialdevice->id = monocoque_serial_open(serialdevice, portdev);
if (serialdevice->id == -1) return serialdevice->id;
unsigned char p1[] = MOZA_RPM_COLOR_PAYLOAD_1;
unsigned char p2[] = MOZA_RPM_COLOR_PAYLOAD_2;
@@ -88,11 +87,10 @@ int moza_new_init(SerialDevice* serialdevice, const char* portdev)
p3[MOZA_COLOR_PAYLOAD_SIZE-1] = moza_checksum(p3, MOZA_COLOR_PAYLOAD_SIZE);
p4[MOZA_COLOR_PAYLOAD_SIZE-1] = moza_checksum(p4, MOZA_COLOR_PAYLOAD_SIZE);
unsigned char* payloads[] = {p1, p2, p3, p4};
for (int i = 0; i < 4; i++) {
int result = monocoque_serial_write(serialdevice->id, payloads[i], MOZA_COLOR_PAYLOAD_SIZE, MOZA_TIMEOUT);
if (result < 0) return result;
}
monocoque_serial_write(serialdevice->id, p1, MOZA_COLOR_PAYLOAD_SIZE, MOZA_TIMEOUT);
monocoque_serial_write(serialdevice->id, p2, MOZA_COLOR_PAYLOAD_SIZE, MOZA_TIMEOUT);
monocoque_serial_write(serialdevice->id, p3, MOZA_COLOR_PAYLOAD_SIZE, MOZA_TIMEOUT);
monocoque_serial_write(serialdevice->id, p4, MOZA_COLOR_PAYLOAD_SIZE, MOZA_TIMEOUT);
return 0;
return serialdevice->id;
}
+38 -32
View File
@@ -27,13 +27,10 @@ int check(enum sp_return result)
error_message = sp_last_error_message();
sloge("error: serial write failed: %s", error_message);
sp_free_error_message(error_message);
return result;
case SP_ERR_SUPP:
printf("Error: Not supported.\n");
return result;
case SP_ERR_MEM:
printf("Error: Couldn't allocate memory.\n");
return result;
case SP_OK:
default:
return result;
@@ -117,30 +114,23 @@ int monocoque_input_wait(uint8_t serialdevicenum)
return sp_input_waiting(monocoque_serial_dev.port);
}
// Helper function to get and validate device
static monocoque_serial_device* monocoque_get_serial_device(uint8_t serialdevicenum)
int monocoque_serial_write(uint8_t serialdevicenum, void* data, size_t size, int timeout)
{
monocoque_serial_device* dev = &monocoque_serial_devices[serialdevicenum];
slogt("serial device id %i", serialdevicenum);
slogt("port name: %s, busy %i, open %i, openfail %i", dev->portname, dev->busy, dev->open, dev->openfail);
if(dev->port == NULL)
monocoque_serial_device monocoque_serial_dev = monocoque_serial_devices[serialdevicenum];
slogt("port name: %s, busy %i, open %i, openfail %i", monocoque_serial_dev.portname, monocoque_serial_dev.busy, monocoque_serial_dev.open, monocoque_serial_dev.busy);
if(monocoque_serial_dev.port == NULL)
{
sloge("port is null");
}
return dev;
}
int monocoque_serial_write(uint8_t serialdevicenum, void* data, size_t size, int timeout)
{
monocoque_serial_device* dev = monocoque_get_serial_device(serialdevicenum);
int result = -1;
if(dev->busy == false && dev->open == true)
if(monocoque_serial_dev.busy == false && monocoque_serial_dev.open == true)
{
dev->busy = true;
result = sp_blocking_write(dev->port, data, size, timeout);
monocoque_serial_dev.busy = true;
result = sp_blocking_write(monocoque_serial_dev.port, data, size, timeout);
}
else
{
@@ -148,51 +138,67 @@ int monocoque_serial_write(uint8_t serialdevicenum, void* data, size_t size, int
result = -1;
}
slogt("write result is %i", result);
dev->busy = false;
monocoque_serial_dev.busy = false;
return result;
}
int monocoque_serial_write_block(uint8_t serialdevicenum, void* data, size_t size, int timeout)
{
monocoque_serial_device* dev = monocoque_get_serial_device(serialdevicenum);
slogt("serial device id %i", serialdevicenum);
monocoque_serial_device monocoque_serial_dev = monocoque_serial_devices[serialdevicenum];
slogt("port name: %s, busy %i, open %i, openfail %i", monocoque_serial_dev.portname, monocoque_serial_dev.busy, monocoque_serial_dev.open, monocoque_serial_dev.busy);
if(monocoque_serial_dev.port == NULL)
{
sloge("port is null");
}
int result = -1;
if(dev->open == true)
if(monocoque_serial_dev.open == true)
{
while(dev->busy == true)
while(monocoque_serial_dev.busy == true)
{
slogt("hopefully this doesn't happen long");
continue;
}
dev->busy = true;
result = sp_blocking_write(dev->port, data, size, timeout);
monocoque_serial_dev.busy = true;
result = sp_blocking_write(monocoque_serial_dev.port, data, size, timeout);
slogi("actually performed write");
}
dev->busy = false;
monocoque_serial_dev.busy = false;
return result;
}
int monocoque_serial_read_block(uint8_t serialdevicenum, void* data, size_t size, int timeout)
{
monocoque_serial_device* dev = monocoque_get_serial_device(serialdevicenum);
slogt("serial device id %i", serialdevicenum);
monocoque_serial_device monocoque_serial_dev = monocoque_serial_devices[serialdevicenum];
slogt("port name: %s, busy %i, open %i, openfail %i", monocoque_serial_dev.portname, monocoque_serial_dev.busy, monocoque_serial_dev.open, monocoque_serial_dev.busy);
if(monocoque_serial_dev.port == NULL)
{
sloge("port is null");
}
int result = -1;
if(dev->open == true)
if(monocoque_serial_dev.open == true)
{
while(dev->busy == true)
while(monocoque_serial_dev.busy == true)
{
slogt("hopefully this doesn't happen long");
continue;
}
dev->busy = true;
result = sp_blocking_read(dev->port, data, size, timeout);
monocoque_serial_dev.busy = true;
result = sp_blocking_read(monocoque_serial_dev.port, data, size, timeout);
slogi("actually performed read");
}
dev->busy = false;
monocoque_serial_dev.busy = false;
return result;
}
+8 -34
View File
@@ -11,7 +11,6 @@
#include "serial/arduino.h"
#include "serial/moza.h"
#include "serial/moza_new.h"
#include "serial/moza_ks_pro_wheel.h"
#include "../helper/parameters.h"
#include "../simulatorapi/simapi/simapi/simdata.h"
#include "../slog/slog.h"
@@ -27,10 +26,6 @@ int serial_wheel_update(SimDevice* this, SimData* simdata)
moza_new_update(serialdevice, simdata);
break;
case SERIALDEV__MOZA_KS_PRO_WHEEL:
moza_ks_pro_wheel_update(serialdevice, simdata);
break;
case SIMDEVSUBTYPE_MOZAR5:
default:
moza_update(serialdevice, simdata->rpms, simdata->maxrpm);
@@ -123,9 +118,8 @@ int arduino_simwind_update(SimDevice* this, SimData* simdata)
serialdevice->u.simwinddata.velocity = ceil(simdata->velocity*KPHTOMPH);
slogt("Updating arduino device speed to %i", serialdevice->u.simwinddata.velocity);
serialdevice->u.simwinddata.fanpower = (int)(serialdevice->fanpower * 255);
slogt("Sending fanpower: %i (from config: %f)", serialdevice->u.simwinddata.fanpower, serialdevice->fanpower);
// this can be added to the config, all config dependent can be added to init
serialdevice->u.simwinddata.fanpower = (int)0.6 * 255;
size_t size = sizeof(SimWindData);
arduino_update(serialdevice, &serialdevice->u.simwinddata, size);
@@ -225,7 +219,7 @@ int serial_wheel_free(SimDevice* this)
return 0;
}
int serialdev_init(SerialDevice* serialdevice, DeviceSettings* ds, SimInfo* siminfo)
int serialdev_init(SerialDevice* serialdevice, DeviceSettings* ds)
{
slogi("initializing serial device on port %s to %i...", ds->serialdevsettings.portdev, ds->serialdevsettings.baud);
int error = 0;
@@ -245,9 +239,6 @@ int serialdev_init(SerialDevice* serialdevice, DeviceSettings* ds, SimInfo* simi
case SERIALDEV__MOZA_NEW:
error = moza_new_init(serialdevice, ds->serialdevsettings.portdev);
break;
case SERIALDEV__MOZA_KS_PRO_WHEEL:
error = moza_ks_pro_wheel_init(serialdevice, ds->serialdevsettings.portdev);
break;
case ARDUINODEV__SIMLED__CUSTOM:
serialdevice->m.device_specific_config_file = strdup(ds->specific_config_file);
error = arduino_custom_init(serialdevice, ds->serialdevsettings.portdev, serialdevice->m.device_specific_config_file, true);
@@ -285,7 +276,7 @@ static const vtable arduino_simwind_vtable = { &arduino_simwind_update, &seriald
static const vtable arduino_simhaptic_vtable = { &arduino_simhaptic_update, &serialdev_free };
static const vtable serialwheel_vtable = { &serial_wheel_update, &serial_wheel_free };
SerialDevice* new_serial_device(DeviceSettings* ds, MonocoqueSettings* ms, SimInfo* siminfo) {
SerialDevice* new_serial_device(DeviceSettings* ds, MonocoqueSettings* ms) {
SerialDevice* this = (SerialDevice*) malloc(sizeof(SerialDevice));
@@ -294,7 +285,6 @@ SerialDevice* new_serial_device(DeviceSettings* ds, MonocoqueSettings* ms, SimIn
this->m.derived = this;
this->m.vtable = &serial_simdevice_vtable;
this->type = SERIALDEV_ARDUINO;
int error = 0;
slogt("Attempting to configure arduino device with subtype: %i", ds->dev_subtype);
switch (ds->dev_subtype) {
@@ -327,8 +317,7 @@ SerialDevice* new_serial_device(DeviceSettings* ds, MonocoqueSettings* ms, SimIn
case (SIMDEVTYPE_SIMWIND):
this->devicetype = ARDUINODEV__SIMWIND;
this->m.vtable = &arduino_simwind_vtable;
this->fanpower = ds->serialdevsettings.fanpower;
slogi("Initializing arduino devices for sim wind with fanpower: %f", this->fanpower);
slogi("Initializing arduino devices for sim wind.");
break;
case (SIMDEVTYPE_ARDUINOCUSTOM):
this->devicetype = ARDUINODEV__CUSTOM;
@@ -336,10 +325,6 @@ SerialDevice* new_serial_device(DeviceSettings* ds, MonocoqueSettings* ms, SimIn
slogi("Initializing custom arduino device.");
break;
case (SIMDEVTYPE_SERIALHAPTIC):
if(siminfo->SimSupportsHapticEffects == false)
{
error = MONOCOQUE_ERROR_UNSUPPORTED_SIM_FEATURE;
}
this->devicetype = ARDUINODEV__HAPTIC;
this->m.vtable = &arduino_simhaptic_vtable;
this->u.simhapticdata.motor1 = 0;
@@ -352,7 +337,6 @@ SerialDevice* new_serial_device(DeviceSettings* ds, MonocoqueSettings* ms, SimIn
this->u.simhapticdata.effect4 = 0;
this->state = 0;
this->ampfactor = ds->serialdevsettings.ampfactor;
this->fanpower = ds->serialdevsettings.fanpower;
slogi("Initializing arduino device for haptic effects.");
break;
case (SIMDEVTYPE_SERIALWHEEL):
@@ -365,11 +349,6 @@ SerialDevice* new_serial_device(DeviceSettings* ds, MonocoqueSettings* ms, SimIn
this->devicetype = SERIALDEV__MOZA_NEW;
this->m.vtable = &serialwheel_vtable;
break;
case SIMDEVSUBTYPE_MOZA_KS_PRO_WHEEL:
slogi("Initializing new firmware Moza serial wheel device.");
this->devicetype = SERIALDEV__MOZA_KS_PRO_WHEEL;
this->m.vtable = &serialwheel_vtable;
break;
case SIMDEVSUBTYPE_MOZAR5:
default:
//move this stuff to wheeldevice or it's own serial wheel device module
@@ -380,7 +359,7 @@ SerialDevice* new_serial_device(DeviceSettings* ds, MonocoqueSettings* ms, SimIn
}
}
if(this->devicetype == ARDUINODEV__HAPTIC && error == 0)
if(this->devicetype == ARDUINODEV__HAPTIC)
{
this->m.hapticeffect.threshold = ds->threshold;
this->m.hapticeffect.effecttype = ds->effect_type;
@@ -391,15 +370,10 @@ SerialDevice* new_serial_device(DeviceSettings* ds, MonocoqueSettings* ms, SimIn
this->m.hapticeffect.tyrediameterconfig = ms->tyre_diameter_config;
}
if(error == 0)
{
slogi("Starting serial device initialization");
error = serialdev_init(this, ds, siminfo);
}
int error = serialdev_init(this, ds);
if (error != 0)
if (error < 0)
{
slogw("Did not initialize usb device due to error code %i", error);
free(this);
return NULL;
}
+1 -2
View File
@@ -13,8 +13,7 @@ typedef enum
ARDUINODEV__SIMLED = 4,
ARDUINODEV__SIMLED__CUSTOM = 5,
ARDUINODEV__CUSTOM = 6,
SERIALDEV__MOZA_NEW = 7,
SERIALDEV__MOZA_KS_PRO_WHEEL = 8
SERIALDEV__MOZA_NEW = 7
}
SerialDeviceType;
+5 -5
View File
@@ -24,9 +24,9 @@ int devupdate(SimDevice* this, SimData* simdata)
return 0;
}
int devinit(SimDevice* simdevices, SimInfo* siminfo, int numdevices, DeviceSettings* ds, MonocoqueSettings* ms)
int devinit(SimDevice* simdevices, int numdevices, DeviceSettings* ds, MonocoqueSettings* ms)
{
slogi("initializing simdevices for simapi %i...", siminfo->simulatorapi);
slogi("initializing simdevices...");
int devices = 0;
for (int j = 0; j < numdevices; j++)
@@ -34,7 +34,7 @@ int devinit(SimDevice* simdevices, SimInfo* siminfo, int numdevices, DeviceSetti
simdevices[j].initialized = false;
if (ds[j].dev_type == SIMDEV_USB) {
USBDevice* sim = new_usb_device(&ds[j], ms, siminfo);
USBDevice* sim = new_usb_device(&ds[j], ms);
if (sim != NULL)
{
simdevices[j] = sim->m;
@@ -56,7 +56,7 @@ int devinit(SimDevice* simdevices, SimInfo* siminfo, int numdevices, DeviceSetti
}
else
{
SoundDevice* sim = new_sound_device(&ds[j], ms, siminfo);
SoundDevice* sim = new_sound_device(&ds[j], ms);
if (sim != NULL)
{
@@ -75,7 +75,7 @@ int devinit(SimDevice* simdevices, SimInfo* siminfo, int numdevices, DeviceSetti
if (ds[j].dev_type == SIMDEV_SERIAL) {
SerialDevice* sim = new_serial_device(&ds[j], ms, siminfo);
SerialDevice* sim = new_serial_device(&ds[j], ms);
if (sim != NULL)
{
simdevices[j] = sim->m;
+5 -6
View File
@@ -4,7 +4,7 @@
#include <stdbool.h>
#include <hidapi/hidapi.h>
#include <lua.h>
#include "lua.h"
#include "usbdevice.h"
#include "sounddevice.h"
@@ -66,7 +66,6 @@ typedef struct
int endled;
int baudrate;
double ampfactor;
double fanpower;
double state;
union
{
@@ -83,7 +82,7 @@ int arduino_simwind_update(SimDevice* this, SimData* simdata);
int arduino_simhaptic_update(SimDevice* this, SimData* simdata);
int serialdev_free(SimDevice* this);
SerialDevice* new_serial_device(DeviceSettings* ds, MonocoqueSettings* ms, SimInfo* siminfo);
SerialDevice* new_serial_device(DeviceSettings* ds, MonocoqueSettings* ms);
/********* USB HID Devices *****/
typedef enum
@@ -113,7 +112,7 @@ USBDevice;
int usbdev_update(SimDevice* this, SimData* simdata);
int usbdev_free(SimDevice* this);
USBDevice* new_usb_device(DeviceSettings* ds, MonocoqueSettings* ms, SimInfo* siminfo);
USBDevice* new_usb_device(DeviceSettings* ds, MonocoqueSettings* ms);
/********* Sound Devices *****/
@@ -138,7 +137,7 @@ int sounddev_gearshift_update(SimDevice* this, SimData* simdata);
int sounddev_tyreslip_update(SimDevice* this, SimData* simdata);
int sounddev_free(SimDevice* this);
SoundDevice* new_sound_device(DeviceSettings* ds, MonocoqueSettings* ms, SimInfo* siminfo);
SoundDevice* new_sound_device(DeviceSettings* ds, MonocoqueSettings* ms);
/***** Generic Methods *********/
@@ -146,7 +145,7 @@ int update(SimDevice* simdevice, SimData* simdata);
int devupdate(SimDevice* simdevice, SimData* simdata);
int devinit(SimDevice* simdevices, SimInfo* siminfo, int numdevices, DeviceSettings* ds, MonocoqueSettings* ms);
int devinit(SimDevice* simdevices, int numdevices, DeviceSettings* ds, MonocoqueSettings* ms);
int devfree(SimDevice* simdevices, int numdevices);
+5 -2
View File
@@ -19,8 +19,10 @@ int setupsound()
slogi("connecting pulseaudio...");
// Get a mainloop and its context
mainloop = pa_threaded_mainloop_new();
assert(mainloop);
mainloop_api = pa_threaded_mainloop_get_api(mainloop);
context = pa_context_new(mainloop_api, "Monocoque");
assert(context);
pa_context_set_state_callback(context, &context_state_cb, mainloop);
@@ -28,12 +30,13 @@ int setupsound()
pa_threaded_mainloop_lock(mainloop);
// Start the mainloop
pa_threaded_mainloop_start(mainloop);
pa_context_connect(context, NULL, 0, NULL);
assert(pa_threaded_mainloop_start(mainloop) == 0);
assert(pa_context_connect(context, NULL, 0, NULL) == 0);
// Wait for the context to be ready
for(;;) {
pa_context_state_t context_state = pa_context_get_state(context);
assert(PA_CONTEXT_IS_GOOD(context_state));
if (context_state == PA_CONTEXT_READY) break;
pa_threaded_mainloop_wait(mainloop);
}
@@ -207,14 +207,14 @@ int usb_generic_shaker_init(SoundDevice* sounddevice, pa_threaded_mainloop* main
// for now i'm only supporting playing on one specified channel which is the concept you should build your setups around
cv.values[pan] = channel_volume;
pa_stream_connect_playback(stream, devname, &buffer_attr, stream_flags, &cv, NULL);
assert(pa_stream_connect_playback(stream, devname, &buffer_attr, stream_flags, &cv, NULL) == 0);
//pa_stream_connect_playback(stream, devname, &buffer_attr, stream_flags, &cv, NULL);
// Wait for the stream to be ready
for(;;)
{
pa_stream_state_t stream_state = pa_stream_get_state(stream);
PA_STREAM_IS_GOOD(stream_state);
assert(PA_STREAM_IS_GOOD(stream_state));
//PA_STREAM_IS_GOOD(stream_state);
if (stream_state == PA_STREAM_READY) break;
pa_threaded_mainloop_wait(mainloop);
+68 -92
View File
@@ -231,112 +231,88 @@ static const vtable tyrelock_sound_simdevice_vtable = { &sounddev_tyrelock_updat
static const vtable absbrakes_sound_simdevice_vtable = { &sounddev_absbrakes_update, &sounddev_free };
static const vtable suspension_sound_simdevice_vtable = { &sounddev_suspension_update, &sounddev_free };
SoundDevice* new_sound_device(DeviceSettings* ds, MonocoqueSettings* ms, SimInfo* siminfo) {
SoundDevice* new_sound_device(DeviceSettings* ds, MonocoqueSettings* ms) {
SoundDevice* this = (SoundDevice*) malloc(sizeof(SoundDevice));
this->m.update = &update;
this->m.free = &simdevfree;
this->m.derived = this;
int error = 0;
switch (ds->effect_type)
{
slogt("Attempting to configure sound device with subtype: %i", ds->effect_type);
switch (ds->effect_type) {
case (EFFECT_ENGINERPM):
this->m.hapticeffect.effecttype = EFFECT_ENGINERPM;
this->m.vtable = &engine_sound_simdevice_vtable;
slogi("Initializing sound device for engine vibrations.");
break;
case (EFFECT_GEARSHIFT):
this->m.hapticeffect.effecttype = EFFECT_GEARSHIFT;
this->m.vtable = &gear_sound_simdevice_vtable;
slogi("Initializing sound device for gear shift vibrations.");
break;
case (EFFECT_TYRESLIP):
this->m.hapticeffect.effecttype = EFFECT_TYRESLIP;
this->m.hapticeffect.threshold = ds->threshold;
this->m.hapticeffect.threshold = ds->threshold;
slogt("Haptic effect: %i %i", this->m.hapticeffect.effecttype, ds->effect_type);
this->m.hapticeffect.tyre = ds->tyre;
this->m.hapticeffect.useconfig = ms->useconfig;
this->m.hapticeffect.configcheck = &ms->configcheck;
this->m.hapticeffect.tyrediameterconfig = ms->tyre_diameter_config;
this->m.vtable = &tyreslip_sound_simdevice_vtable;
slogi("Initializing sound device for tyre slip vibrations.");
break;
case (EFFECT_TYRELOCK):
this->m.hapticeffect.effecttype = EFFECT_TYRELOCK;
this->m.hapticeffect.threshold = ds->threshold;
this->m.hapticeffect.threshold = ds->threshold;
slogt("Haptic effect: %i %i", this->m.hapticeffect.effecttype, ds->effect_type);
this->m.hapticeffect.tyre = ds->tyre;
this->m.hapticeffect.useconfig = ms->useconfig;
this->m.hapticeffect.configcheck = &ms->configcheck;
this->m.hapticeffect.tyrediameterconfig = ms->tyre_diameter_config;
this->m.vtable = &tyrelock_sound_simdevice_vtable;
slogi("Initializing sound device for tyre slip vibrations.");
break;
case (EFFECT_ABSBRAKES):
this->m.hapticeffect.effecttype = EFFECT_ABSBRAKES;
this->m.hapticeffect.threshold = ds->threshold;
this->m.hapticeffect.threshold = ds->threshold;
slogt("Haptic effect: %i %i", this->m.hapticeffect.effecttype, ds->effect_type);
this->m.hapticeffect.tyre = ds->tyre;
this->m.hapticeffect.useconfig = ms->useconfig;
this->m.hapticeffect.configcheck = &ms->configcheck;
this->m.hapticeffect.tyrediameterconfig = ms->tyre_diameter_config;
this->m.vtable = &absbrakes_sound_simdevice_vtable;
slogi("Initializing sound device for abs vibrations.");
break;
case (EFFECT_SUSPENSION):
if(siminfo->SimSupportsHapticEffects == false)
{
slogw("Skipping sound effect setup because sim does not support haptic effects");
error = MONOCOQUE_ERROR_UNSUPPORTED_SIM_FEATURE;
}
defaut:
error = 0;
this->m.hapticeffect.effecttype = EFFECT_SUSPENSION;
this->m.hapticeffect.threshold = ds->threshold;
this->m.hapticeffect.threshold = ds->threshold;
slogt("Haptic effect: %i %i on tyre %i", this->m.hapticeffect.effecttype, ds->effect_type, ds->tyre);
this->m.hapticeffect.tyre = ds->tyre;
this->m.hapticeffect.useconfig = ms->useconfig;
this->m.hapticeffect.configcheck = &ms->configcheck;
this->m.hapticeffect.tyrediameterconfig = ms->tyre_diameter_config;
this->m.vtable = &suspension_sound_simdevice_vtable;
slogi("Initializing sound device for suspension vibrations.");
break;
}
slogt("Attempting to use sound device %s", ds->sounddevsettings.dev);
if(error == 0)
{
slogt("Attempting to configure sound device with subtype: %i", ds->effect_type);
switch (ds->effect_type)
{
case (EFFECT_ENGINERPM):
this->m.hapticeffect.effecttype = EFFECT_ENGINERPM;
this->m.vtable = &engine_sound_simdevice_vtable;
slogi("Initializing sound device for engine vibrations.");
break;
case (EFFECT_GEARSHIFT):
this->m.hapticeffect.effecttype = EFFECT_GEARSHIFT;
this->m.vtable = &gear_sound_simdevice_vtable;
slogi("Initializing sound device for gear shift vibrations.");
break;
case (EFFECT_TYRESLIP):
this->m.hapticeffect.effecttype = EFFECT_TYRESLIP;
this->m.hapticeffect.threshold = ds->threshold;
this->m.hapticeffect.threshold = ds->threshold;
slogt("Haptic effect: %i %i", this->m.hapticeffect.effecttype, ds->effect_type);
this->m.hapticeffect.tyre = ds->tyre;
this->m.hapticeffect.useconfig = ms->useconfig;
this->m.hapticeffect.configcheck = &ms->configcheck;
this->m.hapticeffect.tyrediameterconfig = ms->tyre_diameter_config;
this->m.vtable = &tyreslip_sound_simdevice_vtable;
slogi("Initializing sound device for tyre slip vibrations.");
break;
case (EFFECT_TYRELOCK):
this->m.hapticeffect.effecttype = EFFECT_TYRELOCK;
this->m.hapticeffect.threshold = ds->threshold;
this->m.hapticeffect.threshold = ds->threshold;
slogt("Haptic effect: %i %i", this->m.hapticeffect.effecttype, ds->effect_type);
this->m.hapticeffect.tyre = ds->tyre;
this->m.hapticeffect.useconfig = ms->useconfig;
this->m.hapticeffect.configcheck = &ms->configcheck;
this->m.hapticeffect.tyrediameterconfig = ms->tyre_diameter_config;
this->m.vtable = &tyrelock_sound_simdevice_vtable;
slogi("Initializing sound device for tyre slip vibrations.");
break;
case (EFFECT_ABSBRAKES):
this->m.hapticeffect.effecttype = EFFECT_ABSBRAKES;
this->m.hapticeffect.threshold = ds->threshold;
this->m.hapticeffect.threshold = ds->threshold;
slogt("Haptic effect: %i %i", this->m.hapticeffect.effecttype, ds->effect_type);
this->m.hapticeffect.tyre = ds->tyre;
this->m.hapticeffect.useconfig = ms->useconfig;
this->m.hapticeffect.configcheck = &ms->configcheck;
this->m.hapticeffect.tyrediameterconfig = ms->tyre_diameter_config;
this->m.vtable = &absbrakes_sound_simdevice_vtable;
slogi("Initializing sound device for abs vibrations.");
break;
case (EFFECT_SUSPENSION):
this->m.hapticeffect.effecttype = EFFECT_SUSPENSION;
this->m.hapticeffect.threshold = ds->threshold;
this->m.hapticeffect.threshold = ds->threshold;
slogt("Haptic effect: %i %i on tyre %i", this->m.hapticeffect.effecttype, ds->effect_type, ds->tyre);
this->m.hapticeffect.tyre = ds->tyre;
this->m.hapticeffect.useconfig = ms->useconfig;
this->m.hapticeffect.configcheck = &ms->configcheck;
this->m.hapticeffect.tyrediameterconfig = ms->tyre_diameter_config;
this->m.vtable = &suspension_sound_simdevice_vtable;
slogi("Initializing sound device for suspension vibrations.");
break;
}
}
if(error == 0)
{
slogt("Attempting to use sound device %s", ds->sounddevsettings.dev);
error = sounddev_init(this, ds->sounddevsettings.dev, ds->tyre, ds->sounddevsettings);
}
int error = sounddev_init(this, ds->sounddevsettings.dev, ds->tyre, ds->sounddevsettings);
if (error != 0)
{
free(this);
+4 -5
View File
@@ -54,7 +54,7 @@ int usbdev_free(SimDevice* this)
return 0;
}
int usbdev_init(USBDevice* usbdevice, DeviceSettings* ds, SimInfo* siminfo)
int usbdev_init(USBDevice* usbdevice, DeviceSettings* ds)
{
slogi("initializing usb device...");
int error = 0;
@@ -70,7 +70,7 @@ int usbdev_init(USBDevice* usbdevice, DeviceSettings* ds, SimInfo* siminfo)
error = wheeldev_init(usbdevice, ds);
break;
case USBDEV_GENERICHAPTIC :
error = usbhapticdev_init(&usbdevice->u.hapticdevice, ds, siminfo);
error = usbhapticdev_init(&usbdevice->u.hapticdevice, ds);
break;
}
@@ -79,7 +79,7 @@ int usbdev_init(USBDevice* usbdevice, DeviceSettings* ds, SimInfo* siminfo)
static const vtable usb_simdevice_vtable = { &usbdev_update, &usbdev_free };
USBDevice* new_usb_device(DeviceSettings* ds, MonocoqueSettings* ms, SimInfo* siminfo) {
USBDevice* new_usb_device(DeviceSettings* ds, MonocoqueSettings* ms) {
USBDevice* this = (USBDevice*) malloc(sizeof(USBDevice));
@@ -112,11 +112,10 @@ USBDevice* new_usb_device(DeviceSettings* ds, MonocoqueSettings* ms, SimInfo* si
this->type = USBDEV_GENERICHAPTIC;
}
int error = usbdev_init(this, ds, siminfo);
int error = usbdev_init(this, ds);
if (error != 0)
{
slogw("Did not initialize usb device due to error code %i", error);
free(this);
return NULL;
}
+1 -7
View File
@@ -67,14 +67,8 @@ int usbhapticdev_free(USBGenericHapticDevice* usbhapticdevice)
return 0;
}
int usbhapticdev_init(USBGenericHapticDevice* usbhapticdevice, DeviceSettings* ds, SimInfo* siminfo)
int usbhapticdev_init(USBGenericHapticDevice* usbhapticdevice, DeviceSettings* ds)
{
if(siminfo->SimSupportsHapticEffects == false)
{
slogi("This sim does not support haptic effects");
return MONOCOQUE_ERROR_UNSUPPORTED_SIM_FEATURE;
}
int error = 0;
usbhapticdevice->state = 0;
usbhapticdevice->value0 = ds->usbdevsettings.value0;
+1 -1
View File
@@ -31,7 +31,7 @@ USBGenericHapticDevice;
int usbhapticdev_update(USBGenericHapticDevice* hapticdevice, SimData* simdata, int tyre, int useconfig, int* configcheck, char* configfile);
int usbhapticdev_init(USBGenericHapticDevice* hapticdevice, DeviceSettings* ds, SimInfo* siminfo);
int usbhapticdev_init(USBGenericHapticDevice* hapticdevice, DeviceSettings* ds);
int usbhapticdev_free(USBGenericHapticDevice* hapticdevice);
#endif
+82 -97
View File
@@ -29,7 +29,6 @@ uv_idle_t idler;
uv_timer_t datachecktimer;
uv_timer_t showstatstimer;
uv_timer_t datamaptimer;
uv_timer_t tyrediametertimer;
uv_udp_t recv_socket;
bool doui = false;
@@ -38,7 +37,6 @@ int appstate = 0;
void shmdatamapcallback(uv_timer_t* handle);
void showstatscallback(uv_timer_t* handle);
void datacheckcallback(uv_timer_t* handle);
void tyrediametercheckcallback(uv_timer_t* handle);
void startdatalogger(MonocoqueSettings* ms, loop_data* l);
static void close_walk_cb(uv_handle_t* handle, void* arg)
@@ -227,67 +225,26 @@ void devicetimercallback(uv_timer_t* handle)
SimData* simdata = f->simdata;
SimDevice* device = f->simdevice;
device->update(device, simdata);
}
void tyrediametercheckcallback(uv_timer_t* handle)
{
void* b = uv_handle_get_data((uv_handle_t*) handle);
device_loop_data* f = (device_loop_data*) b;
SimData* simdata = f->simdata;
if(simdata->car != NULL || simdata->car[0] != 0)
{
slogi("car is %s", simdata->car);
// check for saved tyre diameter in config file
// if not saved version exists get tyre diameter and save it
// use config check variable to track if the config check has been performed
// avoid many opens of the same file
int error = 0;
if(hasTyreDiameter(simdata)==false && f->ms->configcheck == 0)
{
slogi("attempting load of tyre diameter config");
error = loadtyreconfig(simdata, f->ms->tyre_diameter_config, true);
f->ms->configcheck = 1;
}
if(hasTyreDiameter(simdata)==false)
{
slogt("could not find tyre diameter in config file, attempting to calculate new");
getTyreDiameter(simdata);
// if this successfully calculates data the diameters will be saved to the file after the
// sim stops actively mapping data
}
}
if(hasTyreDiameter(simdata)==true)
{
int a = loadtyreconfig(simdata, f->ms->tyre_diameter_config, false);
if(a < 0)
{
slogi("saving new tyre diameter config for car %s");
savetyreconfig(simdata, f->ms->tyre_diameter_config);
}
uv_timer_stop(handle);
}
}
void looprun(MonocoqueSettings* ms, loop_data* f, SimData* simdata)
{
if (doui == true)
{
slogi("looking for ui config %s pass 1 simapi %i", ms->config_str, f->siminfo.simulatorapi);
int confignum = getconfigtouse2(ms->config_str, simdata->car, f->siminfo.simulatorapi);
slogi("looking for ui config %s pass 1", ms->config_str);
int confignum = getconfigtouse2(ms->config_str, simdata->car, f->sim);
slogi("first pass finished");
if(confignum == -1)
{
slogi("looking for ui config %s pass 2", ms->config_str);
confignum = getconfigtouse1(ms->config_str, simdata->car, f->siminfo.simulatorapi);
confignum = getconfigtouse1(ms->config_str, simdata->car, f->sim);
}
if(confignum == -1)
{
slogi("looking for ui config %s pass 3", ms->config_str);
confignum = getconfigtouse(ms->config_str, simdata->car, f->siminfo.simulatorapi);
confignum = getconfigtouse(ms->config_str, simdata->car, f->sim);
}
int configureddevices;
@@ -302,8 +259,7 @@ void looprun(MonocoqueSettings* ms, loop_data* f, SimData* simdata)
}
f->simdevices = malloc(f->numdevices * sizeof(SimDevice));
int initdevices = devinit(f->simdevices, &f->siminfo, configureddevices, ds, ms);
slogi("initialized %i devices", initdevices);
int initdevices = devinit(f->simdevices, configureddevices, ds, ms);
for( int i = 0; i < configureddevices; i++)
{
@@ -315,7 +271,6 @@ void looprun(MonocoqueSettings* ms, loop_data* f, SimData* simdata)
SimDevice* devices = f->simdevices;
f->device_timers = (uv_timer_t*) (malloc(uv_handle_size(UV_TIMER) * numdevices));
f->device_batons = (device_loop_data*) (malloc(sizeof(device_loop_data) * numdevices));
f->started_tyre_calc_thread = false;
for (int x = 0; x < numdevices; x++)
{
@@ -330,26 +285,10 @@ void looprun(MonocoqueSettings* ms, loop_data* f, SimData* simdata)
int interval = 1000/devices[x].fps;
uv_timer_start(dt, devicetimercallback, 0, interval);
slogi("starting device type %i at id at %i fps: %i (%i ms ticks)", devices[x].type, x, devices[x].fps, interval);
SimInfo siminfo = f->siminfo;
if(f->started_tyre_calc_thread == false)
{
if(devices[x].hapticeffect.effecttype == EFFECT_TYRELOCK || devices[x].hapticeffect.effecttype == EFFECT_TYRESLIP || devices[x].hapticeffect.effecttype == EFFECT_ABSBRAKES)
{
if(siminfo.SimCalculatesTyreDiameter == false && siminfo.SimSupportsHapticEffects == true && siminfo.SimCalculatesSlipRatio == false && f->ms->useconfig == 1 && f->ms->tyre_diameter_config != NULL)
{
slogi("Starting thread to calculate tyre diameters and save to config file");
f->started_tyre_calc_thread = true;
f->tyrebaton = (device_loop_data*) malloc(sizeof(device_loop_data));
f->tyrebaton->simdata = simdata;
f->tyrebaton->ms = f->ms;
uv_handle_set_data((uv_handle_t*) &tyrediametertimer, (void*) f->tyrebaton);
uv_timer_start(&tyrediametertimer, tyrediametercheckcallback, 0, 1000);
}
}
}
}
else
{
slogw("skipped id %i", x);
}
}
@@ -357,6 +296,43 @@ void looprun(MonocoqueSettings* ms, loop_data* f, SimData* simdata)
uv_timer_start(&showstatstimer, showstatscallback, 0, 100);
doui = false;
}
else
{
//showstats(simdata);
//SimDevice* devices = f->simdevices;
//int numdevices = f->numdevices;
//for (int x = 0; x < numdevices; x++)
//{
// if (devices[x].initialized == true && devices[x].type == 2)
// {
// devices[x].update(&devices[x], simdata);
// }
//}
if(f->ms->useconfig == 1 && f->ms->tyre_diameter_config != NULL)
{
if(simdata->car != NULL || simdata->car[0] != 0)
{
// check for saved tyre diameter in config file
// if not saved version exists get tyre diameter and save it
// use config check variable to track if the config check has been performed
// avoid many opens of the same file
int error = 0;
if(hasTyreDiameter(simdata)==false && f->ms->configcheck == 0)
{
slogi("attempting load of tyre diameter config");
error = loadtyreconfig(simdata, f->ms->tyre_diameter_config, true);
f->ms->configcheck = 1;
}
if(hasTyreDiameter(simdata)==false)
{
slogt("could not find tyre diameter in config file, attempting to calculate new");
getTyreDiameter(simdata);
}
}
}
}
}
void showstatscallback(uv_timer_t* handle)
@@ -388,12 +364,16 @@ void releaseloop(loop_data* f, SimData* simdata, SimMap* simmap)
// uv_close((uv_handle_t*)&recv_socket, NULL);
//}
slogi("releasing devices, please wait");
//attempt tyre diameter saving
uv_timer_stop(&tyrediametertimer);
if(f->started_tyre_calc_thread == true)
if(hasTyreDiameter(simdata) == true)
{
free(f->tyrebaton);
int a = loadtyreconfig(simdata, f->ms->tyre_diameter_config, false);
if(a < 0)
{
slogi("saving new tyre diameter config");
savetyreconfig(simdata, f->ms->tyre_diameter_config);
}
}
f->uion = false;
@@ -436,7 +416,7 @@ void releaseloop(loop_data* f, SimData* simdata, SimMap* simmap)
}
free(devices);
int r = simapi_sim_clear(simdata, simmap, false);
int r = simfree(simdata, simmap, f->map);
slogd("simfree returned %i", r);
f->numdevices = 0;
slogi("stopped mapping data, press q again to quit");
@@ -466,11 +446,11 @@ void shmdatamapcallback(uv_timer_t* handle)
//appstate = 2;
if (appstate == 2)
{
simapi_datamap(simdata, simmap, f->siminfo.mapapi, false, NULL);
simdatamap(simdata, simmap, NULL, f->map, false, NULL);
looprun(ms, f, simdata);
}
if (f->siminfo.isSimOn == false || simdata->simstatus <= 1 || appstate <= 1)
if (f->simstate == false || simdata->simstatus <= 1 || appstate <= 1)
{
releaseloop(f, simdata, simmap);
}
@@ -503,11 +483,11 @@ static void on_udp_recv(uv_udp_t* handle, ssize_t nread, const uv_buf_t* rcvbuf,
if (appstate == 2)
{
simapi_datamap(simdata, simmap, f->siminfo.mapapi, true, a);
simdatamap(simdata, simmap, NULL, f->map, true, a);
looprun(ms, f, simdata);
}
if (f->siminfo.isSimOn == false || simdata->simstatus <= 1 || appstate <= 1)
if (f->simstate == false || simdata->simstatus <= 1 || appstate <= 1)
{
releaseloop(f, simdata, simmap);
}
@@ -518,7 +498,7 @@ static void on_udp_recv(uv_udp_t* handle, ssize_t nread, const uv_buf_t* rcvbuf,
int startudp(int port)
{
uv_udp_init(uv_default_loop(), &recv_socket);
struct sockaddr_in recv_addr;
uv_ip4_addr("0.0.0.0", port, &recv_addr);
int err = uv_udp_bind(&recv_socket, (const struct sockaddr *) &recv_addr, UV_UDP_REUSEADDR);
@@ -531,7 +511,7 @@ void udpstart(MonocoqueSettings* sms, loop_data* f, SimData* simdata, SimMap* si
{
if (appstate == 2)
{
simapi_datamap(simdata, simmap, f->siminfo.simulatorapi, true, NULL);
simdatamap(simdata, simmap, NULL, f->sim, true, NULL);
if (doui == true)
{
looprun(sms, f, simdata);
@@ -548,14 +528,19 @@ void datacheckcallback(uv_timer_t* handle)
if ( appstate == 1 )
{
f->siminfo = simapi_get_sim(simdata, simmap, f->ms->force_udp_mode, startudp, false);
SimInfo si = getSim(simdata, simmap, f->ms->force_udp_mode, startudp, false);
//TODO: move all this to a siminfo struct in loop_data
f->simstate = si.isSimOn;
f->sim = si.simulatorapi;
f->map = si.mapapi;
f->use_udp = si.SimUsesUDP;
if(f->ms->force_udp_mode == true)
{
f->use_udp = true;
}
}
if (f->siminfo.isSimOn == true && simdata->simstatus >= 2)
if (f->simstate == true && simdata->simstatus >= 2)
{
if ( appstate == 1 )
{
@@ -566,12 +551,13 @@ void datacheckcallback(uv_timer_t* handle)
simdata->tyrediameter[2] = -1;
simdata->tyrediameter[3] = -1;
if(f->use_udp == true || f->siminfo.SimUsesUDP == true)
if(f->use_udp == true)
{
slogt("starting udp receive loop");
udpstart(f->ms, f, simdata, simmap);
uv_udp_recv_start(&recv_socket, on_alloc, on_udp_recv);
slogt("udp receive loop started");
uv_timer_stop(handle);
}
else
{
@@ -579,11 +565,12 @@ void datacheckcallback(uv_timer_t* handle)
slogd("starting telemetry mapping at %i fps (%i ms ticks)", f->ms->fps, interval);
uv_timer_start(&datamaptimer, shmdatamapcallback, 2000, interval);
}
//uv_timer_start(&datachecktimer, datacheckcallback, 0, 3000);
}
if(appstate == 2)
{
f->siminfo = simapi_get_sim(simdata, simmap, f->ms->force_udp_mode, NULL, false);
if(f->siminfo.isSimOn == false)
SimInfo si = getSim(simdata, simmap, f->ms->force_udp_mode, NULL, false);
if(si.isSimOn == false)
{
appstate = 1;
releaseloop(f, simdata, simmap);
@@ -633,7 +620,7 @@ int monocoque_mainloop(MonocoqueSettings* ms)
{
SimData* simdata = malloc(sizeof(SimData));
SimMap* simmap = simapi_simmap_create();
SimMap* simmap = createSimMap();
struct termios newsettings, canonicalmode;
tcgetattr(0, &canonicalmode);
@@ -651,25 +638,23 @@ int monocoque_mainloop(MonocoqueSettings* ms)
baton->simmap = simmap;
baton->simdata = simdata;
baton->ms = ms;
baton->simstate = false;
baton->uion = false;
baton->releasing = false;
baton->use_udp = false;
baton->sim = 0;
baton->req.data = (void*) baton;
simapi_set_log_info(simapilib_loginfo);
simapi_set_log_debug(simapilib_logdebug);
simapi_set_log_trace(simapilib_logtrace);
set_simapi_log_info(simapilib_loginfo);
set_simapi_log_debug(simapilib_logdebug);
set_simapi_log_trace(simapilib_logtrace);
if (0 != uv_poll_init(uv_default_loop(), poll, 0))
{
return 1;
};
uv_udp_init(uv_default_loop(), &recv_socket);
uv_timer_init(uv_default_loop(), &datachecktimer);
uv_timer_init(uv_default_loop(), &showstatstimer);
uv_timer_init(uv_default_loop(), &datamaptimer);
uv_timer_init(uv_default_loop(), &tyrediametertimer);
slogd("setting initial app state");
appstate = 1;
@@ -701,7 +686,7 @@ int monocoque_mainloop(MonocoqueSettings* ms)
free(baton);
free(simdata);
free(simmap);
freesimmap(simmap, false);
return 0;
}
@@ -744,7 +729,7 @@ int tester(SimDevice* devices, int numdevices)
sleep(1);
fprintf(stdout, "Revving rpm from 1000 to 8000 and back\n");
// TODO: look into this, my serial leds make this hang
for (int r = 0; r < 8000; r += 3)
{
simdata->rpms = 1000 + r;
+3 -9
View File
@@ -10,33 +10,27 @@
typedef struct device_loop_data
{
// these are all pointers to pointers and freed independently, usually in releaseloop
uv_work_t req;
SimData* simdata;
SimDevice* simdevice;
MonocoqueSettings* ms;
SimInfo siminfo;
} device_loop_data;
typedef struct loop_data
{
uv_work_t req;
SimulatorAPI sim;
SimulatorAPI map;
bool use_udp;
bool simstate;
bool uion;
bool releasing;
bool started_tyre_calc_thread;
int numdevices;
SimInfo siminfo;
// monocoque settings is a pointer from monocoque.c and freed there
MonocoqueSettings* ms;
// these are freed at the end of the main gameloop
SimData* simdata;
SimMap* simmap;
// these all get malloced in looprun and freed in releaseloop
SimDevice* simdevices;
uv_timer_t* device_timers;
device_loop_data* device_batons;
device_loop_data* tyrebaton;
} loop_data;
+2 -16
View File
@@ -113,16 +113,6 @@ int strtodevsubsubtype(const char* device_subsubtype, DeviceSettings* ds)
ds->dev_subsubtype = SIMDEVSUBTYPE_MOZAR5;
devfound = true;
}
if (strcicmp(device_subsubtype, "MozaR3") == 0)
{
ds->dev_subsubtype = SIMDEVSUBTYPE_MOZAR5;
devfound = true;
}
if (strcicmp(device_subsubtype, "MozaKSProWheel") == 0)
{
ds->dev_subsubtype = SIMDEVSUBTYPE_MOZA_KS_PRO_WHEEL;
devfound = true;
}
if (strcicmp(device_subsubtype, "CSLELITEV3PEDALS") == 0)
{
ds->dev_subsubtype = SIMDEVSUBTYPE_CSLELITEV3PEDALS;
@@ -720,7 +710,7 @@ int devsetup(const char* device_type, const char* device_subtype, const char* co
}
}
if (ds->dev_subtype == SIMDEVTYPE_USBHAPTIC || ds->dev_subtype == SIMDEVTYPE_USBWHEEL || ds->dev_subtype == SIMDEVTYPE_SERIALWHEEL)
if (ds->dev_subtype == SIMDEVTYPE_USBHAPTIC || ds->dev_subtype == SIMDEVTYPE_USBWHEEL)
{
// logic for different devices
int b = 0;
@@ -871,11 +861,7 @@ int devsetup(const char* device_type, const char* device_subtype, const char* co
found = config_setting_lookup_float(device_settings, "ampfactor", &ampfactor);
ds->serialdevsettings.ampfactor = ampfactor;
double fanpower = 0.6;
config_setting_lookup_float(device_settings, "fanpower", &fanpower);
ds->serialdevsettings.fanpower = fanpower;
slogt("set port baud rate to %i, ampfactor %f, fanpower %f", baud, ampfactor, fanpower);
slogt("set port baud rate to %i, ampfactor %f", baud, ampfactor);
}
+7 -10
View File
@@ -45,8 +45,7 @@ typedef enum
SIMDEVSUBTYPE_SIMAGICP1000PEDALS = 5,
SIMDEVSUBTYPE_SIMAGICGTNEO = 6,
SIMDEVSUBTYPE_MOZA_NEW = 7,
SIMDEVSUBTYPE_LOGITECH_G29 = 8,
SIMDEVSUBTYPE_MOZA_KS_PRO_WHEEL = 9
SIMDEVSUBTYPE_LOGITECH_G29 = 8
}
DeviceSubSubType;
@@ -110,13 +109,12 @@ MonocoqueGear;
typedef enum
{
MONOCOQUE_ERROR_NONE = 0,
MONOCOQUE_ERROR_UNKNOWN = 1,
MONOCOQUE_ERROR_INVALID_SIM = 2,
MONOCOQUE_ERROR_INVALID_DEV = 3,
MONOCOQUE_ERROR_NODATA = 4,
MONOCOQUE_ERROR_UNKNOWN_DEV = 5,
MONOCOQUE_ERROR_UNSUPPORTED_SIM_FEATURE = 6,
MONOCOQUE_ERROR_NONE = 0,
MONOCOQUE_ERROR_UNKNOWN = 1,
MONOCOQUE_ERROR_INVALID_SIM = 2,
MONOCOQUE_ERROR_INVALID_DEV = 3,
MONOCOQUE_ERROR_NODATA = 4,
MONOCOQUE_ERROR_UNKNOWN_DEV = 5
}
MonocoqueError;
@@ -169,7 +167,6 @@ typedef struct
int startled;
int endled;
float ampfactor;
float fanpower;
int baud;
}
SerialDeviceSettings;
+2 -6
View File
@@ -193,8 +193,6 @@ int main(int argc, char** argv)
SimDevice* tachdev = malloc(sizeof(SimDevice));
tachdev->initialized = false;
SimData* sdata = malloc(sizeof(SimData));
SimInfo* siminfo = malloc(sizeof(SimInfo));
simapi_set_faux_siminfo(siminfo);
DeviceSettings* ds = malloc(sizeof(DeviceSettings));
error = devsetup("USB", "Tachometer", "None", ms, ds, NULL);
@@ -207,7 +205,7 @@ int main(int argc, char** argv)
{
int devices = 0;
devices = devinit(tachdev, siminfo, 1, ds, ms);
devices = devinit(tachdev, 1, ds, ms);
if(devices < 1)
{
error = MONOCOQUE_ERROR_INVALID_DEV;
@@ -290,9 +288,7 @@ int main(int argc, char** argv)
int numdevices = uiloadconfig(ms->config_str, confignum, configureddevices, ms, ds);
SimDevice* simdevices = malloc(numdevices * sizeof(SimDevice));
SimInfo* siminfo = malloc(sizeof(SimInfo));
simapi_set_faux_siminfo(siminfo);
int initdevices = devinit(simdevices, siminfo, configureddevices, ds, ms);
int initdevices = devinit(simdevices, configureddevices, ds, ms);
for( int i = 0; i < configureddevices; i++)
{
settingsfree(ds[i]);
@@ -40,6 +40,7 @@ set(simulatorapi_source_files
simapi/simapi/mapping/wreckfest2mapper.c
simapi/simapi/mapping/forzamapper.c
simapi/simapi/getpid.c
simapi/simapi/getpid.h
)
add_library(simulatorapi STATIC ${simulatorapi_source_files})
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
-254
View File
@@ -1,254 +0,0 @@
#!/bin/bash
# Monocoque Distrobox Installer
# For immutable Linux distributions (Bazzite, Silverblue, etc.)
# where native package managers are unavailable.
#
# Installs monocoque and dependencies inside an Arch Linux distrobox container,
# with wrapper scripts on the host for transparent access.
set -euo pipefail
SCRIPT_VERSION="1.0.0"
CONTAINER="simracing"
INSTALL_DIR="$HOME/.local/share/simracing"
BIN_DIR="$HOME/.local/bin"
CONFIG_DIR="$HOME/.config/monocoque"
# Color output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
print_header() {
echo ""
echo "╔══════════════════════════════════════════════════════════════════╗"
echo "║ Monocoque Distrobox Installer v${SCRIPT_VERSION} ║"
echo "╚══════════════════════════════════════════════════════════════════╝"
echo ""
}
# --- Main ---
print_header
# Check ~/.local/bin is in PATH
if [[ ":$PATH:" != *":$BIN_DIR:"* ]]; then
log_error "$BIN_DIR is not in your PATH."
log_info "Add this to your shell config:"
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
exit 1
fi
# Check distrobox is available
if ! command -v distrobox &>/dev/null; then
log_error "distrobox is not installed."
log_info "Install distrobox first: https://distrobox.it/#installation"
exit 1
fi
# Ensure dialout group exists and user is a member
log_info "Checking serial device access (dialout group)..."
if ! grep -q '^dialout:' /etc/group 2>/dev/null; then
if grep -q '^dialout:' /usr/lib/group 2>/dev/null; then
log_info "Adding dialout group to /etc/group (Fedora Atomic fix)..."
grep -E '^dialout:' /usr/lib/group | sudo tee -a /etc/group >/dev/null
else
log_info "Creating dialout group..."
sudo groupadd dialout
fi
fi
if ! groups | grep -qw dialout; then
log_info "Adding $USER to the dialout group for serial device access..."
sudo usermod -aG dialout "$USER"
log_warn "You will need to REBOOT after setup completes for serial access to work."
echo ""
fi
# Prevent ModemManager from grabbing Moza serial devices
UDEV_RULE="/etc/udev/rules.d/99-moza-serial.rules"
if [ ! -f "$UDEV_RULE" ]; then
if systemctl is-active --quiet ModemManager 2>/dev/null; then
echo ""
log_warn "ModemManager is running on your system."
echo " Moza wheel bases use USB serial devices that ModemManager may claim,"
echo " preventing monocoque from communicating with the wheel."
echo ""
echo " A udev rule can tell ModemManager to ignore Moza devices (vendor 346e)."
echo " This only affects Moza USB devices — other modems will work normally."
echo ""
read -rp "Install udev rule to prevent ModemManager from grabbing Moza devices? [Y/n]: " mm_confirm
if [[ "$mm_confirm" =~ ^[Nn]$ ]]; then
echo ""
log_info "Skipped udev rule. If monocoque can't talk to your wheel, run:"
echo " sudo tee $UDEV_RULE <<< 'ACTION==\"add|change\", SUBSYSTEM==\"usb\", ATTR{idVendor}==\"346e\", ENV{ID_MM_DEVICE_IGNORE}=\"1\"'"
echo " sudo udevadm control --reload-rules && sudo udevadm trigger"
echo ""
else
log_info "Installing udev rule..."
echo 'ACTION=="add|change", SUBSYSTEM=="usb", ATTR{idVendor}=="346e", ENV{ID_MM_DEVICE_IGNORE}="1"' | sudo tee "$UDEV_RULE" >/dev/null
sudo udevadm control --reload-rules
sudo udevadm trigger
log_success "ModemManager udev rule installed"
fi
else
# ModemManager not running — install the rule silently
echo 'ACTION=="add|change", SUBSYSTEM=="usb", ATTR{idVendor}=="346e", ENV{ID_MM_DEVICE_IGNORE}="1"' | sudo tee "$UDEV_RULE" >/dev/null
sudo udevadm control --reload-rules
sudo udevadm trigger
fi
fi
# Create the Arch Linux distrobox container
if ! distrobox list 2>/dev/null | grep -q "$CONTAINER"; then
log_info "Creating Arch Linux container '$CONTAINER'..."
distrobox create \
--image docker.io/library/archlinux:latest \
--name "$CONTAINER" \
--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
log_info "Container '$CONTAINER' already exists, skipping creation."
fi
# Install packages inside the container
log_info "Installing packages inside container (this may take a few minutes)..."
distrobox enter "$CONTAINER" -- bash -c '
set -euo pipefail
# Install build dependencies
echo "Installing build dependencies..."
sudo pacman -Syu --needed --noconfirm base-devel git mingw-w64-gcc
# Install yay (AUR helper) if not present
if ! command -v yay &>/dev/null; then
echo "Installing yay AUR helper..."
TMPDIR=$(mktemp -d)
git clone https://aur.archlinux.org/yay-bin.git "$TMPDIR/yay-bin"
cd "$TMPDIR/yay-bin"
makepkg -si --noconfirm
cd /
rm -rf "$TMPDIR"
fi
# Install AUR packages sequentially (simd depends on simapi, monocoque depends on both)
echo "Installing AUR packages..."
yay -S --needed --noconfirm simapi-git
yay -S --needed --noconfirm simd-git
yay -S --needed --noconfirm monocoque-git
# Build simshmbridge (not on AUR)
INSTALL_DIR="$HOME/.local/share/simracing"
mkdir -p "$INSTALL_DIR"
cd "$INSTALL_DIR"
if [ ! -d "simshmbridge" ]; then
echo "Cloning simshmbridge..."
git clone --recurse-submodules "https://github.com/Spacefreak18/simshmbridge.git"
else
echo "simshmbridge already cloned, pulling latest..."
cd simshmbridge && git pull && git submodule update --init --recursive && cd ..
fi
echo "Building simshmbridge..."
cd "$INSTALL_DIR/simshmbridge"
git submodule update --init --recursive
make clean 2>/dev/null || true
make -j$(nproc)
echo ""
echo "All components built successfully inside container."
'
# Install wrapper scripts to ~/.local/bin
log_info "Installing wrapper scripts..."
mkdir -p "$BIN_DIR"
cat > "$BIN_DIR/start-simd" << 'EOF'
#!/usr/bin/env bash
exec distrobox enter 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 "$@"
EOF
chmod +x "$BIN_DIR/start-monocoque"
cat > "$BIN_DIR/test-monocoque" << 'EOF'
#!/usr/bin/env bash
exec distrobox enter simracing -- monocoque test -vv "$@"
EOF
chmod +x "$BIN_DIR/test-monocoque"
log_success "Wrapper scripts installed"
# Setup monocoque config
mkdir -p "$CONFIG_DIR"
if [ ! -f "$CONFIG_DIR/monocoque.config" ]; then
log_info "Creating monocoque config template..."
cat > "$CONFIG_DIR/monocoque.config" << 'EOF'
configs = (
{
sim = "default";
car = "default";
devices = (
{
device = "Serial";
type = "Wheel";
subtype = "MozaNew";
devpath = "/dev/serial/by-id/CHANGE_ME_TO_YOUR_MOZA_BASE";
baud = 115200;
});
}
);
EOF
log_success "Config created at $CONFIG_DIR/monocoque.config"
else
log_info "Config already exists, skipping"
fi
# Done
echo ""
echo "╔══════════════════════════════════════════════════════════════════╗"
echo "║ Installation Complete! ║"
echo "╚══════════════════════════════════════════════════════════════════╝"
echo ""
log_success "Monocoque (distrobox) installed!"
echo ""
echo " Installed:"
echo " AUR packages: simapi-git, simd-git, monocoque-git (in '$CONTAINER' container)"
echo " Bridge: $INSTALL_DIR/simshmbridge/"
echo " Config: $CONFIG_DIR/monocoque.config"
echo " Commands: start-simd, start-monocoque, test-monocoque"
echo ""
echo " Next steps:"
echo " 1. Set your device path in $CONFIG_DIR/monocoque.config"
echo " (replace CHANGE_ME_TO_YOUR_MOZA_BASE with your device from /dev/serial/by-id/)"
echo " 2. Test with: test-monocoque"
echo " 3. Set Steam launch options for your games to start the telemetry stack automatically:"
echo " In Steam > Game Properties > Launch Options, add:"
echo " start-simd & start-monocoque & <bridge_path> %command%"
echo " For example, for Assetto Corsa:"
echo " start-simd & start-monocoque & $INSTALL_DIR/simshmbridge/assets/acbridge.exe %command%"
echo ""
echo " For tools that automate steps 1 and 3 (Moza auto-detection, Steam launch"
echo " option configuration, unified game launcher), visit:"
echo " https://github.com/cescofry/simracing-utilities"
echo ""
@@ -1,102 +0,0 @@
#!/bin/bash
# Monocoque Distrobox Uninstaller
# Removes the distrobox-based monocoque installation.
set -euo pipefail
CONTAINER="simracing"
BIN_DIR="$HOME/.local/bin"
INSTALL_DIR="$HOME/.local/share/simracing"
CONFIG_DIR="$HOME/.config/monocoque"
UDEV_RULE="/etc/udev/rules.d/99-moza-serial.rules"
# Color output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
print_header() {
echo ""
echo "╔══════════════════════════════════════════════════════════════════╗"
echo "║ Monocoque Distrobox Uninstaller ║"
echo "╚══════════════════════════════════════════════════════════════════╝"
echo ""
}
print_header
log_warn "This will remove:"
echo " - Distrobox container '$CONTAINER'"
echo " - Wrapper scripts ($BIN_DIR/start-simd, start-monocoque, test-monocoque)"
echo " - simshmbridge source ($INSTALL_DIR)"
echo ""
echo "This will NOT remove:"
echo " - Configuration files ($CONFIG_DIR)"
echo " - Convenience scripts (simracing-launch, configure-moza, etc.)"
echo ""
read -rp "Continue with uninstallation? [y/N]: " confirm
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
log_info "Uninstallation cancelled"
exit 0
fi
echo ""
# Remove wrapper scripts
log_info "Removing wrapper scripts..."
rm -f "$BIN_DIR/start-simd"
rm -f "$BIN_DIR/start-monocoque"
rm -f "$BIN_DIR/test-monocoque"
log_success "Wrapper scripts removed"
# Remove simshmbridge source
if [ -d "$INSTALL_DIR" ]; then
log_info "Removing simshmbridge source..."
rm -rf "$INSTALL_DIR"
log_success "simshmbridge source removed"
fi
# Remove distrobox container
if distrobox list 2>/dev/null | grep -q "$CONTAINER"; then
log_info "Removing distrobox container '$CONTAINER'..."
distrobox rm --force "$CONTAINER"
log_success "Container '$CONTAINER' removed"
else
log_info "Container '$CONTAINER' not found, skipping"
fi
# Optionally remove udev rule
if [ -f "$UDEV_RULE" ]; then
echo ""
read -rp "Remove ModemManager udev rule ($UDEV_RULE)? [y/N]: " remove_udev
if [[ "$remove_udev" =~ ^[Yy]$ ]]; then
sudo rm -f "$UDEV_RULE"
sudo udevadm control --reload-rules
sudo udevadm trigger
log_success "udev rule removed"
else
log_info "Keeping udev rule"
fi
fi
echo ""
log_success "Uninstallation complete!"
echo ""
log_info "Config files preserved at $CONFIG_DIR"
echo " To remove those too: rm -rf $CONFIG_DIR"
echo ""
+2 -2
View File
@@ -1,4 +1,4 @@
#dnf install pulseaudio-libs-devel argtable-devel libconfig-devel hidapi-devel libserialport-devel lua-devel libuv-devel libxdg-basedir-devel libxml2-devel procps-ng-devel
#dnf install pulseaudio-libs-devel argtable-devel libconfig-devel hidapi-devel libserialport-devel lua-devel libuv-devel libxdg-basedir-devel libxml2-devel
Summary: A device manager for racing sims
Name: monocoque
Version: 0.0.5
@@ -10,7 +10,7 @@ URL: https://spacefreak18.github.io/simapi
Distribution: Fedora Linux
Vendor: spacefreak18
Packager: Paul Jones <paul@spacefreak18.xyz>
Requires: pulseaudio-libs argtable libconfig hidapi libserialport libuv libxdg-basedir lua-libs libxml2 procps-ng
Requires: pulseaudio-libs argtable libconfig hidapi libserialport libuv libxdg-basedir lua-libs libxml2
%description
A device manager for Racing sims