diff --git a/src/openvr/ivrinput.cpp b/src/openvr/ivrinput.cpp index be89508..48a7d2c 100644 --- a/src/openvr/ivrinput.cpp +++ b/src/openvr/ivrinput.cpp @@ -131,6 +131,9 @@ SteamIVRInput::SteamIVRInput() m_xAxisLockToggle( action_keys::xAxisLockToggle ), m_yAxisLockToggle( action_keys::yAxisLockToggle ), m_zAxisLockToggle( action_keys::zAxisLockToggle ), + m_keyboardOne( action_keys::keyboardOne ), + m_keyboardTwo( action_keys::keyboardTwo ), + m_keyboardThree( action_keys::keyboardThree ), m_chaperoneToggle( action_keys::chaperoneToggle ), m_pushToTalk( action_keys::pushToTalk ), m_leftHaptic( action_keys::hapticsLeft ), @@ -302,6 +305,19 @@ bool SteamIVRInput::proxState() return isDigitalActionActivatedConstant( m_pushToTalk ); } +bool SteamIVRInput::keyboardOne() +{ + return isDigitalActionActivatedOnce( m_keyboardOne ); +} + +bool SteamIVRInput::keyboardTwo() +{ + return isDigitalActionActivatedOnce( m_keyboardTwo ); +} +bool SteamIVRInput::keyboardThree() +{ + return isDigitalActionActivatedOnce( m_keyboardThree ); +} /*! Returns the action handle of the Left Haptic Action */ diff --git a/src/openvr/ivrinput.h b/src/openvr/ivrinput.h index 13b3f3b..e640316 100644 --- a/src/openvr/ivrinput.h +++ b/src/openvr/ivrinput.h @@ -49,6 +49,10 @@ namespace action_keys constexpr auto zAxisLockToggle = "/actions/misc/in/ZAxisLockToggle"; constexpr auto pushToTalk = "/actions/misc/in/PushToTalk"; + constexpr auto keyboardOne = "/actions/misc/in/KeyboardOne"; + constexpr auto keyboardTwo = "/actions/misc/in/KeyboardTwo"; + constexpr auto keyboardThree = "/actions/misc/in/KeyboardThree"; + constexpr auto hapticsLeft = "/actions/haptic/out/HapticsLeft"; constexpr auto hapticsRight = "/actions/haptic/out/HapticsRight"; constexpr auto proxSensor = "/actions/misc/in/ProxSensor"; @@ -139,6 +143,10 @@ public: bool pushToTalk(); + bool keyboardOne(); + bool keyboardTwo(); + bool keyboardThree(); + vr::VRActionHandle_t leftHapticActionHandle(); vr::VRActionHandle_t rightHapticActionHandle(); @@ -197,6 +205,11 @@ private: DigitalAction m_yAxisLockToggle; DigitalAction m_zAxisLockToggle; + // Keyboard Shortcuts + DigitalAction m_keyboardOne; + DigitalAction m_keyboardTwo; + DigitalAction m_keyboardThree; + // Misc Bindings DigitalAction m_chaperoneToggle; diff --git a/src/overlaycontroller.cpp b/src/overlaycontroller.cpp index e668650..f6be36a 100644 --- a/src/overlaycontroller.cpp +++ b/src/overlaycontroller.cpp @@ -21,6 +21,7 @@ #include #include "utils/Matrix.h" #include "openvr/overlay_utils.h" +#include "keyboard_input/input_sender.h" // application namespace namespace advsettings @@ -588,6 +589,42 @@ void OverlayController::processPushToTalkBindings() } } +void OverlayController::processKeyboardBindings() +{ + constexpr auto settingsKeyboardName = "keyboardShortcuts"; + + if ( m_actions.keyboardOne() ) + { + constexpr auto defaultDiscordMuteBinding = "^>m"; + // run keyboard + appSettings()->beginGroup( settingsKeyboardName ); + const auto commands + = appSettings() + ->value( "keyboardOne", defaultDiscordMuteBinding ) + .toString() + .toStdString(); + appSettings()->endGroup(); + sendStringAsInput( commands ); + } + if ( m_actions.keyboardTwo() ) + { + // run keyboard + appSettings()->beginGroup( settingsKeyboardName ); + const auto commands + = appSettings()->value( "keyboardTwo" ).toString().toStdString(); + appSettings()->endGroup(); + sendStringAsInput( commands ); + } + if ( m_actions.keyboardThree() ) + { + // run keyboard + appSettings()->beginGroup( settingsKeyboardName ); + const auto commands + = appSettings()->value( "keyboardThree" ).toString().toStdString(); + appSettings()->endGroup(); + sendStringAsInput( commands ); + } +} /*! Checks if an action has been activated and dispatches the related action if it has been. @@ -601,6 +638,8 @@ void OverlayController::processInputBindings() processPushToTalkBindings(); processChaperoneBindings(); + + processKeyboardBindings(); } // vsync implementation: diff --git a/src/overlaycontroller.h b/src/overlaycontroller.h index 8b3f752..1921fd8 100644 --- a/src/overlaycontroller.h +++ b/src/overlaycontroller.h @@ -135,6 +135,7 @@ private: void processMotionBindings(); void processPushToTalkBindings(); void processChaperoneBindings(); + void processKeyboardBindings(); public: OverlayController( bool desktopMode, bool noSound, QQmlEngine& qmlEngine ); diff --git a/src/package_files/action_manifest.json b/src/package_files/action_manifest.json index 4bcf9a6..f464e36 100644 --- a/src/package_files/action_manifest.json +++ b/src/package_files/action_manifest.json @@ -160,6 +160,21 @@ "name": "/actions/misc/in/ProxSensor", "requirement": "optional", "type": "boolean" + }, + { + "name": "/actions/misc/in/KeyboardOne", + "requirement": "optional", + "type": "boolean" + }, + { + "name": "/actions/misc/in/KeyboardTwo", + "requirement": "optional", + "type": "boolean" + }, + { + "name": "/actions/misc/in/KeyboardThree", + "requirement": "optional", + "type": "boolean" } ], @@ -220,7 +235,10 @@ "/actions/misc/in/ZAxisLockToggle" : "Z-Axis Lock Toggle", "/actions/misc/in/PushToTalk" : "Push To Talk", "/actions/misc/in/ChaperoneToggle" : "Chaperone Toggle", - "/actions/misc/in/ProxSensor" : "Proximity Sensor" + "/actions/misc/in/ProxSensor" : "Proximity Sensor", + "/actions/misc/in/KeyboardOne" : "Keyboard Shortcut One", + "/actions/misc/in/KeyboardTwo" : "Keyboard Shortcut Two", + "/actions/misc/in/KeyboardThree" : "Keyboard Shortcut Three" } ] } \ No newline at end of file