More mouse and PIC fixes and the mouse now takes of the ration between guest resolution and actual render area size, multiplied by the DPI, when returning coordinate deltas, also unified the delta return function across the various emulated mice.

This commit is contained in:
OBattler
2023-08-11 04:45:32 +02:00
parent 291dab2334
commit 782015a923
13 changed files with 299 additions and 243 deletions

View File

@@ -42,9 +42,12 @@
#include <QLibrary>
#include <QElapsedTimer>
#include <QScreen>
#include "qt_rendererstack.hpp"
#include "qt_mainwindow.hpp"
#include "qt_progsettings.hpp"
#include "qt_util.hpp"
#ifdef Q_OS_UNIX
# include <sys/mman.h>
@@ -641,7 +644,7 @@ plat_get_global_config_dir(char* strptr)
}
void
plat_init_rom_paths()
plat_init_rom_paths(void)
{
auto paths = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
@@ -727,4 +730,10 @@ plat_get_cpu_string(char *outbuf, uint8_t len) {
qstrncpy(outbuf, cpu_string.toUtf8().constData(), len);
}
}
double
plat_get_dpi(void)
{
return util::screenOfWidget(main_window)->devicePixelRatio();
}

View File

@@ -27,6 +27,7 @@
extern "C" {
#include <86box/86box.h>
#include <86box/plat.h>
#include <86box/video.h>
}
@@ -51,62 +52,71 @@ integer_scale(double *d, double *g)
void
RendererCommon::onResize(int width, int height)
{
if ((video_fullscreen == 0) && (video_fullscreen_scale_maximized ? ((parentWidget->isMaximized() == false) && (main_window->isAncestorOf(parentWidget) && main_window->isMaximized() == false)) : 1)) {
/* This is needed so that the if below does not take like, 5 lines. */
bool is_fs = (video_fullscreen == 0);
bool parent_max = (parentWidget->isMaximized() == false);
bool main_is_ancestor = main_window->isAncestorOf(parentWidget);
bool main_max = main_window->isMaximized();
bool main_is_max = (main_is_ancestor && main_max == false);
if (is_fs && (video_fullscreen_scale_maximized ? (parent_max && main_is_max) : 1))
destination.setRect(0, 0, width, height);
return;
}
double dx;
double dy;
double dw;
double dh;
double gsr;
else {
double dx;
double dy;
double dw;
double dh;
double gsr;
double hw = width;
double hh = height;
double gw = source.width();
double gh = source.height();
double hsr = hw / hh;
double hw = width;
double hh = height;
double gw = source.width();
double gh = source.height();
double hsr = hw / hh;
switch (video_fullscreen_scale) {
case FULLSCR_SCALE_INT:
gsr = gw / gh;
if (gsr <= hsr) {
dw = hh * gsr;
dh = hh;
} else {
dw = hw;
dh = hw / gsr;
}
integer_scale(&dw, &gw);
integer_scale(&dh, &gh);
dx = (hw - dw) / 2.0;
dy = (hh - dh) / 2.0;
destination.setRect(dx, dy, dw, dh);
break;
case FULLSCR_SCALE_43:
case FULLSCR_SCALE_KEEPRATIO:
if (video_fullscreen_scale == FULLSCR_SCALE_43) {
gsr = 4.0 / 3.0;
} else {
switch (video_fullscreen_scale) {
case FULLSCR_SCALE_INT:
gsr = gw / gh;
}
if (gsr <= hsr) {
dw = hh * gsr;
dh = hh;
} else {
dw = hw;
dh = hw / gsr;
}
integer_scale(&dw, &gw);
integer_scale(&dh, &gh);
dx = (hw - dw) / 2.0;
dy = (hh - dh) / 2.0;
destination.setRect((int) dx, (int) dy, (int) dw, (int) dh);
break;
case FULLSCR_SCALE_43:
case FULLSCR_SCALE_KEEPRATIO:
if (video_fullscreen_scale == FULLSCR_SCALE_43)
gsr = 4.0 / 3.0;
else
gsr = gw / gh;
if (gsr <= hsr) {
dw = hh * gsr;
dh = hh;
} else {
dw = hw;
dh = hw / gsr;
}
dx = (hw - dw) / 2.0;
dy = (hh - dh) / 2.0;
destination.setRect(dx, dy, dw, dh);
break;
case FULLSCR_SCALE_FULL:
default:
destination.setRect(0, 0, hw, hh);
break;
if (gsr <= hsr) {
dw = hh * gsr;
dh = hh;
} else {
dw = hw;
dh = hw / gsr;
}
dx = (hw - dw) / 2.0;
dy = (hh - dh) / 2.0;
destination.setRect((int) dx, (int) dy, (int) dw, (int) dh);
break;
case FULLSCR_SCALE_FULL:
default:
destination.setRect(0, 0, (int) hw, (int) hh);
break;
}
}
monitors[r_monitor_index].mon_res_x = (int) ((double) destination.width() * plat_get_dpi());
monitors[r_monitor_index].mon_res_y = (int) ((double) destination.height() * plat_get_dpi());
}
bool

View File

@@ -38,8 +38,10 @@ public:
virtual bool hasBlitFunc() { return false; }
virtual void blit(int x, int y, int w, int h) { }
int r_monitor_index = 0;
protected:
bool eventDelegate(QEvent *event, bool &result);
bool eventDelegate(QEvent *event, bool &result);
QRect source { 0, 0, 0, 0 };
QRect destination;

View File

@@ -552,3 +552,19 @@ RendererStack::event(QEvent* event)
}
return QStackedWidget::event(event);
}
void
RendererStack::setFocusRenderer()
{
if (current)
current->setFocus();
}
void
RendererStack::onResize(int width, int height)
{
if (rendererWindow) {
rendererWindow->r_monitor_index = m_monitor_index;
rendererWindow->onResize(width, height);
}
}

View File

@@ -71,16 +71,8 @@ public:
/* Returns options dialog for current renderer */
QDialog *getOptions(QWidget *parent) { return rendererWindow ? rendererWindow->getOptions(parent) : nullptr; }
void setFocusRenderer()
{
if (current)
current->setFocus();
}
void onResize(int width, int height)
{
if (rendererWindow)
rendererWindow->onResize(width, height);
}
void setFocusRenderer();
void onResize(int width, int height);
void (*mouse_capture_func)(QWindow *window) = nullptr;
void (*mouse_uncapture_func)() = nullptr;