Added rotation/panning support for trackpads in 3D mode #53

(cherry picked from commit 3ebde34d8f)
This commit is contained in:
sunnystormy 2016-04-06 02:15:34 -04:00 committed by Rémi Verschelde
parent 4bde902de1
commit 5c98674a8b
1 changed files with 22 additions and 5 deletions

View File

@ -819,7 +819,6 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
} }
} }
switch(p_event.type) { switch(p_event.type) {
case InputEvent::MOUSE_BUTTON: { case InputEvent::MOUSE_BUTTON: {
@ -1204,11 +1203,9 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
} }
} break; } break;
case InputEvent::MOUSE_MOTION: { case InputEvent::MOUSE_MOTION: {
const InputEventMouseMotion &m=p_event.mouse_motion; const InputEventMouseMotion &m=p_event.mouse_motion;
_edit.mouse_pos=Point2(p_event.mouse_motion.x,p_event.mouse_motion.y); _edit.mouse_pos=Point2(p_event.mouse_motion.x,p_event.mouse_motion.y);
if (spatial_editor->get_selected()) { if (spatial_editor->get_selected()) {
@ -1558,6 +1555,26 @@ void SpatialEditorViewport::_sinput(const InputEvent &p_event) {
if (m.mod.alt) if (m.mod.alt)
nav_mode = NAVIGATION_PAN; nav_mode = NAVIGATION_PAN;
} }
}else{
// Handle trackpad (no external mouse) use case
int mod = 0;
if (m.mod.shift)
mod=KEY_SHIFT;
if (m.mod.alt)
mod=KEY_ALT;
if (m.mod.control)
mod=KEY_CONTROL;
if (m.mod.meta)
mod=KEY_META;
if(mod){
if (mod == _get_key_modifier("3d_editor/pan_modifier"))
nav_mode = NAVIGATION_PAN;
else if (mod == _get_key_modifier("3d_editor/zoom_modifier"))
nav_mode = NAVIGATION_ZOOM;
else if (mod == _get_key_modifier("3d_editor/orbit_modifier"))
nav_mode = NAVIGATION_ORBIT;
}
} }
switch(nav_mode) { switch(nav_mode) {