Add the ability to disablee keybindings (closes #2238)

This commit is contained in:
Alexander Bock
2022-10-14 11:24:44 +02:00
parent b8c0a92c7c
commit 524b78f5d2
3 changed files with 27 additions and 8 deletions

View File

@@ -90,6 +90,8 @@ public:
// Callback functions
void keyboardCallback(Key key, KeyModifier modifier, KeyAction action);
bool disabledKeybindings() const;
void mouseButtonCallback(MouseButton button, MouseAction action);
void mousePositionCallback(double x, double y);
void mouseScrollWheelCallback(double pos);
@@ -169,6 +171,7 @@ private:
std::optional<NavigationState> _pendingNavigationState;
properties::BoolProperty _disableKeybindings;
properties::BoolProperty _disableMouseInputs;
properties::BoolProperty _disableJoystickInputs;
properties::BoolProperty _useKeyFrameInteraction;

View File

@@ -1443,7 +1443,11 @@ void OpenSpaceEngine::keyboardCallback(Key key, KeyModifier mod, KeyAction actio
}
global::navigationHandler->keyboardCallback(key, mod, action);
global::keybindingManager->keyboardCallback(key, mod, action);
if (!global::navigationHandler->disabledKeybindings()) {
global::keybindingManager->keyboardCallback(key, mod, action);
}
global::interactionMonitor->markInteraction();
}

View File

@@ -59,20 +59,26 @@ namespace {
constexpr std::string_view _loggerCat = "NavigationHandler";
using namespace openspace;
constexpr properties::Property::PropertyInfo KeyDisableMouseInputInfo = {
constexpr openspace::properties::Property::PropertyInfo DisableKeybindingsInfo = {
"DisableKeybindings",
"Disable all Keybindings",
"Disables all keybindings without removing them. Please note that this does not "
"apply to the key to open the console"
};
constexpr openspace::properties::Property::PropertyInfo DisableMouseInputInfo = {
"DisableMouseInputs",
"Disable all mouse inputs",
"Disables all mouse inputs and prevents them from affecting the camera"
};
constexpr properties::Property::PropertyInfo KeyDisableJoystickInputInfo = {
constexpr openspace::properties::Property::PropertyInfo DisableJoystickInputInfo = {
"DisableJoystickInputs",
"Disable all joystick inputs",
"Disables all joystick inputs and prevents them from affecting the camera"
};
constexpr properties::Property::PropertyInfo KeyFrameInfo = {
constexpr openspace::properties::Property::PropertyInfo FrameInfo = {
"UseKeyFrameInteraction",
"Use keyframe interaction",
"If this is set to 'true' the entire interaction is based off key frames rather "
@@ -84,13 +90,15 @@ namespace openspace::interaction {
NavigationHandler::NavigationHandler()
: properties::PropertyOwner({ "NavigationHandler" })
, _disableMouseInputs(KeyDisableMouseInputInfo, false)
, _disableJoystickInputs(KeyDisableJoystickInputInfo, false)
, _useKeyFrameInteraction(KeyFrameInfo, false)
, _disableKeybindings(DisableKeybindingsInfo, false)
, _disableMouseInputs(DisableMouseInputInfo, false)
, _disableJoystickInputs(DisableJoystickInputInfo, false)
, _useKeyFrameInteraction(FrameInfo, false)
{
addPropertySubOwner(_orbitalNavigator);
addPropertySubOwner(_pathNavigator);
addProperty(_disableKeybindings);
addProperty(_disableMouseInputs);
addProperty(_disableJoystickInputs);
addProperty(_useKeyFrameInteraction);
@@ -368,6 +376,10 @@ void NavigationHandler::keyboardCallback(Key key, KeyModifier modifier, KeyActio
_keyboardInputState.keyboardCallback(key, modifier, action);
}
bool NavigationHandler::disabledKeybindings() const {
return _disableKeybindings;
}
NavigationState NavigationHandler::navigationState() const {
const SceneGraphNode* referenceFrame = _orbitalNavigator.followingAnchorRotation() ?
_orbitalNavigator.anchorNode() :