add more inputs to controller mapping

This commit is contained in:
David Back 2018-08-27 16:35:36 -07:00
parent 75d7bf0424
commit f81fe6b29f
2 changed files with 42 additions and 24 deletions

View file

@ -304,6 +304,8 @@ controller::Input::NamedVector KeyboardMouseDevice::InputDevice::getAvailableInp
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::Key_BracketLeft), "BracketLeft"));
availableInputs.append(Input::NamedPair(makeInput(Qt::Key_BracketRight), "BracketRight"));
availableInputs.append(Input::NamedPair(makeInput(Qt::LeftButton), "LeftMouseButton"));
availableInputs.append(Input::NamedPair(makeInput(Qt::MiddleButton), "MiddleMouseButton"));

View file

@ -1863,28 +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 === 'd' && event.isControl) {
selectionManager.clearSelections();
} else if (event.text === "t") {
selectionDisplay.toggleSpaceMode();
} else if (event.text === "f") {
if (isActive) {
if (selectionManager.hasSelection()) {
cameraManager.enable();
cameraManager.focus(selectionManager.worldPosition,
selectionManager.worldDimensions,
Menu.isOptionChecked(MENU_EASE_ON_FOCUS));
}
}
} else if (event.text === '[') {
if (isActive) {
cameraManager.enable();
}
} else if (event.text === 'g') {
if (isActive && selectionManager.hasSelection()) {
grid.moveToSelection();
}
} else if (event.key === KEY_P && event.isControl && !event.isAutoRepeat ) {
if (event.key === KEY_P && event.isControl && !event.isAutoRepeat) {
if (event.isShifted) {
unparentSelectedEntities();
} else {
@ -1900,9 +1879,46 @@ function deleteKey(value) {
deleteSelectedEntities();
}
}
function deselectKey(value) {
if (value === 0) { // on release
selectionManager.clearSelections();
}
}
function toggleKey(value) {
if (value === 0) { // on release
selectionDisplay.toggleSpaceMode();
}
}
function focusKey(value) {
if (value === 0) { // on release
if (selectionManager.hasSelection()) {
cameraManager.enable();
cameraManager.focus(selectionManager.worldPosition,
selectionManager.worldDimensions,
Menu.isOptionChecked(MENU_EASE_ON_FOCUS));
}
}
}
function cameraKey(value) {
if (value === 0) { // on release
cameraManager.enable();
}
}
function gridKey(value) {
if (value === 0) { // on release
if (selectionManager.hasSelection()) {
grid.moveToSelection();
}
}
}
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);
mapping.from([Controller.Hardware.Keyboard.Delete]).when([Controller.Hardware.Application.PlatformWindows]).to(deleteKey);
mapping.from([Controller.Hardware.Keyboard.Backspace]).when([Controller.Hardware.Application.PlatformMac]).to(deleteKey);
mapping.from([Controller.Hardware.Keyboard.D]).when([Controller.Hardware.Keyboard.Control]).to(deselectKey);
mapping.from([Controller.Hardware.Keyboard.T]).to(toggleKey);
mapping.from([Controller.Hardware.Keyboard.F]).to(focusKey);
mapping.from([Controller.Hardware.Keyboard.BracketLeft]).to(cameraKey);
mapping.from([Controller.Hardware.Keyboard.G]).to(gridKey);
function recursiveAdd(newParentID, parentData) {
if (parentData.children !== undefined) {