More mouse fixes (thanks, coldbrewed!), and mitigated IRQ clear spam from serial and AT NVR.
This commit is contained in:
@@ -171,8 +171,7 @@ mouse_scale_coord_x(double x, int mul)
|
||||
double ratio = 1.0;
|
||||
|
||||
if (!mouse_raw)
|
||||
ratio = ((double) monitors[0].mon_unscaled_size_x) /
|
||||
(monitors[0].mon_res_x * plat_get_dpi());
|
||||
ratio = ((double) monitors[0].mon_unscaled_size_x) / monitors[0].mon_res_x;
|
||||
|
||||
if (mul)
|
||||
x *= ratio;
|
||||
@@ -188,8 +187,7 @@ mouse_scale_coord_y(double y, int mul)
|
||||
double ratio = 1.0;
|
||||
|
||||
if (!mouse_raw)
|
||||
ratio = ((double) monitors[0].mon_efscrnsz_y) /
|
||||
(monitors[0].mon_res_y * plat_get_dpi());
|
||||
ratio = ((double) monitors[0].mon_efscrnsz_y) / monitors[0].mon_res_y;
|
||||
|
||||
if (mul)
|
||||
y *= ratio;
|
||||
@@ -198,6 +196,7 @@ mouse_scale_coord_y(double y, int mul)
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
void
|
||||
mouse_subtract_x(int *delta_x, int *o_x, int min, int max, int abs)
|
||||
{
|
||||
@@ -205,6 +204,8 @@ mouse_subtract_x(int *delta_x, int *o_x, int min, int max, int abs)
|
||||
double smax_x;
|
||||
double rsmin_x;
|
||||
double smin_x;
|
||||
int ds_x;
|
||||
int scaled_x;
|
||||
|
||||
rsmin_x = mouse_scale_coord_x(min, 0);
|
||||
if (abs) {
|
||||
@@ -217,28 +218,39 @@ mouse_subtract_x(int *delta_x, int *o_x, int min, int max, int abs)
|
||||
smin_x = rsmin_x;
|
||||
}
|
||||
|
||||
/* Default the X and Y overflows to 1. */
|
||||
smax_x = floor(smax_x);
|
||||
smin_x = ceil(smin_x);
|
||||
|
||||
/* Default the X overflow to 1. */
|
||||
if (o_x != NULL)
|
||||
*o_x = 1;
|
||||
|
||||
ds_x = mouse_scale_coord_x(real_x, 1);
|
||||
|
||||
if (ds_x >= 0.0)
|
||||
scaled_x = (int) floor(mouse_scale_coord_x(real_x, 1));
|
||||
else
|
||||
scaled_x = (int) ceil(mouse_scale_coord_x(real_x, 1));
|
||||
|
||||
if (real_x > smax_x) {
|
||||
if (abs)
|
||||
*delta_x = (int) mouse_scale_coord_x(real_x, 1);
|
||||
else
|
||||
if (abs) {
|
||||
*delta_x = scaled_x;
|
||||
real_x -= mouse_scale_coord_x((double) scaled_x, 0);
|
||||
} else {
|
||||
*delta_x = max;
|
||||
real_x -= smax_x;
|
||||
real_x -= smax_x;
|
||||
}
|
||||
} else if (real_x < smin_x) {
|
||||
if (abs)
|
||||
*delta_x = (int) mouse_scale_coord_x(real_x, 1);
|
||||
else
|
||||
if (abs) {
|
||||
*delta_x = scaled_x;
|
||||
real_x -= mouse_scale_coord_x((double) scaled_x, 0);
|
||||
} else {
|
||||
*delta_x = min;
|
||||
real_x += ABS(smin_x);
|
||||
real_x += ABS(smin_x);
|
||||
}
|
||||
} else {
|
||||
if (abs)
|
||||
*delta_x = (int) mouse_scale_coord_x(real_x, 1);
|
||||
else
|
||||
*delta_x = (int) mouse_scale_coord_x(real_x, 1);
|
||||
real_x = 0.0;
|
||||
*delta_x = scaled_x;
|
||||
real_x -= mouse_scale_coord_x((double) scaled_x, 0);
|
||||
if (o_x != NULL)
|
||||
*o_x = 0;
|
||||
}
|
||||
@@ -259,6 +271,8 @@ mouse_subtract_y(int *delta_y, int *o_y, int min, int max, int invert, int abs)
|
||||
double smax_y;
|
||||
double rsmin_y;
|
||||
double smin_y;
|
||||
int ds_y;
|
||||
int scaled_y;
|
||||
|
||||
if (invert)
|
||||
real_y = -real_y;
|
||||
@@ -274,28 +288,39 @@ mouse_subtract_y(int *delta_y, int *o_y, int min, int max, int invert, int abs)
|
||||
smin_y = rsmin_y;
|
||||
}
|
||||
|
||||
/* Default the X and Y overflows to 1. */
|
||||
smax_y = floor(smax_y);
|
||||
smin_y = ceil(smin_y);
|
||||
|
||||
/* Default Y overflow to 1. */
|
||||
if (o_y != NULL)
|
||||
*o_y = 1;
|
||||
|
||||
ds_y = mouse_scale_coord_x(real_y, 1);
|
||||
|
||||
if (ds_y >= 0.0)
|
||||
scaled_y = (int) floor(mouse_scale_coord_x(real_y, 1));
|
||||
else
|
||||
scaled_y = (int) ceil(mouse_scale_coord_x(real_y, 1));
|
||||
|
||||
if (real_y > smax_y) {
|
||||
if (abs)
|
||||
*delta_y = (int) mouse_scale_coord_y(real_y, 1);
|
||||
else
|
||||
if (abs) {
|
||||
*delta_y = scaled_y;
|
||||
real_y -= mouse_scale_coord_y((double) scaled_y, 0);
|
||||
} else {
|
||||
*delta_y = max;
|
||||
real_y -= smax_y;
|
||||
real_y -= smax_y;
|
||||
}
|
||||
} else if (real_y < smin_y) {
|
||||
if (abs)
|
||||
*delta_y = (int) mouse_scale_coord_y(real_y, 1);
|
||||
else
|
||||
if (abs) {
|
||||
*delta_y = scaled_y;
|
||||
real_y -= mouse_scale_coord_y((double) scaled_y, 0);
|
||||
} else {
|
||||
*delta_y = min;
|
||||
real_y += ABS(smin_y);
|
||||
real_y += ABS(smin_y);
|
||||
}
|
||||
} else {
|
||||
if (abs)
|
||||
*delta_y = (int) mouse_scale_coord_y(real_y, 1);
|
||||
else
|
||||
*delta_y = (int) mouse_scale_coord_y(real_y, 1);
|
||||
real_y = 0.0;
|
||||
*delta_y = scaled_y;
|
||||
real_y -= mouse_scale_coord_y((double) scaled_y, 0);
|
||||
if (o_y != NULL)
|
||||
*o_y = 0;
|
||||
}
|
||||
@@ -324,8 +349,8 @@ int
|
||||
mouse_moved(void)
|
||||
{
|
||||
/* Convert them to integer so we treat < 1.0 and > -1.0 as 0. */
|
||||
int ret = (((int) floor(atomic_load(&mouse_x)) != 0) ||
|
||||
((int) floor(atomic_load(&mouse_y)) != 0));
|
||||
int ret = (((int) floor(mouse_scale_coord_x(atomic_load(&mouse_x), 1)) != 0) ||
|
||||
((int) floor(mouse_scale_coord_x(atomic_load(&mouse_y), 1)) != 0));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@@ -109,8 +109,12 @@ serial_transmit_period(serial_t *dev)
|
||||
void
|
||||
serial_do_irq(serial_t *dev, int set)
|
||||
{
|
||||
if (dev->irq != 0xff)
|
||||
picint_common(1 << dev->irq, !!(dev->type >= SERIAL_16450), set, &dev->irq_state);
|
||||
if (dev->irq != 0xff) {
|
||||
if (set || (dev->irq_state != !!set))
|
||||
picint_common(1 << dev->irq, !!(dev->type >= SERIAL_16450), set, &dev->irq_state);
|
||||
if (dev->type >= SERIAL_16450)
|
||||
dev->irq_state = !!set;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
14
src/nvr_at.c
14
src/nvr_at.c
@@ -440,12 +440,14 @@ timer_update_irq(nvr_t *nvr)
|
||||
local_t *local = (local_t *) nvr->data;
|
||||
uint8_t irq = (nvr->regs[RTC_REGB] & nvr->regs[RTC_REGC]) & (REGB_UIE | REGB_AIE | REGB_PIE);
|
||||
|
||||
if (irq) {
|
||||
nvr->regs[RTC_REGC] |= REGC_IRQF;
|
||||
picintlevel(1 << nvr->irq, &local->irq_state);
|
||||
} else {
|
||||
nvr->regs[RTC_REGC] &= ~REGC_IRQF;
|
||||
picintclevel(1 << nvr->irq, &local->irq_state);
|
||||
if (irq || (local->irq_state != !!irq)) {
|
||||
if (irq) {
|
||||
nvr->regs[RTC_REGC] |= REGC_IRQF;
|
||||
picintlevel(1 << nvr->irq, &local->irq_state);
|
||||
} else {
|
||||
nvr->regs[RTC_REGC] &= ~REGC_IRQF;
|
||||
picintclevel(1 << nvr->irq, &local->irq_state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user