MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / event

Method event

pcsx2-qt/DisplayWidget.cpp:290–444  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288}
289
290bool DisplaySurface::event(QEvent* event)
291{
292 switch (event->type())
293 {
294 case QEvent::KeyPress:
295 case QEvent::KeyRelease:
296 {
297 handleKeyInputEvent(event);
298 return true;
299 }
300
301 case QEvent::MouseMove:
302 {
303 const QMouseEvent* mouse_event = static_cast<QMouseEvent*>(event);
304
305 if (!m_relative_mouse_enabled)
306 {
307 const qreal dpr = devicePixelRatio();
308 const QPoint mouse_pos = mouse_event->pos();
309
310 const float scaled_x = static_cast<float>(static_cast<qreal>(mouse_pos.x()) * dpr);
311 const float scaled_y = static_cast<float>(static_cast<qreal>(mouse_pos.y()) * dpr);
312 InputManager::UpdatePointerAbsolutePosition(0, scaled_x, scaled_y);
313 }
314 else
315 {
316 // On windows, we use winapi here. The reason being that the coordinates in QCursor
317 // are un-dpi-scaled, so we lose precision at higher desktop scalings.
318 float dx = 0.0f, dy = 0.0f;
319
320#ifndef _WIN32
321 const QPoint mouse_pos = QCursor::pos();
322 if (mouse_pos != m_relative_mouse_center_pos)
323 {
324 dx = static_cast<float>(mouse_pos.x() - m_relative_mouse_center_pos.x());
325 dy = static_cast<float>(mouse_pos.y() - m_relative_mouse_center_pos.y());
326 QCursor::setPos(m_relative_mouse_center_pos);
327 }
328#else
329 POINT mouse_pos;
330 if (GetCursorPos(&mouse_pos))
331 {
332 dx = static_cast<float>(mouse_pos.x - m_relative_mouse_center_pos.x());
333 dy = static_cast<float>(mouse_pos.y - m_relative_mouse_center_pos.y());
334 SetCursorPos(m_relative_mouse_center_pos.x(), m_relative_mouse_center_pos.y());
335 }
336#endif
337
338 if (dx != 0.0f)
339 InputManager::UpdatePointerRelativeDelta(0, InputPointerAxis::X, dx);
340 if (dy != 0.0f)
341 InputManager::UpdatePointerRelativeDelta(0, InputPointerAxis::Y, dy);
342 }
343
344 return true;
345 }
346
347 case QEvent::MouseButtonPress:

Callers 2

hid_pointer_syncFunction · 0.45
hid_keyboard_eventFunction · 0.45

Calls 8

toggleFullscreenMethod · 0.80
clampFunction · 0.50
maxFunction · 0.50
roundFunction · 0.50
widthFunction · 0.50
heightFunction · 0.50
typeMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected