Completely reworked mouse handling - should now be smoother due to there no longer being a multi-layered game of telephone going on with all the various interim coordinate counters, also rewritten the serial mouse emulation ground ground up.
This commit is contained in:
@@ -1279,10 +1279,12 @@ pc_run(void)
|
||||
startblit();
|
||||
cpu_exec(cpu_s->rspeed / 100);
|
||||
#ifdef USE_GDBSTUB /* avoid a KBC FIFO overflow when CPU emulation is stalled */
|
||||
// if (gdbstub_step == GDBSTUB_EXEC)
|
||||
if (gdbstub_step == GDBSTUB_EXEC) {
|
||||
#endif
|
||||
#if 0
|
||||
mouse_process();
|
||||
if (!mouse_timed)
|
||||
mouse_process();
|
||||
#ifdef USE_GDBSTUB /* avoid a KBC FIFO overflow when CPU emulation is stalled */
|
||||
}
|
||||
#endif
|
||||
joystick_process();
|
||||
endblit();
|
||||
|
@@ -19,7 +19,9 @@
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2017-2018 Fred N. van Kempen.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdatomic.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
@@ -37,17 +39,22 @@ typedef struct mouse_t {
|
||||
} mouse_t;
|
||||
|
||||
int mouse_type = 0;
|
||||
int mouse_x;
|
||||
int mouse_y;
|
||||
int mouse_z;
|
||||
int mouse_buttons;
|
||||
atomic_int mouse_x;
|
||||
atomic_int mouse_y;
|
||||
atomic_int mouse_z;
|
||||
atomic_int mouse_buttons;
|
||||
int mouse_mode;
|
||||
int mouse_timed = 1;
|
||||
int mouse_tablet_in_proximity = 0;
|
||||
int tablet_tool_type = 1; /* 0 = Puck/Cursor, 1 = Pen */
|
||||
|
||||
double mouse_x_abs;
|
||||
double mouse_y_abs;
|
||||
|
||||
double mouse_sensitivity = 1.0;
|
||||
double mouse_x_error = 0.0;
|
||||
double mouse_y_error = 0.0;
|
||||
|
||||
pc_timer_t mouse_timer; /* mouse event timer */
|
||||
|
||||
static const device_t mouse_none_device = {
|
||||
@@ -155,22 +162,81 @@ mouse_close(void)
|
||||
static void
|
||||
mouse_timer_poll(UNUSED(void *priv))
|
||||
{
|
||||
/* Poll at 255 Hz, maximum supported by PS/2 mic. */
|
||||
/* Poll at the specified sample rate. */
|
||||
timer_on_auto(&mouse_timer, 1000000.0 / sample_rate);
|
||||
|
||||
#ifdef USE_GDBSTUB /* avoid a KBC FIFO overflow when CPU emulation is stalled */
|
||||
if (gdbstub_step == GDBSTUB_EXEC)
|
||||
if (gdbstub_step == GDBSTUB_EXEC) {
|
||||
#endif
|
||||
mouse_process();
|
||||
if (mouse_timed)
|
||||
mouse_process();
|
||||
#ifdef USE_GDBSTUB /* avoid a KBC FIFO overflow when CPU emulation is stalled */
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
mouse_scale(int x, int y)
|
||||
{
|
||||
pclog("mouse_scale()\n");
|
||||
double scaled_x = (((double) x) * mouse_sensitivity) + mouse_x_error;
|
||||
double scaled_y = (((double) y) * mouse_sensitivity) + mouse_y_error;
|
||||
|
||||
mouse_x += (int) scaled_x;
|
||||
mouse_y += (int) scaled_y;
|
||||
|
||||
mouse_x_error = scaled_x - floor(scaled_x);
|
||||
mouse_y_error = scaled_y - floor(scaled_y);
|
||||
}
|
||||
|
||||
void
|
||||
mouse_scale_x(int x)
|
||||
{
|
||||
double scaled_x = ((double) x) * mouse_sensitivity + mouse_x_error;
|
||||
|
||||
mouse_x += (int) scaled_x;
|
||||
|
||||
mouse_x_error = scaled_x - ((double) mouse_x);
|
||||
}
|
||||
|
||||
void
|
||||
mouse_scale_y(int y)
|
||||
{
|
||||
double scaled_y = ((double) y) * mouse_sensitivity + mouse_y_error;
|
||||
|
||||
mouse_y += (int) scaled_y;
|
||||
|
||||
mouse_y_error = scaled_y - ((double) mouse_y);
|
||||
}
|
||||
|
||||
void
|
||||
mouse_set_z(int z)
|
||||
{
|
||||
mouse_z += z;
|
||||
}
|
||||
|
||||
void
|
||||
mouse_set_buttons_ex(int b)
|
||||
{
|
||||
mouse_buttons = b;
|
||||
}
|
||||
|
||||
int
|
||||
mouse_get_buttons_ex(void)
|
||||
{
|
||||
return mouse_buttons;
|
||||
}
|
||||
|
||||
void
|
||||
mouse_set_sample_rate(double new_rate)
|
||||
{
|
||||
mouse_timed = (new_rate > 0.0);
|
||||
|
||||
timer_stop(&mouse_timer);
|
||||
|
||||
sample_rate = new_rate;
|
||||
timer_on_auto(&mouse_timer, 1000000.0 / sample_rate);
|
||||
if (mouse_timed)
|
||||
timer_on_auto(&mouse_timer, 1000000.0 / sample_rate);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -186,6 +252,9 @@ mouse_reset(void)
|
||||
mouse_x = mouse_y = mouse_z = 0;
|
||||
mouse_buttons = 0x00;
|
||||
mouse_mode = 0;
|
||||
mouse_timed = 1;
|
||||
|
||||
mouse_x_error = mouse_y_error = 0.0;
|
||||
|
||||
/* If no mouse configured, we're done. */
|
||||
if (mouse_type == 0)
|
||||
@@ -222,19 +291,14 @@ mouse_process(void)
|
||||
if (mouse_curr == NULL)
|
||||
return;
|
||||
|
||||
if (mouse_poll_ex)
|
||||
if ((mouse_mode >= 1) && mouse_poll_ex)
|
||||
mouse_poll_ex();
|
||||
else
|
||||
mouse_poll();
|
||||
|
||||
if ((mouse_dev_poll != NULL) || (mouse_curr->poll != NULL)) {
|
||||
if (mouse_curr->poll != NULL)
|
||||
mouse_curr->poll(mouse_x, mouse_y, mouse_z, mouse_buttons, mouse_x_abs, mouse_y_abs, mouse_priv);
|
||||
else
|
||||
mouse_dev_poll(mouse_x, mouse_y, mouse_z, mouse_buttons, mouse_priv);
|
||||
|
||||
/* Reset mouse deltas. */
|
||||
mouse_x = mouse_y = mouse_z = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -68,6 +68,7 @@
|
||||
*/
|
||||
#include <inttypes.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdatomic.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
@@ -80,6 +81,7 @@
|
||||
#include <86box/timer.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/mouse.h>
|
||||
#include <86box/plat.h>
|
||||
#include <86box/plat_unused.h>
|
||||
#include <86box/random.h>
|
||||
|
||||
@@ -147,8 +149,6 @@ typedef struct mouse {
|
||||
int irq;
|
||||
int bn;
|
||||
int flags;
|
||||
int mouse_delayed_dx;
|
||||
int mouse_delayed_dy;
|
||||
int mouse_buttons;
|
||||
int mouse_buttons_last;
|
||||
int toggle_counter;
|
||||
@@ -480,10 +480,13 @@ bm_poll(int x, int y, UNUSED(int z), int b, UNUSED(double abs_x), UNUSED(double
|
||||
mouse_t *dev = (mouse_t *) priv;
|
||||
int xor ;
|
||||
|
||||
if (!mouse_capture && !video_fullscreen)
|
||||
return 1;
|
||||
|
||||
if (!(dev->flags & FLAG_ENABLED))
|
||||
return 1; /* Mouse is disabled, do nothing. */
|
||||
|
||||
if (!x && !y && !((b ^ dev->mouse_buttons_last) & 0x07)) {
|
||||
if (!mouse_x && !mouse_y && !((b ^ dev->mouse_buttons_last) & 0x07)) {
|
||||
dev->mouse_buttons_last = b;
|
||||
return 1; /* State has not changed, do nothing. */
|
||||
}
|
||||
@@ -498,7 +501,7 @@ bm_poll(int x, int y, UNUSED(int z), int b, UNUSED(double abs_x), UNUSED(double
|
||||
so update bits 6-3 here. */
|
||||
|
||||
/* If the mouse has moved, set bit 6. */
|
||||
if (x || y)
|
||||
if (mouse_x || mouse_y)
|
||||
dev->mouse_buttons |= 0x40;
|
||||
|
||||
/* Set bits 3-5 according to button state changes. */
|
||||
@@ -508,26 +511,30 @@ bm_poll(int x, int y, UNUSED(int z), int b, UNUSED(double abs_x), UNUSED(double
|
||||
|
||||
dev->mouse_buttons_last = b;
|
||||
|
||||
/* Clamp x and y to between -128 and 127 (int8_t range). */
|
||||
if (x > 127)
|
||||
x = 127;
|
||||
if (x < -128)
|
||||
x = -128;
|
||||
|
||||
if (y > 127)
|
||||
y = 127;
|
||||
if (y < -128)
|
||||
y = -128;
|
||||
|
||||
if (dev->timer_enabled) {
|
||||
/* Update delayed coordinates. */
|
||||
dev->mouse_delayed_dx += x;
|
||||
dev->mouse_delayed_dy += y;
|
||||
} else {
|
||||
if (!dev->timer_enabled) {
|
||||
/* If the counters are not frozen, update them. */
|
||||
if (!(dev->flags & FLAG_HOLD)) {
|
||||
dev->current_x = (int8_t) x;
|
||||
dev->current_y = (int8_t) y;
|
||||
if (mouse_x > 127) {
|
||||
dev->current_x = 127;
|
||||
mouse_x -= 127;
|
||||
} else if (mouse_x < 1-128) {
|
||||
dev->current_x = -128;
|
||||
mouse_x += 128;
|
||||
} else {
|
||||
dev->current_x = mouse_x;
|
||||
mouse_x = 0;
|
||||
}
|
||||
|
||||
if (mouse_y > 127) {
|
||||
dev->current_y = 127;
|
||||
mouse_y -= 127;
|
||||
} else if (mouse_y < 1-128) {
|
||||
dev->current_y = -128;
|
||||
mouse_y += 128;
|
||||
} else {
|
||||
dev->current_y = mouse_y;
|
||||
mouse_y = 0;
|
||||
}
|
||||
|
||||
dev->current_b = dev->mouse_buttons;
|
||||
}
|
||||
@@ -538,6 +545,7 @@ bm_poll(int x, int y, UNUSED(int z), int b, UNUSED(double abs_x), UNUSED(double
|
||||
bm_log("DEBUG: Data Interrupt Fired...\n");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -548,31 +556,31 @@ bm_update_data(mouse_t *dev)
|
||||
{
|
||||
int delta_x;
|
||||
int delta_y;
|
||||
int xor ;
|
||||
int xor;
|
||||
|
||||
/* If the counters are not frozen, update them. */
|
||||
if (!(dev->flags & FLAG_HOLD)) {
|
||||
if ((mouse_capture || video_fullscreen) && !(dev->flags & FLAG_HOLD)) {
|
||||
/* Update the deltas and the delays. */
|
||||
if (dev->mouse_delayed_dx > 127) {
|
||||
if (mouse_x > 127) {
|
||||
delta_x = 127;
|
||||
dev->mouse_delayed_dx -= 127;
|
||||
} else if (dev->mouse_delayed_dx < -128) {
|
||||
mouse_x -= 127;
|
||||
} else if (mouse_x < -128) {
|
||||
delta_x = -128;
|
||||
dev->mouse_delayed_dx += 128;
|
||||
mouse_x += 128;
|
||||
} else {
|
||||
delta_x = dev->mouse_delayed_dx;
|
||||
dev->mouse_delayed_dx = 0;
|
||||
delta_x = mouse_x;
|
||||
mouse_x = 0;
|
||||
}
|
||||
|
||||
if (dev->mouse_delayed_dy > 127) {
|
||||
if (mouse_y > 127) {
|
||||
delta_y = 127;
|
||||
dev->mouse_delayed_dy -= 127;
|
||||
} else if (dev->mouse_delayed_dy < -128) {
|
||||
mouse_y -= 127;
|
||||
} else if (mouse_y < -128) {
|
||||
delta_y = -128;
|
||||
dev->mouse_delayed_dy += 128;
|
||||
mouse_y += 128;
|
||||
} else {
|
||||
delta_y = dev->mouse_delayed_dy;
|
||||
dev->mouse_delayed_dy = 0;
|
||||
delta_y = mouse_y;
|
||||
mouse_y = 0;
|
||||
}
|
||||
|
||||
dev->current_x = (int8_t) delta_x;
|
||||
@@ -659,8 +667,6 @@ bm_init(const device_t *info)
|
||||
}
|
||||
mouse_set_buttons(dev->bn);
|
||||
|
||||
dev->mouse_delayed_dx = 0;
|
||||
dev->mouse_delayed_dy = 0;
|
||||
dev->mouse_buttons = 0;
|
||||
dev->mouse_buttons_last = 0;
|
||||
dev->sig_val = 0; /* the signature port value */
|
||||
@@ -707,6 +713,8 @@ bm_init(const device_t *info)
|
||||
else
|
||||
bm_log("Standard MS/Logitech BusMouse initialized\n");
|
||||
|
||||
mouse_set_sample_rate(0.0);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
|
@@ -13,6 +13,7 @@
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*/
|
||||
#include <stdarg.h>
|
||||
#include <stdatomic.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
@@ -23,6 +24,7 @@
|
||||
#include <86box/device.h>
|
||||
#include <86box/keyboard.h>
|
||||
#include <86box/mouse.h>
|
||||
#include <86box/plat.h>
|
||||
#include <86box/plat_unused.h>
|
||||
|
||||
enum {
|
||||
@@ -75,40 +77,51 @@ ps2_report_coordinates(atkbc_dev_t *dev, int main)
|
||||
uint8_t buff[3] = { 0x08, 0x00, 0x00 };
|
||||
int temp_z;
|
||||
|
||||
if (dev->x > 255) {
|
||||
dev->x = 255;
|
||||
if (mouse_x > 255) {
|
||||
buff[0] |= 0x40;
|
||||
buff[1] = 255;
|
||||
mouse_x -= 255;
|
||||
} else if (mouse_x < -256) {
|
||||
buff[0] |= (0x40 | 0x10);
|
||||
mouse_x += 256;
|
||||
} else {
|
||||
if (mouse_x < 0)
|
||||
buff[0] |= 0x10;
|
||||
buff[1] = mouse_x;
|
||||
mouse_x = 0;
|
||||
}
|
||||
if (dev->x < -256) {
|
||||
dev->x = -256;
|
||||
buff[0] |= 0x40;
|
||||
}
|
||||
if (dev->y > 255) {
|
||||
dev->y = 255;
|
||||
buff[0] |= 0x80;
|
||||
}
|
||||
if (dev->y < -256) {
|
||||
dev->y = -256;
|
||||
buff[0] |= 0x80;
|
||||
}
|
||||
if (dev->z < -8)
|
||||
dev->z = -8;
|
||||
if (dev->z > 7)
|
||||
dev->z = 7;
|
||||
|
||||
if (dev->x < 0)
|
||||
buff[0] |= 0x10;
|
||||
if (dev->y < 0)
|
||||
buff[0] |= 0x20;
|
||||
buff[0] |= (dev->b & ((dev->flags & FLAG_INTELLI) ? 0x07 : 0x03));
|
||||
buff[1] = (dev->x & 0xff);
|
||||
buff[2] = (dev->y & 0xff);
|
||||
if (mouse_y < -255) {
|
||||
buff[0] |= 0x80;
|
||||
buff[2] = 255;
|
||||
mouse_y += 255;
|
||||
} else if (mouse_y > 256) {
|
||||
buff[0] |= (0x80 | 0x20);
|
||||
mouse_y -= 256;
|
||||
} else {
|
||||
if (mouse_y > 0)
|
||||
buff[0] |= 0x20;
|
||||
buff[2] = -mouse_y;
|
||||
mouse_y = 0;
|
||||
}
|
||||
|
||||
if (dev->z < -7) {
|
||||
temp_z = 7;
|
||||
temp_z += 7;
|
||||
} else if (mouse_z > 8) {
|
||||
temp_z = (-8) & 0x0f;
|
||||
mouse_z -= 8;
|
||||
} else {
|
||||
temp_z = (-mouse_y) & 0x0f;
|
||||
mouse_z = 0;
|
||||
}
|
||||
|
||||
buff[0] |= (mouse_buttons & ((dev->flags & FLAG_INTELLI) ? 0x07 : 0x03));
|
||||
|
||||
kbc_at_dev_queue_add(dev, buff[0], main);
|
||||
kbc_at_dev_queue_add(dev, buff[1], main);
|
||||
kbc_at_dev_queue_add(dev, buff[2], main);
|
||||
if (dev->flags & FLAG_INTMODE) {
|
||||
temp_z = dev->z & 0x0f;
|
||||
if (dev->flags & FLAG_5BTN) {
|
||||
if (mouse_buttons & 8)
|
||||
temp_z |= 0x10;
|
||||
@@ -121,8 +134,6 @@ ps2_report_coordinates(atkbc_dev_t *dev, int main)
|
||||
}
|
||||
kbc_at_dev_queue_add(dev, temp_z, main);
|
||||
}
|
||||
|
||||
dev->x = dev->y = dev->z = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -132,7 +143,7 @@ ps2_set_defaults(atkbc_dev_t *dev)
|
||||
dev->rate = 100;
|
||||
mouse_set_sample_rate(100.0);
|
||||
dev->resolution = 2;
|
||||
dev->flags &= 0x88;
|
||||
dev->flags &= 0x188;
|
||||
mouse_scan = 0;
|
||||
}
|
||||
|
||||
@@ -316,25 +327,17 @@ ps2_poll(int x, int y, int z, int b, UNUSED(double abs_x), UNUSED(double abs_y),
|
||||
atkbc_dev_t *dev = (atkbc_dev_t *) priv;
|
||||
int packet_size = (dev->flags & FLAG_INTMODE) ? 4 : 3;
|
||||
|
||||
if (!mouse_scan || (!x && !y && !z && (b == dev->b)))
|
||||
return 0xff;
|
||||
int cond = (!mouse_capture && !video_fullscreen) || (!mouse_scan || (!x && !y && !z && (b == dev->b))) ||
|
||||
((dev->mode == MODE_STREAM) && (kbc_at_dev_queue_pos(dev, 1) >= (FIFO_SIZE - packet_size)));
|
||||
|
||||
if ((dev->mode == MODE_STREAM) && (kbc_at_dev_queue_pos(dev, 1) < (FIFO_SIZE - packet_size))) {
|
||||
dev->x = x;
|
||||
dev->y = -y;
|
||||
dev->z = -z;
|
||||
dev->b = b;
|
||||
} else {
|
||||
dev->x += x;
|
||||
dev->y -= y;
|
||||
dev->z -= z;
|
||||
if (!cond) {
|
||||
dev->b = b;
|
||||
|
||||
if (dev->mode == MODE_STREAM)
|
||||
ps2_report_coordinates(dev, 1);
|
||||
}
|
||||
|
||||
if ((dev->mode == MODE_STREAM) && (kbc_at_dev_queue_pos(dev, 1) < (FIFO_SIZE - packet_size)))
|
||||
ps2_report_coordinates(dev, 1);
|
||||
|
||||
return 0;
|
||||
return cond;
|
||||
}
|
||||
|
||||
/*
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -20,6 +20,11 @@
|
||||
#ifndef EMU_MOUSE_H
|
||||
#define EMU_MOUSE_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
/* Yes, a big no-no, but I'm saving myself time here. */
|
||||
#include <stdatomic.h>
|
||||
#endif
|
||||
|
||||
#define MOUSE_TYPE_NONE 0 /* no mouse configured */
|
||||
#define MOUSE_TYPE_INTERNAL 1 /* machine has internal mouse */
|
||||
#define MOUSE_TYPE_LOGIBUS 2 /* Logitech/ATI Bus Mouse */
|
||||
@@ -39,20 +44,26 @@
|
||||
|
||||
#define MOUSE_TYPE_ONBOARD 0x80 /* Mouse is an on-board version of one of the above. */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#else
|
||||
extern atomic_int mouse_x;
|
||||
extern atomic_int mouse_y;
|
||||
extern atomic_int mouse_z;
|
||||
extern atomic_int mouse_buttons;
|
||||
#endif
|
||||
|
||||
extern int mouse_type;
|
||||
extern int mouse_x;
|
||||
extern int mouse_y;
|
||||
extern int mouse_z;
|
||||
extern int mouse_mode; /* 1 = Absolute, 0 = Relative */
|
||||
extern int mouse_timed; /* 1 = Timed, 0 = Constant */
|
||||
extern int mouse_tablet_in_proximity;
|
||||
extern double mouse_x_abs;
|
||||
extern double mouse_y_abs;
|
||||
extern int mouse_buttons;
|
||||
extern int tablet_tool_type;
|
||||
extern double mouse_sensitivity;
|
||||
extern double mouse_x_error;
|
||||
extern double mouse_y_error;
|
||||
|
||||
#ifdef EMU_DEVICE_H
|
||||
extern const device_t *mouse_get_device(int mouse);
|
||||
@@ -79,11 +90,16 @@ extern void mouse_set_buttons(int buttons);
|
||||
extern void mouse_set_poll_ex(void (*poll_ex)(void));
|
||||
extern void mouse_process(void);
|
||||
extern void mouse_set_poll(int (*f)(int, int, int, int, void *), void *);
|
||||
extern void mouse_poll(void);
|
||||
|
||||
extern void mouse_bus_set_irq(void *priv, int irq);
|
||||
|
||||
extern void mouse_set_sample_rate(double new_rate);
|
||||
extern void mouse_scale(int x, int y);
|
||||
extern void mouse_scale_x(int x);
|
||||
extern void mouse_scale_y(int y);
|
||||
extern void mouse_set_z(int z);
|
||||
extern void mouse_set_buttons_ex(int b);
|
||||
extern int mouse_get_buttons_ex(void);
|
||||
|
||||
extern char *mouse_get_name(int mouse);
|
||||
extern char *mouse_get_internal_name(int mouse);
|
||||
|
61
src/io.c
61
src/io.c
@@ -318,8 +318,12 @@ inb(uint16_t port)
|
||||
amstrad_latch = AMSTRAD_SW9 | 0x80000000;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
cycles -= io_delay;
|
||||
if (!found) {
|
||||
if (is286)
|
||||
cycles -= io_delay;
|
||||
else
|
||||
sub_cycles(io_delay);
|
||||
}
|
||||
|
||||
/* TriGem 486-BIOS MHz output. */
|
||||
#if 0
|
||||
@@ -327,7 +331,16 @@ inb(uint16_t port)
|
||||
ret = 0xfe;
|
||||
#endif
|
||||
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) in b(%04X) = %02X\n", CS, cpu_state.pc, in_smm, found, qfound, port, ret);
|
||||
/* if (port == 0x23)
|
||||
ret = 0x00; */
|
||||
|
||||
if (port == 0x7f)
|
||||
ret = 0x00;
|
||||
|
||||
// if ((port != 0x42) && (port != 0x61) && (port != 0x3b4) && (port != 0x3ba) && (port != 0x3da)) {
|
||||
if (((port >= 0xcf8) && (port <= 0xcff)) || ((port >= 0xc000) && (port <= 0xcfff))) {
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) in b(%04X) = %02X\n", CS, cpu_state.pc, in_smm, found, qfound, port, ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -362,14 +375,21 @@ outb(uint16_t port, uint8_t val)
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
cycles -= io_delay;
|
||||
if (is286)
|
||||
cycles -= io_delay;
|
||||
else
|
||||
sub_cycles(io_delay);
|
||||
|
||||
#ifdef USE_DYNAREC
|
||||
if (cpu_use_dynarec && ((port == 0xeb) || (port == 0xed)))
|
||||
update_tsc();
|
||||
#endif
|
||||
}
|
||||
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) outb(%04X, %02X)\n", CS, cpu_state.pc, in_smm, found, qfound, port, val);
|
||||
// if ((port != 0x43) && (port != 0xea)) {
|
||||
if (((port >= 0xcf8) && (port <= 0xcff)) || ((port >= 0xc000) && (port <= 0xcfff))) {
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) outb(%04X, %02X)\n", CS, cpu_state.pc, in_smm, found, qfound, port, val);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -430,10 +450,16 @@ inw(uint16_t port)
|
||||
amstrad_latch = AMSTRAD_SW9 | 0x80000000;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
cycles -= io_delay;
|
||||
if (!found) {
|
||||
if (is286)
|
||||
cycles -= io_delay;
|
||||
else
|
||||
sub_cycles(io_delay);
|
||||
}
|
||||
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) in w(%04X) = %04X\n", CS, cpu_state.pc, in_smm, found, qfound, port, ret);
|
||||
if (((port >= 0xcf8) && (port <= 0xcff)) || ((port >= 0xc000) && (port <= 0xcfff))) {
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) in w(%04X) = %04X\n", CS, cpu_state.pc, in_smm, found, qfound, port, ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -481,14 +507,21 @@ outw(uint16_t port, uint16_t val)
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
cycles -= io_delay;
|
||||
if (is286)
|
||||
cycles -= io_delay;
|
||||
else
|
||||
sub_cycles(io_delay);
|
||||
|
||||
#ifdef USE_DYNAREC
|
||||
if (cpu_use_dynarec && ((port == 0xeb) || (port == 0xed)))
|
||||
update_tsc();
|
||||
#endif
|
||||
}
|
||||
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) outw(%04X, %04X)\n", CS, cpu_state.pc, in_smm, found, qfound, port, val);
|
||||
// if (port != 0xea) {
|
||||
if (((port >= 0xcf8) && (port <= 0xcff)) || ((port >= 0xc000) && (port <= 0xcfff))) {
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) outw(%04X, %04X)\n", CS, cpu_state.pc, in_smm, found, qfound, port, val);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -580,7 +613,9 @@ inl(uint16_t port)
|
||||
if (!found)
|
||||
cycles -= io_delay;
|
||||
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) in l(%04X) = %08X\n", CS, cpu_state.pc, in_smm, found, qfound, port, ret);
|
||||
if (((port >= 0xcf8) && (port <= 0xcff)) || ((port >= 0xc000) && (port <= 0xcfff))) {
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) in l(%04X) = %08X\n", CS, cpu_state.pc, in_smm, found, qfound, port, ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -651,7 +686,9 @@ outl(uint16_t port, uint32_t val)
|
||||
#endif
|
||||
}
|
||||
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) outl(%04X, %08X)\n", CS, cpu_state.pc, in_smm, found, qfound, port, val);
|
||||
if (((port >= 0xcf8) && (port <= 0xcff)) || ((port >= 0xc000) && (port <= 0xcfff))) {
|
||||
io_log("[%04X:%08X] (%i, %i, %04i) outl(%04X, %08X)\n", CS, cpu_state.pc, in_smm, found, qfound, port, val);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
@@ -37,21 +37,6 @@ static std::vector<std::pair<int, libevdev *>> evdev_mice;
|
||||
static std::atomic<bool> stopped = false;
|
||||
static QThread *evdev_thread;
|
||||
|
||||
static std::atomic<int> evdev_mouse_rel_x = 0, evdev_mouse_rel_y = 0;
|
||||
|
||||
void
|
||||
evdev_mouse_poll()
|
||||
{
|
||||
if (!evdev_mice.size() || !mouse_capture) {
|
||||
evdev_mouse_rel_x = 0;
|
||||
evdev_mouse_rel_y = 0;
|
||||
return;
|
||||
}
|
||||
mouse_x = evdev_mouse_rel_x;
|
||||
mouse_y = evdev_mouse_rel_y;
|
||||
evdev_mouse_rel_x = evdev_mouse_rel_y = 0;
|
||||
}
|
||||
|
||||
void
|
||||
evdev_thread_func()
|
||||
{
|
||||
@@ -67,11 +52,11 @@ evdev_thread_func()
|
||||
struct input_event ev;
|
||||
if (pfds[i].revents & POLLIN) {
|
||||
while (libevdev_next_event(evdev_mice[i].second, LIBEVDEV_READ_FLAG_NORMAL, &ev) == 0) {
|
||||
if (ev.type == EV_REL && mouse_capture) {
|
||||
if (evdev_mice.size() && (ev.type == EV_REL) && mouse_capture) {
|
||||
if (ev.code == REL_X)
|
||||
evdev_mouse_rel_x += ev.value;
|
||||
mouse_scale_x(ev.value);
|
||||
if (ev.code == REL_Y)
|
||||
evdev_mouse_rel_y += ev.value;
|
||||
mouse_scale_y(ev.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,3 @@
|
||||
#ifdef EVDEV_INPUT
|
||||
void evdev_init();
|
||||
void evdev_mouse_poll();
|
||||
#endif
|
||||
|
@@ -17,13 +17,6 @@ extern int mouse_capture;
|
||||
extern void plat_mouse_capture(int);
|
||||
}
|
||||
|
||||
typedef struct mouseinputdata {
|
||||
int deltax, deltay, deltaz;
|
||||
int mousebuttons;
|
||||
} mouseinputdata;
|
||||
|
||||
static mouseinputdata mousedata;
|
||||
|
||||
CocoaEventFilter::~CocoaEventFilter()
|
||||
{
|
||||
}
|
||||
@@ -31,6 +24,8 @@ CocoaEventFilter::~CocoaEventFilter()
|
||||
bool
|
||||
CocoaEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, result_t *result)
|
||||
{
|
||||
int b = 0;
|
||||
|
||||
if (mouse_capture) {
|
||||
if (eventType == "mac_generic_NSEvent") {
|
||||
NSEvent *event = (NSEvent *) message;
|
||||
@@ -38,12 +33,11 @@ CocoaEventFilter::nativeEventFilter(const QByteArray &eventType, void *message,
|
||||
|| [event type] == NSEventTypeLeftMouseDragged
|
||||
|| [event type] == NSEventTypeRightMouseDragged
|
||||
|| [event type] == NSEventTypeOtherMouseDragged) {
|
||||
mousedata.deltax += [event deltaX];
|
||||
mousedata.deltay += [event deltaY];
|
||||
mouse_scale([event deltaX], [event deltaY]);
|
||||
return true;
|
||||
}
|
||||
if ([event type] == NSEventTypeScrollWheel) {
|
||||
mousedata.deltaz += [event deltaY];
|
||||
mouse_set_z([event deltaY]);
|
||||
return true;
|
||||
}
|
||||
switch ([event type]) {
|
||||
@@ -51,27 +45,32 @@ CocoaEventFilter::nativeEventFilter(const QByteArray &eventType, void *message,
|
||||
return false;
|
||||
case NSEventTypeLeftMouseDown:
|
||||
{
|
||||
mousedata.mousebuttons |= 1;
|
||||
b = mouse_get_buttons_ex() | 1;
|
||||
mouse_set_buttons_ex(b);
|
||||
break;
|
||||
}
|
||||
case NSEventTypeLeftMouseUp:
|
||||
{
|
||||
mousedata.mousebuttons &= ~1;
|
||||
b = mouse_get_buttons_ex() & ~1;
|
||||
mouse_set_buttons_ex(b);
|
||||
break;
|
||||
}
|
||||
case NSEventTypeRightMouseDown:
|
||||
{
|
||||
mousedata.mousebuttons |= 2;
|
||||
b = mouse_get_buttons_ex() | 2;
|
||||
mouse_set_buttons_ex(b);
|
||||
break;
|
||||
}
|
||||
case NSEventTypeRightMouseUp:
|
||||
{
|
||||
mousedata.mousebuttons &= ~2;
|
||||
b = mouse_get_buttons_ex() & ~2;
|
||||
mouse_set_buttons_ex(b);
|
||||
break;
|
||||
}
|
||||
case NSEventTypeOtherMouseDown:
|
||||
{
|
||||
mousedata.mousebuttons |= 4;
|
||||
b = mouse_get_buttons_ex() | 4;
|
||||
mouse_set_buttons_ex(b);
|
||||
break;
|
||||
}
|
||||
case NSEventTypeOtherMouseUp:
|
||||
@@ -80,7 +79,8 @@ CocoaEventFilter::nativeEventFilter(const QByteArray &eventType, void *message,
|
||||
plat_mouse_capture(0);
|
||||
return true;
|
||||
}
|
||||
mousedata.mousebuttons &= ~4;
|
||||
b = mouse_get_buttons_ex() & ~4;
|
||||
mouse_set_buttons_ex(b);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -89,13 +89,3 @@ CocoaEventFilter::nativeEventFilter(const QByteArray &eventType, void *message,
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
extern "C" void
|
||||
macos_poll_mouse()
|
||||
{
|
||||
mouse_x = mousedata.deltax;
|
||||
mouse_y = mousedata.deltay;
|
||||
mouse_z = mousedata.deltaz;
|
||||
mousedata.deltax = mousedata.deltay = mousedata.deltaz = 0;
|
||||
mouse_buttons = mousedata.mousebuttons;
|
||||
}
|
||||
|
@@ -256,7 +256,6 @@ main(int argc, char *argv[])
|
||||
auto rawInputFilter = WindowsRawInputFilter::Register(main_window);
|
||||
if (rawInputFilter) {
|
||||
app.installNativeEventFilter(rawInputFilter.get());
|
||||
QObject::connect(main_window, &MainWindow::pollMouse, (WindowsRawInputFilter *) rawInputFilter.get(), &WindowsRawInputFilter::mousePoll, Qt::DirectConnection);
|
||||
main_window->setSendKeyboardInput(false);
|
||||
}
|
||||
#endif
|
||||
|
@@ -253,8 +253,6 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
|
||||
emit updateMenuResizeOptions();
|
||||
|
||||
connect(this, &MainWindow::pollMouse, ui->stackedWidget, &RendererStack::mousePoll, Qt::DirectConnection);
|
||||
|
||||
connect(this, &MainWindow::setMouseCapture, this, [this](bool state) {
|
||||
mouse_capture = state ? 1 : 0;
|
||||
qt_mouse_capture(mouse_capture);
|
||||
@@ -764,7 +762,6 @@ MainWindow::initRendererMonitorSlot(int monitor_index)
|
||||
secondaryRenderer->switchRenderer((RendererStack::Renderer) vid_api);
|
||||
secondaryRenderer->setMouseTracking(true);
|
||||
}
|
||||
connect(this, &MainWindow::pollMouse, secondaryRenderer.get(), &RendererStack::mousePoll, Qt::DirectConnection);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -890,6 +887,9 @@ MainWindow::on_actionSettings_triggered()
|
||||
Settings settings(this);
|
||||
settings.setModal(true);
|
||||
settings.setWindowModality(Qt::WindowModal);
|
||||
settings.setWindowFlag(Qt::CustomizeWindowHint, true);
|
||||
settings.setWindowFlag(Qt::WindowTitleHint, true);
|
||||
settings.setWindowFlag(Qt::WindowSystemMenuHint, false);
|
||||
settings.exec();
|
||||
|
||||
switch (settings.result()) {
|
||||
|
@@ -39,7 +39,6 @@ signals:
|
||||
void paint(const QImage &image);
|
||||
void resizeContents(int w, int h);
|
||||
void resizeContentsMonitor(int w, int h, int monitor_index);
|
||||
void pollMouse();
|
||||
void statusBarMessage(const QString &msg);
|
||||
void updateStatusBarPanes();
|
||||
void updateStatusBarActivity(int tag, bool active);
|
||||
|
@@ -49,26 +49,19 @@
|
||||
extern "C" {
|
||||
#include <86box/86box.h>
|
||||
#include <86box/config.h>
|
||||
#include <86box/mouse.h>
|
||||
#include <86box/plat.h>
|
||||
#include <86box/video.h>
|
||||
|
||||
double mouse_sensitivity = 1.0;
|
||||
double mouse_x_error = 0.0, mouse_y_error = 0.0;
|
||||
#include <86box/mouse.h>
|
||||
}
|
||||
|
||||
struct mouseinputdata {
|
||||
atomic_int deltax;
|
||||
atomic_int deltay;
|
||||
atomic_int deltaz;
|
||||
atomic_int mousebuttons;
|
||||
atomic_bool mouse_tablet_in_proximity;
|
||||
|
||||
std::atomic<double> x_abs;
|
||||
std::atomic<double> y_abs;
|
||||
};
|
||||
static mouseinputdata mousedata;
|
||||
|
||||
extern "C" void macos_poll_mouse();
|
||||
extern MainWindow *main_window;
|
||||
RendererStack::RendererStack(QWidget *parent, int monitor_index)
|
||||
: QStackedWidget(parent)
|
||||
@@ -94,29 +87,21 @@ RendererStack::RendererStack(QWidget *parent, int monitor_index)
|
||||
# ifdef WAYLAND
|
||||
if (!stricmp(mouse_type, "wayland")) {
|
||||
wl_init();
|
||||
this->mouse_poll_func = wl_mouse_poll;
|
||||
this->mouse_capture_func = wl_mouse_capture;
|
||||
this->mouse_uncapture_func = wl_mouse_uncapture;
|
||||
}
|
||||
# endif
|
||||
# ifdef EVDEV_INPUT
|
||||
if (!stricmp(mouse_type, "evdev")) {
|
||||
if (!stricmp(mouse_type, "evdev"))
|
||||
evdev_init();
|
||||
this->mouse_poll_func = evdev_mouse_poll;
|
||||
}
|
||||
# endif
|
||||
if (!stricmp(mouse_type, "xinput2")) {
|
||||
extern void xinput2_init();
|
||||
extern void xinput2_poll();
|
||||
extern void xinput2_exit();
|
||||
xinput2_init();
|
||||
this->mouse_poll_func = xinput2_poll;
|
||||
this->mouse_exit_func = xinput2_exit;
|
||||
}
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
this->mouse_poll_func = macos_poll_mouse;
|
||||
#endif
|
||||
}
|
||||
|
||||
RendererStack::~RendererStack()
|
||||
@@ -149,49 +134,25 @@ RendererStack::mousePoll()
|
||||
{
|
||||
if (m_monitor_index >= 1) {
|
||||
if (mouse_mode >= 1) {
|
||||
mouse_x_abs = mousedata.x_abs;
|
||||
mouse_y_abs = mousedata.y_abs;
|
||||
if (!mouse_tablet_in_proximity) {
|
||||
mouse_x_abs = mousedata.x_abs;
|
||||
mouse_y_abs = mousedata.y_abs;
|
||||
if (!mouse_tablet_in_proximity)
|
||||
mouse_tablet_in_proximity = mousedata.mouse_tablet_in_proximity;
|
||||
}
|
||||
if (mousedata.mouse_tablet_in_proximity) {
|
||||
mouse_buttons = mousedata.mousebuttons;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
if (mouse_mode == 0) {
|
||||
mouse_x_abs = mousedata.x_abs;
|
||||
mouse_y_abs = mousedata.y_abs;
|
||||
mouse_x_abs = mousedata.x_abs;
|
||||
mouse_y_abs = mousedata.y_abs;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __APPLE__
|
||||
mouse_x = mousedata.deltax;
|
||||
mouse_y = mousedata.deltay;
|
||||
mouse_z = mousedata.deltaz;
|
||||
mousedata.deltax = mousedata.deltay = mousedata.deltaz = 0;
|
||||
mouse_buttons = mousedata.mousebuttons;
|
||||
|
||||
if (this->mouse_poll_func)
|
||||
#endif
|
||||
this->mouse_poll_func();
|
||||
|
||||
mouse_x_abs = mousedata.x_abs;
|
||||
mouse_y_abs = mousedata.y_abs;
|
||||
mouse_tablet_in_proximity = mousedata.mouse_tablet_in_proximity;
|
||||
|
||||
double scaled_x = mouse_x * mouse_sensitivity + mouse_x_error;
|
||||
double scaled_y = mouse_y * mouse_sensitivity + mouse_y_error;
|
||||
|
||||
mouse_x = static_cast<int>(scaled_x);
|
||||
mouse_y = static_cast<int>(scaled_y);
|
||||
|
||||
mouse_x_error = scaled_x - mouse_x;
|
||||
mouse_y_error = scaled_y - mouse_y;
|
||||
}
|
||||
|
||||
int ignoreNextMouseEvent = 1;
|
||||
@@ -212,8 +173,9 @@ RendererStack::mouseReleaseEvent(QMouseEvent *event)
|
||||
isMouseDown &= ~1;
|
||||
return;
|
||||
}
|
||||
if (mouse_capture || mouse_mode >= 1) {
|
||||
mousedata.mousebuttons &= ~event->button();
|
||||
if (mouse_capture || (mouse_mode >= 1)) {
|
||||
if ((mouse_mode >= 1) && ((m_monitor_index < 1) || mousedata.mouse_tablet_in_proximity))
|
||||
mouse_set_buttons_ex(mouse_get_buttons_ex() & ~event->button());
|
||||
}
|
||||
isMouseDown &= ~1;
|
||||
}
|
||||
@@ -222,8 +184,9 @@ void
|
||||
RendererStack::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
isMouseDown |= 1;
|
||||
if (mouse_capture || mouse_mode >= 1) {
|
||||
mousedata.mousebuttons |= event->button();
|
||||
if (mouse_capture || (mouse_mode >= 1)) {
|
||||
if ((mouse_mode >= 1) && ((m_monitor_index < 1) || mousedata.mouse_tablet_in_proximity))
|
||||
mouse_set_buttons_ex(mouse_get_buttons_ex() | event->button());
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
@@ -231,9 +194,7 @@ RendererStack::mousePressEvent(QMouseEvent *event)
|
||||
void
|
||||
RendererStack::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (mouse_capture) {
|
||||
mousedata.deltaz += event->pixelDelta().y();
|
||||
}
|
||||
mouse_set_z(event->pixelDelta().y());
|
||||
}
|
||||
|
||||
void
|
||||
@@ -258,8 +219,12 @@ RendererStack::mouseMoveEvent(QMouseEvent *event)
|
||||
event->accept();
|
||||
return;
|
||||
}
|
||||
mousedata.deltax += event->pos().x() - oldPos.x();
|
||||
mousedata.deltay += event->pos().y() - oldPos.y();
|
||||
|
||||
#if defined __unix__ && !defined __HAIKU__
|
||||
if (!stricmp(mouse_type, "wayland"))
|
||||
mouse_scale(event->pos().x() - oldPos.x(), event->pos().y() - oldPos.y());
|
||||
#endif
|
||||
|
||||
if (QApplication::platformName() == "eglfs") {
|
||||
leaveEvent((QEvent *) event);
|
||||
ignoreNextMouseEvent--;
|
||||
|
@@ -82,9 +82,9 @@ public:
|
||||
rendererWindow->onResize(width, height);
|
||||
}
|
||||
|
||||
void (*mouse_poll_func)() = nullptr;
|
||||
void (*mouse_capture_func)(QWindow *window) = nullptr;
|
||||
void (*mouse_uncapture_func)() = nullptr;
|
||||
|
||||
void (*mouse_exit_func)() = nullptr;
|
||||
|
||||
signals:
|
||||
|
@@ -198,12 +198,6 @@ static const uint16_t sdl_to_xt[0x200] = {
|
||||
[SDL_SCANCODE_NONUSBACKSLASH] = 0x56,
|
||||
};
|
||||
|
||||
typedef struct mouseinputdata {
|
||||
int deltax, deltay, deltaz;
|
||||
int mousebuttons;
|
||||
} mouseinputdata;
|
||||
static mouseinputdata mousedata;
|
||||
|
||||
// #define ENABLE_SDL_LOG 3
|
||||
#ifdef ENABLE_SDL_LOG
|
||||
int sdl_do_log = ENABLE_SDL_LOG;
|
||||
@@ -620,16 +614,14 @@ sdl_main()
|
||||
event.wheel.x *= -1;
|
||||
event.wheel.y *= -1;
|
||||
}
|
||||
mousedata.deltaz = event.wheel.y;
|
||||
mouse_set_z(event.wheel.y);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SDL_MOUSEMOTION:
|
||||
{
|
||||
if (mouse_capture || video_fullscreen) {
|
||||
mousedata.deltax += event.motion.xrel;
|
||||
mousedata.deltay += event.motion.yrel;
|
||||
}
|
||||
if (mouse_capture || video_fullscreen)
|
||||
mouse_scale(event.motion.xrel, event.motion.yrel);
|
||||
break;
|
||||
}
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
@@ -660,10 +652,10 @@ sdl_main()
|
||||
buttonmask = 4;
|
||||
break;
|
||||
}
|
||||
if (event.button.state == SDL_PRESSED) {
|
||||
mousedata.mousebuttons |= buttonmask;
|
||||
} else
|
||||
mousedata.mousebuttons &= ~buttonmask;
|
||||
if (event.button.state == SDL_PRESSED)
|
||||
mouse_set_buttons_ex(mouse_get_buttons_ex() | buttonmask);
|
||||
else
|
||||
mouse_set_buttons_ex(mouse_get_buttons_ex() & ~buttonmask);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -714,13 +706,3 @@ sdl_mouse_capture(int on)
|
||||
{
|
||||
SDL_SetRelativeMouseMode((SDL_bool) on);
|
||||
}
|
||||
|
||||
void
|
||||
sdl_mouse_poll()
|
||||
{
|
||||
mouse_x = mousedata.deltax;
|
||||
mouse_y = mousedata.deltay;
|
||||
mouse_z = mousedata.deltaz;
|
||||
mousedata.deltax = mousedata.deltay = mousedata.deltaz = 0;
|
||||
mouse_buttons = mousedata.mousebuttons;
|
||||
}
|
||||
|
@@ -68,6 +68,5 @@ enum sdl_main_status {
|
||||
extern enum sdl_main_status sdl_main();
|
||||
|
||||
extern void sdl_mouse_capture(int on);
|
||||
extern void sdl_mouse_poll();
|
||||
|
||||
#endif /*WIN_SDL_H*/
|
||||
|
@@ -88,12 +88,6 @@ qt_blit(int x, int y, int w, int h, int monitor_index)
|
||||
main_window->blitToWidget(x, y, w, h, monitor_index);
|
||||
}
|
||||
|
||||
void
|
||||
mouse_poll()
|
||||
{
|
||||
main_window->pollMouse();
|
||||
}
|
||||
|
||||
extern "C" int vid_resize;
|
||||
void
|
||||
plat_resize_request(int w, int h, int monitor_index)
|
||||
|
@@ -35,6 +35,8 @@
|
||||
|
||||
#include <QMenuBar>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <86box/keyboard.h>
|
||||
@@ -338,85 +340,73 @@ void
|
||||
WindowsRawInputFilter::mouse_handle(PRAWINPUT raw)
|
||||
{
|
||||
RAWMOUSE state = raw->data.mouse;
|
||||
static int x;
|
||||
static int y;
|
||||
static int x, delta_x;
|
||||
static int y, delta_y;
|
||||
static int b, delta_z;
|
||||
|
||||
pclog("WindowsRawInputFilter::mouse_handle()\n");
|
||||
|
||||
b = mouse_get_buttons_ex();
|
||||
|
||||
/* read mouse buttons and wheel */
|
||||
if (state.usButtonFlags & RI_MOUSE_LEFT_BUTTON_DOWN)
|
||||
buttons |= 1;
|
||||
b |= 1;
|
||||
else if (state.usButtonFlags & RI_MOUSE_LEFT_BUTTON_UP)
|
||||
buttons &= ~1;
|
||||
b &= ~1;
|
||||
|
||||
if (state.usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_DOWN)
|
||||
buttons |= 4;
|
||||
b |= 4;
|
||||
else if (state.usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_UP)
|
||||
buttons &= ~4;
|
||||
b &= ~4;
|
||||
|
||||
if (state.usButtonFlags & RI_MOUSE_RIGHT_BUTTON_DOWN)
|
||||
buttons |= 2;
|
||||
b |= 2;
|
||||
else if (state.usButtonFlags & RI_MOUSE_RIGHT_BUTTON_UP)
|
||||
buttons &= ~2;
|
||||
b &= ~2;
|
||||
|
||||
if (state.usButtonFlags & RI_MOUSE_BUTTON_4_DOWN)
|
||||
buttons |= 8;
|
||||
b |= 8;
|
||||
else if (state.usButtonFlags & RI_MOUSE_BUTTON_4_UP)
|
||||
buttons &= ~8;
|
||||
b &= ~8;
|
||||
|
||||
if (state.usButtonFlags & RI_MOUSE_BUTTON_5_DOWN)
|
||||
buttons |= 16;
|
||||
b |= 16;
|
||||
else if (state.usButtonFlags & RI_MOUSE_BUTTON_5_UP)
|
||||
buttons &= ~16;
|
||||
|
||||
b &= ~16;
|
||||
|
||||
mouse_set_buttons_ex(b);
|
||||
|
||||
if (state.usButtonFlags & RI_MOUSE_WHEEL) {
|
||||
dwheel += (SHORT) state.usButtonData / 120;
|
||||
}
|
||||
delta_z = (SHORT) state.usButtonData / 120;
|
||||
mouse_set_z(delta_z);
|
||||
} else
|
||||
delta_z = 0;
|
||||
|
||||
if (state.usFlags & MOUSE_MOVE_ABSOLUTE) {
|
||||
/* absolute mouse, i.e. RDP or VNC
|
||||
* seems to work fine for RDP on Windows 10
|
||||
* Not sure about other environments.
|
||||
*/
|
||||
dx += (state.lLastX - x) / 25;
|
||||
dy += (state.lLastY - y) / 25;
|
||||
delta_x = (state.lLastX - x) / 25;
|
||||
delta_y = (state.lLastY - y) / 25;
|
||||
x = state.lLastX;
|
||||
y = state.lLastY;
|
||||
} else {
|
||||
/* relative mouse, i.e. regular mouse */
|
||||
dx += state.lLastX;
|
||||
dy += state.lLastY;
|
||||
delta_x = state.lLastX;
|
||||
delta_y = state.lLastY;
|
||||
}
|
||||
HWND wnd = (HWND) window->winId();
|
||||
|
||||
mouse_scale(delta_x, delta_y);
|
||||
|
||||
HWND wnd = (HWND)window->winId();
|
||||
|
||||
RECT rect;
|
||||
|
||||
GetWindowRect(wnd, &rect);
|
||||
|
||||
int left = rect.left + (rect.right - rect.left) / 2;
|
||||
int top = rect.top + (rect.bottom - rect.top) / 2;
|
||||
int top = rect.top + (rect.bottom - rect.top) / 2;
|
||||
|
||||
SetCursorPos(left, top);
|
||||
}
|
||||
|
||||
void
|
||||
WindowsRawInputFilter::mousePoll()
|
||||
{
|
||||
if (mouse_mode >= 1) return;
|
||||
if (mouse_capture || video_fullscreen) {
|
||||
static int b = 0;
|
||||
|
||||
if (dx != 0 || dy != 0 || dwheel != 0) {
|
||||
mouse_x += dx;
|
||||
mouse_y += dy;
|
||||
mouse_z = dwheel;
|
||||
|
||||
dx = 0;
|
||||
dy = 0;
|
||||
dwheel = 0;
|
||||
}
|
||||
|
||||
if (b != buttons) {
|
||||
mouse_buttons = buttons;
|
||||
b = buttons;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -59,9 +59,6 @@ public:
|
||||
|
||||
~WindowsRawInputFilter();
|
||||
|
||||
public slots:
|
||||
void mousePoll();
|
||||
|
||||
private:
|
||||
MainWindow *window;
|
||||
uint16_t scancode_map[768];
|
||||
|
@@ -26,6 +26,7 @@
|
||||
#include <QGuiApplication>
|
||||
|
||||
extern "C" {
|
||||
#include <86box/mouse.h>
|
||||
#include <86box/plat.h>
|
||||
}
|
||||
|
||||
@@ -34,28 +35,12 @@ static zwp_relative_pointer_v1 *rel_pointer = nullptr;
|
||||
static zwp_pointer_constraints_v1 *conf_pointer_interface = nullptr;
|
||||
static zwp_locked_pointer_v1 *conf_pointer = nullptr;
|
||||
|
||||
static int rel_mouse_x = 0;
|
||||
static int rel_mouse_y = 0;
|
||||
static bool wl_init_ok = false;
|
||||
|
||||
void
|
||||
rel_mouse_event(void *data, zwp_relative_pointer_v1 *zwp_relative_pointer_v1, uint32_t tstmp, uint32_t tstmpl, wl_fixed_t dx, wl_fixed_t dy, wl_fixed_t dx_real, wl_fixed_t dy_real)
|
||||
{
|
||||
rel_mouse_x += wl_fixed_to_int(dx_real);
|
||||
rel_mouse_y += wl_fixed_to_int(dy_real);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
extern int mouse_x, mouse_y;
|
||||
}
|
||||
|
||||
void
|
||||
wl_mouse_poll()
|
||||
{
|
||||
mouse_x = rel_mouse_x;
|
||||
mouse_y = rel_mouse_y;
|
||||
rel_mouse_x = 0;
|
||||
rel_mouse_y = 0;
|
||||
mouse_scale(wl_fixed_to_int(dx_real), wl_fixed_to_int(dy_real));
|
||||
}
|
||||
|
||||
static struct zwp_relative_pointer_v1_listener rel_listener = {
|
||||
|
@@ -1,5 +1,4 @@
|
||||
class QWindow;
|
||||
void wl_mouse_capture(QWindow *window);
|
||||
void wl_mouse_uncapture();
|
||||
void wl_mouse_poll();
|
||||
void wl_init();
|
||||
|
@@ -48,7 +48,7 @@ static Display *disp = nullptr;
|
||||
static QThread *procThread = nullptr;
|
||||
static XIEventMask ximask;
|
||||
static std::atomic<bool> exitfromthread = false;
|
||||
static std::atomic<double> xi2_mouse_x = 0, xi2_mouse_y = 0, xi2_mouse_abs_x = 0, xi2_mouse_abs_y = 0;
|
||||
static std::atomic<double> xi2_mouse_abs_x = 0, xi2_mouse_abs_y = 0;
|
||||
static int xi2opcode = 0;
|
||||
static double prev_coords[2] = { 0.0 };
|
||||
static Time prev_time = 0;
|
||||
@@ -168,9 +168,9 @@ common_motion:
|
||||
if ((v->mode == XIModeRelative) && (rawev->sourceid != xtest_pointer)) {
|
||||
/* Set relative coordinates. */
|
||||
if (axis == 0)
|
||||
xi2_mouse_x = xi2_mouse_x + coords[axis];
|
||||
mouse_scale_x(coords[axis]);
|
||||
else
|
||||
xi2_mouse_y = xi2_mouse_y + coords[axis];
|
||||
mouse_scale_y(coords[axis]);
|
||||
} else {
|
||||
/* Convert absolute value range to pixel granularity, then to relative coordinates. */
|
||||
int disp_screen = XDefaultScreen(disp);
|
||||
@@ -188,7 +188,7 @@ common_motion:
|
||||
}
|
||||
|
||||
if (xi2_mouse_abs_x != 0)
|
||||
xi2_mouse_x = xi2_mouse_x + (abs_div - xi2_mouse_abs_x);
|
||||
mouse_scale_x(abs_div - xi2_mouse_abs_x);
|
||||
xi2_mouse_abs_x = abs_div;
|
||||
} else {
|
||||
if (v->mode == XIModeRelative) {
|
||||
@@ -202,7 +202,7 @@ common_motion:
|
||||
}
|
||||
|
||||
if (xi2_mouse_abs_y != 0)
|
||||
xi2_mouse_y = xi2_mouse_y + (abs_div - xi2_mouse_abs_y);
|
||||
mouse_scale_y(abs_div - xi2_mouse_abs_y);
|
||||
xi2_mouse_abs_y = abs_div;
|
||||
}
|
||||
}
|
||||
@@ -273,14 +273,3 @@ xinput2_init()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
xinput2_poll()
|
||||
{
|
||||
if (procThread && mouse_capture) {
|
||||
mouse_x = xi2_mouse_x;
|
||||
mouse_y = xi2_mouse_y;
|
||||
}
|
||||
xi2_mouse_x = 0;
|
||||
xi2_mouse_y = 0;
|
||||
}
|
||||
|
@@ -699,19 +699,6 @@ typedef struct mouseinputdata {
|
||||
int mousebuttons;
|
||||
} mouseinputdata;
|
||||
SDL_mutex *mousemutex;
|
||||
static mouseinputdata mousedata;
|
||||
void
|
||||
mouse_poll(void)
|
||||
{
|
||||
SDL_LockMutex(mousemutex);
|
||||
mouse_x = mousedata.deltax;
|
||||
mouse_y = mousedata.deltay;
|
||||
mouse_z = mousedata.deltaz;
|
||||
mousedata.deltax = mousedata.deltay = mousedata.deltaz = 0;
|
||||
mouse_buttons = mousedata.mousebuttons;
|
||||
SDL_UnlockMutex(mousemutex);
|
||||
}
|
||||
|
||||
int real_sdl_w;
|
||||
int real_sdl_h;
|
||||
void
|
||||
@@ -1182,7 +1169,7 @@ main(int argc, char **argv)
|
||||
event.wheel.y *= -1;
|
||||
}
|
||||
SDL_LockMutex(mousemutex);
|
||||
mousedata.deltaz = event.wheel.y;
|
||||
mouse_set_z(event.wheel.y);
|
||||
SDL_UnlockMutex(mousemutex);
|
||||
}
|
||||
break;
|
||||
@@ -1191,8 +1178,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
if (mouse_capture || video_fullscreen) {
|
||||
SDL_LockMutex(mousemutex);
|
||||
mousedata.deltax += event.motion.xrel;
|
||||
mousedata.deltay += event.motion.yrel;
|
||||
mouse_scale(event.motion.xrel, event.motion.yrel);
|
||||
SDL_UnlockMutex(mousemutex);
|
||||
}
|
||||
break;
|
||||
@@ -1232,10 +1218,10 @@ main(int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
SDL_LockMutex(mousemutex);
|
||||
if (event.button.state == SDL_PRESSED) {
|
||||
mousedata.mousebuttons |= buttonmask;
|
||||
} else
|
||||
mousedata.mousebuttons &= ~buttonmask;
|
||||
if (event.button.state == SDL_PRESSED)
|
||||
mouse_set_buttons_ex(mouse_get_buttons_ex() | buttonmask);
|
||||
else
|
||||
mouse_set_buttons_ex(mouse_get_buttons_ex() & ~buttonmask);
|
||||
SDL_UnlockMutex(mousemutex);
|
||||
}
|
||||
break;
|
||||
|
@@ -21,17 +21,16 @@
|
||||
*/
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <stdatomic.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <86box/86box.h>
|
||||
#include <86box/mouse.h>
|
||||
#include <86box/pic.h>
|
||||
#include <86box/plat.h>
|
||||
#include <86box/win.h>
|
||||
|
||||
int mouse_capture;
|
||||
double mouse_sensitivity = 1.0; /* Unused. */
|
||||
double mouse_x_error = 0.0; /* Unused. */
|
||||
double mouse_y_error = 0.0; /* Unused. */
|
||||
|
||||
typedef struct {
|
||||
int buttons;
|
||||
@@ -65,53 +64,62 @@ void
|
||||
win_mouse_handle(PRAWINPUT raw)
|
||||
{
|
||||
RAWMOUSE state = raw->data.mouse;
|
||||
static int x;
|
||||
static int y;
|
||||
static int x, delta_x;
|
||||
static int y, delta_y;
|
||||
static int b, delta_z;
|
||||
|
||||
b = mouse_get_buttons_ex();
|
||||
|
||||
/* read mouse buttons and wheel */
|
||||
if (state.usButtonFlags & RI_MOUSE_LEFT_BUTTON_DOWN)
|
||||
mousestate.buttons |= 1;
|
||||
b |= 1;
|
||||
else if (state.usButtonFlags & RI_MOUSE_LEFT_BUTTON_UP)
|
||||
mousestate.buttons &= ~1;
|
||||
b &= ~1;
|
||||
|
||||
if (state.usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_DOWN)
|
||||
mousestate.buttons |= 4;
|
||||
b |= 4;
|
||||
else if (state.usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_UP)
|
||||
mousestate.buttons &= ~4;
|
||||
b &= ~4;
|
||||
|
||||
if (state.usButtonFlags & RI_MOUSE_RIGHT_BUTTON_DOWN)
|
||||
mousestate.buttons |= 2;
|
||||
b |= 2;
|
||||
else if (state.usButtonFlags & RI_MOUSE_RIGHT_BUTTON_UP)
|
||||
mousestate.buttons &= ~2;
|
||||
b &= ~2;
|
||||
|
||||
if (state.usButtonFlags & RI_MOUSE_BUTTON_4_DOWN)
|
||||
mousestate.buttons |= 8;
|
||||
b |= 8;
|
||||
else if (state.usButtonFlags & RI_MOUSE_BUTTON_4_UP)
|
||||
mousestate.buttons &= ~8;
|
||||
b &= ~8;
|
||||
|
||||
if (state.usButtonFlags & RI_MOUSE_BUTTON_5_DOWN)
|
||||
mousestate.buttons |= 16;
|
||||
b |= 16;
|
||||
else if (state.usButtonFlags & RI_MOUSE_BUTTON_5_UP)
|
||||
mousestate.buttons &= ~16;
|
||||
b &= ~16;
|
||||
|
||||
mouse_set_buttons_ex(b);
|
||||
|
||||
if (state.usButtonFlags & RI_MOUSE_WHEEL) {
|
||||
mousestate.dwheel += (SHORT) state.usButtonData / 120;
|
||||
}
|
||||
delta_z = (SHORT) state.usButtonData / 120;
|
||||
mouse_set_z(delta_z);
|
||||
} else
|
||||
delta_z = 0;
|
||||
|
||||
if (state.usFlags & MOUSE_MOVE_ABSOLUTE) {
|
||||
/* absolute mouse, i.e. RDP or VNC
|
||||
* seems to work fine for RDP on Windows 10
|
||||
* Not sure about other environments.
|
||||
*/
|
||||
mousestate.dx += (state.lLastX - x) / 25;
|
||||
mousestate.dy += (state.lLastY - y) / 25;
|
||||
delta_x = (state.lLastX - x) / 25;
|
||||
delta_y = (state.lLastY - y) / 25;
|
||||
x = state.lLastX;
|
||||
y = state.lLastY;
|
||||
} else {
|
||||
/* relative mouse, i.e. regular mouse */
|
||||
mousestate.dx += state.lLastX;
|
||||
mousestate.dy += state.lLastY;
|
||||
delta_x = state.lLastX;
|
||||
delta_y = state.lLastY;
|
||||
}
|
||||
|
||||
mouse_scale(delta_x, delta_y);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -124,27 +132,3 @@ win_mouse_close(void)
|
||||
ridev.usUsage = 0x02;
|
||||
RegisterRawInputDevices(&ridev, 1, sizeof(ridev));
|
||||
}
|
||||
|
||||
void
|
||||
mouse_poll(void)
|
||||
{
|
||||
static int b = 0;
|
||||
if (mouse_capture || video_fullscreen) {
|
||||
if (mousestate.dx != 0 || mousestate.dy != 0 || mousestate.dwheel != 0) {
|
||||
mouse_x += mousestate.dx;
|
||||
mouse_y += mousestate.dy;
|
||||
mouse_z = mousestate.dwheel;
|
||||
|
||||
mousestate.dx = 0;
|
||||
mousestate.dy = 0;
|
||||
mousestate.dwheel = 0;
|
||||
|
||||
// pclog("dx=%d, dy=%d, dwheel=%d\n", mouse_x, mouse_y, mouse_z);
|
||||
}
|
||||
|
||||
if (b != mousestate.buttons) {
|
||||
mouse_buttons = mousestate.buttons;
|
||||
b = mousestate.buttons;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user