aboutsummaryrefslogtreecommitdiff
path: root/src/survive_default_devices.c
blob: 5d2cda75333f509db01bb7eaabe4382a1282f67f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <stdlib.h>
#include <string.h>
#include "survive_default_devices.h"

static SurviveObject* survive_create_device(SurviveContext * ctx,
					    const char* driver_name,
					    void* driver,
					    const char* device_name,
					    haptic_func fn) {
  SurviveObject * device = calloc( 1, sizeof( SurviveObject ) );

  device->ctx = ctx;
  device->driver = driver;
  memcpy( device->codename, device_name, strlen(device_name) );
  memcpy( device->drivername, driver_name, strlen(driver_name) );

  device->timebase_hz = 48000000;
  device->pulsedist_max_ticks = 500000;
  device->pulselength_min_sync = 2200;
  device->pulse_in_clear_time = 35000;
  device->pulse_max_for_sweep = 1800;
  device->pulse_synctime_offset = 20000;
  device->pulse_synctime_slack = 5000;
  device->timecenter_ticks = device->timebase_hz / 240;

  device->haptic = fn;
  
  return device;
}

SurviveObject* survive_create_hmd(SurviveContext * ctx, const char* driver_name, void* driver) {
  return survive_create_device(ctx, driver_name, driver, "HMD", 0);
}

SurviveObject* survive_create_wm0(SurviveContext * ctx, const char* driver_name, void* driver, haptic_func fn) {
  return survive_create_device(ctx, driver_name, driver, "WM0", fn);
}
SurviveObject* survive_create_wm1(SurviveContext * ctx, const char* driver_name, void* driver, haptic_func fn) {
  return survive_create_device(ctx, driver_name, driver, "WM1", fn);
}
SurviveObject* survive_create_tr0(SurviveContext * ctx, const char* driver_name, void* driver) {
  return survive_create_device(ctx, driver_name, driver, "TR0", 0);
}
SurviveObject* survive_create_ww0(SurviveContext * ctx, const char* driver_name, void* driver) {
  return survive_create_device(ctx, driver_name, driver, "WW0", 0);
}