platform states, edit controller mapping, separate mac/win delete

This commit is contained in:
David Back 2018-08-27 14:53:13 -07:00
parent 467fe56103
commit b6edb2c9d6
3 changed files with 42 additions and 4 deletions

View file

@ -726,6 +726,9 @@ static const QString STATE_SNAP_TURN = "SnapTurn";
static const QString STATE_ADVANCED_MOVEMENT_CONTROLS = "AdvancedMovement";
static const QString STATE_GROUNDED = "Grounded";
static const QString STATE_NAV_FOCUSED = "NavigationFocused";
static const QString STATE_PLATFORM_WINDOWS = "PlatformWindows";
static const QString STATE_PLATFORM_MAC = "PlatformMac";
static const QString STATE_PLATFORM_ANDROID = "PlatformAndroid";
// Statically provided display and input plugins
extern DisplayPluginList getDisplayPlugins();
@ -909,7 +912,8 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
DependencyManager::set<MessagesClient>();
controller::StateController::setStateVariables({ { STATE_IN_HMD, STATE_CAMERA_FULL_SCREEN_MIRROR,
STATE_CAMERA_FIRST_PERSON, STATE_CAMERA_THIRD_PERSON, STATE_CAMERA_ENTITY, STATE_CAMERA_INDEPENDENT,
STATE_SNAP_TURN, STATE_ADVANCED_MOVEMENT_CONTROLS, STATE_GROUNDED, STATE_NAV_FOCUSED } });
STATE_SNAP_TURN, STATE_ADVANCED_MOVEMENT_CONTROLS, STATE_GROUNDED, STATE_NAV_FOCUSED,
STATE_PLATFORM_WINDOWS, STATE_PLATFORM_MAC, STATE_PLATFORM_WINDOWS } });
DependencyManager::set<UserInputMapper>();
DependencyManager::set<controller::ScriptingInterface, ControllerScriptingInterface>();
DependencyManager::set<InterfaceParentFinder>();
@ -1683,6 +1687,27 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
_applicationStateDevice->setInputVariant(STATE_NAV_FOCUSED, []() -> float {
return DependencyManager::get<OffscreenUi>()->navigationFocused() ? 1 : 0;
});
_applicationStateDevice->setInputVariant(STATE_PLATFORM_WINDOWS, []() -> float {
#if defined(Q_OS_WIN)
return 1;
#else
return 0;
#endif
});
_applicationStateDevice->setInputVariant(STATE_PLATFORM_MAC, []() -> float {
#if defined(Q_OS_MAC)
return 1;
#else
return 0;
#endif
});
_applicationStateDevice->setInputVariant(STATE_PLATFORM_ANDROID, []() -> float {
#if defined(Q_OS_ANDROID)
return 1;
#else
return 0;
#endif
});
// Setup the _keyboardMouseDevice, _touchscreenDevice, _touchscreenVirtualPadDevice and the user input mapper with the default bindings
userInputMapper->registerDevice(_keyboardMouseDevice->getInputDevice());

View file

@ -302,6 +302,8 @@ controller::Input::NamedVector KeyboardMouseDevice::InputDevice::getAvailableInp
availableInputs.append(Input::NamedPair(makeInput(Qt::Key_PageDown), QKeySequence(Qt::Key_PageDown).toString()));
availableInputs.append(Input::NamedPair(makeInput(Qt::Key_Tab), QKeySequence(Qt::Key_Tab).toString()));
availableInputs.append(Input::NamedPair(makeInput(Qt::Key_Control), "Control"));
availableInputs.append(Input::NamedPair(makeInput(Qt::Key_Delete), "Delete"));
availableInputs.append(Input::NamedPair(makeInput(Qt::Key_Backspace), QKeySequence(Qt::Key_Backspace).toString()));
availableInputs.append(Input::NamedPair(makeInput(Qt::LeftButton), "LeftMouseButton"));
availableInputs.append(Input::NamedPair(makeInput(Qt::MiddleButton), "MiddleMouseButton"));

View file

@ -20,6 +20,8 @@
var EDIT_TOGGLE_BUTTON = "com.highfidelity.interface.system.editButton";
var CONTROLLER_MAPPING_NAME = "com.highfidelity.editMode";
Script.include([
"libraries/stringHelpers.js",
"libraries/dataViewHelpers.js",
@ -860,6 +862,7 @@ var toolBar = (function () {
cameraManager.disable();
selectionDisplay.triggerMapping.disable();
tablet.landscape = false;
Controller.disableMapping(CONTROLLER_MAPPING_NAME);
} else {
if (shouldUseEditTabletApp()) {
tablet.loadQMLSource("hifi/tablet/Edit.qml", true);
@ -876,6 +879,7 @@ var toolBar = (function () {
selectionDisplay.triggerMapping.enable();
print("starting tablet in landscape mode");
tablet.landscape = true;
Controller.enableMapping(CONTROLLER_MAPPING_NAME);
// Not sure what the following was meant to accomplish, but it currently causes
// everybody else to think that Interface has lost focus overall. fogbugzid:558
// Window.setFocus();
@ -1859,9 +1863,7 @@ var keyReleaseEvent = function (event) {
cameraManager.keyReleaseEvent(event);
}
// since sometimes our menu shortcut keys don't work, trap our menu items here also and fire the appropriate menu items
if (event.text === "DELETE") {
deleteSelectedEntities();
} else if (event.text === 'd' && event.isControl) {
if (event.text === 'd' && event.isControl) {
selectionManager.clearSelections();
} else if (event.text === "t") {
selectionDisplay.toggleSpaceMode();
@ -1893,6 +1895,15 @@ var keyReleaseEvent = function (event) {
Controller.keyReleaseEvent.connect(keyReleaseEvent);
Controller.keyPressEvent.connect(keyPressEvent);
function deleteKey(value) {
if (value === 0) { // on release
deleteSelectedEntities();
}
}
var mapping = Controller.newMapping(CONTROLLER_MAPPING_NAME);
mapping.from([Controller.Hardware.Keyboard.Delete]).when([Controller.Hardware.Application.PlatformWindows]).peek().to(deleteKey);
mapping.from([Controller.Hardware.Keyboard.Backspace]).when([Controller.Hardware.Application.PlatformMac]).peek().to(deleteKey);
function recursiveAdd(newParentID, parentData) {
if (parentData.children !== undefined) {
var children = parentData.children;