|
@@ -9,6 +9,7 @@
|
|
|
|
|
|
#include <openhmd.h>
|
|
|
#include <stdio.h>
|
|
|
+#include <stdlib.h>
|
|
|
|
|
|
void ohmd_sleep(double);
|
|
|
|
|
@@ -36,6 +37,11 @@ void print_infoi(ohmd_device* hmd, const char* name, int len, ohmd_int_value val
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
{
|
|
|
+ int device_idx = 0;
|
|
|
+
|
|
|
+ if(argc > 1)
|
|
|
+ device_idx = atoi(argv[1]);
|
|
|
+
|
|
|
ohmd_context* ctx = ohmd_ctx_create();
|
|
|
|
|
|
// Probe for devices
|
|
@@ -50,7 +56,7 @@ int main(int argc, char** argv)
|
|
|
// Print device information
|
|
|
for(int i = 0; i < num_devices; i++){
|
|
|
int device_class = 0, device_flags = 0;
|
|
|
- char* device_class_s[] = {"HMD", "Controller", "Generic Tracker", "Unknown"};
|
|
|
+ const char* device_class_s[] = {"HMD", "Controller", "Generic Tracker", "Unknown"};
|
|
|
|
|
|
ohmd_list_geti(ctx, i, OHMD_DEVICE_CLASS, &device_class);
|
|
|
ohmd_list_geti(ctx, i, OHMD_DEVICE_FLAGS, &device_flags);
|
|
@@ -68,8 +74,9 @@ int main(int argc, char** argv)
|
|
|
printf(" right controller: %s\n\n", device_flags & OHMD_DEVICE_FLAGS_RIGHT_CONTROLLER ? "yes" : "no");
|
|
|
}
|
|
|
|
|
|
- // Open default device (0)
|
|
|
- ohmd_device* hmd = ohmd_list_open_device(ctx, 0);
|
|
|
+ // Open specified device idx or 0 (default) if nothing specified
|
|
|
+ printf("opening device: %d\n", device_idx);
|
|
|
+ ohmd_device* hmd = ohmd_list_open_device(ctx, device_idx);
|
|
|
|
|
|
if(!hmd){
|
|
|
printf("failed to open device: %s\n", ohmd_ctx_get_error(ctx));
|
|
@@ -93,12 +100,28 @@ int main(int argc, char** argv)
|
|
|
print_infof(hmd, "distortion k:", 6, OHMD_DISTORTION_K);
|
|
|
|
|
|
print_infoi(hmd, "digital button count:", 1, OHMD_BUTTON_COUNT);
|
|
|
- print_infoi(hmd, "analog axis count: ", 1, OHMD_ANALOG_AXIS_COUNT);
|
|
|
+ print_infoi(hmd, "control count: ", 1, OHMD_CONTROL_COUNT);
|
|
|
|
|
|
- printf("\n");
|
|
|
+ int control_count;
|
|
|
+ ohmd_device_geti(hmd, OHMD_CONTROL_COUNT, &control_count);
|
|
|
+
|
|
|
+ const char* controls_fn_str[] = { "generic", "trigger", "trigger_click", "squeeze", "menu", "home",
|
|
|
+ "analog-x", "analog-y", "anlog_press", "button-a", "button-b", "button-x", "button-y"};
|
|
|
+
|
|
|
+ const char* controls_type_str[] = {"digital", "analog"};
|
|
|
+
|
|
|
+ int controls_fn[64];
|
|
|
+ int controls_types[64];
|
|
|
+
|
|
|
+ ohmd_device_geti(hmd, OHMD_CONTROLS_FUNCTIONS, controls_fn);
|
|
|
+ ohmd_device_geti(hmd, OHMD_CONTROLS_TYPES, controls_types);
|
|
|
+
|
|
|
+ printf("%-25s", "controls:");
|
|
|
+ for(int i = 0; i < control_count; i++){
|
|
|
+ printf("%s (%s)%s", controls_fn_str[controls_fn[i]], controls_type_str[controls_types[i]], i == control_count - 1 ? "" : ", ");
|
|
|
+ }
|
|
|
|
|
|
- int analog_axis_count;
|
|
|
- ohmd_device_geti(hmd, OHMD_ANALOG_AXIS_COUNT, &analog_axis_count);
|
|
|
+ printf("\n\n");
|
|
|
|
|
|
// Ask for n rotation quaternions and position vectors
|
|
|
for(int i = 0; i < 10000; i++){
|
|
@@ -116,10 +139,10 @@ int main(int argc, char** argv)
|
|
|
|
|
|
// read analog axes
|
|
|
float axes[256];
|
|
|
- ohmd_device_getf(hmd, OHMD_ANALOG_AXES_STATE, axes);
|
|
|
+ ohmd_device_getf(hmd, OHMD_CONTROLS_STATE, axes);
|
|
|
|
|
|
- printf("%-25s", "axes:");
|
|
|
- for(int i = 0; i < analog_axis_count; i++)
|
|
|
+ printf("%-25s", "controls:");
|
|
|
+ for(int i = 0; i < control_count; i++)
|
|
|
{
|
|
|
printf("%f ", axes[i]);
|
|
|
}
|