aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE16
-rw-r--r--README.md47
-rw-r--r--src/survive_data.c32
-rw-r--r--src/survive_process.c8
-rw-r--r--src/survive_usb.c31
5 files changed, 116 insertions, 18 deletions
diff --git a/LICENSE b/LICENSE
index 853f6b0..ce16fc0 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,20 @@
+NOTICE: Portions of this project are tightly based off of OSVR-Vive-Libre
+ which is under a forced-source license. I have rewritten as much as I can
+ to avoid that, however, I may have made some mistakes. Magic numbers
+ have not been modified as they cannot and (thankfully) are exempt from
+ copyright law.
+
+NOTICE: Based off of https://github.com/collabora/OSVR-Vive-Libre
+ Originally Copyright 2016 Philipp Zabel
+ Originally Copyright 2016 Lubosz Sarnecki <lubosz.sarnecki@collabora.co.uk>
+ Originally Copyright (C) 2013 Fredrik Hultin
+ Originally Copyright (C) 2013 Jakob Bornecrantz
+
+All other code is:
+
MIT License
-Copyright (c) 2016 CNLohr
+Copyright (c) <>< 2016 CNLohr
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 3ea8406..6a5be4e 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,47 @@
# libsurvive
-High-performance Vive Library
+
+**WARNING PROJECT NOT YET IN EXPERIMENTAL PHASE**
+
+## Introduction
+High-performance HTC Vive Library
+
+I say "high-performance" really this project is based tightly off of OSVR-Vive-Libre, but, specifically is an attempt to:
+
+1) Minimize external libraries. Actual reason for starting this: Downloading all of the libraries needed for OSVR-Vive-Libre maxed out my data plan.
+2) Put it under an open-source instead of a force-source license. (GPL to MIT/X11)
+3) Write it in C.
+4) Avoid extra layers where convenient.
+5) (long shot) Make the vive vivable for use with Intel Integrated Graphics systems.
+
+
+Will I succeed? Probably not.
+
+Definitely going to try!
+
+
+## External dependencies
+
+* libUSB
+* pthread
+* (planned, may not be needed) lapack
+
+If I ever get to video output... OpenGL.
+
+## Architecture
+
+There is an internal representation and an external representation. These lines may get blurred. Internal representation lives in .h files in the ```src/``` folder. External lives in ```include/``` folder.
+
+It is written in some fairly stout "layers" which are basically just function calls:
+
+| Layer | Description | Status |
+| ------------------------------------------------ |
+| survive_usb.c | Data is taken in at "survive_usb.c" from libusb. | Done |
+| survive_data.c | Raw HID messages are processed into logical "light" "analog" and "imu" messages. | Mostly done, Missing light data from controllers, and lighthouse data. |
+| survive_process.c | Process the high-level data into solutions for | Not yet started. Will be done by ultramn |
+
+I may or may not read data from the Vive regarding configuration. If I do, it would be added to the survive_usb.c
+
+
+
+
+
diff --git a/src/survive_data.c b/src/survive_data.c
index fae75f5..e9ca274 100644
--- a/src/survive_data.c
+++ b/src/survive_data.c
@@ -3,13 +3,13 @@
#include "survive_internal.h"
#include <stdint.h>
+#include <string.h>
#define POP1 (*(readdata++))
#define POP2 (*(((uint16_t*)((readdata+=2)-2))))
#define POP4 (*(((uint32_t*)((readdata+=4)-4))))
-
struct LightcapElement
{
uint8_t sensor_id;
@@ -70,6 +70,8 @@ static void handle_lightcap( struct SurviveObject * so, struct LightcapElement *
static void handle_watchman( struct SurviveObject * w, uint8_t * readdata )
{
+ uint8_t startread[29];
+ memcpy( startread, readdata, 29 );
uint8_t time1 = POP1;
uint8_t qty = POP1;
uint8_t time2 = POP1;
@@ -143,6 +145,12 @@ static void handle_watchman( struct SurviveObject * w, uint8_t * readdata )
if( qty )
{
qty++;
+ readdata--;
+ *readdata = type;
+ //Put type back on stack. It might have changed
+ //from above.
+
+
#if 0 //Doesn't work!!!!
int reads = qty/6;
@@ -163,14 +171,34 @@ static void handle_watchman( struct SurviveObject * w, uint8_t * readdata )
}
#endif
+ //What does post data look like?
+
+ //1) code, code, code, PAAYYLOOAAADDD
+ //"code" typically has 2 or fewer bits in word set.
+ // code = 0x00 = expect 5 bytes
+ // code = 0x08 = expect 5 bytes
+ // code = 0x10 = expect 5 bytes
+ // code = 0x5c = ???? ... 12?
+ // code = 0x91 = ???? ... 25 bytes?
+
+
#if 1
- printf( "POST %d: %4d %02x (%02x%02x) - ", propset, qty, type, time1, time2 );
+ printf( "POST %d: %4d (%02x%02x) - ", propset, qty, time1, time2 );
for( i = 0; i < qty; i++ )
{
printf( "%02x ", readdata[i] );
}
printf("\n");
#endif
+
+#if 0
+ printf( " SRR: " );
+ for( i = 0; i < 29; i++ )
+ {
+ printf( "%02x ", startread[i] );
+ }
+ printf( "\n" );
+#endif
}
return;
diff --git a/src/survive_process.c b/src/survive_process.c
index 07fb990..18cc1da 100644
--- a/src/survive_process.c
+++ b/src/survive_process.c
@@ -8,8 +8,8 @@ void survive_light_process( struct SurviveObject * so, int sensor_id, int acode,
void survive_imu_process( struct SurviveObject * so, int16_t * accelgyro, uint32_t timecode, int id )
{
- if( so->codename[0] != 'H' )
- {
- printf( "I %s %d %d %d %d %d %d %d %d\n", so->codename, timecode, accelgyro[0], accelgyro[1], accelgyro[2], accelgyro[3], accelgyro[4], accelgyro[5], id );
- }
+// if( so->codename[0] != 'H' )
+// {
+// printf( "I %s %d %d %d %d %d %d %d %d\n", so->codename, timecode, accelgyro[0], accelgyro[1], accelgyro[2], accelgyro[3], accelgyro[4], accelgyro[5], id );
+// }
}
diff --git a/src/survive_usb.c b/src/survive_usb.c
index 92e61db..8ca2b87 100644
--- a/src/survive_usb.c
+++ b/src/survive_usb.c
@@ -1,8 +1,22 @@
+//<>< (C) 2016 C. Lohr
+//
+//Based off of https://github.com/collabora/OSVR-Vive-Libre
+// Originally Copyright 2016 Philipp Zabel
+// Originally Copyright 2016 Lubosz Sarnecki <lubosz.sarnecki@collabora.co.uk>
+// Originally Copyright (C) 2013 Fredrik Hultin
+// Originally Copyright (C) 2013 Jakob Bornecrantz
+//
+//But, re-written as best as I can to get it put under a /real/ open souce license.
+//If there are portions of the code too similar to the original, I would like to know
+//so they can be re-written.
+
+
#include "survive_internal.h"
#include <libusb-1.0/libusb.h>
#include <stdio.h>
#include <unistd.h> //sleep if I ever use it.
+
const short vidpids[] = {
0x0bb4, 0x2c87, 0, //The main HTC HMD device
0x28de, 0x2000, 0, //Valve lighthouse
@@ -18,19 +32,20 @@ const char * devnames[] = {
}; //length MAX_USB_INTERFACES
-static void handle_transfer(struct libusb_transfer* transfer) {
- struct SurviveUSBInterface * iface = transfer->user_data;
+static void handle_transfer(struct libusb_transfer* transfer)
+{
+ struct SurviveUSBInterface * iface = transfer->user_data;
struct SurviveContext * ctx = iface->ctx;
if( transfer->status != LIBUSB_TRANSFER_COMPLETED )
{
- SV_ERROR("Transfer problem %d with %s", transfer->status, iface->hname );
+ SV_ERROR("Transfer problem %d with %s", transfer->status, iface->hname );
SV_KILL();
return;
}
iface->actual_len = transfer->actual_length;
- iface->cb( iface );
+ iface->cb( iface );
if( libusb_submit_transfer(transfer) )
{
@@ -60,7 +75,7 @@ static int AttachInterface( struct SurviveContext * ctx, int which_interface_am_
libusb_fill_interrupt_transfer( tx, devh, endpoint, iface->buffer, INTBUFFSIZE, handle_transfer, iface, 0);
int rc = libusb_submit_transfer( tx );
- if( rc )
+ if( rc )
{
SV_ERROR( "Error: Could not submit transfer for %s (Code %d)", hname, rc );
return 6;
@@ -158,8 +173,7 @@ int survive_usb_init( struct SurviveContext * ctx )
}
libusb_set_auto_detach_kernel_driver( ctx->udev[i], 1 );
-
- for (int j = 0; j < conf->bNumInterfaces; j++ )
+ for (int j = 0; j < conf->bNumInterfaces; j++ )
{
#if 0
if (libusb_kernel_driver_active(ctx->udev[i], j) == 1) {
@@ -226,9 +240,6 @@ int survive_usb_init( struct SurviveContext * ctx )
usleep( 1000 );
}
#endif
-
- //hret = hid_send_feature_report(drv->hmd_device, vive_magic_enable_lighthouse, sizeof(vive_magic_enable_lighthouse));
- //vl_debug("enable lighthouse magic: %d\n", hret);
}
#endif