Don't ignore mouse motion when touch UI is enabled
This commit is contained in:
parent
4fbcc33ee0
commit
c1342ac0ce
@ -2456,24 +2456,21 @@ void Game::updateCameraOrientation(CameraOrientation *cam, float dtime)
|
|||||||
if (g_touchscreengui) {
|
if (g_touchscreengui) {
|
||||||
cam->camera_yaw += g_touchscreengui->getYawChange();
|
cam->camera_yaw += g_touchscreengui->getYawChange();
|
||||||
cam->camera_pitch = g_touchscreengui->getPitch();
|
cam->camera_pitch = g_touchscreengui->getPitch();
|
||||||
} else {
|
|
||||||
#endif
|
|
||||||
v2s32 center(driver->getScreenSize().Width / 2, driver->getScreenSize().Height / 2);
|
|
||||||
v2s32 dist = input->getMousePos() - center;
|
|
||||||
|
|
||||||
if (m_invert_mouse || camera->getCameraMode() == CAMERA_MODE_THIRD_FRONT) {
|
|
||||||
dist.Y = -dist.Y;
|
|
||||||
}
|
|
||||||
|
|
||||||
f32 sens_scale = getSensitivityScaleFactor();
|
|
||||||
cam->camera_yaw -= dist.X * m_cache_mouse_sensitivity * sens_scale;
|
|
||||||
cam->camera_pitch += dist.Y * m_cache_mouse_sensitivity * sens_scale;
|
|
||||||
|
|
||||||
if (dist.X != 0 || dist.Y != 0)
|
|
||||||
input->setMousePos(center.X, center.Y);
|
|
||||||
#ifdef HAVE_TOUCHSCREENGUI
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
v2s32 center(driver->getScreenSize().Width / 2, driver->getScreenSize().Height / 2);
|
||||||
|
v2s32 dist = input->getMousePos() - center;
|
||||||
|
|
||||||
|
if (m_invert_mouse || camera->getCameraMode() == CAMERA_MODE_THIRD_FRONT) {
|
||||||
|
dist.Y = -dist.Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
f32 sens_scale = getSensitivityScaleFactor();
|
||||||
|
cam->camera_yaw -= dist.X * m_cache_mouse_sensitivity * sens_scale;
|
||||||
|
cam->camera_pitch += dist.Y * m_cache_mouse_sensitivity * sens_scale;
|
||||||
|
|
||||||
|
if (dist.X != 0 || dist.Y != 0)
|
||||||
|
input->setMousePos(center.X, center.Y);
|
||||||
|
|
||||||
if (m_cache_enable_joysticks) {
|
if (m_cache_enable_joysticks) {
|
||||||
f32 sens_scale = getSensitivityScaleFactor();
|
f32 sens_scale = getSensitivityScaleFactor();
|
||||||
@ -2483,6 +2480,11 @@ void Game::updateCameraOrientation(CameraOrientation *cam, float dtime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
cam->camera_pitch = rangelim(cam->camera_pitch, -89.5, 89.5);
|
cam->camera_pitch = rangelim(cam->camera_pitch, -89.5, 89.5);
|
||||||
|
|
||||||
|
#ifdef HAVE_TOUCHSCREENGUI
|
||||||
|
if (g_touchscreengui)
|
||||||
|
g_touchscreengui->setPitch(cam->camera_pitch, center);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -846,6 +846,8 @@ void TouchScreenGUI::translateEvent(const SEvent &event)
|
|||||||
const double d = g_settings->getFloat("mouse_sensitivity", 0.001f, 10.0f) * 3.0f;
|
const double d = g_settings->getFloat("mouse_sensitivity", 0.001f, 10.0f) * 3.0f;
|
||||||
|
|
||||||
m_camera_yaw_change -= dx * d;
|
m_camera_yaw_change -= dx * d;
|
||||||
|
// TODO FIXME why do we clamp to ±180 here
|
||||||
|
// but this is clamped to ±89.5 in updateCameraOrientation?
|
||||||
m_camera_pitch = MYMIN(MYMAX(m_camera_pitch + (dy * d), -180), 180);
|
m_camera_pitch = MYMIN(MYMAX(m_camera_pitch + (dy * d), -180), 180);
|
||||||
|
|
||||||
// update shootline
|
// update shootline
|
||||||
|
@ -179,7 +179,16 @@ public:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
double getPitch() { return m_camera_pitch; }
|
double getPitch() const { return m_camera_pitch; }
|
||||||
|
|
||||||
|
void setPitch(double camera_pitch, v2s32 screen_XY)
|
||||||
|
{
|
||||||
|
m_camera_pitch = camera_pitch;
|
||||||
|
m_shootline = m_device
|
||||||
|
->getSceneManager()
|
||||||
|
->getSceneCollisionManager()
|
||||||
|
->getRayFromScreenCoordinates(screen_XY);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns a line which describes what the player is pointing at.
|
* Returns a line which describes what the player is pointing at.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user