mirror of https://github.com/RPCS3/rpcs3.git
keyboard_pad_handler: fix mouse for multimonitor fullscreen
This commit is contained in:
parent
e53ca429a1
commit
f933947a27
|
@ -306,13 +306,25 @@ void keyboard_pad_handler::mouseMoveEvent(QMouseEvent* event)
|
||||||
static int last_pos_x = 0;
|
static int last_pos_x = 0;
|
||||||
static int last_pos_y = 0;
|
static int last_pos_y = 0;
|
||||||
|
|
||||||
if (m_target && m_target->visibility() == QWindow::Visibility::FullScreen)
|
if (m_target && m_target->visibility() == QWindow::Visibility::FullScreen && m_target->isActive())
|
||||||
{
|
{
|
||||||
QPoint p_delta = m_target->geometry().topLeft() + QPoint(m_target->width() / 2, m_target->height() / 2);
|
// get the screen dimensions
|
||||||
QCursor::setPos(p_delta);
|
const QSize screen = m_target->size();
|
||||||
|
|
||||||
movement_x = event->x() - p_delta.x();
|
// get the center of the screen in global coordinates
|
||||||
movement_y = event->y() - p_delta.y();
|
QPoint p_center = m_target->geometry().topLeft() + QPoint(screen.width() / 2, screen.height() / 2);
|
||||||
|
|
||||||
|
// reset the mouse to the center for consistent results since edge movement won't be registered
|
||||||
|
QCursor::setPos(m_target->screen(), p_center);
|
||||||
|
|
||||||
|
// convert the center into screen coordinates
|
||||||
|
p_center = m_target->mapFromGlobal(p_center);
|
||||||
|
|
||||||
|
// get the delta of the mouse position to the screen center
|
||||||
|
const QPoint p_delta = event->pos() - p_center;
|
||||||
|
|
||||||
|
movement_x = p_delta.x();
|
||||||
|
movement_y = p_delta.y();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue