Compare commits

..
469 Commits
Author SHA1 Message Date
Paul Dino Jones 722cc4eb4e add curl and glew dependencies 2026-08-21 15:45:43 -04:00
Paul Dino Jones 48baedf202 add glu dependency 2026-08-21 15:26:52 -04:00
Paul Dino Jones fdbae6198b temporarily add libcurl as dependency 2026-08-21 15:19:33 -04:00
Paul Dino Jones 1f81a6bc96 removed unneeded include 2026-08-21 15:14:15 -04:00
Paul Dino Jones 89e33cf196 add include guard 2026-08-21 15:09:34 -04:00
Paul Dino Jones 7924ef474e add copyright, icons, and gmonocoque to debian packages 2026-08-21 14:49:38 -04:00
Paul Dino Jones d8c85bdc95 Add gmonocoque to fedora 43 build spec 2026-08-21 14:49:13 -04:00
Paul Dino Jones 19c5afa329 add copyright file to package build 2026-08-21 13:36:14 -04:00
Paul Dino Jones 27aea767d8 Add nappgui to dependencies list 2026-08-21 13:33:50 -04:00
Paul Dino Jones 062a4e77ce add header to copyright file 2026-08-21 13:13:51 -04:00
Paul Dino Jones 68b273376d adding copyright file for debian packages 2026-08-21 13:11:46 -04:00
Paul Dino Jones 698ed02987 adding desktop file 2026-08-21 12:53:05 -04:00
Paul Dino Jones ecaf41265a move things around in CMake file 2026-08-20 17:11:13 -04:00
Paul Dino Jones dd93098f39 added gui code 2026-08-18 16:39:24 -04:00
Paul Dino Jones 6d4567facf Only add gui subdirectory on gui builds 2026-06-25 19:35:09 -04:00
Paul Dino Jones 7f52462b68 Add mgui when building gui. Compile as PIE. Add nappgui submodule 2026-06-25 16:28:10 -04:00
Paul Dino Jones 945a04ee66 Add mgui when building gui 2026-06-25 16:24:05 -04:00
Paul Dino Jones 4a30a9735e Add targets for library, cli and gui components 2026-06-25 13:27:19 -04:00
Paul Dino Jones 27b7da8c89 disable arch builds for now 2026-06-24 16:16:27 -04:00
Paul Dino Jones 78cc80064a Fix issue with new haptic code on usb devices and consolidate some function calls 2026-06-23 20:07:53 -04:00
Paul Dino Jones 8eb433f01e Refactor haptic code and devices that rely on it, to more easily allow devices to use the haptic attributes 2026-06-23 13:29:49 -04:00
Paul Dino Jones c4fa9e4138 custom nspawn script for arch build 2026-06-22 13:09:50 -04:00
Paul Dino Jones a9f49d91b9 update to use parent arch pkgbuild workflow action 2026-06-22 12:54:14 -04:00
Paul Dino Jones 87818b6a22 specify correct arch build action 2026-06-22 12:44:31 -04:00
Paul Dino Jones 17dcdcde23 fix path to PKGBUILD 2026-06-22 12:34:38 -04:00
Paul Dino Jones 5c0f871415 Update path to PKGBUILD 2026-06-22 12:32:47 -04:00
Paul Dino Jones 44b9dce139 Add arch build to CI 2026-06-22 12:27:52 -04:00
Paul Dino Jones a776085b76 Add arch build to CI 2026-06-22 12:25:49 -04:00
Paul Dino Jones 0d30170de0 Set buffer size to 64 bytes for simnet pedals. Send 0 for frequency and amplitude when no effect is playing 2026-06-11 18:28:21 -04:00
Paul Dino Jones 2aee847d7c update to latest simapi for ac evo 2026-06-09 13:05:59 -04:00
Paul Dino Jones 9712396c6f Add initial support for simnet pedals 2026-06-01 16:00:13 -04:00
Paul Dino Jones 6a36c2825f further fix return codes on serial devices 2026-05-29 18:21:52 -04:00
Paul Dino Jones 2b787cba00 cleanup the way errors are returned for arduino type devices 2026-05-29 14:28:24 -04:00
Paul Dino Jones 3c81f749b8 various fixes for weirdness with serial devices 2026-05-28 16:25:55 -04:00
David Scott 3c1b1948fd create a rootful, privileged distrobox container (#47) 2026-05-27 13:49:30 -04:00
Paul Dino Jones 3b10509ecd add some directives that seem necessary for debian 2026-05-25 23:58:33 -04:00
Paul Dino Jones b734330d38 fix lua linking 2026-05-25 23:36:57 -04:00
Paul Dino Jones eb95db1dda rename lua in headers 2026-05-25 23:13:53 -04:00
Paul Dino Jones 3a803550ea add more lua variables back to cmake 2026-05-25 23:11:04 -04:00
Paul Dino Jones 26e0e87cd7 add macro for lua 5.4 backwards compatibility so we can compile against lua 5.4 or 5.5 2026-05-25 23:03:57 -04:00
Paul Dino Jones 7f17a5307c refer explicitly to lua 5.4 in headers 2026-05-25 20:46:47 -04:00
Paul Dino Jones ae87a2eaa5 add more dependencies to install.sh 2026-05-25 19:54:08 -04:00
Paul Dino Jones 738a181d61 force lua 5.4 in cmake 2026-05-25 19:53:47 -04:00
Paul Dino Jones ba6c624a59 Improve lua dependency detection for linking 2026-05-25 19:17:47 -04:00
Brandan Cotton 822d4096e7 make additional data available to lua scripts (#45) 2026-05-25 08:42:19 -04:00
Paul Dino Jones a3e932e2dc updated to latest simapi for process detection 2026-05-23 12:40:42 -04:00
Paul Dino Jones ad53dd654c build simapi in install script 2026-05-22 17:45:36 -04:00
Paul Dino Jones 522185d19b remove deprectated getpid.h file 2026-04-26 19:38:15 -04:00
Paul Dino Jones 030813cd4f Update to latest simapi 2026-04-26 19:16:29 -04:00
Paul Dino Jones 53467a2a5e Fix cmake compile definitions 2026-04-23 17:35:50 -04:00
Paul Dino Jones b5fa399f79 fix cmake boolean 2026-04-23 17:20:57 -04:00
Paul Dino Jones 4a72f760b6 fix proc2 detection 2026-04-23 16:02:02 -04:00
Paul Dino Jones 89c73a2fd3 fix lua version issue 2026-04-23 15:25:21 -04:00
Paul Dino Jones 6b72e23638 Add procps dependency. Update to latest simapi 2026-04-22 16:35:43 -04:00
Tony Miceli 8c6b8ef7ac Fix multiple serial device init issues (#43) 2026-04-20 10:35:36 -04:00
Francesco a628afa815 Distrobox install (#41) 2026-04-20 10:26:16 -04:00
Simon Zengerling 712b900d68 Feat add moza ks pro wheel (#42) 2026-04-11 16:07:17 -04:00
Paul Dino Jones 79642a7653 Add config entry for Moza R3 2026-04-04 10:02:16 -04:00
Tony Miceli fbe92cc1c9 add configurable fanpower for simwind and new PWM sketch (#37) 2026-04-03 18:03:08 -04:00
Paul Dino Jones 9e32b3f286 disable installing systemd service via cmake 2026-03-20 19:47:31 -04:00
Paul Dino Jones b3b2c6854d move saving of tyre diameter config to when we still know the car and sim info 2026-03-18 15:41:57 -04:00
Paul Dino Jones 29b446e648 Fix issue with monocoque not shutting down cleanly when used in standalone udp mode 2026-03-18 11:48:43 -04:00
Paul Dino Jones 0142ab61a3 Refactor how sim calculate tyre diameter data if necessary 2026-03-18 11:10:35 -04:00
Paul Dino Jones 09a832a38e Use sim provided slip ratio if available for slip based effects 2026-03-17 10:32:27 -04:00
Paul Dino Jones 9f99cb3e12 Fix regression braking udp support 2026-03-17 10:31:32 -04:00
Paul Dino Jones acc37e005a Refactor to provide siminfo to help decide if and how a device can be initialize 2026-03-16 17:40:13 -04:00
Paul Dino Jones e5ac137b04 bring in fixes to crashes caused by new simapi 2026-03-11 23:57:01 -04:00
Paul Dino Jones 522a64b0f3 Update to latest simapi 2026-03-11 22:40:01 -04:00
Paul Dino Jones d465db0055 Remove more debug code 2026-03-04 01:09:45 -05:00
Paul Dino Jones 2eb48907a0 fix compilation error 2026-03-03 23:42:18 -05:00
Paul Dino Jones 479c77d251 clean up debug code in pulseaudio mainloop start 2026-03-03 23:37:45 -05:00
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
56 changed files with 3909 additions and 455 deletions
+18
View File
@@ -0,0 +1,18 @@
#!/bin/bash
# https://gitlab.archlinux.org/archlinux/devtools/-/merge_requests/197
args=("$@")
has_keep_unit=0
for arg in "${args[@]}"; do
if [[ "$arg" == "--keep-unit" ]]; then
has_keep_unit=1
fi
done
if ! (( has_keep_unit )); then
args=("--keep-unit" "${args[@]}")
fi
exec /usr/bin/systemd-nspawn "${args[@]}"
+37 -2
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 libgtk-3-dev libuv1-dev libargtable2-dev libserialport-dev libconfig-dev libhidapi-dev liblua5.4-dev libxdg-basedir-dev libxml2-dev libpulse-dev libproc2-dev libcurl4-openssl-dev libglu1-mesa-dev
- name: Set build dir
id: strings
shell: bash
@@ -34,6 +34,7 @@ jobs:
- name: Configure CMake
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DBUILD_GUI=on
-DCMAKE_CXX_COMPILER=g++
-DCMAKE_C_COMPILER=gcc
-DCMAKE_BUILD_TYPE=Release
@@ -42,13 +43,27 @@ jobs:
- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config Release
- name: Copy script files around to stop .github from being added to the package then build the package
- name: Create directories in package
run: |
mkdir PKG_SOURCE
mkdir -p PKG_SOURCE/DEBIAN
mkdir -p PKG_SOURCE/usr/bin/
mkdir -p PKG_SOURCE/usr/share/applications
mkdir -p PKG_SOURCE/usr/share/pixmaps
mkdir -p PKG_SOURCE/usr/share/icons/hicolor/scalable/apps
- name: Download xpm icon
run: |
curl -sSL https://repo.spacefreak18.xyz/monocoque/icons/monocoque.xpm -o PKG_SOURCE/usr/share/pixmaps/monocoque.xpm
- name: Download svg icon
run: |
curl -sSL https://repo.spacefreak18.xyz/monocoque/icons/monocoque.svg -o PKG_SOURCE/usr/share/icons/hicolor/scalable/apps/monocoque.svg
- name: Copy script files around to stop .github from being added to the package then build the package
run: |
cp ./tools/distro/debian/dpkg/${{ matrix.os }}/control ./PKG_SOURCE/DEBIAN/control
cp ./tools/distro/debian/dpkg/copyright ./PKG_SOURCE/DEBIAN/copyright
cp ./build/monocoque ./PKG_SOURCE/usr/bin/monocoque
cp ./build/gmonocoque ./PKG_SOURCE/usr/bin/gmonocoque
cp ./tools/monocoque.desktop ./PKG_SOURCE/usr/share/applications/monocoque.desktop
dpkg-deb --build PKG_SOURCE monocoque-${{ matrix.os }}.deb
- name: Release the Package
@@ -79,3 +94,23 @@ jobs:
with:
files: monocoque-${{ matrix.os }}.rpm
#arch-build:
# runs-on: ubuntu-latest
# container:
# image: archlinux
# options: --privileged
# steps:
# - uses: actions/checkout@v3
# - name: Set proper repository url in PKGBUILD
# run: sed -i "s|%URL%|${{ github.server_url }}/${{ github.repository }}|" $GITHUB_WORKSPACE/tools/distro/arch/git/PKGBUILD
# - run: echo "$GITHUB_WORKSPACE/.github/bin" >> "$GITHUB_PATH"
# - name: Build Arch Linux package
# uses: FFY00/build-arch-package@v1
# with:
# BUILD_SCRIPT: extra-x86_64-build
# PKGBUILD: $GITHUB_WORKSPACE/tools/distro/arch/git/PKGBUILD
# OUTDIR: $HOME/arch-packages
# - name: Release the Package
# uses: softprops/action-gh-release@v1
# with:
# files: $HOME/arch-packages/monocoque*.zst
+3
View File
@@ -2,3 +2,6 @@
path = src/monocoque/simulatorapi/simapi
url = https://github.com/spacefreak18/simapi
# url = git@github.com:spacefreak18/simapi # ssh is better but Microsoft requires an account
[submodule "src/monocoque/mgui/nappgui_src"]
path = src/monocoque/mgui/nappgui_src
url = https://github.com/frang75/nappgui_src
+10
View File
@@ -120,3 +120,13 @@
...
obj:*/lib*/lib*.so.*
}
{
nappgui_gbind_uninitialized
Memcheck:Cond
fun:_gbind_update_control
}
{
gtk_pango_uninitialized
Memcheck:Cond
fun:_pango_is_Vowel_Dependent
}
+28 -5
View File
@@ -10,6 +10,9 @@ endif()
SET_SOURCE_FILES_PROPERTIES( src/monocoque.c PROPERTIES LANGUAGE C)
#set(CMAKE_BUILD_TYPE Debug)
option(BUILD_GUI "Build GUI support" OFF)
option(BUILD_SHARED "Build monocoque shared library" OFF)
project(monocoque)
@@ -50,7 +53,17 @@ endif()
set(HIDAPI_WITH_LIBUSB FALSE) # surely will be used only on Linux
set(BUILD_SHARED_LIBS TRUE) # HIDAPI as static library on all platforms
add_executable(monocoque src/monocoque/monocoque.c)
if(BUILD_SHARED)
add_library(monocoque SHARED src/monocoque/monocoque.c)
else()
add_library(monocoque STATIC src/monocoque/monocoque.c)
endif()
add_executable(monocoque-cli src/monocoque/monocoque-cli.c)
set_target_properties(monocoque-cli PROPERTIES OUTPUT_NAME monocoque)
if(BUILD_GUI)
add_executable(monocoque-gui src/monocoque/monocoque-gui.c)
set_target_properties(monocoque-gui PROPERTIES OUTPUT_NAME gmonocoque)
endif()
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBPROCPS libprocps)
@@ -74,9 +87,6 @@ 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_include_directories(monocoque PUBLIC config ${LIBXML_INCLUDE_DIR} ${LUA_INCLUDE_DIR})
add_subdirectory(src/monocoque/gameloop)
add_subdirectory(src/monocoque/simulatorapi)
@@ -84,6 +94,19 @@ add_subdirectory(src/monocoque/helper)
add_subdirectory(src/monocoque/devices)
add_subdirectory(src/monocoque/slog)
target_link_libraries(monocoque m hidapi-hidraw pulse serialport xml2 argtable2 config gameloop helper devices slog simulatorapi uv xdg-basedir Lua::Lua proc2)
target_include_directories(monocoque PUBLIC config ${LIBXML_INCLUDE_DIR} ${LUA_INCLUDE_DIR})
target_link_libraries(monocoque-cli m hidapi-hidraw pulse serialport xml2 argtable2 config gameloop helper devices slog simulatorapi uv xdg-basedir Lua::Lua proc2)
target_include_directories(monocoque-cli PUBLIC config ${LIBXML_INCLUDE_DIR} ${LUA_INCLUDE_DIR})
if(BUILD_GUI)
add_subdirectory(src/monocoque/mgui)
target_link_libraries(monocoque-gui m hidapi-hidraw pulse serialport xml2 argtable2 config mgui gameloop helper devices slog simulatorapi uv xdg-basedir Lua::Lua proc2)
target_include_directories(monocoque-gui PUBLIC config ${LIBXML_INCLUDE_DIR} ${LUA_INCLUDE_DIR})
endif()
#add_executable(listusb tests/testlibusb.c)
#target_include_directories(listusb PUBLIC)
#target_link_libraries(listusb portaudio hidapi-hidraw)
@@ -166,7 +189,7 @@ else() # GCC/Clang warning option
if(analyze)
message("-- Analyzer is on")
target_compile_options(monocoque PRIVATE -fanalyzer -Wno-analyzer-possible-null-argument -Wno-analyzer-possible-null-dereference)
target_compile_options(monocoque PRIVATE -fanalyzer -Wno-analyzer-possible-null-argument -Wno-analyzer-possible-null-dereference -fsanitize=address -g -fno-omit-frame-pointer)
endif()
enable_cxx_compiler_flag_if_supported("-Wall")
+6 -3
View File
@@ -69,7 +69,7 @@ for installation instructions***
## Building
### Dependencies
### Dependencies (static dependencies are linked as to show their respective copyright and licenses)
- libserialport - arduino serial devices
- hidapi - usb hid devices (hidraw)
- portaudio - sound devices (haptic bass shakers)
@@ -81,9 +81,12 @@ for installation instructions***
- 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)
- [slog](https://github.com/kala13x/slog) (static)
- [nappgui](https://github.com/frang75/nappgui_src) (static) (for GUI)
(sorta optional)
- [simshmbridge](https://github.com/spacefreak18/simshmbridge) - for sims that need shared memory mapping like AC and Project Cars related.
```
pacman -Syu git cmake pulse-native-provider libxdg-basedir libserialport libconfig libuv argtable hidapi lua libproc2
```
-1
View File
@@ -1 +0,0 @@
../../monocoque/simulatorapi/simapi/simapi/simdata.h
+4 -2
View File
@@ -13,8 +13,6 @@ set(devices_source_files
tachdevice.c
wheeldevice.h
wheeldevice.c
usbhapticdevice.h
usbhapticdevice.c
hapticeffect.h
hapticeffect.c
sound.h
@@ -25,6 +23,8 @@ set(devices_source_files
usb/cslelitev3.c
usb/simagicp1000.h
usb/simagicp1000.c
usb/simnetpedals.h
usb/simnetpedals.c
usb/wheels/logitechg29.h
usb/wheels/logitechg29.c
usb/wheels/cammusc5.h
@@ -49,3 +49,5 @@ set(devices_source_files
include_directories("." "usb" "sound" "serial")
add_library(devices STATIC ${devices_source_files})
set_property(TARGET devices PROPERTY POSITION_INDEPENDENT_CODE ON)
+62 -4
View File
@@ -6,6 +6,7 @@
#include <math.h>
#include "usbhapticdevice.h"
#include "simdevice.h"
#include "../../helper/confighelper.h"
#include "../../simulatorapi/simapi/simapi/simdata.h"
#include "../../simulatorapi/simapi/simapi/simmapper.h"
@@ -194,9 +195,66 @@ void getTyreDiameter(SimData* simdata)
}
}
double slipeffect(SimData* simdata, int effecttype, int tyre, double threshold, int useconfig, int* configcheck, char* configfile)
int initializeHapticEffect(HapticEffect* h, HapticEffectSettings* hs, MonocoqueSettings* ms)
{
switch (hs->effect_type)
{
case (EFFECT_ENGINERPM):
h->effecttype = EFFECT_ENGINERPM;
slogi("Initializing haptic effect for engine vibrations.");
break;
case (EFFECT_GEARSHIFT):
h->effecttype = EFFECT_GEARSHIFT;
slogi("Initializing haptic effect for gear shift vibrations.");
break;
case (EFFECT_TYRESLIP):
h->effecttype = EFFECT_TYRESLIP;
slogi("Initializing haptic effect for tyre slip vibrations.");
break;
case (EFFECT_TYRELOCK):
h->effecttype = EFFECT_TYRELOCK;
slogi("Initializing haptic effect for tyre lock vibrations.");
break;
case (EFFECT_ABSBRAKES):
h->effecttype = EFFECT_ABSBRAKES;
slogi("Initializing haptic effect for abs vibrations.");
break;
case (EFFECT_SUSPENSION):
h->effecttype = EFFECT_SUSPENSION;
slogi("Initializing haptic effect for suspension vibrations.");
break;
}
h->tyre = hs->tyre;
slogi("Haptic effect: %i %i, tyre %i %i", h->effecttype, hs->effect_type, h->tyre, hs->tyre);
h->threshold = hs->threshold;
h->modulationType = hs->modulation;
h->basefrequency = hs->frequency;
h->frequencyMax = hs->frequencyMax;
h->baseamplitude = hs->amplitude;
h->amplitudeMax = hs->amplitudeMax;
h->motorposition = hs->motorposition;
h->duration = hs->duration;
slogt("haptic duration: %f", h->duration);
slogt("haptic base frequency: %i", h->basefrequency);
slogt("haptic base amplitude: %i", h->baseamplitude);
slogt("haptic motorposition: %i", h->motorposition);
h->useconfig = ms->useconfig;
h->configcheck = &ms->configcheck;
h->tyrediameterconfig = ms->tyre_diameter_config;
}
double slipeffect(SimData* simdata, HapticEffect* h, int useconfig, int* configcheck, char* configfile)
{
int effecttype = h->effecttype;
int tyre = h->tyre;
double threshold = h->threshold;
double play = 0;
double wheelslip[4];
wheelslip[0] = 0;
@@ -212,7 +270,7 @@ double slipeffect(SimData* simdata, int effecttype, int tyre, double threshold,
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);
//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)
{
@@ -246,7 +304,7 @@ double slipeffect(SimData* simdata, int effecttype, int tyre, double threshold,
case EFFECT_SUSPENSION:
break;
default:
slogd("Unknown effect type");
slogw("Unknown effect type %i", effecttype);
}
if(simdata->Yvelocity <= 0)
{
+34 -3
View File
@@ -2,21 +2,52 @@
#define _HAPTICEFFECT_H
#include <stdio.h>
#include "../helper/confighelper.h"
#include "../simulatorapi/simapi/simapi/simdata.h"
typedef enum
{
HAPTIC_EFFECT_MODULATION_NONE = 0,
HAPTIC_EFFECT_MODULATION_FREQUENCY = 1,
HAPTIC_EFFECT_MODULATION_AMPLIFY = 2,
}
HapticEffectModulationType;
typedef struct
{
uint32_t curr_frequency;
uint32_t curr_amplitude;
double curr_duration;
uint32_t last_gear;
}
CurrentEffectData;
typedef struct
{
double threshold;
VibrationEffectType effecttype;
MonocoqueTyreIdentifier tyre;
HapticEffectModulationType modulationType;
uint32_t volume;
double duration;
double threshold;
uint32_t motorposition;
uint32_t basefrequency;
uint32_t frequencyMax;
uint32_t baseamplitude;
uint32_t amplitudeMax;
CurrentEffectData live_effect;
int useconfig;
int* configcheck;
char* tyrediameterconfig;
}
HapticEffect;
double slipeffect(SimData* simdata, int effecttype, int tyre, double threshold, int useconfig, int* configcheck, char* configfile);
int initializeHapticEffect(HapticEffect* h, HapticEffectSettings* hs, MonocoqueSettings* ms);
double slipeffect(SimData* simdata, HapticEffect* h, int useconfig, int* configcheck, char* configfile);
bool hasTyreDiameter(SimData* simdata);
int loadtyreconfig(SimData* simdata, char* configfile, bool setDiameters);
int savetyreconfig(SimData* simdata, char* configfile);
+6 -7
View File
@@ -128,21 +128,20 @@ int GetNumberOfLeds(SerialDevice* serialdevice, int* numlights)
int arduino_init(SerialDevice* serialdevice, const char* portdev)
{
serialdevice->id = monocoque_serial_open(serialdevice, portdev);
return serialdevice->id;
int id = monocoque_serial_open(serialdevice, portdev);
if (id < 0) return id;
serialdevice->id = id;
return 0;
}
int arduino_custom_init(SerialDevice* serialdevice, const char* portdev, const char* luafile, bool uselights)
{
serialdevice->id = monocoque_serial_open(serialdevice, portdev);
int error = arduino_init(serialdevice, portdev);
int numlights = 0;
monocoque_serial_device serialdev = monocoque_serial_devices[serialdevice->id];
int error = 0;
if(uselights == true)
{
error = GetNumberOfLeds(serialdevice, &numlights);
@@ -179,7 +178,7 @@ int arduino_custom_init(SerialDevice* serialdevice, const char* portdev, const c
slogi("LUA config setup successful.");
return serialdevice->id;
return 0;
}
+28 -23
View File
@@ -61,7 +61,6 @@ int arduino_custom_updater(SimDevice* this, SimData* simdata)
int arduino_customled_updater(SimDevice* this, SimData* simdata)
{
SerialDevice* serialdevice = (void *) this->derived;
arduino_customled_update(serialdevice, simdata);
return 0;
@@ -140,8 +139,12 @@ int arduino_simhaptic_update(SimDevice* this, SimData* simdata)
int result = 1;
slogt("arduino haptic device updating");
serialdevice->u.simhapticdata.motor1 = 0;
serialdevice->u.simhapticdata.motor2 = 0;
serialdevice->u.simhapticdata.motor3 = 0;
serialdevice->u.simhapticdata.motor4 = 0;
double play = slipeffect(simdata, this->hapticeffect.effecttype, this->hapticeffect.tyre, this->hapticeffect.threshold, this->hapticeffect.useconfig, this->hapticeffect.configcheck, this->hapticeffect.tyrediameterconfig);
double play = slipeffect(simdata, &this->hapticeffect, this->hapticeffect.useconfig, this->hapticeffect.configcheck, this->hapticeffect.tyrediameterconfig);
double rplay = play;
play = play * serialdevice->ampfactor;
@@ -149,25 +152,27 @@ int arduino_simhaptic_update(SimDevice* this, SimData* simdata)
{
play = 1.0;
}
int effectspeed = ceil(255 * play);
uint8_t effectspeed = ceil(255 * play);
int motor = serialdevice->motorsposition;
uint8_t motor = this->hapticeffect.motorposition;
if (play != serialdevice->state)
if (play != serialdevice->hapticstate)
{
// motor 1
if (motor == 0 || motor == 4 || motor == 7 || motor == 8 || motor == 10 || motor == 11 || motor == 13 || motor == 14)
{
serialdevice->u.simhapticdata.effect1 = effectspeed;
serialdevice->u.simhapticdata.motor1 = 1;
slogt("Updating arduino haptic device with effect type %i speed motor speed %i on motor %i from original effect %f with ampfactor %f", this->hapticeffect.effecttype, serialdevice->u.simhapticdata.effect3, serialdevice->motorsposition, rplay, serialdevice->ampfactor);
slogt("Updating arduino haptic device with effect type %i speed motor speed %i on motor %i from original effect %f with ampfactor %f", this->hapticeffect.effecttype, serialdevice->u.simhapticdata.effect1, 1, rplay, serialdevice->ampfactor);
}
// motor 3
if (motor == 2 || motor == 6 || motor == 8 || motor == 9 || motor == 10 || motor == 11 || motor == 12 || motor == 14)
{
serialdevice->u.simhapticdata.effect3 = effectspeed;
serialdevice->u.simhapticdata.motor3 = 1;
slogt("Updating arduino haptic device with effect type %i speed motor speed %i on motor %i from original effect %f with ampfactor %f", this->hapticeffect.effecttype, serialdevice->u.simhapticdata.effect3, serialdevice->motorsposition, rplay, serialdevice->ampfactor);
slogt("Updating arduino haptic device with effect type %i speed motor speed %i on motor %i from original effect %f with ampfactor %f", this->hapticeffect.effecttype, serialdevice->u.simhapticdata.effect3, 3, rplay, serialdevice->ampfactor);
}
serialdevice->state = play;
serialdevice->hapticstate = play;
}
size_t size = sizeof(SimHapticData);
@@ -191,7 +196,7 @@ int serialdev_free(SimDevice* this)
serialdevice->u.simhapticdata.motor3 = 1;
serialdevice->u.simhapticdata.effect4 = 0;
serialdevice->u.simhapticdata.motor4 = 1;
serialdevice->state = 0;
serialdevice->hapticstate = 0;
size_t size = sizeof(SimHapticData);
monocoque_serial_write_block(serialdevice->id, &serialdevice->u.simhapticdata, size, 9000);
@@ -227,7 +232,7 @@ int serial_wheel_free(SimDevice* this)
int serialdev_init(SerialDevice* serialdevice, DeviceSettings* ds, SimInfo* siminfo)
{
slogi("initializing serial device on port %s to %i...", ds->serialdevsettings.portdev, ds->serialdevsettings.baud);
slogi("initializing serial device on port %s to %i...", ds->dev, ds->serialdevsettings.baud);
int error = 0;
@@ -240,17 +245,17 @@ int serialdev_init(SerialDevice* serialdevice, DeviceSettings* ds, SimInfo* simi
// the wheel stuff assumed it was a usb
//error = wheeldev_init(&serialdevice->u.wheeldevice, ds);
// maybe this call a more generic serial wheel init first
error = moza_init(serialdevice, ds->serialdevsettings.portdev);
error = moza_init(serialdevice, ds->dev);
break;
case SERIALDEV__MOZA_NEW:
error = moza_new_init(serialdevice, ds->serialdevsettings.portdev);
error = moza_new_init(serialdevice, ds->dev);
break;
case SERIALDEV__MOZA_KS_PRO_WHEEL:
error = moza_ks_pro_wheel_init(serialdevice, ds->serialdevsettings.portdev);
error = moza_ks_pro_wheel_init(serialdevice, ds->dev);
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);
error = arduino_custom_init(serialdevice, ds->dev, serialdevice->m.device_specific_config_file, true);
if(error < 0)
{
free(serialdevice->m.device_specific_config_file);
@@ -258,17 +263,17 @@ int serialdev_init(SerialDevice* serialdevice, DeviceSettings* ds, SimInfo* simi
break;
case ARDUINODEV__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, false);
error = arduino_custom_init(serialdevice, ds->dev, serialdevice->m.device_specific_config_file, false);
if(error < 0)
{
free(serialdevice->m.device_specific_config_file);
}
break;
case ARDUINODEV__SIMLED:
error = arduino_custom_init(serialdevice, ds->serialdevsettings.portdev, NULL, false);
error = arduino_custom_init(serialdevice, ds->dev, NULL, false);
break;
default:
error = arduino_init(serialdevice, ds->serialdevsettings.portdev);
error = arduino_init(serialdevice, ds->dev);
break;
}
@@ -350,7 +355,7 @@ SerialDevice* new_serial_device(DeviceSettings* ds, MonocoqueSettings* ms, SimIn
this->u.simhapticdata.effect2 = 0;
this->u.simhapticdata.effect3 = 0;
this->u.simhapticdata.effect4 = 0;
this->state = 0;
this->hapticstate = 0;
this->ampfactor = ds->serialdevsettings.ampfactor;
this->fanpower = ds->serialdevsettings.fanpower;
slogi("Initializing arduino device for haptic effects.");
@@ -382,10 +387,10 @@ SerialDevice* new_serial_device(DeviceSettings* ds, MonocoqueSettings* ms, SimIn
if(this->devicetype == ARDUINODEV__HAPTIC && error == 0)
{
this->m.hapticeffect.threshold = ds->threshold;
this->m.hapticeffect.effecttype = ds->effect_type;
slogt("Haptic effect: %i %i", this->m.hapticeffect.effecttype, ds->effect_type);
this->m.hapticeffect.tyre = ds->tyre;
this->m.hapticeffect.threshold = ds->hapticsettings.threshold;
this->m.hapticeffect.effecttype = ds->hapticsettings.effect_type;
slogt("Haptic effect: %i %i", this->m.hapticeffect.effecttype, ds->hapticsettings.effect_type);
this->m.hapticeffect.tyre = ds->hapticsettings.tyre;
this->m.hapticeffect.useconfig = ms->useconfig;
this->m.hapticeffect.configcheck = &ms->configcheck;
this->m.hapticeffect.tyrediameterconfig = ms->tyre_diameter_config;
@@ -399,7 +404,7 @@ SerialDevice* new_serial_device(DeviceSettings* ds, MonocoqueSettings* ms, SimIn
if (error != 0)
{
slogw("Did not initialize usb device due to error code %i", error);
slogw("Did not initialize serial device due to error code %i", error);
free(this);
return NULL;
}
+10 -8
View File
@@ -67,7 +67,7 @@ typedef struct
int baudrate;
double ampfactor;
double fanpower;
double state;
double hapticstate;
union
{
SimWindData simwinddata;
@@ -88,10 +88,10 @@ SerialDevice* new_serial_device(DeviceSettings* ds, MonocoqueSettings* ms, SimIn
/********* USB HID Devices *****/
typedef enum
{
USBDEV_UNKNOWN = 0,
USBDEV_TACHOMETER = 1,
USBDEV_GENERICHAPTIC = 2,
USBDEV_WHEEL = 3
USBDEV_UNKNOWN = 0,
USBDEV_TACHOMETER = 1,
USBDEV_GENERICHAPTIC = 2,
USBDEV_WHEEL_OR_PEDALS = 3
}
USBType;
@@ -100,12 +100,14 @@ typedef struct
SimDevice m;
int id;
hid_device* handle;
FILE* filehandle;
char* dev;
double hapticstate;
USBType type;
union
{
TachDevice tachdevice;
WheelDevice wheeldevice;
USBGenericHapticDevice hapticdevice;
} u;
}
USBDevice;
@@ -122,7 +124,6 @@ typedef struct
SimDevice m;
int id;
int configcheck;
SoundEffectModulationType modulationType;
SoundData sounddata;
//#ifdef USE_PULSEAUDIO
pa_stream *stream;
@@ -154,7 +155,8 @@ int simdevfree(SimDevice* this);
/****** USB SubTypes ****************/
int wheeldev_update(USBDevice* usbdevice, SimData* simdata);
int wheelhapticdev_update(SimDevice* this, SimData* simdata);
int wheeldev_update(SimDevice* this, SimData* simdata);
int wheeldev_init(USBDevice* usbdevice, DeviceSettings* ds);
int wheeldev_free(USBDevice* usbdevice);
+39 -89
View File
@@ -15,13 +15,15 @@
#include "../helper/parameters.h"
#include "../slog/slog.h"
int gear_sound_set(SoundDevice* sounddevice, SimData* simdata)
int gear_sound_set(SimDevice* this, SimData* simdata)
{
SoundDevice* sounddevice = (void *) this->derived;
if (sounddevice->sounddata.last_gear != simdata->gear && simdata->gear > 1)
{
//sounddevice->sounddata.gear_sound_data = 3.14;
sounddevice->sounddata.curr_frequency = sounddevice->sounddata.frequency;
sounddevice->sounddata.curr_amplitude = sounddevice->sounddata.amplitude;
sounddevice->sounddata.curr_frequency = this->hapticeffect.basefrequency;
sounddevice->sounddata.curr_amplitude = this->hapticeffect.baseamplitude;
sounddevice->sounddata.curr_duration = 0;
}
sounddevice->sounddata.last_gear = simdata->gear;
@@ -30,27 +32,29 @@ int gear_sound_set(SoundDevice* sounddevice, SimData* simdata)
}
double modulate(SoundDevice* sounddevice, double raw_effect, SoundEffectModulationType modulation)
double modulate(SimDevice* this, double raw_effect, HapticEffectModulationType modulation)
{
SoundDevice* sounddevice = (void *) this->derived;
double modulated_effect = raw_effect;
switch (modulation)
{
case SOUND_EFFECT_MODULATION_FREQUENCY:
modulated_effect = ((sounddevice->sounddata.frequencyMax - sounddevice->sounddata.frequency) * raw_effect) + sounddevice->sounddata.frequency;
case HAPTIC_EFFECT_MODULATION_FREQUENCY:
modulated_effect = ((this->hapticeffect.frequencyMax - this->hapticeffect.basefrequency) * raw_effect) + this->hapticeffect.basefrequency;
sounddevice->sounddata.curr_frequency = modulated_effect;
sounddevice->sounddata.curr_amplitude = sounddevice->sounddata.amplitude;
slogt("set curr frequency to %f from raw effect %f and base frequency %i", sounddevice->sounddata.curr_frequency, raw_effect, sounddevice->sounddata.frequency);
sounddevice->sounddata.curr_amplitude = this->hapticeffect.baseamplitude;
slogt("set curr frequency to %f from raw effect %f and base frequency %i", sounddevice->sounddata.curr_frequency, raw_effect, this->hapticeffect.basefrequency);
break;
case SOUND_EFFECT_MODULATION_AMPLIFY:
modulated_effect = ((sounddevice->sounddata.amplitudeMax - sounddevice->sounddata.amplitude) * raw_effect) + sounddevice->sounddata.amplitude;
case HAPTIC_EFFECT_MODULATION_AMPLIFY:
modulated_effect = ((this->hapticeffect.amplitudeMax - this->hapticeffect.baseamplitude) * raw_effect) + this->hapticeffect.baseamplitude;
sounddevice->sounddata.curr_amplitude = modulated_effect;
sounddevice->sounddata.curr_frequency = sounddevice->sounddata.frequency;
slogt("set curr amplitude to %i from raw effect %f and base amplitude %i", sounddevice->sounddata.curr_amplitude, raw_effect, sounddevice->sounddata.amplitude);
sounddevice->sounddata.curr_frequency = this->hapticeffect.basefrequency;
slogt("set curr amplitude to %i from raw effect %f and base amplitude %i", sounddevice->sounddata.curr_amplitude, raw_effect, this->hapticeffect.baseamplitude);
break;
case SOUND_EFFECT_MODULATION_NONE:
case HAPTIC_EFFECT_MODULATION_NONE:
default:
sounddevice->sounddata.curr_frequency = sounddevice->sounddata.frequency;
sounddevice->sounddata.curr_amplitude = sounddevice->sounddata.amplitude;
sounddevice->sounddata.curr_frequency = this->hapticeffect.basefrequency;
sounddevice->sounddata.curr_amplitude = this->hapticeffect.baseamplitude;
break;
}
@@ -64,19 +68,19 @@ int sounddev_engine_update(SimDevice* this, SimData* simdata)
double effect = ((double)simdata->rpms/60)/((double)simdata->maxrpm/60);
slogt("Set base effect of %f from rpms of %i", effect, simdata->rpms);
modulate(sounddevice, effect, sounddevice->modulationType);
modulate(this, effect, this->hapticeffect.modulationType);
}
int sounddev_tyreslip_update(SimDevice* this, SimData* simdata)
{
SoundDevice* sounddevice = (void *) this->derived;
double effect = slipeffect(simdata, this->hapticeffect.effecttype, this->hapticeffect.tyre, this->hapticeffect.threshold, this->hapticeffect.useconfig, this->hapticeffect.configcheck, this->hapticeffect.tyrediameterconfig);
slogt("Updating sound device frequency from original tyre slip effect %f", effect);
double effect = slipeffect(simdata, &this->hapticeffect, this->hapticeffect.useconfig, this->hapticeffect.configcheck, this->hapticeffect.tyrediameterconfig);
slogt("Updating sound device frequency from original %i tyre slip effect %f", this->hapticeffect.effecttype, effect);
if (effect > 0)
{
modulate(sounddevice, effect, sounddevice->modulationType);
modulate(this, effect, this->hapticeffect.modulationType);
}
else
{
@@ -91,12 +95,12 @@ int sounddev_tyrelock_update(SimDevice* this, SimData* simdata)
{
SoundDevice* sounddevice = (void *) this->derived;
double play = slipeffect(simdata, this->hapticeffect.effecttype, this->hapticeffect.tyre, this->hapticeffect.threshold, this->hapticeffect.useconfig, this->hapticeffect.configcheck, this->hapticeffect.tyrediameterconfig);
double play = slipeffect(simdata, &this->hapticeffect, this->hapticeffect.useconfig, this->hapticeffect.configcheck, this->hapticeffect.tyrediameterconfig);
slogt("Updating sound device frequency from original tyre lock effect %f", play);
if (play > 0)
{
modulate(sounddevice, play, sounddevice->modulationType);
modulate(this, play, this->hapticeffect.modulationType);
}
else
{
@@ -109,12 +113,12 @@ int sounddev_tyrelock_update(SimDevice* this, SimData* simdata)
int sounddev_absbrakes_update(SimDevice* this, SimData* simdata)
{
SoundDevice* sounddevice = (void *) this->derived;
double play = slipeffect(simdata, this->hapticeffect.effecttype, this->hapticeffect.tyre, this->hapticeffect.threshold, this->hapticeffect.useconfig, this->hapticeffect.configcheck, this->hapticeffect.tyrediameterconfig);
double play = slipeffect(simdata, &this->hapticeffect, this->hapticeffect.useconfig, this->hapticeffect.configcheck, this->hapticeffect.tyrediameterconfig);
slogt("Updating sound device frequency from original abs effect %f", play);
if (play > 0)
{
modulate(sounddevice, play, sounddevice->modulationType);
modulate(this, play, this->hapticeffect.modulationType);
}
else
{
@@ -128,13 +132,13 @@ int sounddev_suspension_update(SimDevice* this, SimData* simdata)
{
SoundDevice* sounddevice = (void *) this->derived;
double effect = slipeffect(simdata, this->hapticeffect.effecttype, this->hapticeffect.tyre, this->hapticeffect.threshold, this->hapticeffect.useconfig, this->hapticeffect.configcheck, this->hapticeffect.tyrediameterconfig);
double effect = slipeffect(simdata, &this->hapticeffect, this->hapticeffect.useconfig, this->hapticeffect.configcheck, this->hapticeffect.tyrediameterconfig);
effect = effect * 10;
slogt("Updating sound device output from original suspension travel effect %f", effect);
if (effect > 0)
{
effect = modulate(sounddevice, effect, sounddevice->modulationType);
effect = modulate(this, effect, this->hapticeffect.modulationType);
}
else
{
@@ -147,9 +151,7 @@ int sounddev_suspension_update(SimDevice* this, SimData* simdata)
int sounddev_gearshift_update(SimDevice* this, SimData* simdata)
{
SoundDevice* sounddevice = (void *) this->derived;
gear_sound_set(sounddevice, simdata);
gear_sound_set(this, simdata);
}
@@ -163,28 +165,17 @@ int sounddev_free(SimDevice* this)
return 0;
}
int sounddev_init(SoundDevice* sounddevice, const char* devname, MonocoqueTyreIdentifier tyre, SoundDeviceSettings sds)
int sounddev_init(SoundDevice* sounddevice, const char* devname, SoundDeviceSettings sds)
{
slogi("initializing standalone sound device...");
slogi("volume is: %i", sds.volume);
slogi("Modulation type: %i", sds.modulation);
slogi("frequency is: %i", sds.frequency);
slogi("frequency Max is: %i", sds.frequencyMax);
slogi("amplitude is: %i", sds.amplitude);
slogi("amplitude Max is: %i", sds.amplitudeMax);
slogi("pan is: %i", sds.pan);
slogi("channels is: %i", sds.channels);
slogi("duration is: %f", sds.duration);
slogi("noise is: %i", sds.noise);
sounddevice->modulationType = sds.modulation;
sounddevice->sounddata.frequency = sds.frequency;
sounddevice->sounddata.frequencyMax = sds.frequencyMax;
sounddevice->sounddata.amplitude = sds.amplitude;
sounddevice->sounddata.amplitudeMax = sds.amplitudeMax;
sounddevice->sounddata.noise = (double)sds.noise;
sounddevice->sounddata.curr_duration = 0;
@@ -198,7 +189,7 @@ int sounddev_init(SoundDevice* sounddevice, const char* devname, MonocoqueTyreId
switch (sounddevice->m.hapticeffect.effecttype) {
case (EFFECT_GEARSHIFT):
sounddevice->sounddata.last_gear = 0;
sounddevice->sounddata.duration = sds.duration;
sounddevice->sounddata.duration = 0.125;
streamname = "Gear";
break;
case (EFFECT_TYRESLIP):
@@ -240,7 +231,7 @@ SoundDevice* new_sound_device(DeviceSettings* ds, MonocoqueSettings* ms, SimInfo
this->m.derived = this;
int error = 0;
switch (ds->effect_type)
switch (ds->hapticsettings.effect_type)
{
case (EFFECT_TYRESLIP):
case (EFFECT_TYRELOCK):
@@ -258,73 +249,32 @@ SoundDevice* new_sound_device(DeviceSettings* ds, MonocoqueSettings* ms, SimInfo
if(error == 0)
{
slogt("Attempting to configure sound device with subtype: %i", ds->effect_type);
switch (ds->effect_type)
initializeHapticEffect(&this->m.hapticeffect, &ds->hapticsettings, ms);
slogt("Attempting to configure sound device with subtype: %i", ds->hapticsettings.effect_type);
switch (ds->hapticsettings.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.");
slogi("Initializing sound device for tyre lock 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;
@@ -333,8 +283,8 @@ SoundDevice* new_sound_device(DeviceSettings* ds, MonocoqueSettings* ms, SimInfo
if(error == 0)
{
slogt("Attempting to use sound device %s", ds->sounddevsettings.dev);
error = sounddev_init(this, ds->sounddevsettings.dev, ds->tyre, ds->sounddevsettings);
slogt("Attempting to use sound device %s", ds->dev);
error = sounddev_init(this, ds->dev, ds->sounddevsettings);
}
if (error != 0)
-12
View File
@@ -8,23 +8,11 @@
//#endif
typedef enum
{
SOUND_EFFECT_MODULATION_NONE = 0,
SOUND_EFFECT_MODULATION_FREQUENCY = 1,
SOUND_EFFECT_MODULATION_AMPLIFY = 2,
}
SoundEffectModulationType;
#define MAX_TABLE_SIZE (6000)
typedef struct
{
uint8_t last_gear;
int volume;
uint32_t frequency;
uint32_t frequencyMax;
uint32_t amplitude;
uint32_t amplitudeMax;
double duration;
double curr_frequency;
uint32_t curr_amplitude;
+12 -13
View File
@@ -3,7 +3,7 @@
#include <string.h>
#include <glob.h>
#include "usbhapticdevice.h"
#include "cslelitev3.h"
#include "../../helper/confighelper.h"
#include "../slog/slog.h"
@@ -11,7 +11,7 @@
const char* SYSFSRUMBLEPATH = "/sys/module/hid_fanatec/drivers/hid:f*/0003:0EB7:183B.*/rumble";
int cslelitev3_update(USBGenericHapticDevice* usbhapticdevice, int effecttype, int play)
int cslelitev3_update(USBDevice* usbdevice, int effecttype, int play)
{
int res = 0;
@@ -33,26 +33,25 @@ int cslelitev3_update(USBGenericHapticDevice* usbhapticdevice, int effecttype, i
}
}
fprintf(usbhapticdevice->filehandle, "%i\n", value);
fflush(usbhapticdevice->filehandle);
fprintf(usbdevice->filehandle, "%i\n", value);
fflush(usbdevice->filehandle);
return res;
}
int cslelitev3_free(USBGenericHapticDevice* usbhapticdevice)
int cslelitev3_free(USBDevice* usbdevice)
{
int res = 0;
free(usbhapticdevice->dev);
free(usbdevice->dev);
fflush(usbhapticdevice->filehandle);
fclose(usbhapticdevice->filehandle);
fflush(usbdevice->filehandle);
fclose(usbdevice->filehandle);
return res;
}
int cslelitev3_init(USBGenericHapticDevice* usbhapticdevice)
int cslelitev3_init(USBDevice* usbdevice)
{
slogi("initializing CSL Elite V3 Pedals...");
@@ -75,7 +74,7 @@ int cslelitev3_init(USBGenericHapticDevice* usbhapticdevice)
{
if (i == 0)
{
usbhapticdevice->dev = strdup(globlist.gl_pathv[i]);
usbdevice->dev = strdup(globlist.gl_pathv[i]);
}
i++;
}
@@ -91,9 +90,9 @@ int cslelitev3_init(USBGenericHapticDevice* usbhapticdevice)
return res;
}
usbhapticdevice->filehandle = fopen(usbhapticdevice->dev, "w");
usbdevice->filehandle = fopen(usbdevice->dev, "w");
if (!usbhapticdevice->filehandle)
if (!usbdevice->filehandle)
{
sloge("Could not open pedal device...");
return res;
+6 -3
View File
@@ -1,8 +1,11 @@
#ifndef _CSLELITEV3_H
#define _CSLELITEV3_H
int cslelitev3_update(USBGenericHapticDevice* usbhapticdevice, int effecttype, int play);
int cslelitev3_init(USBGenericHapticDevice* usbhapticdevice);
int cslelitev3_free(USBGenericHapticDevice* usbhapticdevice);
#include "../wheeldevice.h"
#include "../simdevice.h"
int cslelitev3_update(USBDevice* usbdevice, int effecttype, int play);
int cslelitev3_init(USBDevice* usbdevice);
int cslelitev3_free(USBDevice* usbdevice);
#endif
+17 -17
View File
@@ -3,7 +3,7 @@
#include <string.h>
#include <hidapi/hidapi.h>
#include "usbhapticdevice.h"
#include "simagicp1000.h"
#include "../../helper/confighelper.h"
#include "../slog/slog.h"
@@ -14,12 +14,12 @@
const size_t SIMAGIC_P1000_BUFSIZE = 49;
const char* SIMAGICP1000DEVSTRING = "SIMAGIC P1000 Pedals";
int senddevreport(USBGenericHapticDevice* usbhapticdevice, unsigned char* buf, size_t bufsize)
int senddevreport(USBDevice* usbdevice, unsigned char* buf, size_t bufsize)
{
int res = 0;
if (usbhapticdevice->handle)
if (usbdevice->handle)
{
res = hid_send_feature_report(usbhapticdevice->handle, buf, SIMAGIC_P1000_BUFSIZE);
res = hid_send_feature_report(usbdevice->handle, buf, SIMAGIC_P1000_BUFSIZE);
slogd("sent %i bytes to %s", bufsize, SIMAGICP1000DEVSTRING);
slogt("sent bytes %02x %02x %02x %02x %02x %02x %02x", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
}
@@ -30,7 +30,7 @@ int senddevreport(USBGenericHapticDevice* usbhapticdevice, unsigned char* buf, s
return res != bufsize;
}
int simagicp1000_update(USBGenericHapticDevice* usbhapticdevice, int effecttype, int play)
int simagicp1000_update(USBDevice* usbdevice, int effecttype, int play)
{
int res = 0;
@@ -54,17 +54,17 @@ int simagicp1000_update(USBGenericHapticDevice* usbhapticdevice, int effecttype,
{
case (EFFECT_TYRESLIP):
bytes[2] = 0x02;
senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
senddevreport(usbdevice, bytes, SIMAGIC_P1000_BUFSIZE);
break;
case (EFFECT_TYRELOCK):
bytes[2] = 0x01;
senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
senddevreport(usbdevice, bytes, SIMAGIC_P1000_BUFSIZE);
break;
case (EFFECT_ABSBRAKES):
bytes[2] = 0x02;
senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
senddevreport(usbdevice, bytes, SIMAGIC_P1000_BUFSIZE);
bytes[2] = 0x01;
senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
senddevreport(usbdevice, bytes, SIMAGIC_P1000_BUFSIZE);
break;
}
}
@@ -72,19 +72,19 @@ int simagicp1000_update(USBGenericHapticDevice* usbhapticdevice, int effecttype,
{
bytes[0] = 241;
bytes[2] = 0x01;
senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
senddevreport(usbdevice, bytes, SIMAGIC_P1000_BUFSIZE);
bytes[2] = 0x02;
senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
senddevreport(usbdevice, bytes, SIMAGIC_P1000_BUFSIZE);
}
return res;
}
int simagicp1000_free(USBGenericHapticDevice* usbhapticdevice)
int simagicp1000_free(USBDevice* usbdevice)
{
int res = 0;
hid_close(usbhapticdevice->handle);
hid_close(usbdevice->handle);
res = hid_exit();
return res;
@@ -92,7 +92,7 @@ int simagicp1000_free(USBGenericHapticDevice* usbhapticdevice)
return res;
}
int simagicp1000_init(USBGenericHapticDevice* usbhapticdevice)
int simagicp1000_init(USBDevice* usbdevice)
{
slogi("initializing %s...", SIMAGICP1000DEVSTRING);
@@ -100,9 +100,9 @@ int simagicp1000_init(USBGenericHapticDevice* usbhapticdevice)
res = hid_init();
usbhapticdevice->handle = hid_open(SIMAGIC_VENDOR_ID, SIMAGIC_PRODUCT_ID_P1000, NULL);
usbdevice->handle = hid_open(SIMAGIC_VENDOR_ID, SIMAGIC_PRODUCT_ID_P1000, NULL);
if (!usbhapticdevice->handle)
if (!usbdevice->handle)
{
sloge("Could not find attached %s", SIMAGICP1000DEVSTRING);
res = hid_exit();
@@ -123,7 +123,7 @@ int simagicp1000_init(USBGenericHapticDevice* usbhapticdevice)
bytes[5] = 0x00;
bytes[6] = 0x01;
bytes[7] = 0x02;
res = senddevreport(usbhapticdevice, bytes, SIMAGIC_P1000_BUFSIZE);
res = senddevreport(usbdevice, bytes, SIMAGIC_P1000_BUFSIZE);
slogd("Initialization returned %i", res);
if(res != 0)
{
+6 -3
View File
@@ -1,8 +1,11 @@
#ifndef _SIMAGICP1000_H
#define _SIMAGICP1000_H
int simagicp1000_update(USBGenericHapticDevice* usbhapticdevice, int effecttype, int play);
int simagicp1000_init(USBGenericHapticDevice* usbhapticdevice);
int simagicp1000_free(USBGenericHapticDevice* usbhapticdevice);
#include "../wheeldevice.h"
#include "../simdevice.h"
int simagicp1000_update(USBDevice* usbdevice, int effecttype, int play);
int simagicp1000_init(USBDevice* usbdevice);
int simagicp1000_free(USBDevice* usbdevice);
#endif
+90
View File
@@ -0,0 +1,90 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glob.h>
#include "simnetpedals.h"
#include "../../helper/confighelper.h"
#include "../slog/slog.h"
#define SIMNETPEDALS_BUFSIZE 64
//Byte[0] : 0x01 (fixed) = Report ID
//Byte[1] : 0x00 (fixed)
//Byte[2] : motor number (0x01, 0x2 or 0x4)
//Byte[3]: motor 1 frequency in hz
//Byte[4] : motor 1 amplitude (0 to 100%)
//Byte[5] : motor 2 frequency in hz
//Byte[6]: motor 2 amplitude (0 to 100%)
//Byte[7]: motor 3 frequency in hz
//Byte[8]: motor 3 amplitude (0 to 100%)
int simnetpedals_update(USBDevice* usbdevice, int effecttype, int play, int motorposition, int frequency, int amplitude)
{
int res = 0;
unsigned char bytes[SIMNETPEDALS_BUFSIZE];
for (int x = 0; x < SIMNETPEDALS_BUFSIZE; x++)
{
bytes[x] = 0x00;
}
bytes[0] = 0x01;
bytes[1] = 0x00;
bytes[2] = motorposition;
uint8_t motormultiple = motorposition - 1;
if(motorposition == 0x04)
{
motormultiple = 2;
}
if(play > 0)
{
bytes[3 + (motormultiple * 2)] = frequency;
bytes[4 + (motormultiple * 2)] = amplitude;
}
if (usbdevice->handle)
{
slogt("writing bytes x%02xx%02xx%02xx%02xx%02xx%02xx%02xx%02xx%02x", bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7], bytes[8]);
res = hid_write(usbdevice->handle, bytes, SIMNETPEDALS_BUFSIZE);
}
else
{
slogd("no handle");
}
return res;
}
int simnetpedals_free(USBDevice* usbdevice)
{
int res = 0;
hid_close(usbdevice->handle);
res = hid_exit();
return res;
}
int simnetpedals_init(USBDevice* usbdevice)
{
slogi("initializing simnet pedals...");
int res = 0;
res = hid_init();
usbdevice->handle = hid_open(0xcafe, 0xa301, NULL);
if (!usbdevice->handle)
{
sloge("Could not find attached Simnet Pedals");
res = hid_exit();
return 1;
}
slogd("Found Simnet Pedals handle %i...", usbdevice->handle);
return res;
}
+11
View File
@@ -0,0 +1,11 @@
#ifndef _SIMNETPEDALS_H
#define _SIMNETPEDALS_H
#include "../wheeldevice.h"
#include "../simdevice.h"
int simnetpedals_update(USBDevice* usbdevice, int effecttype, int play, int motorposition, int frequency, int amplitude);
int simnetpedals_init(USBDevice* usbdevice);
int simnetpedals_free(USBDevice* usbdevice);
#endif
@@ -2,7 +2,6 @@
#define _CAMMUSC12_H
#include "../../wheeldevice.h"
#include "../../simdevice.h"
int cammusc12_update(USBDevice* wheeldevice, int maxrpm, int rpm, int gear, int velocity);
+27 -29
View File
@@ -19,11 +19,9 @@ int usbdev_update(SimDevice* this, SimData* simdata)
case USBDEV_TACHOMETER :
tachdev_update(usbdevice, simdata);
break;
case USBDEV_WHEEL :
wheeldev_update(usbdevice, simdata);
break;
case USBDEV_GENERICHAPTIC :
usbhapticdev_update(&usbdevice->u.hapticdevice, simdata, this->hapticeffect.tyre, this->hapticeffect.useconfig, this->hapticeffect.configcheck, this->hapticeffect.tyrediameterconfig);
case USBDEV_WHEEL_OR_PEDALS :
// this should be directed via vtable to wheeldevice.c
//wheeldev_update(usbdevice, simdata);
break;
}
@@ -41,12 +39,9 @@ int usbdev_free(SimDevice* this)
case USBDEV_TACHOMETER :
tachdev_free(usbdevice);
break;
case USBDEV_WHEEL :
case USBDEV_WHEEL_OR_PEDALS :
wheeldev_free(usbdevice);
break;
case USBDEV_GENERICHAPTIC :
usbhapticdev_free(&usbdevice->u.hapticdevice);
break;
}
free(usbdevice);
@@ -66,53 +61,56 @@ int usbdev_init(USBDevice* usbdevice, DeviceSettings* ds, SimInfo* siminfo)
case USBDEV_TACHOMETER :
error = tachdev_init(usbdevice, ds);
break;
case USBDEV_WHEEL :
case USBDEV_WHEEL_OR_PEDALS :
error = wheeldev_init(usbdevice, ds);
break;
case USBDEV_GENERICHAPTIC :
error = usbhapticdev_init(&usbdevice->u.hapticdevice, ds, siminfo);
break;
}
return error;
}
static const vtable usb_simdevice_vtable = { &usbdev_update, &usbdev_free };
static const vtable usb_wheeldevice_vtable = { &wheeldev_update, &usbdev_free };
static const vtable usb_wheelhaptic_vtable = { &wheelhapticdev_update, &usbdev_free };
USBDevice* new_usb_device(DeviceSettings* ds, MonocoqueSettings* ms, SimInfo* siminfo) {
USBDevice* this = (USBDevice*) malloc(sizeof(USBDevice));
int error = 0;
this->m.update = &update;
this->m.free = &simdevfree;
this->m.derived = this;
this->m.vtable = &usb_simdevice_vtable;
// TODO: turn this into a switch when we get more devices
this->type = USBDEV_TACHOMETER;
if(ds->dev_subtype == SIMDEVTYPE_USBWHEEL)
{
this->type = USBDEV_WHEEL;
this->type = USBDEV_WHEEL_OR_PEDALS;
this->m.vtable = &usb_wheeldevice_vtable;
}
// really generic haptic isn't and shouldn't be it's own type
// it's an attribute that is added to a device via composition
// same if that haptic device is a serial device
if (ds->dev_subtype == SIMDEVTYPE_USBHAPTIC)
if(ds->has_haptic_effects == true)
{
this->m.hapticeffect.threshold = ds->threshold;
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->type = USBDEV_GENERICHAPTIC;
if(siminfo->SimSupportsHapticEffects == false)
{
// if the user added haptic effects to the config and the sim does not support it, but still wishes to use features
// just remove the haptic effect from the config?
slogi("This sim does not support haptic effects");
error = MONOCOQUE_ERROR_UNSUPPORTED_SIM_FEATURE;
}
else
{
int error = 0;
this->type = USBDEV_WHEEL_OR_PEDALS;
initializeHapticEffect(&this->m.hapticeffect, &ds->hapticsettings, ms);
this->m.vtable = &usb_wheelhaptic_vtable;
}
}
int error = usbdev_init(this, ds, siminfo);
error = usbdev_init(this, ds, siminfo);
if (error != 0)
{
+20 -24
View File
@@ -7,6 +7,7 @@
#include "hapticeffect.h"
#include "usb/cslelitev3.h"
#include "usb/simagicp1000.h"
#include "usb/simnetpedals.h"
#include "../../helper/confighelper.h"
#include "../../simulatorapi/simapi/simapi/simdata.h"
@@ -16,7 +17,7 @@
int usbhapticdev_update(USBGenericHapticDevice* usbhapticdevice, SimData* simdata, int tyre, int useconfig, int* configcheck, char* configfile)
{
double play = slipeffect(simdata, usbhapticdevice->effecttype, tyre, usbhapticdevice->threshold, useconfig, configcheck, configfile);
double play = slipeffect(simdata, this->hapticeffect.effecttype, tyre, this->hapticeffect.threshold, useconfig, configcheck, configfile);
if (play != usbhapticdevice->state)
{
@@ -27,10 +28,13 @@ int usbhapticdev_update(USBGenericHapticDevice* usbhapticdevice, SimData* simdat
switch ( usbhapticdevice->type )
{
case USBHAPTIC_CSLELITEV3PEDALS:
cslelitev3_update(usbhapticdevice, usbhapticdevice->effecttype, rplay);
cslelitev3_update(usbhapticdevice, this->hapticeffect.effecttype, rplay);
break;
case USBHAPTIC_SIMAGICP1000PEDALS:
simagicp1000_update(usbhapticdevice, usbhapticdevice->effecttype, rplay);
simagicp1000_update(usbhapticdevice, this->hapticeffect.effecttype, rplay);
break;
case USBHAPTIC_SIMNETPEDALS:
simnetpedals_update(usbhapticdevice, this->hapticeffect.effecttype, rplay);
break;
}
}
@@ -39,10 +43,13 @@ int usbhapticdev_update(USBGenericHapticDevice* usbhapticdevice, SimData* simdat
switch ( usbhapticdevice->type )
{
case USBHAPTIC_CSLELITEV3PEDALS:
cslelitev3_update(usbhapticdevice, usbhapticdevice->effecttype, rplay);
cslelitev3_update(usbhapticdevice, this->hapticeffect.effecttype, rplay);
break;
case USBHAPTIC_SIMAGICP1000PEDALS:
simagicp1000_update(usbhapticdevice, usbhapticdevice->effecttype, rplay);
simagicp1000_update(usbhapticdevice, this->hapticeffect.effecttype, rplay);
break;
case USBHAPTIC_SIMNETPEDALS:
simnetpedals_update(usbhapticdevice, this->hapticeffect.effecttype, rplay);
break;
}
}
@@ -62,6 +69,9 @@ int usbhapticdev_free(USBGenericHapticDevice* usbhapticdevice)
case USBHAPTIC_SIMAGICP1000PEDALS:
simagicp1000_free(usbhapticdevice);
break;
case USBHAPTIC_SIMNETPEDALS:
simnetpedals_free(usbhapticdevice);
break;
}
return 0;
@@ -76,25 +86,7 @@ int usbhapticdev_init(USBGenericHapticDevice* usbhapticdevice, DeviceSettings* d
}
int error = 0;
usbhapticdevice->state = 0;
usbhapticdevice->value0 = ds->usbdevsettings.value0;
usbhapticdevice->value1 = ds->usbdevsettings.value1;
usbhapticdevice->state = usbhapticdevice->value0;
usbhapticdevice->effecttype = ds->effect_type;
usbhapticdevice->threshold = ds->threshold;
if(ds->effect_type == EFFECT_TYRESLIP)
{
usbhapticdevice->effecttype = EFFECT_TYRESLIP;
}
if(ds->effect_type == EFFECT_TYRELOCK)
{
usbhapticdevice->effecttype = EFFECT_TYRELOCK;
}
if(ds->effect_type == EFFECT_ABSBRAKES)
{
usbhapticdevice->effecttype = EFFECT_ABSBRAKES;
}
initializeHapticEffect(&this->m.hapticeffect, &ds->hapticsettings, ms);
slogi("initializing standalone usb haptic device...");
// detection of usb device model
@@ -107,6 +99,10 @@ int usbhapticdev_init(USBGenericHapticDevice* usbhapticdevice, DeviceSettings* d
usbhapticdevice->type = USBHAPTIC_CSLELITEV3PEDALS;
error = cslelitev3_init(usbhapticdevice);
break;
case (SIMDEVSUBTYPE_SIMNETPEDALS):
usbhapticdevice->type = USBHAPTIC_SIMNETPEDALS;
error = simnetpedals_init(usbhapticdevice);
break;
default:
slogw("Possibly unknown device");
}
+2 -7
View File
@@ -10,19 +10,14 @@ typedef enum
{
USBHAPTIC_UNKNOWN = 0,
USBHAPTIC_CSLELITEV3PEDALS = 1,
USBHAPTIC_SIMAGICP1000PEDALS = 2
USBHAPTIC_SIMAGICP1000PEDALS = 2,
USBHAPTIC_SIMNETPEDALS = 3
}
HapticType;
typedef struct
{
int id;
HapticType type;
double state;
double threshold;
int value0;
int value1;
VibrationEffectType effecttype;
FILE* filehandle;
hid_device* handle;
char* dev;
+80 -7
View File
@@ -2,20 +2,73 @@
#include <stdlib.h>
#include <string.h>
#include "usb/wheels/logitechg29.h"
#include "usb/wheels/cammusc5.h"
#include "usb/wheels/cammusc12.h"
#include "usb/wheels/gtneo.h"
#include "serial/moza.h"
#include "usb/cslelitev3.h"
#include "usb/simagicp1000.h"
#include "usb/simnetpedals.h"
#include "simdevice.h"
#include "../helper/confighelper.h"
#include "../simulatorapi/simapi/simapi/simdata.h"
#include "../slog/slog.h"
int wheeldev_update(USBDevice* usbdevice, SimData* simdata)
int wheelhapticdev_update(SimDevice* this, SimData* simdata)
{
USBDevice* usbdevice = (void *) this->derived;
WheelDevice* wheeldevice = &usbdevice->u.wheeldevice;
double play = slipeffect(simdata, &this->hapticeffect, this->hapticeffect.useconfig, this->hapticeffect.configcheck, this->hapticeffect.tyrediameterconfig);
if (play != usbdevice->hapticstate)
{
int rplay = 0;
if(play > 0)
{
rplay = 1;
switch ( wheeldevice->type )
{
case WHEELDEV_CSLELITEV3PEDALS:
cslelitev3_update(usbdevice, this->hapticeffect.effecttype, rplay);
break;
case WHEELDEV_SIMAGICP1000PEDALS:
simagicp1000_update(usbdevice, this->hapticeffect.effecttype, rplay);
break;
case WHEELDEV_SIMNETPEDALS:
simnetpedals_update(usbdevice, this->hapticeffect.effecttype, rplay, this->hapticeffect.motorposition, this->hapticeffect.basefrequency, this->hapticeffect.baseamplitude);
break;
}
}
else
{
switch ( wheeldevice->type )
{
case WHEELDEV_CSLELITEV3PEDALS:
cslelitev3_update(usbdevice, this->hapticeffect.effecttype, rplay);
break;
case WHEELDEV_SIMAGICP1000PEDALS:
simagicp1000_update(usbdevice, this->hapticeffect.effecttype, rplay);
break;
case WHEELDEV_SIMNETPEDALS:
simnetpedals_update(usbdevice, this->hapticeffect.effecttype, rplay, this->hapticeffect.motorposition, 0, 0);
break;
}
}
usbdevice->hapticstate = play;
}
return 0;
}
int wheeldev_update(SimDevice* this, SimData* simdata)
{
USBDevice* usbdevice = (void *) this->derived;
WheelDevice* wheeldevice = &usbdevice->u.wheeldevice;
switch ( wheeldevice->type )
{
case WHEELDEV_UNKNOWN :
@@ -72,6 +125,15 @@ int wheeldev_free(USBDevice* usbdevice)
free(usbdevice->m.device_specific_config_file);
}
break;
case WHEELDEV_CSLELITEV3PEDALS:
cslelitev3_free(usbdevice);
break;
case WHEELDEV_SIMAGICP1000PEDALS:
simagicp1000_free(usbdevice);
break;
case WHEELDEV_SIMNETPEDALS:
simnetpedals_free(usbdevice);
break;
}
return 0;
@@ -79,8 +141,9 @@ int wheeldev_free(USBDevice* usbdevice)
int wheeldev_init(USBDevice* usbdevice, DeviceSettings* ds)
{
slogi("initializing wheel device...");
slogi("initializing wheel or pedals device...");
int error = 0;
usbdevice->hapticstate = 0;
// detection of wheel model
WheelDevice* wheeldevice = &usbdevice->u.wheeldevice;
switch (ds->dev_subsubtype) {
@@ -138,11 +201,21 @@ int wheeldev_init(USBDevice* usbdevice, DeviceSettings* ds)
error = -1;
}
break;
default:
wheeldevice->type = WHEELDEV_UNKNOWN;
slogw("Unknown cammus wheel detected, trying C5");
error = cammusc5_init(usbdevice);
case (SIMDEVSUBTYPE_SIMAGICP1000PEDALS):
wheeldevice->type = WHEELDEV_SIMAGICP1000PEDALS;
error = simagicp1000_init(usbdevice);
break;
case (SIMDEVSUBTYPE_CSLELITEV3PEDALS):
slogi("Attempting to initialize CSL Elite V3 Pedals");
wheeldevice->type = WHEELDEV_CSLELITEV3PEDALS;
error = cslelitev3_init(usbdevice);
break;
case (SIMDEVSUBTYPE_SIMNETPEDALS):
wheeldevice->type = WHEELDEV_SIMNETPEDALS;
error = simnetpedals_init(usbdevice);
break;
default:
slogw("Possibly unknown wheel device");
}
+9 -6
View File
@@ -8,12 +8,15 @@
typedef enum
{
WHEELDEV_UNKNOWN = 0,
WHEELDEV_CAMMUSC5 = 1,
WHEELDEV_CAMMUSC12 = 2,
WHEELDEV_MOZAR5 = 3,
WHEELDEV_SIMAGICGTNEO = 4,
WHEELDEV_LOGITECHG29 = 5
WHEELDEV_UNKNOWN = 0,
WHEELDEV_CAMMUSC5 = 1,
WHEELDEV_CAMMUSC12 = 2,
WHEELDEV_MOZAR5 = 3,
WHEELDEV_SIMAGICGTNEO = 4,
WHEELDEV_LOGITECHG29 = 5,
WHEELDEV_CSLELITEV3PEDALS = 6,
WHEELDEV_SIMAGICP1000PEDALS = 7,
WHEELDEV_SIMNETPEDALS = 8
}
WheelType;
+2
View File
@@ -10,3 +10,5 @@ set(LIBXML_INCLUDE_DIR /usr/include/libxml2)
include_directories("." ${LIBXML_INCLUDE_DIR})
add_library(gameloop STATIC ${gameloop_source_files})
set_property(TARGET gameloop PROPERTY POSITION_INDEPENDENT_CODE ON)
+301 -5
View File
@@ -23,6 +23,16 @@
bool go = false;
bool go2 = false;
struct sigaction act;
static pthread_t loop_thread;
static uv_loop_t *loop = NULL;
SimData* simdata;
SimMap* simmap;
loop_data* baton;
device_loop_data* test_baton;
SimDevice* test_simdevice;
SimInfo* test_siminfo;
uv_idle_t idler;
@@ -30,10 +40,11 @@ uv_timer_t datachecktimer;
uv_timer_t showstatstimer;
uv_timer_t datamaptimer;
uv_timer_t tyrediametertimer;
uv_timer_t testdevicetimer;
uv_udp_t recv_socket;
bool doui = false;
int appstate = 0;
void shmdatamapcallback(uv_timer_t* handle);
void showstatscallback(uv_timer_t* handle);
@@ -354,7 +365,7 @@ void looprun(MonocoqueSettings* ms, loop_data* f, SimData* simdata)
}
uv_timer_start(&showstatstimer, showstatscallback, 0, 100);
//uv_timer_start(&showstatstimer, showstatscallback, 0, 100);
doui = false;
}
}
@@ -629,11 +640,240 @@ void cb(uv_poll_t* handle, int status, int events)
void* monocoque_mainloop_start(void* arg)
{
MonocoqueSettings* ms = arg;
simdata = malloc(sizeof(SimData));
simmap = simapi_simmap_create();
slogd("setting initial app state");
appstate = 1;
//struct pollfd mypoll = { STDIN_FILENO, POLLIN|POLLPRI };
//uv_poll_t* poll = (uv_poll_t*) malloc(uv_handle_size(UV_POLL));
baton = (loop_data*) malloc(sizeof(loop_data));
baton->siminfo.mapapi = -1;
baton->simmap = simmap;
baton->simdata = simdata;
baton->ms = ms;
baton->uion = false;
baton->releasing = false;
baton->use_udp = false;
baton->req.data = (void*) baton;
simapi_set_log_info(simapilib_loginfo);
simapi_set_log_debug(simapilib_logdebug);
simapi_set_log_trace(simapilib_logtrace);
//if (0 != uv_poll_init(uv_default_loop(), poll, 0))
//{
// return NULL;
//};
uv_udp_init(loop, &recv_socket);
uv_timer_init(loop, &datachecktimer);
uv_timer_init(loop, &datamaptimer);
uv_timer_init(loop, &tyrediametertimer);
uv_handle_set_data((uv_handle_t*) &datachecktimer, (void*) baton);
uv_handle_set_data((uv_handle_t*) &datamaptimer, (void*) baton);
//uv_handle_set_data((uv_handle_t*) &showstatstimer, (void*) baton);
uv_handle_set_data((uv_handle_t*) &recv_socket, (void*) baton);
//}
//uv_handle_set_data((uv_handle_t*) poll, (void*) baton);
//if (0 != uv_poll_start(poll, UV_READABLE, cb))
//{
// return NULL;
//};
uv_timer_start(&datachecktimer, datacheckcallback, 1000, 1000);
//fprintf(stdout, "Searching for sim data... Press q to quit...\n");
uv_run(loop, UV_RUN_DEFAULT);
return NULL;
}
SimData* get_test_simdata()
{
if(test_baton == NULL)
{
return NULL;
}
return test_baton->simdata;
}
void* monocoque_testloop_start(void* arg)
{
test_loop_args* args = arg;
simmap = simapi_simmap_create();
simapi_set_log_info(simapilib_loginfo);
simapi_set_log_debug(simapilib_logdebug);
simapi_set_log_trace(simapilib_logtrace);
DeviceSettings ds;
//int numdevices = getsingledevice(args->ms->config_str, args->confignum, args->devicenum, args->ms, &ds);
test_simdevice = malloc(1 * sizeof(SimDevice));
test_siminfo = malloc(sizeof(SimInfo));
simapi_set_faux_siminfo(test_siminfo);
int initdevices = devinit(test_simdevice, test_siminfo, 1, args->ds, args->ms);
//settingsfree(ds);
test_baton->siminfo.mapapi = -1;
test_baton->simdevice = test_simdevice;
test_baton->ms = args->ms;
test_baton->req.data = (void*) test_baton;
uv_timer_init(loop, &testdevicetimer);
uv_handle_set_data((uv_handle_t*) &testdevicetimer, (void*) test_baton);
uv_timer_start(&testdevicetimer, devicetimercallback, 1000, 16);
uv_run(loop, UV_RUN_DEFAULT);
return NULL;
}
int monocoque_testloop_stop()
{
uv_timer_stop(&testdevicetimer);
uv_stop(loop);
pthread_join(loop_thread, NULL);
uv_run(loop, UV_RUN_NOWAIT);
uv_walk(loop, close_walk_cb, NULL);
uv_loop_close(loop);
uv_library_shutdown();
slogi("All threads stopped...");
test_simdevice->free(test_simdevice);
free(loop);
free(test_baton);
//free(simdata);
free(simmap);
return 0;
}
int monocoque_mainloop_stop(MonocoqueSettings* ms)
{
uv_udp_recv_stop(&recv_socket);
uv_timer_stop(&datamaptimer);
uv_timer_stop(&datachecktimer);
uv_stop(loop);
pthread_join(loop_thread, NULL);
uv_run(loop, UV_RUN_NOWAIT);
uv_walk(loop, close_walk_cb, NULL);
uv_loop_close(loop);
uv_library_shutdown();
slogi("All threads stopped...");
free(loop);
free(baton);
free(simdata);
free(simmap);
appstate = 0;
return 0;
}
int start_loop(MonocoqueSettings* ms)
{
loop = malloc(sizeof(uv_loop_t));
if (loop == NULL)
{
return -1;
}
if (uv_loop_init(loop) != 0)
{
free(loop);
loop = NULL;
return -1;
}
return pthread_create(&loop_thread, NULL, monocoque_mainloop_start, ms);
}
int start_test(test_loop_args* test_data)
{
test_baton = (device_loop_data*) malloc(sizeof(device_loop_data));
test_baton->simdata = test_data->simdata;
loop = malloc(sizeof(uv_loop_t));
if (loop == NULL)
{
return -1;
}
if (uv_loop_init(loop) != 0)
{
free(loop);
loop = NULL;
return -1;
}
return pthread_create(&loop_thread, NULL, monocoque_testloop_start, test_data);
}
const char* get_simexe_name(void)
{
if(appstate <= 0)
{
return "None Detected";
}
if(baton == NULL)
{
return "None Detected";
}
if(baton->siminfo.simulatorexe <= 0)
{
return "None Detected";
}
return simapi_gametofullstr(baton->siminfo.simulatorexe);
}
const char* get_simd_onoff(void)
{
if(appstate <= 0)
{
return "Not Detected";
}
if(baton == NULL)
{
return "Not Detected";
}
if(baton->siminfo.mapapi == 0)
{
return "Running";
}
return "Not Detected";
}
int monocoque_mainloop(MonocoqueSettings* ms)
{
SimData* simdata = malloc(sizeof(SimData));
SimMap* simmap = simapi_simmap_create();
simdata = malloc(sizeof(SimData));
simmap = simapi_simmap_create();
struct termios newsettings, canonicalmode;
tcgetattr(0, &canonicalmode);
@@ -647,7 +887,7 @@ int monocoque_mainloop(MonocoqueSettings* ms)
uv_poll_t* poll = (uv_poll_t*) malloc(uv_handle_size(UV_POLL));
loop_data* baton = (loop_data*) malloc(sizeof(loop_data));
baton = (loop_data*) malloc(sizeof(loop_data));
baton->simmap = simmap;
baton->simdata = simdata;
baton->ms = ms;
@@ -706,6 +946,58 @@ int monocoque_mainloop(MonocoqueSettings* ms)
return 0;
}
void set_basic_simdata(SimData* simdata)
{
simdata->car[0] = 'C';
simdata->car[1] = 'A';
simdata->car[2] = 'R';
simdata->car[3] = '\0';
simdata->gear = SIMAPI_GEAR_NEUTRAL;
simdata->gearc[0] = 0x4e;
simdata->gearc[1] = 0;
simdata->velocity = 160;
simdata->rpms = 7000;
simdata->maxrpm = 8000;
simdata->abs = 0;
simdata->tyrediameter[0] = -1;
simdata->tyrediameter[1] = -1;
simdata->tyrediameter[2] = -1;
simdata->tyrediameter[3] = -1;
simdata->tyreslipratio[0] = 0;
simdata->tyreslipratio[1] = 0;
simdata->tyreslipratio[2] = 0;
simdata->tyreslipratio[3] = 0;
simdata->Xvelocity = 0;
simdata->Yvelocity = 100;
simdata->Zvelocity = 0;
}
void set_wheel_spin_simdata(SimData* simdata)
{
simdata->velocity = 15;
simdata->tyreRPS[0] = 50;
simdata->tyreRPS[1] = 50;
simdata->tyreRPS[2] = 50;
simdata->tyreRPS[3] = 50;
simdata->tyrediameter[0] = 0.638636385206394;
simdata->tyrediameter[1] = 0.633384434597093;
simdata->tyrediameter[2] = 0.710475735564615;
simdata->tyrediameter[3] = 0.710475735564615;
}
void set_wheel_lock_simdata(SimData* simdata)
{
simdata->velocity = 150;
simdata->tyreRPS[0] = 25;
simdata->tyreRPS[1] = 25;
simdata->tyreRPS[2] = 25;
simdata->tyreRPS[3] = 25;
simdata->tyrediameter[0] = 0.638636385206394;
simdata->tyrediameter[1] = 0.633384434597093;
simdata->tyrediameter[2] = 0.710475735564615;
simdata->tyrediameter[3] = 0.710475735564615;
}
int tester(SimDevice* devices, int numdevices)
{
@@ -737,6 +1029,10 @@ int tester(SimDevice* devices, int numdevices)
simdata->tyrediameter[1] = -1;
simdata->tyrediameter[2] = -1;
simdata->tyrediameter[3] = -1;
simdata->tyreslipratio[0] = 0;
simdata->tyreslipratio[1] = 0;
simdata->tyreslipratio[2] = 0;
simdata->tyreslipratio[3] = 0;
simdata->Xvelocity = 0;
simdata->Yvelocity = 100;
simdata->Zvelocity = 0;
+17
View File
@@ -1,7 +1,24 @@
#include "../devices/simdevice.h"
#include "../helper/parameters.h"
#include "loopdata.h"
extern int appstate;
int tester(SimDevice* devices, int numdevices);
int looper(SimDevice* devices, int numdevices, Parameters* p);
int monocoque_mainloop(MonocoqueSettings* ms);
int start_loop(MonocoqueSettings* ms);
int start_test(test_loop_args* test_loop_data);
int monocoque_mainloop_stop(MonocoqueSettings* ms);
int monocoque_testloop_stop();
const char* get_simd_onoff(void);
const char* get_simexe_name(void);
SimData* get_test_simdata();
void set_basic_simdata(SimData* simdata);
void set_wheel_spin_simdata(SimData* simdata);
void set_wheel_lock_simdata(SimData* simdata);
+8
View File
@@ -40,5 +40,13 @@ typedef struct loop_data
} loop_data;
typedef struct test_loop_args
{
MonocoqueSettings* ms;
DeviceSettings* ds;
SimData* simdata;
int devicenum;
int confignum;
} test_loop_args;
#endif
+2
View File
@@ -11,3 +11,5 @@ set(LIBXML_INCLUDE_DIR /usr/include/libxml2)
include_directories("." ${LIBXML_INCLUDE_DIR})
add_library(helper STATIC ${helper_source_files})
set_property(TARGET helper PROPERTY POSITION_INDEPENDENT_CODE ON)
+677 -131
View File
@@ -37,35 +37,35 @@ int strtoeffecttype(const char* effect, DeviceSettings* ds)
if (strcicmp(effect, "Engine") == 0)
{
ds->is_valid = true;
ds->effect_type = EFFECT_ENGINERPM;
ds->hapticsettings.effect_type = EFFECT_ENGINERPM;
}
if (strcicmp(effect, "Gear") == 0)
{
ds->is_valid = true;
ds->effect_type = EFFECT_GEARSHIFT;
ds->hapticsettings.effect_type = EFFECT_GEARSHIFT;
}
if (strcicmp(effect, "Suspension") == 0)
{
ds->is_valid = true;
ds->effect_type = EFFECT_SUSPENSION;
ds->hapticsettings.effect_type = EFFECT_SUSPENSION;
}
if (strcicmp(effect, "ABS") == 0)
{
ds->is_valid = true;
slogt("found abas effect set");
ds->effect_type = EFFECT_ABSBRAKES;
ds->hapticsettings.effect_type = EFFECT_ABSBRAKES;
}
if ((strcicmp(effect, "SLIP") == 0) || (strcicmp(effect, "TYRESLIP") == 0) || (strcicmp(effect, "TIRESLIP") == 0))
{
ds->is_valid = true;
slogt("found tyreslip effect set");
ds->effect_type = EFFECT_TYRESLIP;
ds->hapticsettings.effect_type = EFFECT_TYRESLIP;
}
if ((strcicmp(effect, "LOCK") == 0) || (strcicmp(effect, "TYRELOCK") == 0) || (strcicmp(effect, "TIRELOCK") == 0))
{
ds->is_valid = true;
slogt("found tyreslock effect set");
ds->effect_type = EFFECT_TYRELOCK;
ds->hapticsettings.effect_type = EFFECT_TYRELOCK;
}
if (ds->is_valid == false)
@@ -128,6 +128,11 @@ int strtodevsubsubtype(const char* device_subsubtype, DeviceSettings* ds)
ds->dev_subsubtype = SIMDEVSUBTYPE_CSLELITEV3PEDALS;
devfound = true;
}
if (strcicmp(device_subsubtype, "SIMNETPEDALS") == 0)
{
ds->dev_subsubtype = SIMDEVSUBTYPE_SIMNETPEDALS;
devfound = true;
}
if (strcicmp(device_subsubtype, "SIMAGICP1000PEDALS") == 0)
{
ds->dev_subsubtype = SIMDEVSUBTYPE_SIMAGICP1000PEDALS;
@@ -138,6 +143,11 @@ int strtodevsubsubtype(const char* device_subsubtype, DeviceSettings* ds)
ds->dev_subsubtype = SIMDEVSUBTYPE_SIMAGICGTNEO;
devfound = true;
}
if (strcicmp(device_subsubtype, "REVBURNER") == 0)
{
ds->dev_subsubtype = SIMDEVSUBTYPE_REVBURNERTACHOMETER;
devfound = true;
}
if(devfound == false)
{
@@ -586,31 +596,31 @@ int gettyre(config_setting_t* device_settings, DeviceSettings* ds) {
const char* temp;
int found = config_setting_lookup_string(device_settings, "tyre", &temp);
ds->tyre = ALLFOUR;
ds->hapticsettings.tyre = ALLFOUR;
if (strcicmp(temp, "FRONTS") == 0)
{
ds->tyre = FRONTS;
ds->hapticsettings.tyre = FRONTS;
}
if (strcicmp(temp, "REARS") == 0)
{
ds->tyre = REARS;
ds->hapticsettings.tyre = REARS;
}
if (strcicmp(temp, "FRONTLEFT") == 0)
{
ds->tyre = FRONTLEFT;
ds->hapticsettings.tyre = FRONTLEFT;
}
if (strcicmp(temp, "FRONTRIGHT") == 0)
{
ds->tyre = FRONTRIGHT;
ds->hapticsettings.tyre = FRONTRIGHT;
}
if (strcicmp(temp, "REARLEFT") == 0)
{
ds->tyre = REARLEFT;
ds->hapticsettings.tyre = REARLEFT;
}
if (strcicmp(temp, "REARRIGHT") == 0)
{
ds->tyre = REARRIGHT;
ds->hapticsettings.tyre = REARRIGHT;
}
}
@@ -674,6 +684,25 @@ int configcheck(const char* config_file_str, int confignum, int* devices)
return 0;
//return cfg;
}
static int config_get_device(const config_setting_t *entry, DeviceSettings *ds)
{
const char *value = NULL;
if (config_setting_lookup_string(entry, "devid", &value))
{
ds->dev = strdup(value);
return ds->dev != NULL;
}
if (config_setting_lookup_string(entry, "devpath", &value))
{
ds->dev = strdup(value);
return ds->dev != NULL;
}
ds->dev = NULL;
return 0;
}
int devsetup(const char* device_type, const char* device_subtype, const char* config_file, MonocoqueSettings* ms, DeviceSettings* ds, config_setting_t* device_settings)
{
@@ -700,6 +729,7 @@ int devsetup(const char* device_type, const char* device_subtype, const char* co
ds->fps = 60;
config_setting_lookup_int(device_settings, "fps", &ds->fps);
config_get_device(device_settings, ds);
if (ds->dev_subtype == SIMDEVTYPE_TACHOMETER)
{
@@ -720,115 +750,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)
{
// logic for different devices
int b = 0;
const char* temp;
int found = config_setting_lookup_string(device_settings, "subtype", &temp);
if(temp != NULL && found > 0)
{
b = strtodevsubsubtype(temp, ds);
}
}
if (ds->dev_subtype == SIMDEVTYPE_USBHAPTIC || ds->dev_type == SIMDEV_SOUND || ds->dev_subtype == SIMDEVTYPE_SERIALHAPTIC)
{
slogt("analysing haptic effect settings");
const char* effect;
config_setting_lookup_string(device_settings, "effect", &effect);
strtoeffecttype(effect, ds);
if (ds->effect_type == EFFECT_TYRESLIP || ds->effect_type == EFFECT_TYRELOCK || ds->effect_type == EFFECT_ABSBRAKES || ds->effect_type == EFFECT_SUSPENSION )
{
gettyre(device_settings, ds);
ds->threshold = 0;
int found = config_setting_lookup_float(device_settings, "threshold", &ds->threshold);
}
if (ds->dev_type == SIMDEV_SOUND)
{
slogi("reading configured sound device settings");
ds->sounddevsettings.frequency = 0;
ds->sounddevsettings.frequencyMax = 0;
ds->sounddevsettings.amplitude = 50;
ds->sounddevsettings.amplitudeMax = 50;
ds->sounddevsettings.volume = 0;
ds->sounddevsettings.pan = 0;
ds->sounddevsettings.channels = 1;
ds->sounddevsettings.duration = 2.0;
ds->sounddevsettings.noise = 0;
if (ds->effect_type == EFFECT_GEARSHIFT)
{
ds->sounddevsettings.duration = .125;
}
if (device_settings != NULL)
{
config_setting_lookup_int(device_settings, "volume", &ds->sounddevsettings.volume);
config_setting_lookup_int(device_settings, "frequency", &ds->sounddevsettings.frequency);
config_setting_lookup_int(device_settings, "frequencyMax", &ds->sounddevsettings.frequencyMax);
config_setting_lookup_int(device_settings, "amplitude", &ds->sounddevsettings.amplitude);
config_setting_lookup_int(device_settings, "amplitudeMax", &ds->sounddevsettings.amplitudeMax);
config_setting_lookup_int(device_settings, "pan", &ds->sounddevsettings.pan);
config_setting_lookup_int(device_settings, "channels", &ds->sounddevsettings.channels);
config_setting_lookup_float(device_settings, "duration", &ds->sounddevsettings.duration);
config_setting_lookup_int(device_settings, "noise", &ds->sounddevsettings.noise);
const char* temp = NULL;
int found = 0;
found = config_setting_lookup_string(device_settings, "devid", &temp);
if (found == CONFIG_FALSE)
{
ds->sounddevsettings.dev = NULL;
}
else
{
if(temp != NULL)
{
ds->sounddevsettings.dev = strdup(temp);
}
}
found = config_setting_lookup_string(device_settings, "modulation", &temp);
ds->sounddevsettings.modulation = SOUND_EFFECT_MODULATION_NONE;
if (found == 0)
{
ds->sounddevsettings.modulation = SOUND_EFFECT_MODULATION_NONE;
slogd("Effect modulation not found, set to none");
}
else
{
if(strcicmp(temp, "FREQUENCY") == 0)
{
ds->sounddevsettings.modulation = SOUND_EFFECT_MODULATION_FREQUENCY;
if(ds->sounddevsettings.frequencyMax == 0 || ds->sounddevsettings.frequencyMax < ds->sounddevsettings.frequency)
{
ds->sounddevsettings.modulation = SOUND_EFFECT_MODULATION_NONE;
slogw("Falling back to no frequency modulation since frequencyMax is either not set or set below target frequency");
}
else
{
slogi("Effect modulation found, set to FREQUENCY");
}
}
else if(strcicmp(temp, "AMPLIFY") == 0)
{
ds->sounddevsettings.modulation = SOUND_EFFECT_MODULATION_AMPLIFY;
slogi("Effect modulation found, set to AMPLIFY");
}
else
{
slogw("%s is not a valid modulation type, falling back to no effect modulation");
ds->sounddevsettings.modulation = SOUND_EFFECT_MODULATION_NONE;
}
}
}
}
}
if (ds->dev_type == SIMDEV_SERIAL)
if (ds->dev_type == SIMDEV_USB)
{
if (device_settings != NULL)
{
@@ -838,9 +760,19 @@ int devsetup(const char* device_type, const char* device_subtype, const char* co
{
strtodevsubsubtype(temp, ds);
}
}
}
config_setting_lookup_string(device_settings, "devpath", &temp);
ds->serialdevsettings.portdev = strdup(temp);
if (ds->dev_type == SIMDEV_SERIAL)
{
if (device_settings != NULL)
{
const char* temp = NULL;
int found = config_setting_lookup_string(device_settings, "subtype", &temp);
if(temp != NULL && found > 0)
{
strtodevsubsubtype(temp, ds);
}
int motorposition = 8;
config_setting_lookup_int(device_settings, "motors", &motorposition);
@@ -881,6 +813,121 @@ int devsetup(const char* device_type, const char* device_subtype, const char* co
}
ds->has_haptic_effects = false;
if (ds->dev_subtype == SIMDEVTYPE_USBHAPTIC || ds->dev_subtype == SIMDEVTYPE_USBWHEEL || ds->dev_type == SIMDEV_SOUND || ds->dev_subtype == SIMDEVTYPE_SERIALHAPTIC)
{
slogt("analysing haptic effect settings");
ds->has_haptic_effects = true;
const char* effect;
config_setting_lookup_string(device_settings, "effect", &effect);
strtoeffecttype(effect, ds);
if (ds->hapticsettings.effect_type == EFFECT_TYRESLIP || ds->hapticsettings.effect_type == EFFECT_TYRELOCK || ds->hapticsettings.effect_type == EFFECT_ABSBRAKES || ds->hapticsettings.effect_type == EFFECT_SUSPENSION )
{
gettyre(device_settings, ds);
ds->hapticsettings.threshold = 0;
int found = config_setting_lookup_float(device_settings, "threshold", &ds->hapticsettings.threshold);
}
slogi("reading configured haptic effect settings");
ds->hapticsettings.frequency = 0;
ds->hapticsettings.frequencyMax = 0;
ds->hapticsettings.amplitude = 50;
ds->hapticsettings.amplitudeMax = 50;
if (ds->hapticsettings.effect_type == EFFECT_GEARSHIFT)
{
ds->hapticsettings.duration = .125;
}
if (device_settings != NULL)
{
config_setting_lookup_int(device_settings, "frequency", &ds->hapticsettings.frequency);
config_setting_lookup_int(device_settings, "frequencyMax", &ds->hapticsettings.frequencyMax);
config_setting_lookup_int(device_settings, "amplitude", &ds->hapticsettings.amplitude);
config_setting_lookup_float(device_settings, "duration", &ds->hapticsettings.duration);
config_setting_lookup_int(device_settings, "amplitudeMax", &ds->hapticsettings.amplitudeMax);
const char* temp = NULL;
int found = 0;
found = config_setting_lookup_string(device_settings, "modulation", &temp);
ds->hapticsettings.modulation = EFFECT_MODULATION_NONE;
if (found == 0)
{
ds->hapticsettings.modulation = EFFECT_MODULATION_NONE;
slogd("Effect modulation not found, set to none");
}
else
{
if(strcicmp(temp, "FREQUENCY") == 0)
{
ds->hapticsettings.modulation = EFFECT_MODULATION_FREQUENCY;
if(ds->hapticsettings.frequencyMax == 0 || ds->hapticsettings.frequencyMax < ds->hapticsettings.frequency)
{
ds->hapticsettings.modulation = EFFECT_MODULATION_NONE;
slogw("Falling back to no frequency modulation since frequencyMax is either not set or set below target frequency");
}
else
{
slogi("Effect modulation found, set to FREQUENCY");
}
}
else if(strcicmp(temp, "AMPLIFY") == 0)
{
ds->hapticsettings.modulation = EFFECT_MODULATION_AMPLIFY;
slogi("Effect modulation found, set to AMPLIFY");
}
else
{
slogw("%s is not a valid modulation type, falling back to no effect modulation");
ds->hapticsettings.modulation = EFFECT_MODULATION_NONE;
}
}
ds->hapticsettings.motorposition = 0;
int motorposition = 1;
config_setting_lookup_int(device_settings, "motors", &motorposition);
ds->hapticsettings.motorposition = motorposition;
}
if (ds->dev_type == SIMDEV_SOUND)
{
slogi("reading configured sound device settings");
ds->sounddevsettings.volume = 0;
ds->sounddevsettings.pan = 0;
ds->sounddevsettings.channels = 1;
ds->sounddevsettings.noise = 0;
if (ds->hapticsettings.effect_type == EFFECT_GEARSHIFT)
{
ds->hapticsettings.duration = .125;
}
if (device_settings != NULL)
{
config_setting_lookup_int(device_settings, "volume", &ds->sounddevsettings.volume);
config_setting_lookup_int(device_settings, "pan", &ds->sounddevsettings.pan);
config_setting_lookup_int(device_settings, "channels", &ds->sounddevsettings.channels);
config_setting_lookup_int(device_settings, "noise", &ds->sounddevsettings.noise);
const char* temp = NULL;
int found = 0;
found = config_setting_lookup_string(device_settings, "devid", &temp);
if (found == CONFIG_FALSE)
{
ds->dev = NULL;
}
else
{
if(temp != NULL)
{
ds->dev = strdup(temp);
}
}
}
}
}
return error;
}
@@ -952,21 +999,516 @@ int uiloadconfig(const char* config_file_str, int confignum, int configureddevic
return numdevices;
}
int settingsfree(DeviceSettings ds)
int getsingledevice(const char* config_file_str, int confignum, int devicenum, MonocoqueSettings* ms, DeviceSettings* ds)
{
if (ds.dev_type == SIMDEV_SERIAL)
int numdevices = 0;
config_t cfg;
config_init(&cfg);
if (!config_read_file(&cfg, config_file_str))
{
if (ds.serialdevsettings.portdev != NULL)
fprintf(stderr, "%s:%d - %s\n", config_error_file(&cfg), config_error_line(&cfg), config_error_text(&cfg));
}
else
{
slogi("Parsing config file");
config_setting_t* config = NULL;
config = config_lookup(&cfg, "configs");
config_setting_t* selectedconfig = config_setting_get_elem(config, confignum);
config_setting_t* config_devices = NULL;
config_devices = config_setting_lookup(selectedconfig, "devices");
int num_devices = config_setting_length(config_devices);
int i = 0;
int error = MONOCOQUE_ERROR_NONE;
while (i<num_devices)
{
free(ds.serialdevsettings.portdev);
if(i!=devicenum)
{
i++;
continue;
}
error = MONOCOQUE_ERROR_NONE;
config_setting_t* config_device = config_setting_get_elem(config_devices, i);
const char* device_type = NULL;
const char* device_subtype = NULL;
const char* device_config_file = NULL;
int found = 0;
config_setting_lookup_string(config_device, "device", &device_type);
config_setting_lookup_string(config_device, "type", &device_subtype);
found = config_setting_lookup_string(config_device, "config", &device_config_file);
slogt("device type: %s", device_type);
slogt("device sub type: %s", device_subtype);
if(found == CONFIG_FALSE)
{
device_config_file = NULL;
}
else
{
slogt("device config file: %s", device_config_file);
}
if (error == MONOCOQUE_ERROR_NONE)
{
error = devsetup(device_type, device_subtype, device_config_file, ms, ds, config_device);
}
if (error == MONOCOQUE_ERROR_NONE)
{
numdevices++;
}
i++;
}
}
if (ds.dev_type == SIMDEV_SOUND)
config_destroy(&cfg);
return numdevices;
}
static const char *haptic_effect_type_to_string(VibrationEffectType effect)
{
switch (effect)
{
if (ds.sounddevsettings.dev != NULL)
case EFFECT_ENGINERPM:
return "EngineRPM";
case EFFECT_GEARSHIFT:
return "GearShift";
case EFFECT_ABSBRAKES:
return "ABS";
case EFFECT_TYRESLIP:
return "TyreSlip";
case EFFECT_TYRELOCK:
return "TyreLock";
case EFFECT_SUSPENSION:
return "Suspension";
default:
return NULL;
}
}
static const char *tyre_identifier_to_string(MonocoqueTyreIdentifier tyre)
{
switch (tyre)
{
case FRONTLEFT:
return "FrontLeft";
case FRONTRIGHT:
return "FrontRight";
case REARLEFT:
return "RearLeft";
case REARRIGHT:
return "RearRight";
case FRONTS:
return "Front";
case REARS:
return "Rear";
case ALLFOUR:
return "ALL";
default:
return NULL;
}
}
static const char *modulation_type_to_string(EffectModulationType modulation)
{
switch (modulation)
{
case EFFECT_MODULATION_NONE:
return "none";
case EFFECT_MODULATION_FREQUENCY:
return "frequency";
case EFFECT_MODULATION_AMPLIFY:
return "amplify";
default:
return NULL;
}
}
static int set_string(config_setting_t *parent, const char *name, const char *value)
{
config_setting_t *setting;
if (value == NULL)
return 1;
setting = config_setting_lookup(parent, name);
if (setting == NULL)
setting = config_setting_add(parent, name, CONFIG_TYPE_STRING);
if (setting == NULL)
return 0;
return config_setting_set_string(setting, value);
}
static int set_int(config_setting_t *parent, const char *name, int value)
{
config_setting_t *setting;
setting = config_setting_lookup(parent, name);
if (setting == NULL)
setting = config_setting_add(parent, name, CONFIG_TYPE_INT);
if (setting == NULL)
return 0;
return config_setting_set_int(setting, value);
}
int set_float(config_setting_t *parent, const char *name, double value)
{
config_setting_t *setting;
setting = config_setting_lookup(parent, name);
if (setting == NULL)
setting = config_setting_add(parent, name, CONFIG_TYPE_FLOAT);
if (setting == NULL)
return 0;
return config_setting_set_float(setting, value);
}
int delete_device_config(config_t *cfg, const char *configfile, int confignum, int devicenum)
{
config_setting_t *configs;
config_setting_t *config;
config_setting_t *devices;
configs = config_lookup(cfg, "configs");
if (configs == NULL)
return -1;
config = config_setting_get_elem(configs, confignum);
if (config == NULL)
return -1;
devices = config_setting_lookup(config, "devices");
if (devices == NULL)
return -1;
if (devicenum < 0 || devicenum >= config_setting_length(devices))
return -1;
if (!config_setting_remove_elem(devices, devicenum))
return -1;
if (!config_write_file(cfg, configfile))
return -1;
return 0;
}
static const char *device_type_to_string(DeviceType device_type)
{
switch (device_type)
{
case SIMDEV_USB:
return "USB";
case SIMDEV_SOUND:
return "Sound";
case SIMDEV_SERIAL:
return "Serial";
case SIMDEV_UNKNOWN:
return "Unknown";
default:
return "Unknown";
}
}
static const char *device_subtype_to_string(DeviceSubType device_subtype)
{
switch (device_subtype)
{
case SIMDEVTYPE_SOUNDHAPTIC:
return "SoundHaptic";
case SIMDEVTYPE_TACHOMETER:
return "Tachometer";
case SIMDEVTYPE_USBHAPTIC:
return "UsbHaptic";
case SIMDEVTYPE_USBWHEEL:
return "UsbWheel";
case SIMDEVTYPE_SHIFTLIGHTS:
return "ShiftLights";
case SIMDEVTYPE_SIMWIND:
return "SimWind";
case SIMDEVTYPE_SERIALHAPTIC:
return "SerialHaptic";
case SIMDEVTYPE_SERIALWHEEL:
return "Wheel";
case SIMDEVTYPE_SIMLED:
return "Simleds";
case SIMDEVTYPE_ARDUINOCUSTOM:
return "ArduinoCustom";
case SIMDEVTYPE_UNKNOWN:
default:
return "Unknown";
}
}
static const char *haptic_effect_to_string(VibrationEffectType effect)
{
switch (effect)
{
case EFFECT_ENGINERPM:
return "Engine";
case EFFECT_GEARSHIFT:
return "Gear";
case EFFECT_ABSBRAKES:
return "ABS";
case EFFECT_TYRESLIP:
return "TyreSlip";
case EFFECT_TYRELOCK:
return "TyreLock";
case EFFECT_SUSPENSION:
return "Suspension";
default:
return "Unknown";
}
}
static const char *modulation_to_string(EffectModulationType modulation)
{
switch (modulation)
{
case EFFECT_MODULATION_NONE:
return "None";
case EFFECT_MODULATION_FREQUENCY:
return "Frequency";
case EFFECT_MODULATION_AMPLIFY:
return "Amplitude";
default:
return "Unknown";
}
}
static const char *tyre_to_string(MonocoqueTyreIdentifier tyre)
{
switch (tyre)
{
case FRONTLEFT:
return "FrontLeft";
case FRONTRIGHT:
return "FrontRight";
case REARLEFT:
return "RearLeft";
case REARRIGHT:
return "RearRight";
case FRONTS:
return "Fronts";
case REARS:
return "Rears";
case ALLFOUR:
return "All";
default:
return "Unknown";
}
}
int save_device_config(config_t *cfg, const char* configfile, int confignum, int devicenum, const DeviceSettings *ds)
{
config_setting_t *configs;
config_setting_t *config_entry;
config_setting_t *devices;
config_setting_t *device_entry;
if (cfg == NULL || ds == NULL)
return 0;
slogd("Saving device with device num %i and confignum %i", devicenum, confignum);
configs = config_lookup(cfg, "configs");
if (configs == NULL)
return 0;
config_entry = config_setting_get_elem(configs, confignum);
if (config_entry == NULL)
return 0;
devices = config_setting_lookup(config_entry, "devices");
if (devices == NULL)
return 0;
device_entry = config_setting_get_elem(devices, devicenum);
if (device_entry == NULL)
{
device_entry = config_setting_add(devices, NULL, CONFIG_TYPE_GROUP);
if (device_entry == NULL)
return 0;
if (config_setting_index(device_entry) != devicenum)
return 0;
}
if (device_entry == NULL)
return 0;
set_string(device_entry, "device", device_type_to_string(ds->dev_type));
set_int(device_entry, "fps", ds->fps);
if (ds->specific_config_file != NULL)
{
set_string(device_entry, "config", ds->specific_config_file);
}
if (ds->dev != NULL)
{
set_string(device_entry, "devid", ds->dev);
}
switch (ds->dev_type)
{
case SIMDEV_SERIAL:
{
free(ds.sounddevsettings.dev);
set_string(device_entry, "type", device_subtype_to_string(ds->dev_type + SerialDevicesOffset));
const SerialDeviceSettings *ss = &ds->serialdevsettings;
set_int(device_entry, "baud", ss->baud);
set_float(device_entry, "ampfactor", ss->ampfactor);
set_float(device_entry, "fanpower", ss->fanpower);
break;
}
case SIMDEV_SOUND:
{
set_string(device_entry, "type", device_subtype_to_string(ds->dev_type));
const SoundDeviceSettings *ss = &ds->sounddevsettings;
set_int(device_entry, "volume", ss->volume);
set_int(device_entry, "pan", ss->pan);
set_int(device_entry, "channels", ss->channels);
set_int(device_entry, "noise", ss->noise);
break;
}
case SIMDEV_USB:
{
set_string(device_entry, "type", device_subtype_to_string(ds->dev_type + USBDevicesOffset));
const USBDeviceSettings *us = &ds->usbdevsettings;
break;
}
default:
break;
}
if(ds->has_haptic_effects == true)
{
slogt("Saving haptic effect settings");
const HapticEffectSettings *hs = &ds->hapticsettings;
set_int(device_entry, "frequency", hs->frequency);
set_int(device_entry, "amplitude", hs->amplitude);
set_int(device_entry, "frequencyMax", hs->frequencyMax);
set_int(device_entry, "amplitudeMax", hs->amplitudeMax);
set_float(device_entry, "threshold", hs->threshold);
set_float(device_entry, "duration", hs->duration);
set_string(device_entry, "effect", haptic_effect_to_string(hs->effect_type));
set_string(device_entry, "tyre", tyre_to_string(hs->tyre));
set_string(device_entry, "modulation", modulation_to_string(hs->modulation));
}
if(ds->has_led_effects == true)
{
slogt("Saving led effect settings");
const SerialDeviceSettings *ss = &ds->serialdevsettings;
set_int(device_entry, "numleds", ss->numleds);
set_int(device_entry, "startled", ss->startled);
set_int(device_entry, "endled", ss->endled);
}
if(!config_write_file(cfg, configfile))
{
return 1;
}
return 0;
}
config_t *open_monocoque_config(const char *filename)
{
config_t *cfg;
if (filename == NULL)
return NULL;
cfg = malloc(sizeof(*cfg));
if (cfg == NULL)
return NULL;
config_init(cfg);
if (!config_read_file(cfg, filename))
{
fprintf(stderr,
"Failed to read config file '%s' (line %d): %s\n",
filename,
config_error_line(cfg),
config_error_text(cfg));
config_destroy(cfg);
free(cfg);
return NULL;
}
return cfg;
}
void close_monocoque_config(config_t* cfg)
{
if (cfg == NULL)
return;
config_destroy(cfg);
}
int settingsfree(DeviceSettings ds)
{
if (ds.dev != NULL)
{
free(ds.dev);
}
if(ds.has_config && ds.specific_config_file != NULL)
@@ -982,17 +1524,21 @@ int monocoquesettingsfree(MonocoqueSettings* ms)
if(ms->tyre_diameter_config != NULL)
{
free(ms->tyre_diameter_config);
ms->tyre_diameter_config = NULL;
}
if(ms->config_str != NULL)
{
free(ms->config_str);
ms->config_str = NULL;
}
if(ms->log_filename_str != NULL)
{
free(ms->log_filename_str);
ms->log_filename_str = NULL;
}
if(ms->log_dirname_str != NULL)
{
free(ms->log_dirname_str);
ms->log_dirname_str = NULL;
}
}
+69 -41
View File
@@ -13,28 +13,32 @@
typedef enum
{
SIMDEV_UNKNOWN = 0,
SIMDEV_USB = 1,
SIMDEV_SOUND = 2,
SIMDEV_SERIAL = 3
SIMDEV_USB = 0,
SIMDEV_SOUND = 1,
SIMDEV_SERIAL = 2,
SIMDEV_UNKNOWN = 3,
}
DeviceType;
typedef enum
{
SIMDEVTYPE_UNKNOWN = 0,
SIMDEVTYPE_TACHOMETER = 1,
SIMDEVTYPE_USBHAPTIC = 2,
SIMDEVTYPE_SHIFTLIGHTS = 3,
SIMDEVTYPE_SIMWIND = 4,
SIMDEVTYPE_SERIALHAPTIC = 5,
SIMDEVTYPE_USBWHEEL = 6,
SIMDEVTYPE_SERIALWHEEL = 7,
SIMDEVTYPE_SIMLED = 8,
SIMDEVTYPE_ARDUINOCUSTOM = 9
SIMDEVTYPE_SOUNDHAPTIC = 1,
SIMDEVTYPE_TACHOMETER = 2,
SIMDEVTYPE_USBHAPTIC = 3,
SIMDEVTYPE_USBWHEEL = 4,
SIMDEVTYPE_SHIFTLIGHTS = 5,
SIMDEVTYPE_SIMWIND = 6,
SIMDEVTYPE_SERIALHAPTIC = 7,
SIMDEVTYPE_SERIALWHEEL = 8,
SIMDEVTYPE_SIMLED = 9,
SIMDEVTYPE_ARDUINOCUSTOM = 10,
}
DeviceSubType;
#define SerialDevicesOffset 5
#define USBDevicesOffset 2
typedef enum
{
SIMDEVSUBTYPE_UNKNOWN = 0,
@@ -46,7 +50,9 @@ typedef enum
SIMDEVSUBTYPE_SIMAGICGTNEO = 6,
SIMDEVSUBTYPE_MOZA_NEW = 7,
SIMDEVSUBTYPE_LOGITECH_G29 = 8,
SIMDEVSUBTYPE_MOZA_KS_PRO_WHEEL = 9
SIMDEVSUBTYPE_MOZA_KS_PRO_WHEEL = 9,
SIMDEVSUBTYPE_SIMNETPEDALS = 10,
SIMDEVSUBTYPE_REVBURNERTACHOMETER = 11
}
DeviceSubSubType;
@@ -73,6 +79,14 @@ typedef enum
}
VibrationEffectType;
typedef enum
{
EFFECT_MODULATION_NONE = 0,
EFFECT_MODULATION_FREQUENCY = 1,
EFFECT_MODULATION_AMPLIFY = 2,
}
EffectModulationType;
typedef enum
{
MOTOR_1 = 0,
@@ -146,6 +160,7 @@ typedef struct
char* config_str;
char* log_filename_str;
char* log_dirname_str;
config_t* cfg;
}
MonocoqueSettings;
@@ -161,41 +176,46 @@ TachometerSettings;
typedef struct
{
char* portdev;
MotorPosition motorsposition;
int numlights;
int numleds;
int startled;
int endled;
uint32_t numlights;
uint32_t numleds;
uint32_t startled;
uint32_t endled;
float ampfactor;
float fanpower;
int baud;
// baud is the only serial thing
uint32_t baud;
}
SerialDeviceSettings;
typedef struct
{
uint32_t frequency;
uint32_t volume;
int lowbound_frequency;
int upperbound_frequency;
uint32_t frequencyMax;
uint32_t amplitudeMax;
uint32_t amplitude;
int pan;
int channels;
double duration;
char* dev;
SoundEffectModulationType modulation;
int noise;
uint32_t pan;
uint32_t channels;
uint32_t noise;
}
SoundDeviceSettings;
typedef struct
{
int value0;
int value1;
uint32_t frequency;
uint32_t amplitude;
uint32_t frequencyMax;
uint32_t amplitudeMax;
double threshold;
double duration;
MotorPosition motorposition;
VibrationEffectType effect_type;
MonocoqueTyreIdentifier tyre;
EffectModulationType modulation;
}
HapticEffectSettings;
typedef struct
{
char* dev;
}
USBDeviceSettings;
@@ -203,18 +223,19 @@ USBDeviceSettings;
typedef struct
{
bool is_valid;
int fps;
DeviceType dev_type;
DeviceSubType dev_subtype;
DeviceSubSubType dev_subsubtype;
// to get really fancy move the effect information to it's own structure that would be a member of
// any device settings member structure that can carry an effect
VibrationEffectType effect_type;
MonocoqueTyreIdentifier tyre;
double threshold;
bool has_haptic_effects;
bool has_led_effects;
char* dev;
bool has_config;
char* specific_config_file;
uint32_t fps;
// union?
HapticEffectSettings hapticsettings;
TachometerSettings tachsettings;
SerialDeviceSettings serialdevsettings;
SoundDeviceSettings sounddevsettings;
@@ -236,9 +257,16 @@ int getconfigtouse2(const char* config_file_str, char* car, int sim);
int getconfigtouse1(const char* config_file_str, char* car, int sim);
int getconfigtouse(const char* config_file_str, char* car, int sim);
config_t *open_monocoque_config(const char *filename);
void close_monocoque_config(config_t *cfg);
int delete_device_config(config_t *cfg, const char *configfile, int confignum, int devicenum);
int save_device_config(config_t *cfg, const char* configfile, int confignum, int devicenum, const DeviceSettings *ds);
int configcheck(const char* config_file_str, int confignum, int* devices);
int uiloadconfig(const char* config_file_str, int confignum, int configureddevices, MonocoqueSettings* ms, DeviceSettings* ds);
int getsingledevice(const char* config_file_str, int confignum, int devicenum, MonocoqueSettings* ms, DeviceSettings* ds);
int getNumberOfConfigs(const char* config_file_str);
#endif
+38
View File
@@ -0,0 +1,38 @@
set(mgui_source_files
addeditaction.c
addeditaction.h
testaction.c
testaction.h
uiconfighelper.c
uiconfighelper.h
mainwindow.h
)
set(NAPPGUI_DEMO NO CACHE BOOL "" FORCE)
set(NAPPGUI_WEB False CACHE BOOL "Build NAppGUI WebView support.")
set(_saved_build_type ${CMAKE_BUILD_TYPE})
set(CMAKE_BUILD_TYPE Release)
add_subdirectory(nappgui_src)
set(CMAKE_BUILD_TYPE ${_saved_build_type})
add_library(mgui STATIC ${mgui_source_files} ${NAppGUI_SOURCE_DIR}/src)
set_property(TARGET mgui PROPERTY POSITION_INDEPENDENT_CODE ON)
add_dependencies(mgui gui osapp osgui draw2d geom2d core osbs sewer encode)
target_include_directories(mgui PUBLIC ${LIBXML_INCLUDE_DIR} ${NAppGUI_SOURCE_DIR}/src ${GTK3_INCLUDE_DIRS})
set_target_properties(mgui PROPERTIES LINKER_LANGUAGE C)
set(NAPPGUI_LIB_DIR ${CMAKE_BINARY_DIR}/Release/lib)
target_link_libraries(mgui PUBLIC
#gui osapp osgui draw2d geom2d core osbs sewer osapp encode
${NAPPGUI_LIB_DIR}/libgui.a
${NAPPGUI_LIB_DIR}/libosapp.a
${NAPPGUI_LIB_DIR}/libosgui.a
${NAPPGUI_LIB_DIR}/libdraw2d.a
${NAPPGUI_LIB_DIR}/libgeom2d.a
${NAPPGUI_LIB_DIR}/libcore.a
${NAPPGUI_LIB_DIR}/libosbs.a
${NAPPGUI_LIB_DIR}/libsewer.a
${NAPPGUI_LIB_DIR}/libosapp.a
${NAPPGUI_LIB_DIR}/libencode.a
${GTK3_LIBRARIES})
+604
View File
@@ -0,0 +1,604 @@
#include <string.h>
#include <nappgui.h>
#include <gui/guiall.h>
#include "addeditaction.h"
#include "testaction.h"
#include "mainwindow.h"
#include "uiconfighelper.h"
#include "../helper/confighelper.h"
#include "../gameloop/gameloop.h"
#include "../gameloop/loopdata.h"
#include "../slog/slog.h"
test_loop_args* test_loop_data;
/*---------------------------------------------------------------------------*/
static Layout *i_modal_layout(AddDeviceData *data, App* app, MonocoqueSettings* ms, enum device_action dev_action, int confignum, int devicenum);
/*---------------------------------------------------------------------------*/
static AddDeviceData *i_modal_data(Window *parent)
{
AddDeviceData *data = heap_new0(AddDeviceData);
data->parent = parent;
data->type = UINT32_MAX;
return data;
}
/*---------------------------------------------------------------------------*/
static void i_destroy_modal_data(AddDeviceData **data)
{
AddDeviceData* d = *data;
DeviceSettings ds = *d->ds;
settingsfree(ds);
free(d->ds);
heap_delete(data, AddDeviceData);
}
/*---------------------------------------------------------------------------*/
static void i_OnTestClose(App *app, Event *e)
{
}
static void update_device_data_from_controls(AddDeviceData* data)
{
data->ds->dev_type = combo_get_selected(data->combo_select_device_class);
data->ds->dev_subtype = combo_get_selected(data->combo_select_device_subtype);
uint32_t device_selected = combo_get_selected(data->combo_select_device);
data->ds->dev = strdup(combo_get_text(data->combo_select_device, device_selected));
if(data->ds->dev_type == SIMDEV_SERIAL)
{
data->ds->dev_subtype = combo_get_selected(data->combo_select_device_subtype) + SerialDevicesOffset;
}
if(data->ds->dev_type == SIMDEV_USB)
{
data->ds->dev_subtype = combo_get_selected(data->combo_select_device_subtype) + USBDevicesOffset;
}
data->ds->hapticsettings.tyre = combo_get_selected(data->combo_select_tyre);
data->ds->hapticsettings.effect_type = combo_get_selected(data->combo_select_effect);
data->ds->hapticsettings.modulation = combo_get_selected(data->combo_select_modulation);
}
static void i_OnTestDevice(AddDeviceData *data, Event *e)
{
update_device_data_from_controls(data);
Panel *panel = NULL;
data->apppointer->window3 = window_create(ekWINDOW_STDRES);
SimData* t_simdata = malloc(sizeof(SimData));
set_basic_simdata(t_simdata);
set_wheel_spin_simdata(t_simdata);
if(data->ds->has_haptic_effects == true)
{
if(data->ds->hapticsettings.effect_type == EFFECT_TYRELOCK)
{
set_wheel_lock_simdata(t_simdata);
}
}
test_loop_data = malloc(sizeof(test_loop_args));
test_loop_data->ms = data->ms;
test_loop_data->confignum = data->confignum;
test_loop_data->devicenum = data->devicenum;
test_loop_data->ds = data->ds;
test_loop_data->simdata = t_simdata;
start_test(test_loop_data);
panel = test_window(data->apppointer->window3, data->apppointer);
window_panel(data->apppointer->window3, panel);
window_origin(data->apppointer->window3, v2df(800, 200));
window_title(data->apppointer->window3, "monocoque");
window_OnClose(data->apppointer->window3, listener(data->apppointer, i_OnTestClose, App));
window_modal(data->apppointer->window3, data->apppointer->window);
window_destroy(&data->apppointer->window3);
free(t_simdata);
free(test_loop_data);
}
static void addHapticDeviceLayout(AddDeviceData* data)
{
struct _add_device_t* subwindow = data;
subwindow->haptic_effect_sublayout = layout_create(8, 3);
subwindow->label_select_effect = label_create();
subwindow->combo_select_effect = combo_create();
subwindow->label_select_modulation = label_create();
subwindow->combo_select_modulation = combo_create();
subwindow->label_select_tyre = label_create();
subwindow->combo_select_tyre = combo_create();
subwindow->label_motorposition = label_create();
subwindow->edit_motorposition = edit_create();
subwindow->label_frequency = label_create();
subwindow->edit_frequency = edit_create();
subwindow->label_amplitude = label_create();
subwindow->edit_amplitude = edit_create();
subwindow->label_frequencyMax = label_create();
subwindow->edit_frequencyMax = edit_create();
subwindow->label_amplitudeMax = label_create();
subwindow->edit_amplitudeMax = edit_create();
subwindow->label_threshold = label_create();
subwindow->edit_threshold = edit_create();
subwindow->label_duration = label_create();
subwindow->edit_duration = edit_create();
label_text(subwindow->label_select_effect, "Effect:");
label_text(subwindow->label_select_modulation, "Modulation:");
label_text(subwindow->label_select_tyre, "Tyre:");
label_text(subwindow->label_motorposition, "Motor Position:");
label_text(subwindow->label_frequency, "Frequency:");
label_text(subwindow->label_amplitude, "Amplitude:");
label_text(subwindow->label_frequencyMax, "Max Frequency:");
label_text(subwindow->label_amplitudeMax, "Max Amplitude:");
label_text(subwindow->label_threshold, "Threshold:");
label_text(subwindow->label_duration, "Duration:");
layout_label(subwindow->haptic_effect_sublayout, subwindow->label_select_effect, 0, 0);
layout_combo(subwindow->haptic_effect_sublayout, subwindow->combo_select_effect, 1, 0);
layout_label(subwindow->haptic_effect_sublayout, subwindow->label_select_modulation, 2, 0);
layout_combo(subwindow->haptic_effect_sublayout, subwindow->combo_select_modulation, 3, 0);
layout_label(subwindow->haptic_effect_sublayout, subwindow->label_select_tyre, 4, 0);
layout_combo(subwindow->haptic_effect_sublayout, subwindow->combo_select_tyre, 5, 0);
layout_label(subwindow->haptic_effect_sublayout, subwindow->label_motorposition, 6, 0);
layout_edit(subwindow->haptic_effect_sublayout, subwindow->edit_motorposition, 7, 0);
combo_add_elem(subwindow->combo_select_effect, "Engine", NULL);
combo_add_elem(subwindow->combo_select_effect, "Gear", NULL);
combo_add_elem(subwindow->combo_select_effect, "ABS", NULL);
combo_add_elem(subwindow->combo_select_effect, "TyreSlip", NULL);
combo_add_elem(subwindow->combo_select_effect, "TyreLock", NULL);
combo_add_elem(subwindow->combo_select_effect, "Suspension", NULL);
combo_add_elem(subwindow->combo_select_modulation, "None", NULL);
combo_add_elem(subwindow->combo_select_modulation, "Frequency", NULL);
combo_add_elem(subwindow->combo_select_modulation, "Amplitude", NULL);
combo_add_elem(subwindow->combo_select_tyre, "FrontLeft", NULL);
combo_add_elem(subwindow->combo_select_tyre, "FrontRight", NULL);
combo_add_elem(subwindow->combo_select_tyre, "RearLeft", NULL);
combo_add_elem(subwindow->combo_select_tyre, "RearRight", NULL);
combo_add_elem(subwindow->combo_select_tyre, "Fronts", NULL);
combo_add_elem(subwindow->combo_select_tyre, "Rears", NULL);
combo_add_elem(subwindow->combo_select_tyre, "All", NULL);
layout_label(subwindow->haptic_effect_sublayout, subwindow->label_frequency, 0, 1);
layout_edit(subwindow->haptic_effect_sublayout, subwindow->edit_frequency, 1, 1);
layout_label(subwindow->haptic_effect_sublayout, subwindow->label_amplitude, 2, 1);
layout_edit(subwindow->haptic_effect_sublayout, subwindow->edit_amplitude, 3, 1);
layout_label(subwindow->haptic_effect_sublayout, subwindow->label_frequencyMax, 6, 1);
layout_edit(subwindow->haptic_effect_sublayout, subwindow->edit_frequencyMax, 7, 1);
layout_label(subwindow->haptic_effect_sublayout, subwindow->label_amplitudeMax, 0, 2);
layout_edit(subwindow->haptic_effect_sublayout, subwindow->edit_amplitudeMax, 1, 2);
layout_label(subwindow->haptic_effect_sublayout, subwindow->label_threshold, 2, 2);
layout_edit(subwindow->haptic_effect_sublayout, subwindow->edit_threshold, 3, 2);
layout_label(subwindow->haptic_effect_sublayout, subwindow->label_duration, 4, 2);
layout_edit(subwindow->haptic_effect_sublayout, subwindow->edit_duration, 5, 2);
cell_dbind(layout_cell(subwindow->haptic_effect_sublayout, 1, 1), HapticEffectSettings, uint32_t, frequency);
cell_dbind(layout_cell(subwindow->haptic_effect_sublayout, 3, 1), HapticEffectSettings, uint32_t, amplitude);
cell_dbind(layout_cell(subwindow->haptic_effect_sublayout, 7, 1), HapticEffectSettings, uint32_t, frequencyMax);
cell_dbind(layout_cell(subwindow->haptic_effect_sublayout, 1, 2), HapticEffectSettings, uint32_t, amplitudeMax);
cell_dbind(layout_cell(subwindow->haptic_effect_sublayout, 7, 0), HapticEffectSettings, uint32_t, motorposition);
cell_dbind(layout_cell(subwindow->haptic_effect_sublayout, 3, 2), HapticEffectSettings, real64_t, threshold);
cell_dbind(layout_cell(subwindow->haptic_effect_sublayout, 5, 2), HapticEffectSettings, real64_t, duration);
cell_dbind(layout_cell(subwindow->haptic_effect_sublayout, 3, 0), HapticEffectSettings, uint32_t, modulation);
cell_dbind(layout_cell(subwindow->haptic_effect_sublayout, 5, 0), HapticEffectSettings, uint32_t, tyre);
cell_dbind(layout_cell(subwindow->haptic_effect_sublayout, 1, 0), HapticEffectSettings, uint32_t, effect_type);
layout_dbind(subwindow->haptic_effect_sublayout, NULL, HapticEffectSettings);
layout_dbind_obj(subwindow->haptic_effect_sublayout, &data->ds->hapticsettings, HapticEffectSettings);
// can i get this from the dbind
combo_selected(subwindow->combo_select_tyre, data->ds->hapticsettings.tyre);
combo_selected(subwindow->combo_select_effect, data->ds->hapticsettings.effect_type);
combo_selected(subwindow->combo_select_modulation, data->ds->hapticsettings.modulation);
for (uint32_t row = 0; row < 3; row++)
{
for (uint32_t col = 1; col < 8; col += 2)
{
layout_halign(subwindow->haptic_effect_sublayout, col, row, ekJUSTIFY);
}
}
}
static void addSerialDeviceLayout(AddDeviceData* data)
{
struct _add_device_t* subwindow = data;
subwindow->serial_device_sublayout = layout_create(4, 1);
subwindow->edit_baud = edit_create();
subwindow->label_baud = label_create();
label_text(subwindow->label_baud, "baud: ");
layout_label(subwindow->serial_device_sublayout, subwindow->label_baud, 0, 0);
layout_edit(subwindow->serial_device_sublayout, subwindow->edit_baud, 1, 0);
cell_dbind(layout_cell(subwindow->serial_device_sublayout, 1, 0), SerialDeviceSettings, uint32_t, baud);
layout_dbind(subwindow->serial_device_sublayout, NULL, SerialDeviceSettings);
layout_dbind_obj(subwindow->serial_device_sublayout, &data->ds->serialdevsettings, SerialDeviceSettings);
layout_update(subwindow->serial_device_sublayout);
}
static void addSoundDeviceLayout(AddDeviceData* data)
{
struct _add_device_t* subwindow = data;
subwindow->sound_device_sublayout = layout_create(6, 1);
subwindow->edit_channel = edit_create();
subwindow->edit_channels = edit_create();
subwindow->label_channel = label_create();
subwindow->label_channels = label_create();
subwindow->label_volume = label_create();
subwindow->edit_volume = edit_create();
label_text(subwindow->label_channel, "Channel: ");
label_text(subwindow->label_channels, "Channels: ");
label_text(subwindow->label_volume, "Volume:");
layout_label(subwindow->sound_device_sublayout, subwindow->label_channel, 0, 0);
layout_label(subwindow->sound_device_sublayout, subwindow->label_channels, 2, 0);
layout_label(subwindow->sound_device_sublayout, subwindow->label_volume, 4, 0);
layout_edit(subwindow->sound_device_sublayout, subwindow->edit_channel, 1, 0);
layout_edit(subwindow->sound_device_sublayout, subwindow->edit_channels, 3, 0);
layout_edit(subwindow->sound_device_sublayout, subwindow->edit_volume, 5, 0);
cell_dbind(layout_cell(subwindow->sound_device_sublayout, 1, 0), SoundDeviceSettings, uint32_t, pan);
cell_dbind(layout_cell(subwindow->sound_device_sublayout, 3, 0), SoundDeviceSettings, uint32_t, channels);
cell_dbind(layout_cell(subwindow->sound_device_sublayout, 5, 0), SoundDeviceSettings, uint32_t, volume);
layout_dbind(subwindow->sound_device_sublayout, NULL, SoundDeviceSettings);
layout_dbind_obj(subwindow->sound_device_sublayout, &data->ds->sounddevsettings, SoundDeviceSettings);
layout_update(subwindow->sound_device_sublayout);
}
static void addLedDeviceLayout(AddDeviceData* data)
{
struct _add_device_t* subwindow = data;
subwindow->led_device_sublayout = layout_create(6,1);
subwindow->edit_num_leds = edit_create();
subwindow->edit_start_led = edit_create();
subwindow->edit_end_led = edit_create();
subwindow->label_num_leds = label_create();
subwindow->label_start_led = label_create();
subwindow->label_end_led = label_create();
label_text(subwindow->label_num_leds, "Leds: ");
label_text(subwindow->label_start_led, "Start Led: ");
label_text(subwindow->label_end_led, "End Led: ");
layout_label(subwindow->led_device_sublayout, subwindow->label_num_leds, 0, 0);
layout_label(subwindow->led_device_sublayout, subwindow->label_start_led, 2, 0);
layout_label(subwindow->led_device_sublayout, subwindow->label_end_led, 4, 0);
layout_edit(subwindow->led_device_sublayout, subwindow->edit_num_leds, 1, 0);
layout_edit(subwindow->led_device_sublayout, subwindow->edit_start_led, 3, 0);
layout_edit(subwindow->led_device_sublayout, subwindow->edit_end_led, 5, 0);
cell_dbind(layout_cell(subwindow->led_device_sublayout, 1, 0), SerialDeviceSettings, uint32_t, numleds);
cell_dbind(layout_cell(subwindow->led_device_sublayout, 3, 0), SerialDeviceSettings, uint32_t, startled);
cell_dbind(layout_cell(subwindow->led_device_sublayout, 5, 0), SerialDeviceSettings, uint32_t, endled);
layout_dbind(subwindow->led_device_sublayout, NULL, SerialDeviceSettings);
layout_dbind_obj(subwindow->led_device_sublayout, &data->ds->serialdevsettings, SerialDeviceSettings);
layout_update(subwindow->led_device_sublayout);
}
/*---------------------------------------------------------------------------*/
static void i_OnSaveDevice(AddDeviceData *data, Event *e)
{
update_device_data_from_controls(data);
slogd("Attempting save of device class %i device type %i device %s", data->ds->dev_type, data->ds->dev_subtype, data->ds->dev);
save_device_config(data->ms->cfg, data->ms->config_str, data->confignum, data->devicenum, data->ds);
}
static void i_OnDeviceSubtypeSelect(AddDeviceData *data, Event *e)
{
const EvButton *p = event_params(e, EvButton);
cell_visible(data->cell_led_device_layout, false);
cell_visible(data->cell_haptic_effect_layout, false);
data->ds->has_led_effects = false;
data->ds->has_haptic_effects = false;
uint32_t selected = combo_get_selected(data->combo_select_device_subtype);
const char_t *text = combo_get_text(data->combo_select_device_subtype, selected);
if (text != NULL && strcmp(text, "SIMLED") == 0)
{
cell_visible(data->cell_led_device_layout, true);
data->ds->has_led_effects = true;
}
if (text != NULL && strcmp(text, "SOUNDHAPTIC") == 0)
{
cell_visible(data->cell_haptic_effect_layout, true);
data->ds->has_haptic_effects = true;
}
panel_update(data->panel);
}
static void populateSerialSubTypesCombo(Combo* combo)
{
combo_add_elem(combo, "ShiftLights", NULL);
combo_add_elem(combo, "SimWind", NULL);
combo_add_elem(combo, "Haptic", NULL);
combo_add_elem(combo, "Wheel", NULL);
combo_add_elem(combo, "SimLed", NULL);
combo_add_elem(combo, "Custom", NULL);
}
static void i_OnDeviceClassSelect(AddDeviceData *data, Event *e)
{
const EvButton *p = event_params(e, EvButton);
panel_visible_layout(data->device_specific_panel, 0);
cell_visible(data->cell_led_device_layout, false);
cell_visible(data->cell_haptic_effect_layout, false);
panel_update(data->device_specific_panel);
combo_clear(data->combo_select_device);
combo_text(data->combo_select_device, "");
combo_clear(data->combo_select_device_subtype);
combo_text(data->combo_select_device_subtype, "");
uint32_t selected = combo_get_selected(data->combo_select_device_class);
const char_t *text = combo_get_text(data->combo_select_device_class, selected);
if (text != NULL && strcmp(text, "Serial") == 0)
{
add_serial_devices_to_combo(data->combo_select_device);
populateSerialSubTypesCombo(data->combo_select_device_subtype);
panel_visible_layout(data->device_specific_panel, 1);
// since SIMLED will be selected we will show led settings
cell_visible(data->cell_led_device_layout, true);
data->ds->has_led_effects = true;
}
if (text != NULL && strcmp(text, "Sound") == 0)
{
add_sound_devices_to_combo(data->combo_select_device);
combo_add_elem(data->combo_select_device_subtype, "Haptic", NULL);
panel_visible_layout(data->device_specific_panel, 2);
// since HAPTIC will be selected we will show haptic settings
cell_visible(data->cell_haptic_effect_layout, true);
data->ds->has_haptic_effects = true;
}
combo_selected(data->combo_select_device, 0);
combo_selected(data->combo_select_device_subtype, 0);
panel_update(data->device_specific_panel);
panel_update(data->panel);
}
static Panel* device_specific_panel_create(AddDeviceData *data)
{
Panel *panel = panel_create();
data->empty_device_sublayout = layout_create(4, 1);
addSerialDeviceLayout(data);
addSoundDeviceLayout(data);
panel_layout(panel, data->empty_device_sublayout);
panel_layout(panel, data->serial_device_sublayout);
panel_layout(panel, data->sound_device_sublayout);
return panel;
}
static Layout *i_modal_layout(AddDeviceData *data, App* app, MonocoqueSettings* ms, enum device_action dev_action, int confignum, int devicenum)
{
struct _add_device_t* subwindow = data;
subwindow->main_outer_layout = layout_create(1,11);
subwindow->top_selection_layout = layout_create(4,1);
subwindow->general_settings_layout = layout_create(4, 1);
// device class specific settings ( max 1 row so far )
// possible led specific settings ( 1 row )
// possible haptic specific settings ( 3 rows )
subwindow->add_save_test_layout = layout_create(2,1);
subwindow->combo_select_device_class = combo_create();
subwindow->combo_select_device_subtype = combo_create();
subwindow->combo_select_device = combo_create();
subwindow->label_select_device_class = label_create();
subwindow->label_select_device_subtype = label_create();
subwindow->label_select_device = label_create();
label_text(subwindow->label_select_device_class, "Device Class: ");
label_text(subwindow->label_select_device_subtype, "Device SubType: ");
label_text(subwindow->label_select_device, "Device: ");
layout_label(subwindow->top_selection_layout, subwindow->label_select_device_class, 0, 0);
layout_combo(subwindow->top_selection_layout, subwindow->combo_select_device_class, 1, 0);
layout_label(subwindow->top_selection_layout, subwindow->label_select_device_subtype, 2, 0);
layout_combo(subwindow->top_selection_layout, subwindow->combo_select_device_subtype, 3, 0);
layout_label(subwindow->general_settings_layout, subwindow->label_select_device, 2, 0);
layout_combo(subwindow->general_settings_layout, subwindow->combo_select_device, 3, 0);
subwindow->edit_fps = edit_create();
subwindow->label_fps = label_create();
label_text(subwindow->label_fps, "fps: ");
layout_label(subwindow->general_settings_layout, subwindow->label_fps, 0, 0);
layout_edit(subwindow->general_settings_layout, subwindow->edit_fps, 1, 0);
cell_dbind(layout_cell(subwindow->top_selection_layout, 1, 0), DeviceSettings, uint32_t, dev_type);
cell_dbind(layout_cell(subwindow->top_selection_layout, 3, 0), DeviceSettings, uint32_t, dev_subtype);
cell_dbind(layout_cell(subwindow->general_settings_layout, 1, 0), DeviceSettings, uint32_t, fps);
layout_dbind(subwindow->general_settings_layout, NULL, DeviceSettings);
layout_dbind(subwindow->top_selection_layout, NULL, DeviceSettings);
layout_dbind_obj(subwindow->general_settings_layout, data->ds, DeviceSettings);
subwindow->device_specific_panel = device_specific_panel_create(data);
panel_visible_layout(data->device_specific_panel, 0);
addLedDeviceLayout(data);
addHapticDeviceLayout(data);
subwindow->test_button = button_push();
subwindow->save_button = button_push();
button_text(subwindow->test_button, "Test");
button_text(subwindow->save_button, "Save");
layout_button(subwindow->add_save_test_layout, subwindow->test_button, 0, 0);
layout_button(subwindow->add_save_test_layout, subwindow->save_button, 1, 0);
button_OnClick(subwindow->test_button, listener(data, i_OnTestDevice, AddDeviceData));
button_OnClick(subwindow->save_button, listener(data, i_OnSaveDevice, AddDeviceData));
layout_layout(subwindow->main_outer_layout, subwindow->top_selection_layout, 0, 0);
layout_layout(subwindow->main_outer_layout, subwindow->general_settings_layout, 0, 1);
layout_panel(subwindow->main_outer_layout, subwindow->device_specific_panel, 0, 2);
layout_layout(subwindow->main_outer_layout, subwindow->led_device_sublayout, 0, 3);
layout_layout(subwindow->main_outer_layout, subwindow->haptic_effect_sublayout, 0, 4);
layout_layout(subwindow->main_outer_layout, subwindow->add_save_test_layout, 0, 7);
subwindow->cell_led_device_layout = layout_cell(subwindow->main_outer_layout, 0, 3);
subwindow->cell_haptic_effect_layout = layout_cell(subwindow->main_outer_layout, 0, 4);
cell_visible(subwindow->cell_led_device_layout, false);
cell_visible(subwindow->cell_haptic_effect_layout, false);
if(dev_action == DEVICE_ACTION_ADD)
{
combo_add_elem(subwindow->combo_select_device_class, "USB", NULL);
combo_add_elem(subwindow->combo_select_device_class, "Sound", NULL);
combo_add_elem(subwindow->combo_select_device_class, "Serial", NULL);
combo_OnSelect(subwindow->combo_select_device_class, listener(data, i_OnDeviceClassSelect, AddDeviceData));
combo_OnSelect(subwindow->combo_select_device_subtype, listener(data, i_OnDeviceSubtypeSelect, AddDeviceData));
return subwindow->main_outer_layout;
}
char str0[255];
sprintf(str0, "%s", data->ds->dev);
combo_add_elem(subwindow->combo_select_device, str0, NULL);
subwindow->cell_top_selection_layout = layout_cell(subwindow->main_outer_layout, 0, 0);
cell_enabled(subwindow->cell_top_selection_layout, false);
if(data->ds->dev_type == SIMDEV_SERIAL)
{
combo_add_elem(subwindow->combo_select_device_class, "Serial", NULL);
add_serial_devices_to_combo(data->combo_select_device);
populateSerialSubTypesCombo(data->combo_select_device_subtype);
combo_selected(subwindow->combo_select_device_subtype, data->ds->dev_subtype - SerialDevicesOffset);
panel_visible_layout(data->device_specific_panel, 1);
}
if(data->ds->dev_type == SIMDEV_SOUND)
{
combo_add_elem(subwindow->combo_select_device_class, "Sound", NULL);
add_sound_devices_to_combo(data->combo_select_device);
combo_add_elem(data->combo_select_device_subtype, "Haptic", NULL);
combo_selected(subwindow->combo_select_device_subtype, data->ds->dev_subtype);
panel_visible_layout(data->device_specific_panel, 2);
cell_visible(data->cell_haptic_effect_layout, true);
}
if(data->ds->dev_type == SIMDEV_USB)
{
combo_selected(subwindow->combo_select_device_subtype, data->ds->dev_subtype - USBDevicesOffset);
panel_visible_layout(data->device_specific_panel, 2);
}
if(data->ds->dev_subtype == SIMDEVTYPE_SIMLED) {
cell_visible(data->cell_led_device_layout, true);
}
combo_selected(subwindow->combo_select_device_class, 0);
return subwindow->main_outer_layout;
}
/*---------------------------------------------------------------------------*/
Panel *adddevice_window(Window *parent, App* app, MonocoqueSettings* ms, enum device_action dev_action, int confignum, int devicenum)
{
Panel *panel = panel_create();
AddDeviceData *data = i_modal_data(parent);
data->panel = panel;
data->devicenum = devicenum;
data->confignum = confignum;
data->ds = malloc(sizeof(DeviceSettings));
// move this somewhere better or use dbind to set this stuff
data->ds->dev_type = 0;
data->ds->dev_subtype = 0;
data->ds->dev_subsubtype = 0;
data->ds->dev = NULL;
data->ds->fps = 60;
data->ds->specific_config_file = NULL;
data->ds->has_config = false;
data->ds->serialdevsettings.baud = 115200;
data->ds->serialdevsettings.startled = 0;
data->ds->serialdevsettings.endled = 0;
data->ds->serialdevsettings.numleds = 0;
data->ds->sounddevsettings.channels = 2;
data->ds->sounddevsettings.pan = 0;
data->ds->sounddevsettings.volume = 50;
data->ds->sounddevsettings.noise = 0;
data->ds->hapticsettings.frequency = 32;
data->ds->hapticsettings.amplitude = 50;
data->ds->hapticsettings.frequencyMax = 0;
data->ds->hapticsettings.amplitudeMax = 0;
data->ds->hapticsettings.motorposition = 0;
data->ds->hapticsettings.threshold = 0.0;
data->ds->hapticsettings.duration = 0.0;
data->ds->hapticsettings.modulation = 1;
data->ds->hapticsettings.tyre = 0;
data->ds->hapticsettings.effect_type = 0;
data->ds->has_led_effects = false;
data->ds->has_haptic_effects = false;
data->ms = ms;
data->apppointer = app;
if(dev_action == DEVICE_ACTION_EDIT)
{
int numdevices = getsingledevice(ms->config_str, confignum, devicenum, ms, data->ds);
}
Layout *layout = i_modal_layout(data, app, ms, dev_action, confignum, devicenum);
panel_layout(panel, layout);
panel_data(panel, &data, i_destroy_modal_data, AddDeviceData);
return panel;
}
+97
View File
@@ -0,0 +1,97 @@
#include <gui/gui.hxx>
#include "mainwindow.h"
Panel *adddevice_window(Window *parent, App* app, MonocoqueSettings* ms, enum device_action dev_action, int confignum, int devicenum);
typedef struct _add_device_t AddDeviceData;
struct _add_device_t
{
Layout* main_outer_layout;
Layout* top_selection_layout;
Label* label_select_device_class;
Label* label_select_device_subtype;
Label* label_select_device;
Combo* combo_select_device_class;
Combo* combo_select_device_subtype;
Combo* combo_select_device;
Edit* edit_select_device;
Layout* general_settings_layout;
Label* label_fps;
Edit* edit_fps;
Button* check_use_lua;
Layout* empty_device_sublayout;
Panel* device_specific_panel;
// sound sublayout
Layout* sound_device_sublayout;
Label* label_channel;
Label* label_channels;
Label* label_volume;
Edit* edit_channel;
Edit* edit_channels;
Edit* edit_volume;
// serial sublayout
Layout* serial_device_sublayout;
Label* label_baud;
Edit* edit_baud;
// led sublayout
Layout* led_device_sublayout;
Label* label_num_leds;
Label* label_start_led;
Label* label_end_led;
Edit* edit_num_leds;
Edit* edit_start_led;
Edit* edit_end_led;
Layout* haptic_effect_sublayout;
Label* label_select_effect;
Combo* combo_select_effect;
Label* label_select_modulation;
Combo* combo_select_modulation;
Label* label_select_tyre;
Combo* combo_select_tyre;
Label* label_motorposition;
Edit* edit_motorposition;
Label* label_frequency;
Edit* edit_frequency;
Label* label_amplitude;
Edit* edit_amplitude;
Label* label_frequencyMax;
Edit* edit_frequencyMax;
Label* label_amplitudeMax;
Edit* edit_amplitudeMax;
Label* label_threshold;
Edit* edit_threshold;
Label* label_duration;
Edit* edit_duration;
Layout* add_save_test_layout;
Button* test_button;
Button* save_button;
Cell* cell_top_selection_layout;
Cell* cell_led_device_layout;
Cell* cell_haptic_effect_layout;
uint32_t type;
Label *label;
MonocoqueSettings* ms;
DeviceSettings* ds;
Panel* panel;
App* apppointer;
int confignum;
int devicenum;
Window *parent;
};
+44
View File
@@ -0,0 +1,44 @@
#include "../helper/confighelper.h"
#pragma once
enum device_action {
DEVICE_ACTION_ADD, DEVICE_ACTION_EDIT, DEVICE_ACTION_DELETE
};
typedef struct _app_t App;
struct _app_t
{
bool_t is_running;
Panel *main_panel;
Panel *subpanel;
Layout *layout1;
Layout *layout2;
Layout *layout3;
Layout *layout4;
Layout *sub_layout;
Window *window;
Window *window2;
Window *window3;
Layout* layout;
Combo* combo_configurations;
ListBox* listbox_devices;
Button *button_startstop;
Button *button_add;
Button *button_edit;
Button *button_del;
Button *button_test;
Label *label_configurations;
Label *label_game_status;
Label *label_simd_status;
Cell* devices_subpanel;
};
+188
View File
@@ -0,0 +1,188 @@
/* Listboxes */
#include "testaction.h"
#include "../gameloop/gameloop.h"
#include "mainwindow.h"
#include <gui/guiall.h>
typedef struct _modal_data_t gModalData;
struct _modal_data_t
{
uint32_t type;
Label *label;
Window *parent;
};
/*---------------------------------------------------------------------------*/
static Layout *i_modal_layout(gModalData *data, Window *window, App *app);
/*---------------------------------------------------------------------------*/
static gModalData *i_modal_data(Window *parent)
{
gModalData *data = heap_new0(gModalData);
data->parent = parent;
data->type = UINT32_MAX;
return data;
}
/*---------------------------------------------------------------------------*/
static void i_OnTestDone(Window *window, Event *e)
{
Button *button = event_sender(e, Button);
window_stop_modal(window, button_get_tag(button));
}
/*---------------------------------------------------------------------------*/
static void i_OnTestDataUpdate(Window* window, Event* e)
{
Button *button = event_sender(e, Button);
//SimData* simdata = get_test_simdata();
}
/*---------------------------------------------------------------------------*/
static void i_destroy_modal_data(gModalData **data)
{
monocoque_testloop_stop();
heap_delete(data, gModalData);
}
/*---------------------------------------------------------------------------*/
static Layout *i_modal_layout(gModalData *data, Window* window, App *app)
{
struct _test_device_t subwindow;
subwindow.main_outer_layout = layout_create(1,7);
subwindow.data_edit_layout = layout_create(8,6);
subwindow.add_save_test_layout = layout_create(2,1);
subwindow.edit_gear = edit_create();
subwindow.edit_velocity = edit_create();
subwindow.edit_maxrpm = edit_create();
subwindow.edit_rpm = edit_create();
subwindow.label_gear = label_create();
subwindow.label_velocity = label_create();
subwindow.label_maxrpm = label_create();
subwindow.label_rpm = label_create();
subwindow.label_tyre_diameter_1 = label_create();
subwindow.label_tyre_diameter_2 = label_create();
subwindow.label_tyre_diameter_3 = label_create();
subwindow.label_tyre_diameter_4 = label_create();
subwindow.label_tyre_rps_1 = label_create();
subwindow.label_tyre_rps_2 = label_create();
subwindow.label_tyre_rps_3 = label_create();
subwindow.label_tyre_rps_4 = label_create();
subwindow.edit_tyre_diameter_1 = edit_create();
subwindow.edit_tyre_diameter_2 = edit_create();
subwindow.edit_tyre_diameter_3 = edit_create();
subwindow.edit_tyre_diameter_4 = edit_create();
subwindow.edit_tyre_rps_1 = edit_create();
subwindow.edit_tyre_rps_2 = edit_create();
subwindow.edit_tyre_rps_3 = edit_create();
subwindow.edit_tyre_rps_4 = edit_create();
subwindow.update_button = button_push();
subwindow.done_button = button_push();
label_text(subwindow.label_gear, "gear: ");
label_text(subwindow.label_velocity, "velocity: ");
label_text(subwindow.label_maxrpm, "max rpm: ");
label_text(subwindow.label_rpm, "rpm: ");
button_text(subwindow.update_button, "Update");
button_text(subwindow.done_button, "Done");
button_OnClick(subwindow.done_button, listener(window, i_OnTestDone, Window));
button_OnClick(subwindow.update_button, listener(window, i_OnTestDataUpdate, Window));
layout_layout(subwindow.main_outer_layout, subwindow.data_edit_layout, 0, 2);
layout_layout(subwindow.main_outer_layout, subwindow.add_save_test_layout, 0, 5);
layout_label(subwindow.data_edit_layout, subwindow.label_gear, 0, 0);
layout_label(subwindow.data_edit_layout, subwindow.label_velocity, 2, 0);
layout_label(subwindow.data_edit_layout, subwindow.label_maxrpm, 0, 1);
layout_label(subwindow.data_edit_layout, subwindow.label_rpm, 2, 1);
layout_edit(subwindow.data_edit_layout, subwindow.edit_gear, 1, 0);
layout_edit(subwindow.data_edit_layout, subwindow.edit_velocity, 3, 0);
layout_edit(subwindow.data_edit_layout, subwindow.edit_maxrpm, 1, 1);
layout_edit(subwindow.data_edit_layout, subwindow.edit_rpm, 3, 1);
layout_label(subwindow.data_edit_layout, subwindow.label_tyre_rps_1, 0, 2);
layout_label(subwindow.data_edit_layout, subwindow.label_tyre_rps_2, 2, 2);
layout_label(subwindow.data_edit_layout, subwindow.label_tyre_rps_3, 4, 2);
layout_label(subwindow.data_edit_layout, subwindow.label_tyre_rps_4, 6, 2);
layout_label(subwindow.data_edit_layout, subwindow.label_tyre_diameter_1, 0, 3);
layout_label(subwindow.data_edit_layout, subwindow.label_tyre_diameter_2, 2, 3);
layout_label(subwindow.data_edit_layout, subwindow.label_tyre_diameter_3, 4, 3);
layout_label(subwindow.data_edit_layout, subwindow.label_tyre_diameter_4, 6, 3);
label_text(subwindow.label_tyre_rps_1, "rps_lf");
label_text(subwindow.label_tyre_rps_2, "rps_rf");
label_text(subwindow.label_tyre_rps_3, "rps_lr");
label_text(subwindow.label_tyre_rps_4, "rps_rr");
label_text(subwindow.label_tyre_diameter_1, "diameter_lf");
label_text(subwindow.label_tyre_diameter_2, "diameter_rf");
label_text(subwindow.label_tyre_diameter_3, "diameter_lr");
label_text(subwindow.label_tyre_diameter_4, "diameter_rr");
layout_edit(subwindow.data_edit_layout, subwindow.edit_tyre_rps_1, 1, 2);
layout_edit(subwindow.data_edit_layout, subwindow.edit_tyre_rps_2, 3, 2);
layout_edit(subwindow.data_edit_layout, subwindow.edit_tyre_rps_3, 5, 2);
layout_edit(subwindow.data_edit_layout, subwindow.edit_tyre_rps_4, 7, 2);
layout_edit(subwindow.data_edit_layout, subwindow.edit_tyre_diameter_1, 1, 3);
layout_edit(subwindow.data_edit_layout, subwindow.edit_tyre_diameter_2, 3, 3);
layout_edit(subwindow.data_edit_layout, subwindow.edit_tyre_diameter_3, 5, 3);
layout_edit(subwindow.data_edit_layout, subwindow.edit_tyre_diameter_4, 7, 3);
cell_dbind(layout_cell(subwindow.data_edit_layout, 1, 0), SimData, uint32_t, gear);
cell_dbind(layout_cell(subwindow.data_edit_layout, 3, 0), SimData, uint32_t, velocity);
cell_dbind(layout_cell(subwindow.data_edit_layout, 1, 1), SimData, uint32_t, maxrpm);
cell_dbind(layout_cell(subwindow.data_edit_layout, 3, 1), SimData, uint32_t, rpms);
cell_dbind(layout_cell(subwindow.data_edit_layout, 1, 2), SimData, real64_t, tyreRPS[0]);
cell_dbind(layout_cell(subwindow.data_edit_layout, 3, 2), SimData, real64_t, tyreRPS[1]);
cell_dbind(layout_cell(subwindow.data_edit_layout, 5, 2), SimData, real64_t, tyreRPS[2]);
cell_dbind(layout_cell(subwindow.data_edit_layout, 7, 2), SimData, real64_t, tyreRPS[3]);
cell_dbind(layout_cell(subwindow.data_edit_layout, 1, 3), SimData, real64_t, tyrediameter[0]);
cell_dbind(layout_cell(subwindow.data_edit_layout, 3, 3), SimData, real64_t, tyrediameter[1]);
cell_dbind(layout_cell(subwindow.data_edit_layout, 5, 3), SimData, real64_t, tyrediameter[2]);
cell_dbind(layout_cell(subwindow.data_edit_layout, 7, 3), SimData, real64_t, tyrediameter[3]);
SimData* simdata = get_test_simdata();
layout_dbind(subwindow.data_edit_layout, NULL, SimData);
layout_dbind_obj(subwindow.data_edit_layout, simdata, SimData);
layout_button(subwindow.add_save_test_layout, subwindow.update_button, 0, 0);
layout_button(subwindow.add_save_test_layout, subwindow.done_button, 1, 0);
return subwindow.main_outer_layout;
}
/*---------------------------------------------------------------------------*/
Panel *test_window(Window *parent, App* app)
{
Panel *panel = panel_create();
gModalData *data = i_modal_data(parent);
Layout *layout = i_modal_layout(data, parent, app);
panel_layout(panel, layout);
panel_data(panel, &data, i_destroy_modal_data, gModalData);
return panel;
}
+44
View File
@@ -0,0 +1,44 @@
#include <gui/gui.hxx>
#include "mainwindow.h"
Panel *test_window(Window *parent, App* app);
struct _test_device_t
{
Layout* main_outer_layout;
Layout* data_edit_layout;
Layout* add_save_test_layout;
Label* label_gear;
Label* label_velocity;
Label* label_maxrpm;
Label* label_rpm;
Edit* edit_gear;
Edit* edit_velocity;
Edit* edit_maxrpm;
Edit* edit_rpm;
Label* label_tyre_diameter_1;
Label* label_tyre_diameter_2;
Label* label_tyre_diameter_3;
Label* label_tyre_diameter_4;
Label* label_tyre_rps_1;
Label* label_tyre_rps_2;
Label* label_tyre_rps_3;
Label* label_tyre_rps_4;
Edit* edit_tyre_diameter_1;
Edit* edit_tyre_diameter_2;
Edit* edit_tyre_diameter_3;
Edit* edit_tyre_diameter_4;
Edit* edit_tyre_rps_1;
Edit* edit_tyre_rps_2;
Edit* edit_tyre_rps_3;
Edit* edit_tyre_rps_4;
Button* update_button;
Button* done_button;
};
+311
View File
@@ -0,0 +1,311 @@
#include <string.h>
#include <dirent.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <gui/combo.h>
#include <gui/listbox.h>
#include <libserialport.h>
#include <libconfig.h>
#include "../helper/confighelper.h"
typedef struct pa_devicelist {
uint8_t initialized;
char name[512];
uint32_t index;
char description[256];
} pa_devicelist_t;
int find_default_config(config_setting_t *configs)
{
int count = config_setting_length(configs);
for (int i = 0; i < count; i++)
{
config_setting_t *entry = config_setting_get_elem(configs, i);
const char *sim;
const char *api;
const char *car;
if (!config_setting_lookup_string(entry, "sim", &sim))
continue;
if (!config_setting_lookup_string(entry, "api", &api))
continue;
if (!config_setting_lookup_string(entry, "car", &car))
continue;
if ((strcmp(sim, "default") == 0 || strcmp(sim, "all") == 0) &&
(strcmp(api, "default") == 0 || strcmp(api, "all") == 0) &&
(strcmp(car, "default") == 0 || strcmp(car, "all") == 0))
{
return i;
}
}
return -1;
}
int add_serial_devices_to_combo(Combo *combo)
{
// from libserialport examples
struct sp_port **port_list;
enum sp_return result = sp_list_ports(&port_list);
if (result != SP_OK)
{
return -1;
}
int i;
for (i = 0; port_list[i] != NULL; i++)
{
struct sp_port *port = port_list[i];
char port_name[256];
const char *name_ptr = sp_get_port_name(port);
if (name_ptr != NULL)
{
snprintf(port_name, sizeof(port_name), "%s", name_ptr);
combo_add_elem(combo, port_name, NULL);
}
else
{
port_name[0] = '\0';
}
}
sp_free_port_list(port_list);
return 0;
}
void populate_combo_box(Combo* combo, config_t* cfg)
{
config_setting_t *configs;
int count;
int i;
configs = config_lookup(cfg, "configs");
if (configs == NULL || !config_setting_is_list(configs))
return;
count = config_setting_length(configs);
for (i = 0; i < count; i++)
{
config_setting_t *cfg_entry;
const char *sim = "";
const char *car = "";
const char *api = "";
char text[256];
cfg_entry = config_setting_get_elem(configs, i);
config_setting_lookup_string(cfg_entry, "sim", &sim);
config_setting_lookup_string(cfg_entry, "car", &car);
config_setting_lookup_string(cfg_entry, "api", &api);
snprintf(text, sizeof(text), "%s / %s / %s", sim, car, api);
combo_add_elem(combo, text, NULL);
}
}
void populate_device_list(ListBox *listbox, config_t* cfg)
{
int count;
config_setting_t* devices;
devices = config_lookup(cfg, "configs");
if (devices == NULL)
{
fprintf(stderr, "No configs section found\n");
return;
}
config_setting_t* config = NULL;
config = config_lookup(cfg, "configs");
int config_num = find_default_config(config);
config_setting_t* selectedconfig = config_setting_get_elem(config, config_num);
config_setting_t* config_devices = NULL;
config_devices = config_setting_lookup(selectedconfig, "devices");
count = config_setting_length(config_devices);
for (int i = 0; i < count; i++)
{
config_setting_t *dev = config_setting_get_elem(config_devices, i);
const char *device = "";
const char *type = "";
const char *subtype = "";
const char *effect = "";
const char *tyre = "";
config_setting_lookup_string(dev, "device", &device);
char text[256];
if (strcasecmp(device, "sound") == 0)
{
config_setting_lookup_string(dev, "effect", &effect);
config_setting_lookup_string(dev, "tyre", &tyre);
snprintf(text, sizeof(text), "%s - %s - %s",
device, effect, tyre);
}
else
{
config_setting_lookup_string(dev, "type", &type);
config_setting_lookup_string(dev, "subtype", &subtype);
snprintf(text, sizeof(text), "%s - %s - %s",
device, type, subtype);
}
listbox_add_elem(listbox, text, NULL);
}
}
void pa_sinklist_cb(pa_context *c, const pa_sink_info *l, int eol, void *userdata) {
pa_devicelist_t *pa_devicelist = userdata;
int ctr = 0;
// If eol is set to a positive number, you're at the end of the list
if (eol > 0) {
return;
}
// We know we've allocated 16 slots to hold devices. Loop through our
// structure and find the first one that's "uninitialized." Copy the
// contents into it and we're done. If we receive more than 16 devices,
// they're going to get dropped. You could make this dynamically allocate
// space for the device list, but this is a simple example.
for (ctr = 0; ctr < 16; ctr++) {
if (! pa_devicelist[ctr].initialized) {
strncpy(pa_devicelist[ctr].name, l->name, 511);
strncpy(pa_devicelist[ctr].description, l->description, 255);
pa_devicelist[ctr].index = l->index;
pa_devicelist[ctr].initialized = 1;
break;
}
}
}
int add_sound_devices_to_combo(Combo *combo)
{
pa_mainloop *mainloop;
pa_context *context;
pa_operation *operation;
pa_context_state_t state;
pa_devicelist_t output[16] = {0};
int retval;
//pa_devicelist_t* output = malloc(sizeof(pa_devicelist_t) * 16);
//memset(output, 0, sizeof(pa_devicelist_t) * 16);
mainloop = pa_mainloop_new();
if (mainloop == NULL)
return 0;
context = pa_context_new(
pa_mainloop_get_api(mainloop),
"Monocoque");
if (context == NULL)
{
pa_mainloop_free(mainloop);
return 0;
}
if (pa_context_connect(context, NULL, 0, NULL) < 0)
{
pa_context_unref(context);
pa_mainloop_free(mainloop);
return 0;
}
/*
* Wait for PulseAudio to become ready.
*/
while (1)
{
if (pa_mainloop_iterate(mainloop, 1, &retval) < 0)
goto error;
state = pa_context_get_state(context);
if (state == PA_CONTEXT_READY)
break;
if (!PA_CONTEXT_IS_GOOD(state))
goto error;
}
/*
* Enumerate all PulseAudio output devices (sinks).
*/
operation = pa_context_get_sink_info_list(
context,
pa_sinklist_cb,
&output);
if (operation == NULL)
goto error;
/*
* Run the mainloop until enumeration is complete.
*/
while (pa_operation_get_state(operation) == PA_OPERATION_RUNNING)
{
if (pa_mainloop_iterate(mainloop, 1, &retval) < 0)
{
pa_operation_unref(operation);
goto error;
}
}
for (size_t i = 0; i < 16; i++)
{
if (!output[i].initialized)
{
continue;
}
if (output[i].name[0] == '\0')
{
continue;
}
combo_add_elem(combo, output[i].name, NULL);
}
pa_operation_unref(operation);
pa_context_disconnect(context);
pa_context_unref(context);
pa_mainloop_free(mainloop);
return 1;
error:
pa_context_disconnect(context);
pa_context_unref(context);
pa_mainloop_free(mainloop);
return 0;
}
+14
View File
@@ -0,0 +1,14 @@
#pragma once
#include <gui/combo.h>
#include <gui/listbox.h>
#include <libconfig.h>
#include "../helper/confighelper.h"
int find_default_config(config_setting_t *configs);
void populate_combo_box(Combo* combo, config_t* cfg);
void populate_device_list(ListBox *listbox, config_t* cfg);
void add_serial_devices_to_combo(Combo *combo);
void add_sound_devices_to_combo(Combo *combo);
+337
View File
@@ -0,0 +1,337 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>
#include <basedir_fs.h>
#include <libconfig.h>
#include "gameloop/gameloop.h"
#include "gameloop/tachconfig.h"
#include "devices/simdevice.h"
#include "devices/sound.h"
#include "helper/parameters.h"
#include "helper/dirhelper.h"
#include "helper/confighelper.h"
#include "simulatorapi/simapi/simapi/simdata.h"
#include "slog/slog.h"
#define PROGRAM_NAME "monocoque"
int appstate = 0;
void display_banner()
{
printf("______ ______________ ___________________________________ ___________\n");
printf("___ |/ /_ __ \\__ | / /_ __ \\_ ____/_ __ \\_ __ \\_ / / /__ ____/\n");
printf("__ /|_/ /_ / / /_ |/ /_ / / / / _ / / / / / / / / /__ __/ \n");
printf("_ / / / / /_/ /_ /| / / /_/ // /___ / /_/ // /_/ // /_/ / _ /___ \n");
printf("/_/ /_/ \\____/ /_/ |_/ \\____/ \\____/ \\____/ \\___\\_\\\\____/ /_____/ \n");
}
void SetSettingsFromParameters(Parameters* p, MonocoqueSettings* ms, char* configdir_str, char* cachedir_str)
{
if(p->user_specified_config_file == true && does_file_exist(p->config_filepath))
{
ms->config_str = strdup(p->config_filepath);
}
else
{
if(p->user_specified_config_dir == true && does_directory_exist(p->config_dirpath))
{
asprintf(&ms->config_str, "%s/%s", p->config_dirpath, "monocoque.config");
}
else
{
asprintf(&ms->config_str, "%s%s", configdir_str, "monocoque.config");
}
}
if(p->user_specified_log_file == true && does_file_exist(p->log_fullfilename_str))
{
ms->log_dirname_str = strdup(p->log_dirname_str);
ms->log_filename_str = strdup(p->log_filename_str);
}
else
{
ms->log_dirname_str = strdup(cachedir_str);
ms->log_filename_str = strdup("monocoque.log");
}
ms->fps = p->fps;
ms->verbosity_count = p->verbosity_count;
ms->program_action = A_TEST;
if (p->program_action == A_PLAY)
{
ms->program_action = A_PLAY;
}
if (p->program_action == A_CONFIG_TACH)
{
ms->program_action = A_CONFIG_TACH;
}
ms->force_udp_mode = false;
ms->disable_audio = p->disable_audio;
}
int main(int argc, char** argv)
{
appstate = 0;
display_banner();
char* home_dir_str = gethome();
if(home_dir_str == NULL)
{
fprintf(stderr, "You need a home directory");
return 0;
}
Parameters* p = NULL;
p = malloc(sizeof(Parameters));
MonocoqueSettings* ms = malloc(sizeof(MonocoqueSettings));;
ConfigError ppe = getParameters(argc, argv, p);
if (ppe == E_SUCCESS_AND_EXIT || ppe == E_SOMETHING_BAD)
{
printf("invalid parameters\n");
goto cleanup_final;
}
xdgHandle xdg;
if(!xdgInitHandle(&xdg))
{
fprintf(stderr, "Function xdgInitHandle() failed, is $HOME unset?\n");
goto cleanup_final;
}
const char* config_home_str = xdgConfigHome(&xdg);
const char* cache_home_str = xdgCacheHome(&xdg);
char* cachedir_str = NULL;
char* configdir_str = NULL;
if(p->user_specified_config_file == false && p->user_specified_config_dir == false)
{
create_xdg_dir(config_home_str);
configdir_str = create_user_dir(home_dir_str, ".config", PROGRAM_NAME);
}
if(p->user_specified_log_file == false)
{
create_xdg_dir(cache_home_str);
cachedir_str = create_user_dir(home_dir_str, ".cache", PROGRAM_NAME);
}
fprintf(stderr, "applying settings\n");
SetSettingsFromParameters(p, ms, configdir_str, cachedir_str);
if(cachedir_str != NULL)
{
free(cachedir_str);
}
if(configdir_str != NULL)
{
free(configdir_str);
}
fprintf(stderr, "settings applied\n");
slog_init("monocoque", SLOG_FLAGS_ALL, 1);
slog_config_t slgCfg;
slog_config_get(&slgCfg);
slgCfg.eColorFormat = SLOG_COLORING_TAG;
slgCfg.eDateControl = SLOG_TIME_ONLY;
strcpy(slgCfg.sFileName, ms->log_filename_str);
strcpy(slgCfg.sFilePath, ms->log_dirname_str);
slgCfg.nTraceTid = 0;
slgCfg.nToScreen = 1;
slgCfg.nUseHeap = 0;
slgCfg.nToFile = 1;
slgCfg.nFlush = 0;
slgCfg.nFlags = SLOG_FLAGS_ALL;
slog_config_set(&slgCfg);
if (ms->verbosity_count < 2)
{
slog_disable(SLOG_TRACE);
}
if (ms->verbosity_count < 1)
{
slog_disable(SLOG_DEBUG);
}
xdgWipeHandle(&xdg);
slogi("checking for diameters config");
char* diameters_file_str;
asprintf(&diameters_file_str, "%s/.config/monocoque/diameters.config", home_dir_str);
ms->tyre_diameter_config = strdup(diameters_file_str);
free(diameters_file_str);
ms->useconfig = 0;
ms->configcheck = 0;
slogi("Testing monocoque config file: %s", ms->config_str);
slogd("using diameters file %s %i", ms->tyre_diameter_config, ms->configcheck);
config_t cfg;
config_init(&cfg);
config_setting_t* config_devices = NULL;
if (!config_read_file(&cfg, ms->config_str))
{
sloge("Issue with monocoque config file: %s:%d - %s", config_error_file(&cfg), config_error_line(&cfg), config_error_text(&cfg));
fprintf(stderr, "Issue with monocoque config file: %s:%d - %s\n", config_error_file(&cfg), config_error_line(&cfg), config_error_text(&cfg));
config_destroy(&cfg);
slog_destroy();
goto cleanup_final;
}
else
{
slogi("Opened and validated monocoque configuration file");
}
config_destroy(&cfg);
if (ms->program_action == A_CONFIG_TACH)
{
int error = 0;
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);
if (error != MONOCOQUE_ERROR_NONE)
{
sloge("Could not proceed with tachometer configuration due to error: %i", error);
}
else
{
int devices = 0;
devices = devinit(tachdev, siminfo, 1, ds, ms);
if(devices < 1)
{
error = MONOCOQUE_ERROR_INVALID_DEV;
}
}
if (error != MONOCOQUE_ERROR_NONE)
{
sloge("Could not proceed with tachometer configuration due to error: %i", error);
}
else
{
slogi("configuring tachometer with max revs: %i, granularity: %i, saving to %s", p->max_revs, p->granularity, p->save_file);
config_tachometer(p->max_revs, p->granularity, p->save_file, tachdev, sdata);
}
slogt("freeing devices if necessary");
if(tachdev->initialized == true)
{
slogt("freeing tachmoeter device");
tachdev->free(tachdev);
}
//free(tachdev);
free(sdata);
free(ds);
}
else
{
int error = 0;
error = MONOCOQUE_ERROR_NONE;
//setupsound();
bool pulseaudio = false;
if (ms->program_action == A_PLAY)
{
ms->useconfig = 1;
slogi("running monocoque in gameloop mode..");
//#ifdef USE_PULSEAUDIO
//pa_threaded_mainloop_unlock(mainloop);
pulseaudio = true;
//#endif
if(ms->disable_audio == false)
{
setupsound();
}
//error = looper(devices, numdevices, p);
error = monocoque_mainloop(ms);
if (error == MONOCOQUE_ERROR_NONE)
{
slogi("Game loop exited succesfully with error code: %i", error);
}
else
{
sloge("Game loop exited with error code: %i", error);
}
if(ms->disable_audio == false)
{
freesound();
}
}
else
{
slogi("running monocoque in test mode...");
if(ms->disable_audio == false)
{
setupsound();
}
ms->useconfig = 0;
int configs = getNumberOfConfigs(ms->config_str);
int confignum = getconfigtouse(ms->config_str, "default", configs-1);
int configureddevices;
configcheck(ms->config_str, confignum, &configureddevices);
DeviceSettings* ds = malloc(configureddevices * sizeof(DeviceSettings));
slogd("loading confignum %i, with %i devices.", confignum, configureddevices);
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);
for( int i = 0; i < configureddevices; i++)
{
settingsfree(ds[i]);
}
free(ds);
error = tester(simdevices, numdevices);
if (error == MONOCOQUE_ERROR_NONE)
{
slogi("Test exited succesfully with error code: %i", error);
}
else
{
sloge("Test exited with error code: %i", error);
}
for (int x = 0; x < numdevices; x++)
{
if (simdevices[x].initialized == true)
{
simdevices[x].free(&simdevices[x]);
}
}
if(ms->disable_audio == false)
{
freesound();
}
}
slog_destroy();
}
cleanup_final:
monocoquesettingsfree(ms);
free(ms);
freeparams(p);
free(p);
exit(0);
}
+540
View File
@@ -0,0 +1,540 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>
#include <basedir_fs.h>
#include <libconfig.h>
#include "mgui/uiconfighelper.h"
#include "mgui/addeditaction.h"
#include "mgui/mainwindow.h"
#include "gameloop/gameloop.h"
#include "gameloop/loopdata.h"
#include "gameloop/tachconfig.h"
#include "devices/simdevice.h"
#include "devices/sound.h"
#include "helper/parameters.h"
#include "helper/dirhelper.h"
#include "helper/confighelper.h"
#include "simulatorapi/simapi/simapi/simdata.h"
#include "slog/slog.h"
#include <nappgui.h>
#include <gui/guiall.h>
#define PROGRAM_NAME "monocoque"
MonocoqueSettings ms;
Parameters* p;
char **m_argv;
int m_argc;
int appstate = 0;
void SetSettingsFromParameters(Parameters* p, MonocoqueSettings* ms, char* configdir_str, char* cachedir_str)
{
if(p->user_specified_config_file == true && does_file_exist(p->config_filepath))
{
ms->config_str = strdup(p->config_filepath);
}
else
{
if(p->user_specified_config_dir == true && does_directory_exist(p->config_dirpath))
{
asprintf(&ms->config_str, "%s/%s", p->config_dirpath, "monocoque.config");
}
else
{
asprintf(&ms->config_str, "%s%s", configdir_str, "monocoque.config");
}
}
if(p->user_specified_log_file == true && does_file_exist(p->log_fullfilename_str))
{
ms->log_dirname_str = strdup(p->log_dirname_str);
ms->log_filename_str = strdup(p->log_filename_str);
}
else
{
ms->log_dirname_str = strdup(cachedir_str);
ms->log_filename_str = strdup("monocoque.log");
}
ms->fps = p->fps;
ms->verbosity_count = p->verbosity_count;
ms->program_action = A_TEST;
if (p->program_action == A_PLAY)
{
ms->program_action = A_PLAY;
}
if (p->program_action == A_CONFIG_TACH)
{
ms->program_action = A_CONFIG_TACH;
}
ms->force_udp_mode = false;
ms->disable_audio = p->disable_audio;
}
/*---------------------------------------------------------------------------*/
int monocoque_initialize(int argc, char** argv)
{
char* home_dir_str = gethome();
if(home_dir_str == NULL)
{
fprintf(stderr, "You need a home directory");
return 0;
}
p = NULL;
p = malloc(sizeof(Parameters));
p->config_dirpath = NULL;
p->config_filepath = NULL;
p->log_filename_str = NULL;
p->log_fullfilename_str = NULL;
p->log_dirname_str = NULL;
ConfigError ppe = getParameters(argc, argv, p);
if (ppe == E_SUCCESS_AND_EXIT || ppe == E_SOMETHING_BAD)
{
printf("invalid parameters\n");
//goto cleanup_final;
}
xdgHandle xdg;
if(!xdgInitHandle(&xdg))
{
fprintf(stderr, "Function xdgInitHandle() failed, is $HOME unset?\n");
//goto cleanup_final;
}
const char* config_home_str = xdgConfigHome(&xdg);
const char* cache_home_str = xdgCacheHome(&xdg);
char* cachedir_str = NULL;
char* configdir_str = NULL;
if(p->user_specified_config_file == false && p->user_specified_config_dir == false)
{
create_xdg_dir(config_home_str);
configdir_str = create_user_dir(home_dir_str, ".config", PROGRAM_NAME);
}
if(p->user_specified_log_file == false)
{
create_xdg_dir(cache_home_str);
cachedir_str = create_user_dir(home_dir_str, ".cache", PROGRAM_NAME);
}
SetSettingsFromParameters(p, &ms, configdir_str, cachedir_str);
if(cachedir_str != NULL)
{
free(cachedir_str);
}
if(configdir_str != NULL)
{
free(configdir_str);
}
slog_init("monocoque", SLOG_FLAGS_ALL, 1);
slog_config_t slgCfg;
slog_config_get(&slgCfg);
slgCfg.eColorFormat = SLOG_COLORING_TAG;
slgCfg.eDateControl = SLOG_TIME_ONLY;
strcpy(slgCfg.sFileName, ms.log_filename_str);
strcpy(slgCfg.sFilePath, ms.log_dirname_str);
slgCfg.nTraceTid = 0;
slgCfg.nToScreen = 1;
slgCfg.nUseHeap = 0;
slgCfg.nToFile = 1;
slgCfg.nFlush = 0;
slgCfg.nFlags = SLOG_FLAGS_ALL;
slog_config_set(&slgCfg);
if (ms.verbosity_count < 2)
{
slog_disable(SLOG_TRACE);
}
if (ms.verbosity_count < 1)
{
slog_disable(SLOG_DEBUG);
}
xdgWipeHandle(&xdg);
if(ms.disable_audio == false)
{
setupsound();
}
}
/*---------------------------------------------------------------------------*/
int monocoque_gameloop_start()
{
start_loop(&ms);
}
/*---------------------------------------------------------------------------*/
static void i_OnStart(App *app, Event *e)
{
unref(e);
app->is_running = TRUE;
int rc = 0;
if(appstate == 0)
{
rc = monocoque_gameloop_start();
}
else
{
monocoque_mainloop_stop(&ms);
}
}
/*---------------------------------------------------------------------------*/
static void i_OnStop(App *app, Event *e)
{
monocoque_mainloop_stop(&ms);
}
/*---------------------------------------------------------------------------*/
static void i_OnClose(App *app, Event *e)
{
close_monocoque_config(ms.cfg);
monocoquesettingsfree(&ms);
freeparams(p);
free(p);
for (int i = 0; i < (uint32_t)m_argc; ++i)
free(m_argv[i]);
free(m_argv);
osapp_finish();
unref(app);
unref(e);
}
/*---------------------------------------------------------------------------*/
static void i_OnAddClose(App *app, Event *e)
{
}
static void i_OnDelete(App* app, Event *e)
{
int devicenum = listbox_get_selected(app->listbox_devices);
if(devicenum == UINT32_MAX)
{
return;
}
delete_device_config(ms.cfg, ms.config_str, 0, devicenum);
listbox_clear(app->listbox_devices);
combo_clear(app->combo_configurations);
populate_device_list(app->listbox_devices, ms.cfg);
populate_combo_box(app->combo_configurations, ms.cfg);
}
/*---------------------------------------------------------------------------*/
static void i_OnAddEdit(App* app, Event *e, enum device_action device_action)
{
Panel *panel = NULL;
int devicenum = listbox_get_selected(app->listbox_devices);
if(devicenum == UINT32_MAX && device_action == DEVICE_ACTION_EDIT)
{
return;
}
if(device_action == DEVICE_ACTION_ADD)
{
devicenum = listbox_count(app->listbox_devices);
}
app->window2 = window_create(ekWINDOW_STDRES);
panel = adddevice_window(app->window2, app, &ms, device_action, 0, devicenum);
window_panel(app->window2, panel);
window_origin(app->window2, v2df(800, 200));
window_title(app->window2, "monocoque");
window_OnClose(app->window2, listener(app, i_OnAddClose, App));
window_modal(app->window2, app->window);
window_destroy(&app->window2);
listbox_clear(app->listbox_devices);
combo_clear(app->combo_configurations);
populate_device_list(app->listbox_devices, ms.cfg);
populate_combo_box(app->combo_configurations, ms.cfg);
}
/*---------------------------------------------------------------------------*/
static void i_OnAdd(App *app, Event *e)
{
i_OnAddEdit(app, e, DEVICE_ACTION_ADD);
}
/*---------------------------------------------------------------------------*/
static void i_OnEdit(App *app, Event *e)
{
i_OnAddEdit(app, e, DEVICE_ACTION_EDIT);
}
/*---------------------------------------------------------------------------*/
static void set_bottom_label_status(Label* label)
{
char status_string[256];
snprintf(status_string, 256, "Game: %s Game Status: None Simd: %s", get_simexe_name(), get_simd_onoff());
label_text(label, status_string);
}
/*---------------------------------------------------------------------------*/
static Panel *i_panel(App *app, MonocoqueSettings* ms)
{
app->main_panel = panel_create();
app->subpanel = panel_scroll(FALSE, TRUE);
app->layout = layout_create(8,5);
app->listbox_devices = listbox_create();
listbox_size(app->listbox_devices, s2df(50, 50));
app->combo_configurations = combo_create();
app->label_configurations = label_create();
label_text(app->label_configurations, "Configuration: ");
app->label_game_status = label_create();
app->button_startstop = button_push();
app->button_add = button_push();
app->button_edit = button_push();
app->button_del = button_push();
app->layout1 = layout_create(8,1);
app->layout2 = layout_create(8,1);
app->layout3 = layout_create(1,1);
app->layout4 = layout_create(1,2);
layout_layout(app->layout, app->layout1, 0, 0);
layout_layout(app->layout, app->layout2, 0, 1);
layout_layout(app->layout, app->layout3, 0, 2);
layout_layout(app->layout, app->layout4, 0, 3);
appstate = 0;
set_bottom_label_status(app->label_game_status);
populate_device_list(app->listbox_devices, ms->cfg);
listbox_select(app->listbox_devices, 0, true);
populate_combo_box(app->combo_configurations, ms->cfg);
button_text(app->button_startstop, "Start");
button_text(app->button_add, "Add Device");
button_text(app->button_del, "Delete Device");
button_text(app->button_edit, "Edit Device");
button_OnClick(app->button_startstop, listener(app, i_OnStart, App));
button_OnClick(app->button_add, listener(app, i_OnAdd, App));
button_OnClick(app->button_edit, listener(app, i_OnEdit, App));
button_OnClick(app->button_del, listener(app, i_OnDelete, App));
layout_label(app->layout1, app->label_configurations, 0, 0);
layout_combo(app->layout1, app->combo_configurations, 1, 0);
layout_button(app->layout2, app->button_add, 3, 0);
layout_button(app->layout2, app->button_edit, 4, 0);
layout_button(app->layout2, app->button_del, 5, 0);
layout_listbox(app->layout3, app->listbox_devices, 0, 0);
layout_button(app->layout4, app->button_startstop, 0, 0);
layout_label(app->layout4, app->label_game_status, 0, 1);
panel_layout(app->subpanel, app->layout3);
layout_panel(app->layout, app->subpanel, 0, 2);
panel_layout(app->main_panel, app->layout);
app->devices_subpanel = layout_cell(app->layout, 0, 2);
// spacing
layout_valign(app->layout4, 0, 0, ekBOTTOM);
layout_valign(app->layout4, 0, 1, ekBOTTOM);
layout_halign(app->layout4, 0, 0, ekJUSTIFY);
layout_halign(app->layout4, 0, 1, ekJUSTIFY);
layout_hexpand(app->layout, 0);
layout_hexpand(app->layout4, 0);
layout_vexpand(app->layout, 0);
layout_vexpand(app->layout, 2);
layout_vexpand(app->layout4, 0);
button_vpadding(app->button_startstop, 0);
button_hpadding(app->button_startstop, 0);
layout_hexpand(app->layout1, 1);
return app->main_panel;
}
static App *i_create(void)
{
uint32_t i;
int old_argc = (int)osapp_argc();
m_argc = old_argc + 1;
m_argv = malloc((m_argc+1) * sizeof(char *));
m_argv[m_argc] = NULL;
for (i = 0; i < (uint32_t)m_argc; ++i)
{
char buffer[128];
m_argv[i] = NULL;
if (i == 1)
{
m_argv[i] = strdup("play");
}
else
{
uint32_t old_i = (i > 1) ? i - 1 : i;
osapp_argv(old_i, buffer, sizeof(buffer));
m_argv[i] = strdup(buffer);
}
}
// do some monocoque things here
ms.tyre_diameter_config = NULL;
ms.config_str = NULL;
ms.log_filename_str = NULL;
ms.log_dirname_str = NULL;
monocoque_initialize(m_argc, m_argv);
ms.cfg = open_monocoque_config(ms.config_str);
// find a better spot for this
dbind(SimData, uint32_t, velocity);
dbind(SimData, uint32_t, rpms);
dbind(SimData, uint32_t, gear);
dbind(SimData, uint32_t, maxrpm);
dbind(SimData, real64_t, tyreRPS[0]);
dbind(SimData, real64_t, tyreRPS[1]);
dbind(SimData, real64_t, tyreRPS[2]);
dbind(SimData, real64_t, tyreRPS[3]);
dbind(SimData, real64_t, tyrediameter[0]);
dbind(SimData, real64_t, tyrediameter[1]);
dbind(SimData, real64_t, tyrediameter[2]);
dbind(SimData, real64_t, tyrediameter[3]);
dbind(DeviceSettings, HapticEffectSettings, hapticsettings);
dbind(HapticEffectSettings, uint32_t, frequency);
dbind(HapticEffectSettings, uint32_t, frequencyMax);
dbind(HapticEffectSettings, uint32_t, amplitude);
dbind(HapticEffectSettings, uint32_t, amplitudeMax);
dbind(HapticEffectSettings, uint32_t, motorposition);
dbind(HapticEffectSettings, real64_t, threshold);
dbind(HapticEffectSettings, real64_t, duration);
dbind_enum(VibrationEffectType, EFFECT_ENGINERPM, "Engine RPM");
dbind_enum(VibrationEffectType, EFFECT_GEARSHIFT, "Gear Shift");
dbind_enum(VibrationEffectType, EFFECT_ABSBRAKES, "ABS Brakes");
dbind_enum(VibrationEffectType, EFFECT_TYRESLIP, "Tyre Slip");
dbind_enum(VibrationEffectType, EFFECT_TYRELOCK, "Tyre Lock");
dbind_enum(VibrationEffectType, EFFECT_SUSPENSION, "Suspension");
dbind_enum(EffectModulationType, EFFECT_MODULATION_NONE, "None");
dbind_enum(EffectModulationType, EFFECT_MODULATION_FREQUENCY, "Frequency");
dbind_enum(EffectModulationType, EFFECT_MODULATION_AMPLIFY, "Amplify");
dbind_enum(MonocoqueTyreIdentifier, FRONTLEFT, "Front Left");
dbind_enum(MonocoqueTyreIdentifier, FRONTRIGHT, "Front Right");
dbind_enum(MonocoqueTyreIdentifier, REARLEFT, "Rear Left");
dbind_enum(MonocoqueTyreIdentifier, REARRIGHT, "Rear Right");
dbind_enum(MonocoqueTyreIdentifier, FRONTS, "Fronts");
dbind_enum(MonocoqueTyreIdentifier, REARS, "Rears");
dbind_enum(MonocoqueTyreIdentifier, ALLFOUR, "All Four");
dbind(HapticEffectSettings, uint32_t, modulation);
dbind(HapticEffectSettings, uint32_t, tyre);
dbind(HapticEffectSettings, uint32_t, effect_type);
dbind(DeviceSettings, SerialDeviceSettings, serialdevsettings);
dbind(SerialDeviceSettings, uint32_t, baud);
dbind(SoundDeviceSettings, uint32_t, pan);
dbind(SoundDeviceSettings, uint32_t, channels);
dbind(SoundDeviceSettings, uint32_t, volume);
dbind(DeviceSettings, SerialDeviceSettings, serialdevsettings);
dbind(SerialDeviceSettings, uint32_t, startled);
dbind(SerialDeviceSettings, uint32_t, numleds);
dbind(SerialDeviceSettings, uint32_t, endled);
dbind_enum(DeviceType, SIMDEV_USB, "USB");
dbind_enum(DeviceType, SIMDEV_SOUND, "Sound");
dbind_enum(DeviceType, SIMDEV_SERIAL, "Serial");
dbind(DeviceSettings, DeviceType, dev_type);
dbind(DeviceSettings, uint32_t, dev_subtype);
dbind(DeviceSettings, uint32_t, fps);
//gui stuff
App *app = heap_new0(App);
Panel *panel = i_panel(app, &ms);
app->window = window_create(ekWINDOW_STDRES);
window_panel(app->window, panel);
window_origin(app->window, v2df(800, 200));
window_title(app->window, "monocoque");
window_OnClose(app->window, listener(app, i_OnClose, App));
window_show(app->window);
return app;
}
/*---------------------------------------------------------------------------*/
static void i_destroy(App **app)
{
//monocoquesettingsfree(&ms);
//freeparams(p);
//free(p);
osapp_finish();
window_destroy(&(*app)->window);
heap_delete(app, App);
}
/*---------------------------------------------------------------------------*/
static void i_update(App *app, const real64_t prtime, const real64_t ctime)
{
if (app->is_running == TRUE)
{
if(appstate == 2)
{
button_text(app->button_startstop, "Playing... Press to Stop");
cell_enabled(app->devices_subpanel, false);
}
if(appstate == 1)
{
button_text(app->button_startstop, "Searching for data... Press to Stop");
cell_enabled(app->devices_subpanel, false);
}
if(appstate <= 0)
{
button_text(app->button_startstop, "Start");
cell_enabled(app->devices_subpanel, true);
}
set_bottom_label_status(app->label_game_status);
}
}
/*---------------------------------------------------------------------------*/
#include <osapp/osmain.h>
osmain_sync(.04, i_create, i_destroy, i_update, "", App)
@@ -43,3 +43,5 @@ set(simulatorapi_source_files
)
add_library(simulatorapi STATIC ${simulatorapi_source_files})
set_property(TARGET simulatorapi PROPERTY POSITION_INDEPENDENT_CODE ON)
+2
View File
@@ -4,3 +4,5 @@ set(slog_source_files
)
add_library(slog STATIC ${slog_source_files})
set_property(TARGET slog PROPERTY POSITION_INDEPENDENT_CODE ON)
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+24
View File
@@ -0,0 +1,24 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: monocoque
Upstream-Contact: Paul Jones <paul@spacefreak18.xyz>
Source: https://github.com/spacefreak18/monocoque
Files:
*
Copyright: 2022 Paul Jones
License: GPL-3+
Files:
src/monocoque/slog/slog.?
Copyright: 2015-2025 Sandro Kalatozishvili (s.kalatoz@gmail.com)
License: MIT
Files:
src/monocoque/mgui/nappgui_src/*
Copyright: 2021 Francisco García Collado
License: MIT
Files:
src/monocoque/simulatorapi/simapi/*
Copyright: 2022 Paul Jones
License: LGPL
+6 -4
View File
@@ -122,6 +122,8 @@ if ! distrobox list 2>/dev/null | grep -q "$CONTAINER"; then
distrobox create \
--image docker.io/library/archlinux:latest \
--name "$CONTAINER" \
--root \
--additional-flags "--privileged --security-opt seccomp=unconfined" \
--pre-init-hooks "sed -i 's/^SigLevel.*/SigLevel = Never/' /etc/pacman.conf && pacman -Sy --noconfirm archlinux-keyring && pacman-key --init && pacman-key --populate archlinux && sed -i 's/^SigLevel.*/SigLevel = Required DatabaseOptional/' /etc/pacman.conf"
log_success "Container '$CONTAINER' created"
else
@@ -130,7 +132,7 @@ fi
# Install packages inside the container
log_info "Installing packages inside container (this may take a few minutes)..."
distrobox enter "$CONTAINER" -- bash -c '
distrobox enter --root "$CONTAINER" -- bash -c '
set -euo pipefail
# Install build dependencies
@@ -181,19 +183,19 @@ mkdir -p "$BIN_DIR"
cat > "$BIN_DIR/start-simd" << 'EOF'
#!/usr/bin/env bash
exec distrobox enter simracing -- simd "$@"
exec distrobox enter --root simracing -- simd "$@"
EOF
chmod +x "$BIN_DIR/start-simd"
cat > "$BIN_DIR/start-monocoque" << 'EOF'
#!/usr/bin/env bash
exec distrobox enter simracing -- monocoque play "$@"
exec distrobox enter --root simracing -- monocoque play "$@"
EOF
chmod +x "$BIN_DIR/start-monocoque"
cat > "$BIN_DIR/test-monocoque" << 'EOF'
#!/usr/bin/env bash
exec distrobox enter simracing -- monocoque test -vv "$@"
exec distrobox enter --root simracing -- monocoque test -vv "$@"
EOF
chmod +x "$BIN_DIR/test-monocoque"
@@ -72,9 +72,9 @@ if [ -d "$INSTALL_DIR" ]; then
fi
# Remove distrobox container
if distrobox list 2>/dev/null | grep -q "$CONTAINER"; then
if distrobox list --root 2>/dev/null | grep -q "$CONTAINER"; then
log_info "Removing distrobox container '$CONTAINER'..."
distrobox rm --force "$CONTAINER"
distrobox rm --root --force "$CONTAINER"
log_success "Container '$CONTAINER' removed"
else
log_info "Container '$CONTAINER' not found, skipping"
+4 -2
View File
@@ -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 procps-ng gtk3 libcurl mesa-libGL
%description
A device manager for Racing sims
@@ -27,13 +27,15 @@ cp -r $RPM_SOURCE_DIR/monocoque $RPM_BUILD_DIR/
%build
cd $RPM_BUILD_DIR/monocoque
cmake -B build
cmake -B build -DBUILD_GUI=on
cd build
make
%install
mkdir -p $RPM_BUILD_ROOT/usr/bin
cp $RPM_BUILD_DIR/monocoque/build/monocoque $RPM_BUILD_ROOT/usr/bin/monocoque
cp $RPM_BUILD_DIR/monocoque/build/gmonocoque $RPM_BUILD_ROOT/usr/bin/gmonocoque
%files
/usr/bin/monocoque
/usr/bin/gmonocoque
+9
View File
@@ -0,0 +1,9 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=Monocoque
Comment=Launch Monocoque
Exec=/usr/bin/gmonocoque
Icon=monocoque
Terminal=false
Categories=Game;Development;