More mouse fixes.

This commit is contained in:
OBattler
2023-08-12 17:56:44 +02:00
parent 01e7394101
commit 0ac3bb1620
3 changed files with 14 additions and 4 deletions

View File

@@ -168,7 +168,11 @@ mouse_clear_buttons(void)
static double
mouse_scale_coord_x(double x, int mul)
{
double ratio = (double) monitors[0].mon_unscaled_size_x / (double) monitors[0].mon_res_x;
double ratio = 1.0;
if (!mouse_raw)
ratio = (monitors[0].mon_res_x * plat_get_dpi())/
((double) monitors[0].mon_unscaled_size_x);
if (mul)
x *= ratio;
@@ -181,7 +185,11 @@ mouse_scale_coord_x(double x, int mul)
static double
mouse_scale_coord_y(double y, int mul)
{
double ratio = (double) monitors[0].mon_efscrnsz_y / (double) monitors[0].mon_res_y;
double ratio = 1.0;
if (!mouse_raw)
ratio = (monitors[0].mon_res_y * plat_get_dpi()) /
((double) monitors[0].mon_efscrnsz_y);
if (mul)
y *= ratio;
@@ -386,6 +394,8 @@ mouse_scale_y(int y)
void
mouse_scale(int x, int y)
{
pclog("DPI = %lf (%lfx%lf)\n", plat_get_dpi(), monitors[0].mon_res_x, monitors[0].mon_res_y);
mouse_scale_x(x);
mouse_scale_y(y);
}

View File

@@ -84,7 +84,7 @@ ps2_report_coordinates(atkbc_dev_t *dev, int main)
mouse_subtract_coords(&delta_x, &delta_y, &overflow_x, &overflow_y,
-256, 255, 1, 0);
mouse_subtract_z(&delta_z, -8, 7, 1);
mouse_subtract_z(&delta_z, -8, 7, 0);
buff[0] |= (overflow_y << 7) | (overflow_x << 6) |
((delta_y & 0x0100) >> 3) | ((delta_x & 0x0100) >> 4) |

View File

@@ -279,7 +279,7 @@ sermouse_report_ms(mouse_t *dev)
int b = mouse_get_buttons_ex();
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 0, 0);
mouse_subtract_z(&delta_z, -8, 7, 1);
mouse_subtract_z(&delta_z, -8, 7, 0);
dev->buf[0] = 0x40;
dev->buf[0] |= (((delta_y >> 6) & 0x03) << 2);