Implement beta IVRInput system for testing
In order to test new system: Build and deploy application. Copy both files from IVRInput/ dir into the bin/win64 folder. Change const std::string m_actionManifestPath in steamivrinput.h to be directly to your action_manifest.json file. Run and turn on a Vive controller. Press the menu button. If logs say "NEXT SONG SET!" it works.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"default_bindings": [
|
||||
{
|
||||
"controller_type": "vive_controller",
|
||||
"binding_url": "legacy_actions.json"
|
||||
}
|
||||
],
|
||||
"actions": [
|
||||
{
|
||||
"name": "/actions/main/in/PlayNextTrack",
|
||||
"requirement": "optional",
|
||||
"type": "boolean"
|
||||
}
|
||||
],
|
||||
"action_sets": [
|
||||
{
|
||||
"name": "/actions/main",
|
||||
"usage": "leftright"
|
||||
}
|
||||
],
|
||||
"localization" : [
|
||||
{
|
||||
"language_tag": "en",
|
||||
|
||||
"/actions/main" : "My Game Actions",
|
||||
|
||||
"/actions/main/in/PlayNextTrack" : "Play Next Track"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"alias_info" : {},
|
||||
"app_key" : "matzman666.advancedsettings",
|
||||
"bindings" : {
|
||||
"/actions/main" : {
|
||||
"sources" : [
|
||||
{
|
||||
"inputs" : {
|
||||
"click" : {
|
||||
"output" : "/actions/main/in/playnexttrack"
|
||||
}
|
||||
},
|
||||
"mode" : "button",
|
||||
"path" : "/user/hand/left/input/application_menu"
|
||||
},
|
||||
{
|
||||
"inputs" : {
|
||||
"click" : {
|
||||
"output" : "/actions/main/in/playnexttrack"
|
||||
}
|
||||
},
|
||||
"mode" : "button",
|
||||
"path" : "/user/hand/right/input/application_menu"
|
||||
},
|
||||
{
|
||||
"inputs" : {
|
||||
"click" : {
|
||||
"output" : "/actions/main/in/playnexttrack"
|
||||
}
|
||||
},
|
||||
"mode" : "button",
|
||||
"path" : "/user/hand/right/input/grip"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"controller_type" : "vive_controller",
|
||||
"description" : "",
|
||||
"name" : "My My Test configuration for Vive Controller",
|
||||
"options" : {},
|
||||
"simulated_actions" : []
|
||||
}
|
||||
@@ -58,8 +58,8 @@ SOURCES += src/main.cpp\
|
||||
src/utils/ChaperoneUtils.cpp \
|
||||
src/tabcontrollers/audiomanager/AudioManagerDummy.cpp \
|
||||
src/tabcontrollers/keyboardinput/KeyboardInputDummy.cpp \
|
||||
src/overlaycontroller/openvr_init.cpp
|
||||
|
||||
src/overlaycontroller/openvr_init.cpp \
|
||||
src/steamivrinput.cpp
|
||||
|
||||
HEADERS += src/overlaycontroller.h \
|
||||
src/tabcontrollers/AudioTabController.h \
|
||||
@@ -79,7 +79,8 @@ HEADERS += src/overlaycontroller.h \
|
||||
src/utils/ChaperoneUtils.h \
|
||||
src/tabcontrollers/audiomanager/AudioManagerDummy.h \
|
||||
src/tabcontrollers/keyboardinput/KeyboardInputDummy.h \
|
||||
src/overlaycontroller/openvr_init.h
|
||||
src/overlaycontroller/openvr_init.h \
|
||||
src/steamivrinput.h
|
||||
|
||||
win32 {
|
||||
SOURCES += src/tabcontrollers/audiomanager/AudioManagerWindows.cpp \
|
||||
|
||||
@@ -118,7 +118,7 @@ OverlayController::OverlayController( bool desktopMode,
|
||||
nullptr, "OpenVR Advanced Settings Overlay", "Is OpenVR running?" );
|
||||
throw std::runtime_error( std::string( "No Overlay interface" ) );
|
||||
}
|
||||
|
||||
m_actions.Init( false );
|
||||
// Init controllers
|
||||
m_steamVRTabController.initStage1();
|
||||
m_chaperoneTabController.initStage1();
|
||||
@@ -477,6 +477,13 @@ void OverlayController::OnTimeoutPumpEvents()
|
||||
if ( !vr::VRSystem() )
|
||||
return;
|
||||
|
||||
m_actions.Loop();
|
||||
|
||||
if ( m_actions.nextSongSet() )
|
||||
{
|
||||
LOG( INFO ) << "NEXT SONG SET!";
|
||||
}
|
||||
|
||||
vr::VREvent_t vrEvent;
|
||||
bool chaperoneDataAlreadyUpdated = false;
|
||||
while ( pollNextEvent( m_ulOverlayHandle, &vrEvent ) )
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
#include "tabcontrollers/UtilitiesTabController.h"
|
||||
#include "tabcontrollers/AccessibilityTabController.h"
|
||||
|
||||
#include "steamivrinput.h"
|
||||
|
||||
// application namespace
|
||||
namespace advsettings
|
||||
{
|
||||
@@ -90,6 +92,7 @@ private:
|
||||
|
||||
public: // I know it's an ugly hack to make them public to enable external
|
||||
// access, but I am too lazy to implement getters.
|
||||
SteamIVRInput m_actions;
|
||||
SteamVRTabController m_steamVRTabController;
|
||||
ChaperoneTabController m_chaperoneTabController;
|
||||
MoveCenterTabController m_moveCenterTabController;
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
#include "steamivrinput.h"
|
||||
#include <openvr.h>
|
||||
#include <iostream>
|
||||
|
||||
void SteamIVRInput::Init( const bool init )
|
||||
{
|
||||
if ( init )
|
||||
{
|
||||
auto initError = vr::VRInitError_None;
|
||||
vr::VR_Init( &initError, vr::VRApplication_Overlay );
|
||||
if ( initError != vr::VRInitError_None )
|
||||
{
|
||||
std::cout << "SteamVR init error.";
|
||||
}
|
||||
}
|
||||
|
||||
auto error
|
||||
= vr::VRInput()->SetActionManifestPath( m_actionManifestPath.c_str() );
|
||||
if ( error != vr::EVRInputError::VRInputError_None )
|
||||
{
|
||||
std::cout << "Action manifest error\n";
|
||||
}
|
||||
|
||||
// Get action handle
|
||||
error = vr::VRInput()->GetActionHandle( "/actions/main/in/PlayNextTrack",
|
||||
&m_nextSongHandler );
|
||||
if ( error != vr::EVRInputError::VRInputError_None )
|
||||
{
|
||||
std::cout << "Handle error.\n";
|
||||
}
|
||||
|
||||
error = vr::VRInput()->GetActionSetHandle( "/actions/main",
|
||||
&m_mainSetHandler );
|
||||
if ( error != vr::EVRInputError::VRInputError_None )
|
||||
{
|
||||
std::cout << "Handle error.\n";
|
||||
}
|
||||
|
||||
m_activeActionSet.ulActionSet = m_mainSetHandler;
|
||||
m_activeActionSet.ulRestrictedToDevice = vr::k_ulInvalidInputValueHandle;
|
||||
m_activeActionSet.nPriority = 0;
|
||||
}
|
||||
|
||||
bool SteamIVRInput::nextSongSet()
|
||||
{
|
||||
auto e = vr::VRInput()->GetDigitalActionData(
|
||||
m_nextSongHandler,
|
||||
&m_nextSongData,
|
||||
sizeof( m_nextSongData ),
|
||||
vr::k_ulInvalidInputValueHandle );
|
||||
|
||||
if ( e != vr::EVRInputError::VRInputError_None )
|
||||
{
|
||||
std::cout << e;
|
||||
std::cout << "GetDigitalAction error.\n";
|
||||
}
|
||||
|
||||
if ( m_nextSongData.bActive )
|
||||
{
|
||||
std::cout << "Action Set Active!\n";
|
||||
}
|
||||
|
||||
return m_nextSongData.bState;
|
||||
}
|
||||
|
||||
void SteamIVRInput::Loop()
|
||||
{
|
||||
auto error = vr::VRInput()->UpdateActionState(
|
||||
&m_activeActionSet, sizeof( m_activeActionSet ), 1 );
|
||||
|
||||
if ( error != vr::EVRInputError::VRInputError_None )
|
||||
{
|
||||
std::cout << "Loop error.\n";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef STEAMIVRINPUT_H
|
||||
#define STEAMIVRINPUT_H
|
||||
|
||||
#include <openvr.h>
|
||||
|
||||
class SteamIVRInput
|
||||
{
|
||||
public:
|
||||
void Init( const bool init );
|
||||
void Loop();
|
||||
bool nextSongSet();
|
||||
|
||||
private:
|
||||
const std::string m_actionManifestPath
|
||||
= "YOUR_PATH_HERE\\action_manifest.json";
|
||||
vr::VRActionHandle_t m_nextSongHandler = {};
|
||||
vr::VRActionSetHandle_t m_mainSetHandler = {};
|
||||
vr::VRActiveActionSet_t m_activeActionSet = {};
|
||||
vr::InputDigitalActionData_t m_nextSongData = {};
|
||||
};
|
||||
|
||||
#endif // STEAMIVRINPUT_H
|
||||
Reference in New Issue
Block a user