Browse Source

Input : mouse focus integration.

undefined
Benjamin ‘Touky’ Huet Sam Hocevar <sam@hocevar.net> 11 years ago
parent
commit
dfc2a47f7f
2 changed files with 7 additions and 1 deletions
  1. +4
    -0
      src/platform/sdl/sdlinput.cpp
  2. +3
    -1
      test/meshviewer.cpp

+ 4
- 0
src/platform/sdl/sdlinput.cpp View File

@@ -231,6 +231,10 @@ void SdlInputData::Tick(float seconds)
m_mouse->SetAxis(1,-(mouse.y - vprevmouse.y) * 100.0f / max_screen_size); m_mouse->SetAxis(1,-(mouse.y - vprevmouse.y) * 100.0f / max_screen_size);
} }


//Mouse is focused, Validate the InScreen Key
//Hardcoded 3, not very nice.
m_mouse->SetKey(3, !!(SDL_GetAppState() & SDL_APPMOUSEFOCUS));

if (m_mousecapture) if (m_mousecapture)
{ {
mouse = ivec2(m_app * .5f); mouse = ivec2(m_app * .5f);


+ 3
- 1
test/meshviewer.cpp View File

@@ -101,6 +101,7 @@ enum MVMouseKeyList
MSE_CAM_ROT = KEY_MAX, MSE_CAM_ROT = KEY_MAX,
MSE_CAM_POS, MSE_CAM_POS,
MSE_CAM_FOV, MSE_CAM_FOV,
MSE_FOCUS,


MSE_MAX MSE_MAX
}; };
@@ -237,6 +238,7 @@ public:
m_controller->GetKey(MSE_CAM_ROT).BindMouse("Left"); m_controller->GetKey(MSE_CAM_ROT).BindMouse("Left");
m_controller->GetKey(MSE_CAM_POS).BindMouse("Right"); m_controller->GetKey(MSE_CAM_POS).BindMouse("Right");
m_controller->GetKey(MSE_CAM_FOV).BindMouse("Middle"); m_controller->GetKey(MSE_CAM_FOV).BindMouse("Middle");
m_controller->GetKey(MSE_FOCUS).BindMouse("InScreen");
m_controller->GetAxis(MSEX_CAM_Y).BindMouse("Y"); m_controller->GetAxis(MSEX_CAM_Y).BindMouse("Y");
m_controller->GetAxis(MSEX_CAM_X).BindMouse("X"); m_controller->GetAxis(MSEX_CAM_X).BindMouse("X");
} }
@@ -372,7 +374,7 @@ public:
is_pos = KeyDown(KEY_CAM_POS) || KeyDown(MSE_CAM_POS); is_pos = KeyDown(KEY_CAM_POS) || KeyDown(MSE_CAM_POS);
is_fov = KeyDown(KEY_CAM_FOV) || KeyDown(MSE_CAM_FOV); is_fov = KeyDown(KEY_CAM_FOV) || KeyDown(MSE_CAM_FOV);


if (KeyDown(MSE_CAM_ROT) || KeyDown(MSE_CAM_POS) || KeyDown(MSE_CAM_FOV))
if (KeyDown(MSE_FOCUS) && (KeyDown(MSE_CAM_ROT) || KeyDown(MSE_CAM_POS) || KeyDown(MSE_CAM_FOV)))
{ {
tmpv += vec2(AxisValue(MSEX_CAM_Y), AxisValue(MSEX_CAM_X)); tmpv += vec2(AxisValue(MSEX_CAM_Y), AxisValue(MSEX_CAM_X));
if (KeyDown(MSE_CAM_ROT)) if (KeyDown(MSE_CAM_ROT))


Loading…
Cancel
Save