aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcnlohr <lohr85@gmail.com>2018-06-23 14:27:27 -0400
committercnlohr <lohr85@gmail.com>2018-06-23 14:27:27 -0400
commite8b268f4c0116b135400ef6cf3dc939481de119b (patch)
tree7dfc215d7cf3e7fecb2d68983d010aee2c2bbdef
parent1dea63123ca6735cee354f3eeae69e2e62d61e3b (diff)
downloadlibsurvive-e8b268f4c0116b135400ef6cf3dc939481de119b.tar.gz
libsurvive-e8b268f4c0116b135400ef6cf3dc939481de119b.tar.bz2
Fix units for vive, but not switching scales to incremental.
-rw-r--r--src/survive_default_devices.c15
-rwxr-xr-xsrc/survive_vive.c2
2 files changed, 12 insertions, 5 deletions
diff --git a/src/survive_default_devices.c b/src/survive_default_devices.c
index 05dd10d..ea38d55 100644
--- a/src/survive_default_devices.c
+++ b/src/survive_default_devices.c
@@ -6,6 +6,9 @@
#include "json_helpers.h"
+#define HMD_IMU_HZ 1000.0f
+#define VIVE_DEFAULT_IMU_HZ 250.0f
+
static SurviveObject *
survive_create_device(SurviveContext *ctx, const char *driver_name,
void *driver, const char *device_name, haptic_func fn) {
@@ -17,7 +20,7 @@ survive_create_device(SurviveContext *ctx, const char *driver_name,
memcpy(device->drivername, driver_name, strlen(driver_name));
device->timebase_hz = 48000000;
- device->imu_freq = 250.f;
+ device->imu_freq = VIVE_DEFAULT_IMU_HZ;
device->haptic = fn;
return device;
@@ -167,16 +170,20 @@ int survive_load_htc_config_format(SurviveObject *so, char *ct0conf, int len) {
if (strcmp(so->codename, "HMD") == 0) {
if (so->acc_scale) {
scale3d(so->acc_scale, so->acc_scale, 1. / 8192.0);
+ //Invert X and Y at least on my vive.
+ so->acc_scale[1] *= -1;
+ so->acc_scale[0] *= -1;
}
+ so->imu_freq = HMD_IMU_HZ;
if (so->acc_bias)
scale3d(so->acc_bias, so->acc_bias, 2. / 1000.); // Odd but seems right.
if (so->gyro_scale) {
FLT deg_per_sec = 500;
scale3d(so->gyro_scale, so->gyro_scale, deg_per_sec / (1 << 15) * LINMATHPI / 180.);
- // scale3d(so->gyro_scale, so->gyro_scale, 0.000065665);
+ //Invert X and Y at least on my vive.
+ so->gyro_scale[0] *= -1;
+ so->gyro_scale[1] *= -1;
}
-
- so->imu_freq = 1000.f;
} else if (memcmp(so->codename, "WM", 2) == 0) {
if (so->acc_scale)
scale3d(so->acc_scale, so->acc_scale, 2. / 8192.0);
diff --git a/src/survive_vive.c b/src/survive_vive.c
index 37bec7e..b20052d 100755
--- a/src/survive_vive.c
+++ b/src/survive_vive.c
@@ -553,7 +553,7 @@ int survive_vive_send_magic(SurviveContext * ctx, void * drv, int magic_code, vo
//From actual steam.
if (sv->udev[USB_DEV_HMD])
{
- static uint8_t vive_magic_power_on[64] = { 0x04, 0x78, 0x29, 0x38 };
+ static uint8_t vive_magic_power_on[64] = { 0x04, 0x78, 0x29, 0x38, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01 };
r = update_feature_report( sv->udev[USB_DEV_HMD], 0, vive_magic_power_on, sizeof( vive_magic_power_on ) );
if( r != sizeof( vive_magic_power_on ) ) return 5;
}