Created
August 22, 2019 12:31
-
-
Save ChristophHaag/323974337969c119874c251ebbf0e14b to your computer and use it in GitHub Desktop.
minimal example for bChanged issue since SteamVR 1.7.7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// g++ actions.cpp -o actions -lopenvr_api | |
#include <stdio.h> | |
#include <openvr/openvr.h> | |
#include <chrono> | |
#include <thread> | |
using namespace vr; | |
void check_error(int line, EVRInitError error) { if (error != 0) printf("%d: error %s\n", line, VR_GetVRInitErrorAsSymbol(error)); } | |
void check_input_error(int line, EVRInputError error) { if (error != EVRInputError::VRInputError_None) { printf("Input error at %d: %d\n", line, error); exit (1); } } | |
int main(int argc, char **argv) { | |
if (argc < 2) { | |
printf("Usage:\n\t%s /path/to/actions.json", argv[0]); | |
return 1; | |
} | |
const char *manifest_path = argv[1]; | |
EVRInitError error; | |
VR_Init(&error, vr::VRApplication_Overlay); | |
check_error(__LINE__, error); | |
EVRInputError inputerr = VRInput()->SetActionManifestPath(manifest_path); | |
if (inputerr != EVRInputError::VRInputError_None) printf("Input error %d: %d\n", __LINE__, inputerr); | |
VRActionSetHandle_t test_handle = 0; | |
inputerr = VRInput()->GetActionSetHandle ("/actions/test", &test_handle); | |
check_input_error(__LINE__, inputerr); | |
VRActionHandle_t trigger_handle = 0; | |
inputerr = VRInput()->GetActionHandle ("/actions/test/in/trigger", &trigger_handle); | |
check_input_error(__LINE__, inputerr); | |
VRActionSetHandle_t test2_handle = 0; | |
inputerr = VRInput()->GetActionSetHandle ("/actions/test2", &test2_handle); | |
check_input_error(__LINE__, inputerr); | |
VRActionHandle_t pose_handle = 0; | |
inputerr = VRInput()->GetActionHandle ("/actions/test2/in/hand_pose", &pose_handle); | |
check_input_error(__LINE__, inputerr); | |
VRInputValueHandle_t right_hand_handle = 0; | |
inputerr =VRInput()->GetInputSourceHandle ("/user/hand/right", &right_hand_handle); | |
check_input_error(__LINE__, inputerr); | |
struct VRActiveActionSet_t active_test_action_set = {}; | |
active_test_action_set.ulActionSet = test_handle; | |
struct VRActiveActionSet_t active_test2_action_set = {}; | |
active_test2_action_set.ulActionSet = test2_handle; | |
while (true) { | |
// polling the /actions/test2 set before the /actions/test makes data.bChanged below always false | |
if (true) { | |
inputerr = VRInput()->UpdateActionState(&active_test2_action_set, sizeof(active_test2_action_set), 1); | |
check_input_error(__LINE__, inputerr); | |
/* | |
InputPoseActionData_t pose_data; | |
inputerr = VRInput()->GetPoseActionDataRelativeToNow(pose_handle, TrackingUniverseStanding, 0, &pose_data, sizeof(pose_data), right_hand_handle); | |
check_input_error(__LINE__, inputerr); | |
*/ | |
} | |
inputerr = VRInput()->UpdateActionState(&active_test_action_set, sizeof(active_test_action_set), 1); | |
check_input_error(__LINE__, inputerr); | |
InputDigitalActionData_t data; | |
inputerr = VRInput()->GetDigitalActionData (trigger_handle, &data, sizeof(data), right_hand_handle); | |
check_input_error(__LINE__, inputerr); | |
printf("Right Trigger State: %d, Changed: %d\n", data.bState, data.bChanged); | |
std::this_thread::sleep_for(std::chrono::milliseconds(100)); | |
} | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"default_bindings":[ | |
{ | |
"controller_type":"vive_controller", | |
"binding_url":"bindings_vive_controller.json" | |
}, | |
{ | |
"controller_type": "knuckles", | |
"binding_url": "bindings_vive_controller.json" | |
} | |
], | |
"actions":[ | |
{ | |
"name":"/actions/test/in/trigger", | |
"type":"boolean" | |
}, | |
{ | |
"name": "/actions/test2/in/hand_pose", | |
"type": "pose" | |
} | |
], | |
"action_sets": [ | |
{ | |
"name": "/actions/test", | |
"usage": "leftright" | |
}, | |
{ | |
"name": "/actions/test2", | |
"usage": "leftright" | |
} | |
], | |
"localization":[ | |
{ | |
"language_tag":"en_US", | |
"/actions/test/in/trigger":"Trigger", | |
"/actions/test2/in/hand_pose":"Hand Pose" | |
} | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"bindings" : { | |
"/actions/test" : { | |
"sources" : [ | |
{ | |
"path": "/user/hand/right/input/trigger", | |
"mode": "button", | |
"inputs": { | |
"click": { | |
"output": "/actions/test/in/trigger" | |
} | |
} | |
}, | |
{ | |
"path": "/user/hand/left/input/trigger", | |
"mode": "button", | |
"inputs": { | |
"click": { | |
"output": "/actions/test/in/trigger" | |
} | |
} | |
}, | |
{ | |
"output": "/actions/test2/in/hand_pose", | |
"path": "/user/hand/right/pose/raw" | |
}, | |
{ | |
"output": "/actions/test2/in/hand_pose", | |
"path": "/user/hand/left/pose/raw" | |
} | |
] | |
} | |
}, | |
"controller_type": "vive_controller", | |
"description" : "Test bindings", | |
"name" : "Vive Controller" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment