5 Commits
4 changed files with 28 additions and 36 deletions
+7
View File
@@ -16,12 +16,14 @@ Cross Platform device manager for driving and flight simulators, for use with co
- Includes utility to configure revburner tachometer
- Can send data to any serial device. So far only tested with arduino. Includes sample arduino sketch for sim lights.
- The support for haptic bass shakers is limited and needs the most work. So far the engine rev is a simple sine wave, which I find convincing. The gear shift event works but not convincing enough for me.
- Choice of Portaudio or Pulseaudio backend.
## Dependencies
- libserialport - arduino serial devices
- hidapi - usb hid devices
- libusb - used by hidapi
- portaudio - sound devices (haptic bass shakers)
- pulseaudio - sound devices (haptic bass shakers)
- libenet - UDP support (not yet implemented)
- libxml2
- argtable2
@@ -44,6 +46,11 @@ cmake ..
make
```
to use the pulseaudio backend use this cmake command
```
cmake -DUSE_PULSEAUDIO=YES ..
```
## Testing
### Setting up Your Arduino Device
+13 -6
View File
@@ -5,12 +5,19 @@ devices = ( { device = "USB";
subtype = "Revburner";
granularity = 4;
config = "/home/paul/.config/monocoque/revburner1.xml"; },
{ device = "Sound";
type = "Engine"
devid = "98FD:83AC"; },
{ device = "Sound";
type = "Gear"
devid = "98FD:83AC"; },
{ device = "Sound";
type = "Engine";
devid = "alsa_output.usb-Generic_USB2.0_Device_20170726905959-00.analog-stereo";
pan = 1;
volume = 90;
frequency = 27; },
{ device = "Sound";
type = "Gear"
devid = "alsa_output.usb-Generic_USB2.0_Device_20170726905959-00.analog-stereo";
pan = 1;
duration = .25;
volume = 100;
frequency = 27; },
{ device = "Serial";
type = "ShiftLights";
config = "None";
@@ -123,7 +123,7 @@ int usb_generic_shaker_init(SoundDevice* sounddevice, pa_threaded_mainloop* main
// recommended settings, i.e. server uses sensible values
pa_buffer_attr buffer_attr;
buffer_attr.maxlength = (uint32_t) -1;
buffer_attr.maxlength = (uint32_t) 32767;
buffer_attr.tlength = (uint32_t) -1;
buffer_attr.prebuf = (uint32_t) -1;
buffer_attr.minreq = (uint32_t) -1;
@@ -131,22 +131,17 @@ int usb_generic_shaker_init(SoundDevice* sounddevice, pa_threaded_mainloop* main
pa_cvolume cv;
uint16_t pvolume = ceil(((double) volume/100.0d)*65535);
// Settings copied as per the chromium browser source
pa_stream_flags_t stream_flags;
stream_flags = PA_STREAM_INTERPOLATE_TIMING |
PA_STREAM_NOT_MONOTONIC | PA_STREAM_AUTO_TIMING_UPDATE |
PA_STREAM_ADJUST_LATENCY;
//stream_flags = PA_STREAM_START_CORKED;
pa_stream_flags_t stream_flags;
stream_flags = PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_NOT_MONOTONIC | PA_STREAM_AUTO_TIMING_UPDATE | PA_STREAM_ADJUST_LATENCY | PA_STREAM_START_CORKED;
// Connect stream to the default audio output sink
pa_cvolume_set(&cv, sample_specifications.channels, pvolume);
//pa_cvolume_set(&cv, 1, 0);
pa_cvolume_set_balance(&cv, &channel_map, pan);
assert(pa_stream_connect_playback(stream, devname, &buffer_attr, stream_flags, &cv, NULL) == 0);
// Wait for the stream to be ready
for(;;) {
pa_stream_state_t stream_state = pa_stream_get_state(stream);
+4 -21
View File
@@ -171,17 +171,6 @@ int showstats(SimData* simdata)
int clilooper(SimDevice* devices, int numdevices, Parameters* p, SimData* simdata, SimMap* simmap)
{
slogi("preparing game loop with %i devices...", numdevices);
slogi("sending initial data to devices");
simdata->velocity = 16;
simdata->rpms = 100;
for (int x = 0; x < numdevices; x++)
{
devices[x].update(&devices[x], simdata);
}
sleep(3);
struct pollfd mypoll = { STDIN_FILENO, POLLIN|POLLPRI };
@@ -203,10 +192,9 @@ int clilooper(SimDevice* devices, int numdevices, Parameters* p, SimData* simdat
for (int x = 0; x < numdevices; x++)
{
devices[x].update(&devices[x], simdata);
}
if( poll(&mypoll, 1, 1000.0/DEFAULT_UPDATE_RATE) )
if( poll(&mypoll, 1, 1000.0/update_rate) )
{
scanf("%c", &ch);
if(ch == 'q')
@@ -252,16 +240,11 @@ int looper(SimDevice* devices, int numdevices, Parameters* p)
while (go == true)
{
getSim(simdata, simmap, &p->simon, &p->sim);
if (p->simon == false)
{
getSim(simdata, simmap, &p->simon, &p->sim);
}
if (p->simon == true)
if (p->simon == true && simdata->simstatus > 1)
{
slogi("preparing game loop with %i devices...", numdevices);
clilooper(devices, numdevices, p, simdata, simmap);
}
if (p->simon == true)