Skip to content

Commit

Permalink
you can run with scissors er keys
Browse files Browse the repository at this point in the history
  • Loading branch information
reinago committed Jun 21, 2018
1 parent e76b15e commit a7a82fe
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 deletions.
21 changes: 18 additions & 3 deletions console/src/ButtonParamUILayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,24 @@ bool ButtonParamUILayer::onKey(Key key, int scancode, KeyAction action, Modifier
default: cleanKey = static_cast<uint16_t>(key);
}
cleanKey = cleanKey & ~vislib::sys::KeyCode::KEY_MOD;
if ((mods & KEY_MOD_ALT) == KEY_MOD_ALT) cleanKey |= vislib::sys::KeyCode::KEY_MOD_ALT;
if ((mods & KEY_MOD_CTRL) == KEY_MOD_CTRL) cleanKey |= vislib::sys::KeyCode::KEY_MOD_CTRL;
if ((mods & KEY_MOD_SHIFT) == KEY_MOD_SHIFT) cleanKey |= vislib::sys::KeyCode::KEY_MOD_SHIFT;
if ((mods & KEY_MOD_ALT) == KEY_MOD_ALT) {
::mmcSetInputModifier(hView, MMC_INMOD_ALT, true);
cleanKey |= vislib::sys::KeyCode::KEY_MOD_ALT;
} else {
::mmcSetInputModifier(hView, MMC_INMOD_ALT, false);
}
if ((mods & KEY_MOD_CTRL) == KEY_MOD_CTRL) {
::mmcSetInputModifier(hView, MMC_INMOD_CTRL, true);
cleanKey |= vislib::sys::KeyCode::KEY_MOD_CTRL;
} else {
::mmcSetInputModifier(hView, MMC_INMOD_CTRL, false);
}
if ((mods & KEY_MOD_SHIFT) == KEY_MOD_SHIFT) {
::mmcSetInputModifier(hView, MMC_INMOD_SHIFT, true);
cleanKey |= vislib::sys::KeyCode::KEY_MOD_SHIFT;
} else {
::mmcSetInputModifier(hView, MMC_INMOD_SHIFT, false);
}

vislib::sys::KeyCode keycode(cleanKey);

Expand Down
22 changes: 19 additions & 3 deletions console/src/gl/ATBUILayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,25 @@ bool gl::ATBUILayer::onKey(Key key, int scancode, KeyAction action, Modifiers mo
::TwSetCurrentWindow(atbWinID);

atbKeyMod = 0;
if (mods & Modifiers::KEY_MOD_SHIFT) atbKeyMod |= TW_KMOD_SHIFT;
if (mods & Modifiers::KEY_MOD_CTRL) atbKeyMod |= TW_KMOD_CTRL;
if (mods & Modifiers::KEY_MOD_ALT) atbKeyMod |= TW_KMOD_ALT;
if (mods & Modifiers::KEY_MOD_SHIFT) {
::mmcSetInputModifier(hView, MMC_INMOD_SHIFT, true);
atbKeyMod |= TW_KMOD_SHIFT;
} else {
::mmcSetInputModifier(hView, MMC_INMOD_SHIFT, false);
}
if (mods & Modifiers::KEY_MOD_CTRL) {
::mmcSetInputModifier(hView, MMC_INMOD_CTRL, true);
atbKeyMod |= TW_KMOD_CTRL;
} else {
::mmcSetInputModifier(hView, MMC_INMOD_CTRL, false);
}
if (mods & Modifiers::KEY_MOD_ALT) {
::mmcSetInputModifier(hView, MMC_INMOD_ALT, true);
atbKeyMod |= TW_KMOD_ALT;
} else {
::mmcSetInputModifier(hView, MMC_INMOD_ALT, false);
}


// Process key pressed
if (action == KeyAction::PRESS || action == KeyAction::REPEAT) {
Expand Down
2 changes: 2 additions & 0 deletions core/include/mmcore/view/View3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,8 @@ namespace view {
/** The move step size in world coordinates */
param::ParamSlot viewKeyMoveStepSlot;

param::ParamSlot viewKeyRunFactorSlot;

/** The angle rotate step in degrees */
param::ParamSlot viewKeyAngleStepSlot;

Expand Down
8 changes: 8 additions & 0 deletions core/src/view/View3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ view::View3D::View3D(void) : view::AbstractView3D(), AbstractCamParamSync(), cam
overrideCall(NULL),
#ifdef ENABLE_KEYBOARD_VIEW_CONTROL
viewKeyMoveStepSlot("viewKey::MoveStep", "The move step size in world coordinates"),
viewKeyRunFactorSlot("viewKey::RunFactor", "The factor for step size multiplication when running (shift)"),
viewKeyAngleStepSlot("viewKey::AngleStep", "The angle rotate step in degrees"),
mouseSensitivitySlot("viewKey::MouseSensitivity", "used for WASD mode"),
viewKeyRotPointSlot("viewKey::RotPoint", "The point around which the view will be roateted"),
Expand Down Expand Up @@ -172,6 +173,9 @@ view::View3D::View3D(void) : view::AbstractView3D(), AbstractCamParamSync(), cam
this->viewKeyMoveStepSlot << new param::FloatParam(0.1f, 0.001f);
this->MakeSlotAvailable(&this->viewKeyMoveStepSlot);

this->viewKeyRunFactorSlot << new param::FloatParam(2.0f, 0.1f);
this->MakeSlotAvailable(&this->viewKeyRunFactorSlot);

this->viewKeyAngleStepSlot << new param::FloatParam(15.0f, 0.001f, 360.0f);
this->MakeSlotAvailable(&this->viewKeyAngleStepSlot);

Expand Down Expand Up @@ -1320,6 +1324,10 @@ bool view::View3D::viewKeyPressed(param::ParamSlot& p) {
|| (&p == &this->viewKeyMoveDownSlot)) {
// move
float step = this->viewKeyMoveStepSlot.Param<param::FloatParam>()->Value();
const float runFactor = this->viewKeyRunFactorSlot.Param<param::FloatParam>()->Value();
if (this->modkeys.GetModifierState(vislib::graphics::InputModifiers::MODIFIER_SHIFT)) {
step *= runFactor;
}
vislib::math::Vector<float, 3> move;

if (&p == &this->viewKeyZoomInSlot) {
Expand Down

0 comments on commit a7a82fe

Please sign in to comment.