More clean-ups and mouse fixes.
This commit is contained in:
20
src/device.c
20
src/device.c
@@ -439,13 +439,13 @@ device_has_config(const device_t *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
device_poll(const device_t *dev, int x, int y, int z, int b)
|
device_poll(const device_t *dev)
|
||||||
{
|
{
|
||||||
for (uint16_t c = 0; c < DEVICE_MAX; c++) {
|
for (uint16_t c = 0; c < DEVICE_MAX; c++) {
|
||||||
if (devices[c] != NULL) {
|
if (devices[c] != NULL) {
|
||||||
if (devices[c] == dev) {
|
if (devices[c] == dev) {
|
||||||
if (devices[c]->poll)
|
if (devices[c]->poll)
|
||||||
return (devices[c]->poll(x, y, z, b, 0, 0, device_priv[c]));
|
return (devices[c]->poll(device_priv[c]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -453,22 +453,6 @@ device_poll(const device_t *dev, int x, int y, int z, int b)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
device_register_pci_slot(const device_t *dev, int device, int type, int inta, int intb, int intc, int intd)
|
|
||||||
{
|
|
||||||
for (uint16_t c = 0; c < DEVICE_MAX; c++) {
|
|
||||||
if (devices[c] != NULL) {
|
|
||||||
if (devices[c] == dev) {
|
|
||||||
if (devices[c]->register_pci_slot)
|
|
||||||
devices[c]->register_pci_slot(device, type, inta, intb, intc, intd, device_priv[c]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
device_get_name(const device_t *dev, int bus, char *name)
|
device_get_name(const device_t *dev, int bus, char *name)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ add_library(dev OBJECT bugger.c cassette.c cartridge.c hasp.c hwm.c hwm_lm75.c h
|
|||||||
mouse.c mouse_bus.c mouse_serial.c mouse_ps2.c phoenix_486_jumper.c
|
mouse.c mouse_bus.c mouse_serial.c mouse_ps2.c phoenix_486_jumper.c
|
||||||
mouse_wacom_tablet.c serial_passthrough.c)
|
mouse_wacom_tablet.c serial_passthrough.c)
|
||||||
|
|
||||||
|
target_link_libraries(86Box atomic)
|
||||||
|
|
||||||
if(ISAMEM_RAMPAGE)
|
if(ISAMEM_RAMPAGE)
|
||||||
target_compile_definitions(dev PRIVATE USE_ISAMEM_RAMPAGE)
|
target_compile_definitions(dev PRIVATE USE_ISAMEM_RAMPAGE)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -41,12 +41,6 @@ typedef struct mouse_t {
|
|||||||
} mouse_t;
|
} mouse_t;
|
||||||
|
|
||||||
int mouse_type = 0;
|
int mouse_type = 0;
|
||||||
atomic_int mouse_x;
|
|
||||||
atomic_int mouse_y;
|
|
||||||
atomic_int mouse_z;
|
|
||||||
atomic_int mouse_buttons;
|
|
||||||
atomic_int old_mouse_x;
|
|
||||||
atomic_int old_mouse_y;
|
|
||||||
int mouse_mode;
|
int mouse_mode;
|
||||||
int mouse_timed = 1;
|
int mouse_timed = 1;
|
||||||
int mouse_tablet_in_proximity = 0;
|
int mouse_tablet_in_proximity = 0;
|
||||||
@@ -56,10 +50,6 @@ double mouse_x_abs;
|
|||||||
double mouse_y_abs;
|
double mouse_y_abs;
|
||||||
|
|
||||||
double mouse_sensitivity = 1.0;
|
double mouse_sensitivity = 1.0;
|
||||||
_Atomic double mouse_x_error = 0.0;
|
|
||||||
_Atomic double mouse_y_error = 0.0;
|
|
||||||
_Atomic double mouse_x_raw = 0.0;
|
|
||||||
_Atomic double mouse_y_raw = 0.0;
|
|
||||||
|
|
||||||
pc_timer_t mouse_timer; /* mouse event timer */
|
pc_timer_t mouse_timer; /* mouse event timer */
|
||||||
|
|
||||||
@@ -97,7 +87,7 @@ static mouse_t mouse_devices[] = {
|
|||||||
{ &mouse_internal_device },
|
{ &mouse_internal_device },
|
||||||
{ &mouse_logibus_device },
|
{ &mouse_logibus_device },
|
||||||
{ &mouse_msinport_device },
|
{ &mouse_msinport_device },
|
||||||
#if 0
|
#ifdef USE_GENIBUS
|
||||||
{ &mouse_genibus_device },
|
{ &mouse_genibus_device },
|
||||||
#endif
|
#endif
|
||||||
{ &mouse_mssystems_device },
|
{ &mouse_mssystems_device },
|
||||||
@@ -110,10 +100,18 @@ static mouse_t mouse_devices[] = {
|
|||||||
// clang-format on
|
// clang-format on
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static _Atomic double mouse_x;
|
||||||
|
static _Atomic double mouse_y;
|
||||||
|
static atomic_int mouse_z;
|
||||||
|
static atomic_int mouse_buttons;
|
||||||
|
|
||||||
|
static int mouse_delta_b;
|
||||||
|
static int mouse_old_b;
|
||||||
|
|
||||||
static const device_t *mouse_curr;
|
static const device_t *mouse_curr;
|
||||||
static void *mouse_priv;
|
static void *mouse_priv;
|
||||||
static int mouse_nbut;
|
static int mouse_nbut;
|
||||||
static int (*mouse_dev_poll)(int x, int y, int z, int b, void *priv);
|
static int (*mouse_dev_poll)(void *priv);
|
||||||
static void (*mouse_poll_ex)(void) = NULL;
|
static void (*mouse_poll_ex)(void) = NULL;
|
||||||
|
|
||||||
static double sample_rate = 200.0;
|
static double sample_rate = 200.0;
|
||||||
@@ -136,70 +134,127 @@ mouse_log(const char *fmt, ...)
|
|||||||
# define mouse_log(fmt, ...)
|
# define mouse_log(fmt, ...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void
|
||||||
|
mouse_clear_x(void)
|
||||||
|
{
|
||||||
|
mouse_x = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mouse_clear_y(void)
|
||||||
|
{
|
||||||
|
mouse_y = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mouse_clear_coords(void)
|
mouse_clear_coords(void)
|
||||||
{
|
{
|
||||||
mouse_x = mouse_y = mouse_z = 0;
|
mouse_clear_x();
|
||||||
old_mouse_x = old_mouse_y = 0;
|
mouse_clear_y();
|
||||||
mouse_x_error = mouse_y_error = 0.0;
|
|
||||||
mouse_x_raw = mouse_y_raw = 0.0;
|
mouse_z = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the mouse module. */
|
static void
|
||||||
void
|
mouse_clear_buttons(void)
|
||||||
mouse_init(void)
|
|
||||||
{
|
{
|
||||||
/* Initialize local data. */
|
|
||||||
mouse_clear_coords();
|
|
||||||
mouse_buttons = 0x00;
|
mouse_buttons = 0x00;
|
||||||
|
mouse_old_b = 0x00;
|
||||||
|
|
||||||
mouse_type = MOUSE_TYPE_NONE;
|
mouse_delta_b = 0x00;
|
||||||
mouse_curr = NULL;
|
|
||||||
mouse_priv = NULL;
|
|
||||||
mouse_nbut = 0;
|
|
||||||
mouse_dev_poll = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mouse_close(void)
|
mouse_subtract_x(int *delta_x, int *o_x, int min, int max, int abs)
|
||||||
{
|
{
|
||||||
if (mouse_curr == NULL)
|
double real_x = mouse_x;
|
||||||
return;
|
double smax_x;
|
||||||
|
double rsmin_x;
|
||||||
|
double smin_x;
|
||||||
|
|
||||||
mouse_curr = NULL;
|
rsmin_x = (double) min;
|
||||||
mouse_priv = NULL;
|
if (abs) {
|
||||||
mouse_nbut = 0;
|
smax_x = (double) max + ABS(rsmin_x);
|
||||||
mouse_dev_poll = NULL;
|
max += ABS(min);
|
||||||
|
real_x += rsmin_x;
|
||||||
timer_stop(&mouse_timer);
|
smin_x = 0;
|
||||||
|
} else {
|
||||||
|
smax_x = (double) max;
|
||||||
|
smin_x = rsmin_x;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
/* Default the X and Y overflows to 1. */
|
||||||
mouse_scale_coord_x(int x, int mul)
|
if (o_x != NULL)
|
||||||
{
|
*o_x = 1;
|
||||||
double temp_x = (double) x;
|
|
||||||
double ratio = (double) monitors[0].mon_unscaled_size_x / (double) monitors[0].mon_res_x;
|
|
||||||
|
|
||||||
if (mul)
|
if (real_x > smax_x) {
|
||||||
temp_x *= ratio;
|
*delta_x = abs ? (int) real_x : max;
|
||||||
else
|
real_x -= smax_x;
|
||||||
temp_x /= ratio;
|
} else if (real_x < smin_x) {
|
||||||
|
*delta_x = abs ? (int) real_x : min;
|
||||||
return (int) temp_x;
|
real_x += ABS(smin_x);
|
||||||
|
} else {
|
||||||
|
*delta_x = (int) real_x;
|
||||||
|
real_x = 0.0;
|
||||||
|
if (o_x != NULL)
|
||||||
|
*o_x = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
if (abs)
|
||||||
mouse_scale_coord_y(int y, int mul)
|
real_x -= rsmin_x;
|
||||||
|
|
||||||
|
mouse_x = real_x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* It appears all host platforms give us y in the Microsoft format
|
||||||
|
(positive to the south), so for all non-Microsoft report formsts,
|
||||||
|
we have to invert that. */
|
||||||
|
void
|
||||||
|
mouse_subtract_y(int *delta_y, int *o_y, int min, int max, int invert, int abs)
|
||||||
{
|
{
|
||||||
double temp_y = (double) y;
|
double real_y = mouse_y;
|
||||||
double ratio = (double) monitors[0].mon_efscrnsz_y / (double) monitors[0].mon_res_y;
|
double smax_y;
|
||||||
|
double rsmin_y;
|
||||||
|
double smin_y;
|
||||||
|
|
||||||
if (mul)
|
if (invert)
|
||||||
temp_y *= ratio;
|
real_y = -real_y;
|
||||||
else
|
|
||||||
temp_y /= ratio;
|
|
||||||
|
|
||||||
return (int) temp_y;
|
rsmin_y = (double) min;
|
||||||
|
if (abs) {
|
||||||
|
smax_y = (double) max + ABS(rsmin_y);
|
||||||
|
max += ABS(min);
|
||||||
|
real_y += rsmin_y;
|
||||||
|
smin_y = 0;
|
||||||
|
} else {
|
||||||
|
smax_y = (double) max;
|
||||||
|
smin_y = rsmin_y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Default the X and Y overflows to 1. */
|
||||||
|
if (o_y != NULL)
|
||||||
|
*o_y = 1;
|
||||||
|
|
||||||
|
if (real_y > smax_y) {
|
||||||
|
*delta_y = abs ? (int) real_y : max;
|
||||||
|
real_y -= smax_y;
|
||||||
|
} else if (real_y < smin_y) {
|
||||||
|
*delta_y = abs ? (int) real_y : min;
|
||||||
|
real_y += ABS(smin_y);
|
||||||
|
} else {
|
||||||
|
*delta_y = (int) real_y;
|
||||||
|
real_y = 0.0;
|
||||||
|
if (o_y != NULL)
|
||||||
|
*o_y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (abs)
|
||||||
|
real_y -= rsmin_y;
|
||||||
|
|
||||||
|
if (invert)
|
||||||
|
real_y = -real_y;
|
||||||
|
|
||||||
|
mouse_y = real_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* It appears all host platforms give us y in the Microsoft format
|
/* It appears all host platforms give us y in the Microsoft format
|
||||||
@@ -209,95 +264,38 @@ void
|
|||||||
mouse_subtract_coords(int *delta_x, int *delta_y, int *o_x, int *o_y,
|
mouse_subtract_coords(int *delta_x, int *delta_y, int *o_x, int *o_y,
|
||||||
int min, int max, int invert, int abs)
|
int min, int max, int invert, int abs)
|
||||||
{
|
{
|
||||||
int real_x = mouse_x;
|
mouse_subtract_x(delta_x, o_x, min, max, abs);
|
||||||
int real_y = mouse_y;
|
mouse_subtract_y(delta_y, o_y, min, max, invert, abs);
|
||||||
int smax_x;
|
|
||||||
int smax_y;
|
|
||||||
int rsmin_x;
|
|
||||||
int rsmin_y;
|
|
||||||
int smin_x;
|
|
||||||
int smin_y;
|
|
||||||
|
|
||||||
if (invert)
|
|
||||||
real_y = -real_y;
|
|
||||||
|
|
||||||
rsmin_x = mouse_scale_coord_x(min, 0);
|
|
||||||
rsmin_y = mouse_scale_coord_y(min, 0);
|
|
||||||
if (abs) {
|
|
||||||
smax_x = mouse_scale_coord_x(max, 0) + ABS(rsmin_x);
|
|
||||||
smax_y = mouse_scale_coord_y(max, 0) + ABS(rsmin_y);
|
|
||||||
max += ABS(min);
|
|
||||||
real_x += rsmin_x;
|
|
||||||
real_y += rsmin_y;
|
|
||||||
smin_x = 0;
|
|
||||||
smin_y = 0;
|
|
||||||
} else {
|
|
||||||
smax_x = mouse_scale_coord_x(max, 0);
|
|
||||||
smax_y = mouse_scale_coord_y(max, 0);
|
|
||||||
smin_x = rsmin_x;
|
|
||||||
smin_y = rsmin_y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Default the X and Y overflows to 1. */
|
int
|
||||||
if (o_x != NULL)
|
mouse_moved(void)
|
||||||
*o_x = 1;
|
{
|
||||||
if (o_y != NULL)
|
/* Convert them to integer so we treat < 1.0 and > -1.0 as 0. */
|
||||||
*o_y = 1;
|
int ret = (((int) floor(mouse_x) != 0) || ((int) floor(mouse_y) != 0));
|
||||||
|
|
||||||
if (real_x > smax_x) {
|
return ret;
|
||||||
if (abs)
|
|
||||||
*delta_x = mouse_scale_coord_x(real_x, 1);
|
|
||||||
else
|
|
||||||
*delta_x = max;
|
|
||||||
real_x -= smax_x;
|
|
||||||
} else if (real_x < smin_x) {
|
|
||||||
if (abs)
|
|
||||||
*delta_x = mouse_scale_coord_x(real_x, 1);
|
|
||||||
else
|
|
||||||
*delta_x = min;
|
|
||||||
real_x += ABS(smin_x);
|
|
||||||
} else {
|
|
||||||
if (abs)
|
|
||||||
*delta_x = mouse_scale_coord_x(real_x, 1);
|
|
||||||
else
|
|
||||||
*delta_x = mouse_scale_coord_x(real_x, 1);
|
|
||||||
real_x = 0;
|
|
||||||
if (o_x != NULL)
|
|
||||||
*o_x = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (real_y > smax_y) {
|
int
|
||||||
if (abs)
|
mouse_state_changed(void)
|
||||||
*delta_y = mouse_scale_coord_y(real_y, 1);
|
{
|
||||||
else
|
int b_mask = (1 << mouse_nbut) - 1;
|
||||||
*delta_y = max;
|
int wheel = (mouse_nbut >= 4);
|
||||||
real_y -= smax_y;
|
int ret;
|
||||||
} else if (real_y < smin_y) {
|
|
||||||
if (abs)
|
mouse_delta_b = (mouse_buttons ^ mouse_old_b);
|
||||||
*delta_y = mouse_scale_coord_y(real_y, 1);
|
mouse_old_b = mouse_buttons;
|
||||||
else
|
|
||||||
*delta_y = min;
|
ret = mouse_moved() || ((mouse_z != 0) && wheel) || (mouse_delta_b & b_mask);
|
||||||
real_y += ABS(smin_y);
|
|
||||||
} else {
|
return ret;
|
||||||
if (abs)
|
|
||||||
*delta_y = mouse_scale_coord_y(real_y, 1);
|
|
||||||
else
|
|
||||||
*delta_y = mouse_scale_coord_y(real_y, 1);
|
|
||||||
real_y = 0;
|
|
||||||
if (o_y != NULL)
|
|
||||||
*o_y = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (abs) {
|
int
|
||||||
real_x -= rsmin_x;
|
mouse_mbut_changed(void)
|
||||||
real_y -= rsmin_y;
|
{
|
||||||
}
|
return !!(mouse_delta_b & 0x04);
|
||||||
|
|
||||||
if (invert)
|
|
||||||
real_y = -real_y;
|
|
||||||
|
|
||||||
mouse_x = real_x;
|
|
||||||
mouse_y = real_y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -319,41 +317,27 @@ mouse_timer_poll(UNUSED(void *priv))
|
|||||||
void
|
void
|
||||||
mouse_scale(int x, int y)
|
mouse_scale(int x, int y)
|
||||||
{
|
{
|
||||||
double scaled_x = (((double) x) * mouse_sensitivity);
|
double ratio_x = (double) monitors[0].mon_unscaled_size_x / (double) monitors[0].mon_res_x;
|
||||||
double scaled_y = (((double) y) * mouse_sensitivity);
|
double ratio_y = (double) monitors[0].mon_efscrnsz_y / (double) monitors[0].mon_res_y;
|
||||||
|
|
||||||
scaled_x += mouse_x_error;
|
mouse_x += (((double) x) * mouse_sensitivity * ratio_x);
|
||||||
scaled_y += mouse_y_error;
|
mouse_y += (((double) y) * mouse_sensitivity * ratio_y);
|
||||||
|
|
||||||
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
|
void
|
||||||
mouse_scale_x(int x)
|
mouse_scale_x(int x)
|
||||||
{
|
{
|
||||||
double scaled_x = (((double) x) * mouse_sensitivity);
|
double ratio_x = (double) monitors[0].mon_unscaled_size_x / (double) monitors[0].mon_res_x;
|
||||||
|
|
||||||
scaled_x += mouse_x_error;
|
mouse_x += (((double) x) * mouse_sensitivity * ratio_x);
|
||||||
|
|
||||||
mouse_x += (int) scaled_x;
|
|
||||||
|
|
||||||
mouse_x_error = scaled_x - floor(scaled_x);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mouse_scale_y(int y)
|
mouse_scale_y(int y)
|
||||||
{
|
{
|
||||||
double scaled_y = (((double) y) * mouse_sensitivity);
|
double ratio_y = (double) monitors[0].mon_efscrnsz_y / (double) monitors[0].mon_res_y;
|
||||||
|
|
||||||
scaled_y += mouse_y_error;
|
mouse_y += (((double) y) * mouse_sensitivity * ratio_y);
|
||||||
|
|
||||||
mouse_y += (int) scaled_y;
|
|
||||||
|
|
||||||
mouse_y_error = scaled_y - floor(scaled_y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -362,6 +346,32 @@ mouse_set_z(int z)
|
|||||||
mouse_z += z;
|
mouse_z += z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mouse_clear_z(void)
|
||||||
|
{
|
||||||
|
mouse_z = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mouse_subtract_z(int *delta_z, int min, int max, int invert)
|
||||||
|
{
|
||||||
|
int real_z = invert ? -mouse_z : mouse_z;
|
||||||
|
|
||||||
|
if (mouse_z > max) {
|
||||||
|
*delta_z = max;
|
||||||
|
real_z -= max;
|
||||||
|
} else if (mouse_z < min) {
|
||||||
|
*delta_z = min;
|
||||||
|
real_z += ABS(min);
|
||||||
|
} else {
|
||||||
|
*delta_z = mouse_z;
|
||||||
|
mouse_clear_z();
|
||||||
|
real_z = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
mouse_z = invert ? -real_z : real_z;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mouse_set_buttons_ex(int b)
|
mouse_set_buttons_ex(int b)
|
||||||
{
|
{
|
||||||
@@ -386,39 +396,6 @@ mouse_set_sample_rate(double new_rate)
|
|||||||
timer_on_auto(&mouse_timer, 1000000.0 / sample_rate);
|
timer_on_auto(&mouse_timer, 1000000.0 / sample_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
mouse_reset(void)
|
|
||||||
{
|
|
||||||
if (mouse_curr != NULL)
|
|
||||||
return; /* Mouse already initialized. */
|
|
||||||
|
|
||||||
mouse_log("MOUSE: reset(type=%d, '%s')\n",
|
|
||||||
mouse_type, mouse_devices[mouse_type].device->name);
|
|
||||||
|
|
||||||
/* Clear local data. */
|
|
||||||
mouse_clear_coords();
|
|
||||||
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)
|
|
||||||
return;
|
|
||||||
|
|
||||||
timer_add(&mouse_timer, mouse_timer_poll, NULL, 0);
|
|
||||||
|
|
||||||
/* Poll at 100 Hz, the default of a PS/2 mouse. */
|
|
||||||
sample_rate = 100.0;
|
|
||||||
timer_on_auto(&mouse_timer, 1000000.0 / sample_rate);
|
|
||||||
|
|
||||||
mouse_curr = mouse_devices[mouse_type].device;
|
|
||||||
|
|
||||||
if (mouse_curr != NULL)
|
|
||||||
mouse_priv = device_add(mouse_curr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Callback from the hardware driver. */
|
/* Callback from the hardware driver. */
|
||||||
void
|
void
|
||||||
mouse_set_buttons(int buttons)
|
mouse_set_buttons(int buttons)
|
||||||
@@ -427,9 +404,10 @@ mouse_set_buttons(int buttons)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mouse_set_poll_ex(void (*poll_ex)(void))
|
mouse_get_abs_coords(double *x_abs, double *y_abs)
|
||||||
{
|
{
|
||||||
mouse_poll_ex = poll_ex;
|
*x_abs = mouse_x_abs;
|
||||||
|
*y_abs = mouse_y_abs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -442,14 +420,20 @@ mouse_process(void)
|
|||||||
mouse_poll_ex();
|
mouse_poll_ex();
|
||||||
else if ((mouse_mode == 0) && ((mouse_dev_poll != NULL) || (mouse_curr->poll != NULL))) {
|
else if ((mouse_mode == 0) && ((mouse_dev_poll != NULL) || (mouse_curr->poll != NULL))) {
|
||||||
if (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);
|
mouse_curr->poll(mouse_priv);
|
||||||
else
|
else
|
||||||
mouse_dev_poll(mouse_x, mouse_y, mouse_z, mouse_buttons, mouse_priv);
|
mouse_dev_poll(mouse_priv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
mouse_set_poll(int (*func)(int, int, int, int, void *), void *arg)
|
mouse_set_poll_ex(void (*poll_ex)(void))
|
||||||
|
{
|
||||||
|
mouse_poll_ex = poll_ex;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mouse_set_poll(int (*func)(void *), void *arg)
|
||||||
{
|
{
|
||||||
if (mouse_type != MOUSE_TYPE_INTERNAL)
|
if (mouse_type != MOUSE_TYPE_INTERNAL)
|
||||||
return;
|
return;
|
||||||
@@ -511,3 +495,63 @@ mouse_get_ndev(void)
|
|||||||
{
|
{
|
||||||
return ((sizeof(mouse_devices) / sizeof(mouse_t)) - 1);
|
return ((sizeof(mouse_devices) / sizeof(mouse_t)) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mouse_reset(void)
|
||||||
|
{
|
||||||
|
if (mouse_curr != NULL)
|
||||||
|
return; /* Mouse already initialized. */
|
||||||
|
|
||||||
|
mouse_log("MOUSE: reset(type=%d, '%s')\n",
|
||||||
|
mouse_type, mouse_devices[mouse_type].device->name);
|
||||||
|
|
||||||
|
/* Clear local data. */
|
||||||
|
mouse_clear_coords();
|
||||||
|
mouse_clear_buttons();
|
||||||
|
mouse_mode = 0;
|
||||||
|
mouse_timed = 1;
|
||||||
|
|
||||||
|
/* If no mouse configured, we're done. */
|
||||||
|
if (mouse_type == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
timer_add(&mouse_timer, mouse_timer_poll, NULL, 0);
|
||||||
|
|
||||||
|
/* Poll at 100 Hz, the default of a PS/2 mouse. */
|
||||||
|
sample_rate = 100.0;
|
||||||
|
timer_on_auto(&mouse_timer, 1000000.0 / sample_rate);
|
||||||
|
|
||||||
|
mouse_curr = mouse_devices[mouse_type].device;
|
||||||
|
|
||||||
|
if (mouse_curr != NULL)
|
||||||
|
mouse_priv = device_add(mouse_curr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
mouse_close(void)
|
||||||
|
{
|
||||||
|
if (mouse_curr == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mouse_curr = NULL;
|
||||||
|
mouse_priv = NULL;
|
||||||
|
mouse_nbut = 0;
|
||||||
|
mouse_dev_poll = NULL;
|
||||||
|
|
||||||
|
timer_stop(&mouse_timer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize the mouse module. */
|
||||||
|
void
|
||||||
|
mouse_init(void)
|
||||||
|
{
|
||||||
|
/* Initialize local data. */
|
||||||
|
mouse_clear_coords();
|
||||||
|
mouse_clear_buttons();
|
||||||
|
|
||||||
|
mouse_type = MOUSE_TYPE_NONE;
|
||||||
|
mouse_curr = NULL;
|
||||||
|
mouse_priv = NULL;
|
||||||
|
mouse_nbut = 0;
|
||||||
|
mouse_dev_poll = NULL;
|
||||||
|
}
|
||||||
|
|||||||
@@ -475,12 +475,13 @@ ms_write(uint16_t port, uint8_t val, void *priv)
|
|||||||
|
|
||||||
/* The emulator calls us with an update on the host mouse device. */
|
/* The emulator calls us with an update on the host mouse device. */
|
||||||
static int
|
static int
|
||||||
bm_poll(int x, int y, UNUSED(int z), int b, UNUSED(double abs_x), UNUSED(double abs_y), void *priv)
|
bm_poll(void *priv)
|
||||||
{
|
{
|
||||||
mouse_t *dev = (mouse_t *) priv;
|
mouse_t *dev = (mouse_t *) priv;
|
||||||
int delta_x;
|
int delta_x;
|
||||||
int delta_y;
|
int delta_y;
|
||||||
int xor;
|
int xor;
|
||||||
|
int b = mouse_get_buttons_ex();
|
||||||
|
|
||||||
if (!mouse_capture && !video_fullscreen)
|
if (!mouse_capture && !video_fullscreen)
|
||||||
return 1;
|
return 1;
|
||||||
@@ -488,8 +489,8 @@ bm_poll(int x, int y, UNUSED(int z), int b, UNUSED(double abs_x), UNUSED(double
|
|||||||
if (!(dev->flags & FLAG_ENABLED))
|
if (!(dev->flags & FLAG_ENABLED))
|
||||||
return 1; /* Mouse is disabled, do nothing. */
|
return 1; /* Mouse is disabled, do nothing. */
|
||||||
|
|
||||||
if (!mouse_x && !mouse_y && !((b ^ dev->mouse_buttons_last) & 0x07)) {
|
if (!mouse_state_changed()) {
|
||||||
dev->mouse_buttons_last = b;
|
dev->mouse_buttons_last = 0x00;
|
||||||
return 1; /* State has not changed, do nothing. */
|
return 1; /* State has not changed, do nothing. */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -503,11 +504,11 @@ bm_poll(int x, int y, UNUSED(int z), int b, UNUSED(double abs_x), UNUSED(double
|
|||||||
so update bits 6-3 here. */
|
so update bits 6-3 here. */
|
||||||
|
|
||||||
/* If the mouse has moved, set bit 6. */
|
/* If the mouse has moved, set bit 6. */
|
||||||
if (mouse_x || mouse_y)
|
if (mouse_moved())
|
||||||
dev->mouse_buttons |= 0x40;
|
dev->mouse_buttons |= 0x40;
|
||||||
|
|
||||||
/* Set bits 3-5 according to button state changes. */
|
/* Set bits 3-5 according to button state changes. */
|
||||||
xor = ((dev->current_b ^ dev->mouse_buttons) & 0x07) << 3;
|
xor = ((dev->current_b ^ mouse_get_buttons_ex()) & 0x07) << 3;
|
||||||
dev->mouse_buttons |= xor;
|
dev->mouse_buttons |= xor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,42 +79,36 @@ ps2_report_coordinates(atkbc_dev_t *dev, int main)
|
|||||||
int delta_y;
|
int delta_y;
|
||||||
int overflow_x;
|
int overflow_x;
|
||||||
int overflow_y;
|
int overflow_y;
|
||||||
int temp_z;
|
int b = mouse_get_buttons_ex();
|
||||||
|
int delta_z;
|
||||||
|
|
||||||
mouse_subtract_coords(&delta_x, &delta_y, &overflow_x, &overflow_y,
|
mouse_subtract_coords(&delta_x, &delta_y, &overflow_x, &overflow_y,
|
||||||
-256, 255, 1, 0);
|
-256, 255, 1, 0);
|
||||||
|
mouse_subtract_z(&delta_z, -8, 7, 1);
|
||||||
|
|
||||||
buff[0] = (overflow_y << 7) | (overflow_x << 6) |
|
buff[0] = (overflow_y << 7) | (overflow_x << 6) |
|
||||||
((delta_y & 0x0100) >> 3) | ((delta_x & 0x0100) >> 4) |
|
((delta_y & 0x0100) >> 3) | ((delta_x & 0x0100) >> 4) |
|
||||||
(mouse_buttons & ((dev->flags & FLAG_INTELLI) ? 0x07 : 0x03));
|
(b & ((dev->flags & FLAG_INTELLI) ? 0x07 : 0x03));
|
||||||
buff[1] = (delta_x & 0x00ff);
|
buff[1] = (delta_x & 0x00ff);
|
||||||
buff[2] = (delta_y & 0x00ff);
|
buff[2] = (delta_y & 0x00ff);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
kbc_at_dev_queue_add(dev, buff[0], main);
|
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[1], main);
|
||||||
kbc_at_dev_queue_add(dev, buff[2], main);
|
kbc_at_dev_queue_add(dev, buff[2], main);
|
||||||
if (dev->flags & FLAG_INTMODE) {
|
if (dev->flags & FLAG_INTMODE) {
|
||||||
|
delta_z &= 0x0f;
|
||||||
|
|
||||||
if (dev->flags & FLAG_5BTN) {
|
if (dev->flags & FLAG_5BTN) {
|
||||||
if (mouse_buttons & 8)
|
if (b & 8)
|
||||||
temp_z |= 0x10;
|
delta_z |= 0x10;
|
||||||
if (mouse_buttons & 16)
|
if (b & 16)
|
||||||
temp_z |= 0x20;
|
delta_z |= 0x20;
|
||||||
} else {
|
} else {
|
||||||
/* The wheel coordinate is sign-extended. */
|
/* The wheel coordinate is sign-extended. */
|
||||||
if (temp_z & 0x08)
|
if (delta_z & 0x08)
|
||||||
temp_z |= 0xf0;
|
delta_z |= 0xf0;
|
||||||
}
|
}
|
||||||
kbc_at_dev_queue_add(dev, temp_z, main);
|
kbc_at_dev_queue_add(dev, delta_z, main);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,6 +138,7 @@ static void
|
|||||||
ps2_write(void *priv)
|
ps2_write(void *priv)
|
||||||
{
|
{
|
||||||
atkbc_dev_t *dev = (atkbc_dev_t *) priv;
|
atkbc_dev_t *dev = (atkbc_dev_t *) priv;
|
||||||
|
int b;
|
||||||
uint8_t temp;
|
uint8_t temp;
|
||||||
uint8_t val;
|
uint8_t val;
|
||||||
static uint8_t last_data[6] = { 0x00 };
|
static uint8_t last_data[6] = { 0x00 };
|
||||||
@@ -202,15 +197,16 @@ ps2_write(void *priv)
|
|||||||
|
|
||||||
case 0xe9: /* status request */
|
case 0xe9: /* status request */
|
||||||
mouse_ps2_log("%s: Status request\n", dev->name);
|
mouse_ps2_log("%s: Status request\n", dev->name);
|
||||||
|
b = mouse_get_buttons_ex();
|
||||||
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
kbc_at_dev_queue_add(dev, 0xfa, 0);
|
||||||
temp = (dev->flags & 0x20);
|
temp = (dev->flags & 0x20);
|
||||||
if (mouse_scan)
|
if (mouse_scan)
|
||||||
temp |= FLAG_ENABLED;
|
temp |= FLAG_ENABLED;
|
||||||
if (mouse_buttons & 1)
|
if (b & 1)
|
||||||
temp |= 4;
|
temp |= 4;
|
||||||
if (mouse_buttons & 2)
|
if (b & 2)
|
||||||
temp |= 1;
|
temp |= 1;
|
||||||
if ((mouse_buttons & 4) && (dev->flags & FLAG_INTELLI))
|
if ((b & 4) && (dev->flags & FLAG_INTELLI))
|
||||||
temp |= 2;
|
temp |= 2;
|
||||||
kbc_at_dev_queue_add(dev, temp, 0);
|
kbc_at_dev_queue_add(dev, temp, 0);
|
||||||
kbc_at_dev_queue_add(dev, dev->resolution, 0);
|
kbc_at_dev_queue_add(dev, dev->resolution, 0);
|
||||||
@@ -304,20 +300,16 @@ ps2_write(void *priv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ps2_poll(int x, int y, int z, int b, UNUSED(double abs_x), UNUSED(double abs_y), void *priv)
|
ps2_poll(void *priv)
|
||||||
{
|
{
|
||||||
atkbc_dev_t *dev = (atkbc_dev_t *) priv;
|
atkbc_dev_t *dev = (atkbc_dev_t *) priv;
|
||||||
int packet_size = (dev->flags & FLAG_INTMODE) ? 4 : 3;
|
int packet_size = (dev->flags & FLAG_INTMODE) ? 4 : 3;
|
||||||
|
|
||||||
int cond = (!mouse_capture && !video_fullscreen) || (!mouse_scan || (!x && !y && !z && (b == dev->b))) ||
|
int cond = (!mouse_capture && !video_fullscreen) || (!mouse_scan || mouse_state_changed()) ||
|
||||||
((dev->mode == MODE_STREAM) && (kbc_at_dev_queue_pos(dev, 1) >= (FIFO_SIZE - packet_size)));
|
((dev->mode == MODE_STREAM) && (kbc_at_dev_queue_pos(dev, 1) >= (FIFO_SIZE - packet_size)));
|
||||||
|
|
||||||
if (!cond) {
|
if (!cond && (dev->mode == MODE_STREAM))
|
||||||
dev->b = b;
|
|
||||||
|
|
||||||
if (dev->mode == MODE_STREAM)
|
|
||||||
ps2_report_coordinates(dev, 1);
|
ps2_report_coordinates(dev, 1);
|
||||||
}
|
|
||||||
|
|
||||||
return cond;
|
return cond;
|
||||||
}
|
}
|
||||||
@@ -343,9 +335,6 @@ mouse_ps2_init(const device_t *info)
|
|||||||
if (i > 4)
|
if (i > 4)
|
||||||
dev->flags |= FLAG_EXPLORER;
|
dev->flags |= FLAG_EXPLORER;
|
||||||
|
|
||||||
if (i >= 4)
|
|
||||||
i = 3;
|
|
||||||
|
|
||||||
mouse_ps2_log("%s: buttons=%d\n", dev->name, i);
|
mouse_ps2_log("%s: buttons=%d\n", dev->name, i);
|
||||||
|
|
||||||
/* Tell them how many buttons we have. */
|
/* Tell them how many buttons we have. */
|
||||||
|
|||||||
@@ -82,8 +82,8 @@ typedef struct mouse_t {
|
|||||||
int8_t type; /* type of this device */
|
int8_t type; /* type of this device */
|
||||||
int8_t port;
|
int8_t port;
|
||||||
|
|
||||||
int old_buttons;
|
|
||||||
int state;
|
int state;
|
||||||
|
|
||||||
int bps;
|
int bps;
|
||||||
int rps;
|
int rps;
|
||||||
|
|
||||||
@@ -180,16 +180,17 @@ sermouse_report_msystems(mouse_t *dev)
|
|||||||
{
|
{
|
||||||
int delta_x = 0;
|
int delta_x = 0;
|
||||||
int delta_y = 0;
|
int delta_y = 0;
|
||||||
|
int b = mouse_get_buttons_ex();
|
||||||
|
|
||||||
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 1, 0);
|
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 1, 0);
|
||||||
|
|
||||||
dev->buf[0] = 0x80;
|
dev->buf[0] = 0x80;
|
||||||
dev->buf[0] |= (mouse_buttons & 0x01) ? 0x00 : 0x04; /* left button */
|
dev->buf[0] |= (b & 0x01) ? 0x00 : 0x04; /* left button */
|
||||||
if (dev->but >= 3)
|
if (dev->but >= 3)
|
||||||
dev->buf[0] |= (mouse_buttons & 0x04) ? 0x00 : 0x02; /* middle button */
|
dev->buf[0] |= (b & 0x04) ? 0x00 : 0x02; /* middle button */
|
||||||
else
|
else
|
||||||
dev->buf[0] |= 0x02; /* middle button */
|
dev->buf[0] |= 0x02; /* middle button */
|
||||||
dev->buf[0] |= (mouse_buttons & 0x02) ? 0x00 : 0x01; /* right button */
|
dev->buf[0] |= (b & 0x02) ? 0x00 : 0x01; /* right button */
|
||||||
dev->buf[1] = delta_x;
|
dev->buf[1] = delta_x;
|
||||||
dev->buf[2] = delta_y;
|
dev->buf[2] = delta_y;
|
||||||
dev->buf[2] = delta_x; /* same as byte 1 */
|
dev->buf[2] = delta_x; /* same as byte 1 */
|
||||||
@@ -203,14 +204,15 @@ sermouse_report_3bp(mouse_t *dev)
|
|||||||
{
|
{
|
||||||
int delta_x = 0;
|
int delta_x = 0;
|
||||||
int delta_y = 0;
|
int delta_y = 0;
|
||||||
|
int b = mouse_get_buttons_ex();
|
||||||
|
|
||||||
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 1, 0);
|
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 1, 0);
|
||||||
|
|
||||||
dev->buf[0] = 0x80;
|
dev->buf[0] = 0x80;
|
||||||
dev->buf[0] |= (mouse_buttons & 0x01) ? 0x04 : 0x00; /* left button */
|
dev->buf[0] |= (b & 0x01) ? 0x04 : 0x00; /* left button */
|
||||||
if (dev->but >= 3)
|
if (dev->but >= 3)
|
||||||
dev->buf[0] |= (mouse_buttons & 0x04) ? 0x02 : 0x00; /* middle button */
|
dev->buf[0] |= (b & 0x04) ? 0x02 : 0x00; /* middle button */
|
||||||
dev->buf[0] |= (mouse_buttons & 0x02) ? 0x01 : 0x00; /* right button */
|
dev->buf[0] |= (b & 0x02) ? 0x01 : 0x00; /* right button */
|
||||||
dev->buf[1] = delta_x;
|
dev->buf[1] = delta_x;
|
||||||
dev->buf[2] = delta_y;
|
dev->buf[2] = delta_y;
|
||||||
dev->buf[2] = delta_x; /* same as byte 1 */
|
dev->buf[2] = delta_x; /* same as byte 1 */
|
||||||
@@ -224,6 +226,7 @@ sermouse_report_mmseries(mouse_t *dev)
|
|||||||
{
|
{
|
||||||
int delta_x = 0;
|
int delta_x = 0;
|
||||||
int delta_y = 0;
|
int delta_y = 0;
|
||||||
|
int b = mouse_get_buttons_ex();
|
||||||
|
|
||||||
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -127, 127, 1, 0);
|
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -127, 127, 1, 0);
|
||||||
|
|
||||||
@@ -233,10 +236,10 @@ sermouse_report_mmseries(mouse_t *dev)
|
|||||||
if (delta_y >= 0)
|
if (delta_y >= 0)
|
||||||
dev->buf[0] |= 0x08;
|
dev->buf[0] |= 0x08;
|
||||||
|
|
||||||
dev->buf[0] |= (mouse_buttons & 0x01) ? 0x04 : 0x00; /* left button */
|
dev->buf[0] |= (b & 0x01) ? 0x04 : 0x00; /* left button */
|
||||||
if (dev->but >= 3)
|
if (dev->but >= 3)
|
||||||
dev->buf[0] |= (mouse_buttons & 0x04) ? 0x02 : 0x00; /* middle button */
|
dev->buf[0] |= (b & 0x04) ? 0x02 : 0x00; /* middle button */
|
||||||
dev->buf[0] |= (mouse_buttons & 0x02) ? 0x01 : 0x00; /* right button */
|
dev->buf[0] |= (b & 0x02) ? 0x01 : 0x00; /* right button */
|
||||||
dev->buf[1] = ABS(delta_x) & 0x7f;
|
dev->buf[1] = ABS(delta_x) & 0x7f;
|
||||||
dev->buf[2] = ABS(delta_y) & 0x7f;
|
dev->buf[2] = ABS(delta_y) & 0x7f;
|
||||||
mouse_serial_log("MM series mouse report: %02X %02X %02X\n", dev->buf[0], dev->buf[1], dev->buf[2]);
|
mouse_serial_log("MM series mouse report: %02X %02X %02X\n", dev->buf[0], dev->buf[1], dev->buf[2]);
|
||||||
@@ -249,14 +252,15 @@ sermouse_report_bp1(mouse_t *dev, int abs)
|
|||||||
{
|
{
|
||||||
int delta_x = 0;
|
int delta_x = 0;
|
||||||
int delta_y = 0;
|
int delta_y = 0;
|
||||||
|
int b = mouse_get_buttons_ex();
|
||||||
|
|
||||||
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -2048, 2047, 1, abs);
|
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -2048, 2047, 1, abs);
|
||||||
|
|
||||||
dev->buf[0] = 0x80;
|
dev->buf[0] = 0x80;
|
||||||
dev->buf[0] |= (mouse_buttons & 0x01) ? 0x10 : 0x00; /* left button */
|
dev->buf[0] |= (b & 0x01) ? 0x10 : 0x00; /* left button */
|
||||||
if (dev->but >= 3)
|
if (dev->but >= 3)
|
||||||
dev->buf[0] |= (mouse_buttons & 0x04) ? 0x08 : 0x00; /* middle button */
|
dev->buf[0] |= (b & 0x04) ? 0x08 : 0x00; /* middle button */
|
||||||
dev->buf[0] |= (mouse_buttons & 0x02) ? 0x04 : 0x00; /* right button */
|
dev->buf[0] |= (b & 0x02) ? 0x04 : 0x00; /* right button */
|
||||||
dev->buf[1] = (delta_x & 0x3f);
|
dev->buf[1] = (delta_x & 0x3f);
|
||||||
dev->buf[2] = ((delta_x >> 6) & 0x3f);
|
dev->buf[2] = ((delta_x >> 6) & 0x3f);
|
||||||
dev->buf[3] = (delta_y & 0x3f);
|
dev->buf[3] = (delta_y & 0x3f);
|
||||||
@@ -272,15 +276,17 @@ sermouse_report_ms(mouse_t *dev)
|
|||||||
int delta_x = 0;
|
int delta_x = 0;
|
||||||
int delta_y = 0;
|
int delta_y = 0;
|
||||||
int delta_z = 0;
|
int delta_z = 0;
|
||||||
|
int b = mouse_get_buttons_ex();
|
||||||
|
|
||||||
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 0, 0);
|
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 0, 0);
|
||||||
|
mouse_subtract_z(&delta_z, -8, 7, 1);
|
||||||
|
|
||||||
dev->buf[0] = 0x40;
|
dev->buf[0] = 0x40;
|
||||||
dev->buf[0] |= (((delta_y >> 6) & 0x03) << 2);
|
dev->buf[0] |= (((delta_y >> 6) & 0x03) << 2);
|
||||||
dev->buf[0] |= ((delta_x >> 6) & 0x03);
|
dev->buf[0] |= ((delta_x >> 6) & 0x03);
|
||||||
if (mouse_buttons & 0x01)
|
if (b & 0x01)
|
||||||
dev->buf[0] |= 0x20;
|
dev->buf[0] |= 0x20;
|
||||||
if (mouse_buttons & 0x02)
|
if (b & 0x02)
|
||||||
dev->buf[0] |= 0x10;
|
dev->buf[0] |= 0x10;
|
||||||
dev->buf[1] = delta_x & 0x3f;
|
dev->buf[1] = delta_x & 0x3f;
|
||||||
dev->buf[2] = delta_y & 0x3f;
|
dev->buf[2] = delta_y & 0x3f;
|
||||||
@@ -288,12 +294,12 @@ sermouse_report_ms(mouse_t *dev)
|
|||||||
if (dev->but == 3) {
|
if (dev->but == 3) {
|
||||||
len = 3;
|
len = 3;
|
||||||
if (dev->format == FORMAT_MS) {
|
if (dev->format == FORMAT_MS) {
|
||||||
if (mouse_buttons & 0x04) {
|
if (b & 0x04) {
|
||||||
dev->buf[3] = 0x20;
|
dev->buf[3] = 0x20;
|
||||||
len++;
|
len++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((mouse_buttons ^ dev->old_buttons) & 0x04) {
|
if (mouse_mbut_changed()) {
|
||||||
/* Microsoft 3-button mice send a fourth byte of 0x00 when the middle button
|
/* Microsoft 3-button mice send a fourth byte of 0x00 when the middle button
|
||||||
has changed. */
|
has changed. */
|
||||||
dev->buf[3] = 0x00;
|
dev->buf[3] = 0x00;
|
||||||
@@ -303,19 +309,8 @@ sermouse_report_ms(mouse_t *dev)
|
|||||||
} else if (dev->but == 4) {
|
} else if (dev->but == 4) {
|
||||||
len = 4;
|
len = 4;
|
||||||
|
|
||||||
if (mouse_z > 7) {
|
|
||||||
delta_z = 7;
|
|
||||||
mouse_z -= 7;
|
|
||||||
} else if (mouse_z < -8) {
|
|
||||||
delta_z = -8;
|
|
||||||
mouse_z += 8;
|
|
||||||
} else {
|
|
||||||
delta_z = mouse_z;
|
|
||||||
mouse_z = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev->buf[3] = delta_z & 0x0f;
|
dev->buf[3] = delta_z & 0x0f;
|
||||||
if (mouse_buttons & 0x04)
|
if (b & 0x04)
|
||||||
dev->buf[3] |= 0x10;
|
dev->buf[3] |= 0x10;
|
||||||
} else
|
} else
|
||||||
len = 3;
|
len = 3;
|
||||||
@@ -330,13 +325,14 @@ sermouse_report_hex(mouse_t *dev)
|
|||||||
uint8_t but = 0x00;
|
uint8_t but = 0x00;
|
||||||
int delta_x = 0;
|
int delta_x = 0;
|
||||||
int delta_y = 0;
|
int delta_y = 0;
|
||||||
|
int b = mouse_get_buttons_ex();
|
||||||
|
|
||||||
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 1, 0);
|
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -128, 127, 1, 0);
|
||||||
|
|
||||||
but |= (mouse_buttons & 0x01) ? 0x04 : 0x00; /* left button */
|
but |= (b & 0x01) ? 0x04 : 0x00; /* left button */
|
||||||
if (dev->but >= 3)
|
if (dev->but >= 3)
|
||||||
but |= (mouse_buttons & 0x04) ? 0x02 : 0x00; /* middle button */
|
but |= (b & 0x04) ? 0x02 : 0x00; /* middle button */
|
||||||
but |= (mouse_buttons & 0x02) ? 0x01 : 0x00; /* right button */
|
but |= (b & 0x02) ? 0x01 : 0x00; /* right button */
|
||||||
|
|
||||||
sprintf(ret, "%01X%02X%02X", but & 0x0f, (int8_t) delta_x, (int8_t) delta_y);
|
sprintf(ret, "%01X%02X%02X", but & 0x0f, (int8_t) delta_x, (int8_t) delta_y);
|
||||||
|
|
||||||
@@ -387,16 +383,9 @@ sermouse_report(mouse_t *dev)
|
|||||||
static void
|
static void
|
||||||
sermouse_transmit_report(mouse_t *dev, int from_report)
|
sermouse_transmit_report(mouse_t *dev, int from_report)
|
||||||
{
|
{
|
||||||
int z_changed = (dev->but == 4) ? mouse_z : 0;
|
if (mouse_capture && mouse_state_changed())
|
||||||
int b_changed = ((mouse_buttons ^ dev->old_buttons) & 0x07);
|
|
||||||
|
|
||||||
if (dev->but < 3)
|
|
||||||
b_changed &= ~0x04;
|
|
||||||
|
|
||||||
if (mouse_capture && (mouse_x || mouse_y || z_changed || b_changed)) {
|
|
||||||
sermouse_transmit(dev, sermouse_report(dev), from_report, 1);
|
sermouse_transmit(dev, sermouse_report(dev), from_report, 1);
|
||||||
dev->old_buttons = mouse_buttons;
|
else {
|
||||||
} else {
|
|
||||||
if (dev->prompt || dev->continuous)
|
if (dev->prompt || dev->continuous)
|
||||||
sermouse_set_period(dev, 0.0);
|
sermouse_set_period(dev, 0.0);
|
||||||
else {
|
else {
|
||||||
@@ -418,7 +407,7 @@ sermouse_transmit_report(mouse_t *dev, int from_report)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sermouse_poll(int x, int y, int z, int b, UNUSED(double abs_x), UNUSED(double abs_y), void *priv)
|
sermouse_poll(void *priv)
|
||||||
{
|
{
|
||||||
mouse_t *dev = (mouse_t *) priv;
|
mouse_t *dev = (mouse_t *) priv;
|
||||||
|
|
||||||
@@ -533,6 +522,7 @@ static void
|
|||||||
ltsermouse_process_command(mouse_t *dev)
|
ltsermouse_process_command(mouse_t *dev)
|
||||||
{
|
{
|
||||||
int cmd_to_rps[9] = { 10, 20, 35, 70, 150, 0, -1, 100, 50 };
|
int cmd_to_rps[9] = { 10, 20, 35, 70, 150, 0, -1, 100, 50 };
|
||||||
|
int b;
|
||||||
uint8_t format_codes[FORMATS_NUM] = {
|
uint8_t format_codes[FORMATS_NUM] = {
|
||||||
[FORMAT_BP1_ABS] = 0x0c,
|
[FORMAT_BP1_ABS] = 0x0c,
|
||||||
[FORMAT_BP1_REL] = 0x06,
|
[FORMAT_BP1_REL] = 0x06,
|
||||||
@@ -620,7 +610,8 @@ ltsermouse_process_command(mouse_t *dev)
|
|||||||
break;
|
break;
|
||||||
case 0x05:
|
case 0x05:
|
||||||
/* Diagnostic */
|
/* Diagnostic */
|
||||||
dev->buf[0] = ((mouse_buttons & 0x01) << 2) | ((mouse_buttons & 0x06) >> 1);
|
b = mouse_get_buttons_ex();
|
||||||
|
dev->buf[0] = ((b & 0x01) << 2) | ((b & 0x06) >> 1);
|
||||||
dev->buf[1] = dev->buf[2] = 0x00;
|
dev->buf[1] = dev->buf[2] = 0x00;
|
||||||
sermouse_transmit(dev, 3, 0, 0);
|
sermouse_transmit(dev, 3, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -424,9 +424,17 @@ wacom_write(UNUSED(struct serial_s *serial), void *priv, uint8_t data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
wacom_poll(int x, int y, UNUSED(int z), int b, double abs_x, double abs_y, void *priv)
|
wacom_poll(void *priv)
|
||||||
{
|
{
|
||||||
mouse_wacom_t *wacom = (mouse_wacom_t *) priv;
|
mouse_wacom_t *wacom = (mouse_wacom_t *) priv;
|
||||||
|
int delta_x;
|
||||||
|
int delta_y;
|
||||||
|
int b = mouse_get_buttons_ex();
|
||||||
|
double abs_x;
|
||||||
|
double abs_y;
|
||||||
|
|
||||||
|
mouse_subtract_coords(&delta_x, &delta_y, NULL, NULL, -32768, 32767, 0, 0);
|
||||||
|
mouse_get_abs_coords(&abs_x, &abs_y);
|
||||||
|
|
||||||
if (wacom->settings_bits.cmd_set == WACOM_CMDSET_IV) {
|
if (wacom->settings_bits.cmd_set == WACOM_CMDSET_IV) {
|
||||||
wacom->abs_x = abs_x * 5039. * (wacom->x_res / 1000.);
|
wacom->abs_x = abs_x * 5039. * (wacom->x_res / 1000.);
|
||||||
@@ -442,8 +450,8 @@ wacom_poll(int x, int y, UNUSED(int z), int b, double abs_x, double abs_y, void
|
|||||||
wacom->abs_x = 0;
|
wacom->abs_x = 0;
|
||||||
if (wacom->abs_y < 0)
|
if (wacom->abs_y < 0)
|
||||||
wacom->abs_y = 0;
|
wacom->abs_y = 0;
|
||||||
wacom->rel_x = x;
|
wacom->rel_x = delta_x;
|
||||||
wacom->rel_y = y;
|
wacom->rel_y = delta_y;
|
||||||
}
|
}
|
||||||
if (wacom->b != b)
|
if (wacom->b != b)
|
||||||
wacom->oldb = wacom->b;
|
wacom->oldb = wacom->b;
|
||||||
|
|||||||
@@ -135,8 +135,7 @@ typedef struct _device_ {
|
|||||||
void (*reset)(void *priv);
|
void (*reset)(void *priv);
|
||||||
union {
|
union {
|
||||||
int (*available)(void);
|
int (*available)(void);
|
||||||
int (*poll)(int x, int y, int z, int b, double abs_x, double abs_y, void *priv);
|
int (*poll)(void *priv);
|
||||||
void (*register_pci_slot)(int device, int type, int inta, int intb, int intc, int intd, void *priv);
|
|
||||||
};
|
};
|
||||||
void (*speed_changed)(void *priv);
|
void (*speed_changed)(void *priv);
|
||||||
void (*force_redraw)(void *priv);
|
void (*force_redraw)(void *priv);
|
||||||
@@ -179,8 +178,7 @@ extern void device_close_all(void);
|
|||||||
extern void device_reset_all(uint32_t match_flags);
|
extern void device_reset_all(uint32_t match_flags);
|
||||||
extern void *device_get_priv(const device_t *d);
|
extern void *device_get_priv(const device_t *d);
|
||||||
extern int device_available(const device_t *d);
|
extern int device_available(const device_t *d);
|
||||||
extern int device_poll(const device_t *d, int x, int y, int z, int b);
|
extern int device_poll(const device_t *d);
|
||||||
extern void device_register_pci_slot(const device_t *d, int device, int type, int inta, int intb, int intc, int intd);
|
|
||||||
extern void device_speed_changed(void);
|
extern void device_speed_changed(void);
|
||||||
extern void device_force_redraw(void);
|
extern void device_force_redraw(void);
|
||||||
extern void device_get_name(const device_t *d, int bus, char *name);
|
extern void device_get_name(const device_t *d, int bus, char *name);
|
||||||
|
|||||||
@@ -47,11 +47,6 @@
|
|||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#else
|
|
||||||
extern atomic_int mouse_x;
|
|
||||||
extern atomic_int mouse_y;
|
|
||||||
extern atomic_int mouse_z;
|
|
||||||
extern atomic_int mouse_buttons;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int mouse_type;
|
extern int mouse_type;
|
||||||
@@ -62,19 +57,14 @@ extern double mouse_x_abs;
|
|||||||
extern double mouse_y_abs;
|
extern double mouse_y_abs;
|
||||||
extern int tablet_tool_type;
|
extern int tablet_tool_type;
|
||||||
extern double mouse_sensitivity;
|
extern double mouse_sensitivity;
|
||||||
#ifdef _Atomic
|
|
||||||
extern _Atomic double mouse_x_error;
|
|
||||||
extern _Atomic double mouse_y_error;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef EMU_DEVICE_H
|
#ifdef EMU_DEVICE_H
|
||||||
extern const device_t *mouse_get_device(int mouse);
|
|
||||||
extern void *mouse_ps2_init(const device_t *);
|
extern void *mouse_ps2_init(const device_t *);
|
||||||
|
|
||||||
extern const device_t mouse_logibus_device;
|
extern const device_t mouse_logibus_device;
|
||||||
extern const device_t mouse_logibus_onboard_device;
|
extern const device_t mouse_logibus_onboard_device;
|
||||||
extern const device_t mouse_msinport_device;
|
extern const device_t mouse_msinport_device;
|
||||||
# if 0
|
# ifdef USE_GENIBUS
|
||||||
extern const device_t mouse_genibus_device;
|
extern const device_t mouse_genibus_device;
|
||||||
# endif
|
# endif
|
||||||
extern const device_t mouse_mssystems_device;
|
extern const device_t mouse_mssystems_device;
|
||||||
@@ -85,36 +75,44 @@ extern const device_t mouse_wacom_device;
|
|||||||
extern const device_t mouse_wacom_artpad_device;
|
extern const device_t mouse_wacom_artpad_device;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern void mouse_clear_x(void);
|
||||||
|
extern void mouse_clear_y(void);
|
||||||
extern void mouse_clear_coords(void);
|
extern void mouse_clear_coords(void);
|
||||||
extern void mouse_init(void);
|
extern void mouse_subtract_x(int *delta_x, int *o_x, int min, int max, int abs);
|
||||||
extern void mouse_close(void);
|
extern void mouse_subtract_y(int *delta_y, int *o_y, int min, int max, int invert, int abs);
|
||||||
extern void mouse_subtract_coords(int *delta_x, int *delta_y, int *o_x, int *o_y,
|
extern void mouse_subtract_coords(int *delta_x, int *delta_y, int *o_x, int *o_y,
|
||||||
int min, int max, int invert, int abs);
|
int min, int max, int invert, int abs);
|
||||||
extern void mouse_reset(void);
|
extern int mouse_moved(void);
|
||||||
extern void mouse_set_buttons(int buttons);
|
extern int mouse_state_changed(void);
|
||||||
extern void mouse_set_poll_ex(void (*poll_ex)(void));
|
extern int mouse_mbut_changed(void);
|
||||||
extern void mouse_process(void);
|
|
||||||
extern void mouse_set_poll(int (*f)(int, int, int, int, void *), 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(int x, int y);
|
||||||
extern void mouse_scale_x(int x);
|
extern void mouse_scale_x(int x);
|
||||||
extern void mouse_scale_y(int y);
|
extern void mouse_scale_y(int y);
|
||||||
extern void mouse_set_z(int z);
|
extern void mouse_set_z(int z);
|
||||||
|
extern void mouse_clear_z(void);
|
||||||
|
extern void mouse_subtract_z(int *delta_z, int min, int max, int invert);
|
||||||
extern void mouse_set_buttons_ex(int b);
|
extern void mouse_set_buttons_ex(int b);
|
||||||
extern int mouse_get_buttons_ex(void);
|
extern int mouse_get_buttons_ex(void);
|
||||||
|
extern void mouse_set_sample_rate(double new_rate);
|
||||||
|
extern void mouse_set_buttons(int buttons);
|
||||||
|
extern void mouse_get_abs_coords(double *x_abs, double *y_abs);
|
||||||
|
extern void mouse_process(void);
|
||||||
|
extern void mouse_set_poll_ex(void (*poll_ex)(void));
|
||||||
|
extern void mouse_set_poll(int (*f)(void *), void *);
|
||||||
extern char * mouse_get_name(int mouse);
|
extern char * mouse_get_name(int mouse);
|
||||||
extern char * mouse_get_internal_name(int mouse);
|
extern char * mouse_get_internal_name(int mouse);
|
||||||
extern int mouse_get_from_internal_name(char *s);
|
extern int mouse_get_from_internal_name(char *s);
|
||||||
extern int mouse_has_config(int mouse);
|
extern int mouse_has_config(int mouse);
|
||||||
extern int mouse_get_type(int mouse);
|
#ifdef EMU_DEVICE_H
|
||||||
extern int mouse_get_ndev(void);
|
extern const device_t *mouse_get_device(int mouse);
|
||||||
|
#endif
|
||||||
extern int mouse_get_buttons(void);
|
extern int mouse_get_buttons(void);
|
||||||
|
extern int mouse_get_ndev(void);
|
||||||
|
extern void mouse_reset(void);
|
||||||
|
extern void mouse_close(void);
|
||||||
|
extern void mouse_init(void);
|
||||||
|
|
||||||
extern void mouse_clear_data(void *priv);
|
extern void mouse_bus_set_irq(void *priv, int irq);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,8 +152,6 @@ typedef struct amstrad_t {
|
|||||||
pc_timer_t send_delay_timer;
|
pc_timer_t send_delay_timer;
|
||||||
|
|
||||||
/* Mouse stuff. */
|
/* Mouse stuff. */
|
||||||
uint8_t mousex;
|
|
||||||
uint8_t mousey;
|
|
||||||
int oldb;
|
int oldb;
|
||||||
|
|
||||||
/* Video stuff. */
|
/* Video stuff. */
|
||||||
@@ -2012,9 +2010,9 @@ ms_write(uint16_t addr, UNUSED(uint8_t val), void *priv)
|
|||||||
amstrad_t *ams = (amstrad_t *) priv;
|
amstrad_t *ams = (amstrad_t *) priv;
|
||||||
|
|
||||||
if ((addr == 0x78) || (addr == 0x79))
|
if ((addr == 0x78) || (addr == 0x79))
|
||||||
ams->mousex = 0;
|
mouse_clear_x();
|
||||||
else
|
else
|
||||||
ams->mousey = 0;
|
mouse_clear_y();
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t
|
static uint8_t
|
||||||
@@ -2022,25 +2020,26 @@ ms_read(uint16_t addr, void *priv)
|
|||||||
{
|
{
|
||||||
amstrad_t *ams = (amstrad_t *) priv;
|
amstrad_t *ams = (amstrad_t *) priv;
|
||||||
uint8_t ret;
|
uint8_t ret;
|
||||||
|
int delta = 0;
|
||||||
|
|
||||||
if ((addr == 0x78) || (addr == 0x79)) {
|
if ((addr == 0x78) || (addr == 0x79)) {
|
||||||
ret = ams->mousex;
|
mouse_subtract_x(&delta, NULL, -128, 127, 0);
|
||||||
ams->mousex = 0;
|
mouse_clear_x();
|
||||||
} else {
|
} else {
|
||||||
ret = ams->mousey;
|
mouse_subtract_y(&delta, NULL, -128, 127, 1, 0);
|
||||||
ams->mousey = 0;
|
mouse_clear_y();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = (uint8_t) (int8_t) delta;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ms_poll(int x, int y, UNUSED(int z), int b, void *priv)
|
ms_poll(void *priv)
|
||||||
{
|
{
|
||||||
amstrad_t *ams = (amstrad_t *) priv;
|
amstrad_t *ams = (amstrad_t *) priv;
|
||||||
|
int b = mouse_get_buttons_ex();
|
||||||
ams->mousex += x;
|
|
||||||
ams->mousey -= y;
|
|
||||||
|
|
||||||
if ((b & 1) && !(ams->oldb & 1))
|
if ((b & 1) && !(ams->oldb & 1))
|
||||||
keyboard_send(0x7e);
|
keyboard_send(0x7e);
|
||||||
|
|||||||
@@ -131,9 +131,8 @@ typedef struct m24_kbd_t {
|
|||||||
|
|
||||||
/* Mouse stuff. */
|
/* Mouse stuff. */
|
||||||
int mouse_mode;
|
int mouse_mode;
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
int b;
|
int b;
|
||||||
|
|
||||||
pc_timer_t send_delay_timer;
|
pc_timer_t send_delay_timer;
|
||||||
} m24_kbd_t;
|
} m24_kbd_t;
|
||||||
|
|
||||||
@@ -732,12 +731,14 @@ m24_kbd_reset(void *priv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ms_poll(int x, int y, UNUSED(int z), int b, void *priv)
|
ms_poll(void *priv)
|
||||||
{
|
{
|
||||||
m24_kbd_t *m24_kbd = (m24_kbd_t *) priv;
|
m24_kbd_t *m24_kbd = (m24_kbd_t *) priv;
|
||||||
|
int delta_x;
|
||||||
m24_kbd->x += x;
|
int delta_y;
|
||||||
m24_kbd->y += y;
|
int o_x;
|
||||||
|
int o_y;
|
||||||
|
int b = mouse_get_buttons_ex();
|
||||||
|
|
||||||
if (((key_queue_end - key_queue_start) & 0xf) > 14)
|
if (((key_queue_end - key_queue_start) & 0xf) > 14)
|
||||||
return 0xff;
|
return 0xff;
|
||||||
@@ -770,53 +771,45 @@ ms_poll(int x, int y, UNUSED(int z), int b, void *priv)
|
|||||||
if (((key_queue_end - key_queue_start) & 0xf) > 12)
|
if (((key_queue_end - key_queue_start) & 0xf) > 12)
|
||||||
return 0xff;
|
return 0xff;
|
||||||
|
|
||||||
if (!m24_kbd->x && !m24_kbd->y)
|
if (!mouse_moved())
|
||||||
return 0xff;
|
return 0xff;
|
||||||
|
|
||||||
m24_kbd->y = -m24_kbd->y;
|
mouse_subtract_coords(&delta_x, &delta_y, &o_x, &o_y, -127, 127, 1, 0);
|
||||||
|
|
||||||
if (m24_kbd->x < -127)
|
if ((delta_x == -127) && o_x)
|
||||||
m24_kbd->x = -127;
|
delta_x = 0x80 | ((-delta_x) & 0x7f);
|
||||||
if (m24_kbd->x > 127)
|
|
||||||
m24_kbd->x = 127;
|
|
||||||
if (m24_kbd->x < -127)
|
|
||||||
m24_kbd->x = 0x80 | ((-m24_kbd->x) & 0x7f);
|
|
||||||
|
|
||||||
if (m24_kbd->y < -127)
|
if ((delta_y == -127) && o_y)
|
||||||
m24_kbd->y = -127;
|
delta_y = 0x80 | ((-delta_y) & 0x7f);
|
||||||
if (m24_kbd->y > 127)
|
|
||||||
m24_kbd->y = 127;
|
|
||||||
if (m24_kbd->y < -127)
|
|
||||||
m24_kbd->y = 0x80 | ((-m24_kbd->y) & 0x7f);
|
|
||||||
|
|
||||||
m24_kbd_adddata(0xfe);
|
m24_kbd_adddata(0xfe);
|
||||||
m24_kbd_adddata(m24_kbd->x);
|
m24_kbd_adddata(delta_x);
|
||||||
m24_kbd_adddata(m24_kbd->y);
|
m24_kbd_adddata(delta_y);
|
||||||
|
|
||||||
m24_kbd->x = m24_kbd->y = 0;
|
|
||||||
} else {
|
} else {
|
||||||
while (m24_kbd->x < -4) {
|
mouse_subtract_coords(&delta_x, &delta_y, &o_x, &o_y, -127, 127, 1, 0);
|
||||||
|
|
||||||
|
while (delta_x < -4) {
|
||||||
if (((key_queue_end - key_queue_start) & 0xf) > 14)
|
if (((key_queue_end - key_queue_start) & 0xf) > 14)
|
||||||
return 0xff;
|
return 0xff;
|
||||||
m24_kbd->x += 4;
|
delta_x += 4;
|
||||||
m24_kbd_adddata(m24_kbd->scan[3]);
|
m24_kbd_adddata(m24_kbd->scan[3]);
|
||||||
}
|
}
|
||||||
while (m24_kbd->x > 4) {
|
while (delta_x > 4) {
|
||||||
if (((key_queue_end - key_queue_start) & 0xf) > 14)
|
if (((key_queue_end - key_queue_start) & 0xf) > 14)
|
||||||
return 0xff;
|
return 0xff;
|
||||||
m24_kbd->x -= 4;
|
delta_x -= 4;
|
||||||
m24_kbd_adddata(m24_kbd->scan[4]);
|
m24_kbd_adddata(m24_kbd->scan[4]);
|
||||||
}
|
}
|
||||||
while (m24_kbd->y < -4) {
|
while (delta_y < -4) {
|
||||||
if (((key_queue_end - key_queue_start) & 0xf) > 14)
|
if (((key_queue_end - key_queue_start) & 0xf) > 14)
|
||||||
return 0xff;
|
return 0xff;
|
||||||
m24_kbd->y += 4;
|
delta_y += 4;
|
||||||
m24_kbd_adddata(m24_kbd->scan[5]);
|
m24_kbd_adddata(m24_kbd->scan[5]);
|
||||||
}
|
}
|
||||||
while (m24_kbd->y > 4) {
|
while (delta_y > 4) {
|
||||||
if (((key_queue_end - key_queue_start) & 0xf) > 14)
|
if (((key_queue_end - key_queue_start) & 0xf) > 14)
|
||||||
return 0xff;
|
return 0xff;
|
||||||
m24_kbd->y -= 4;
|
delta_y -= 4;
|
||||||
m24_kbd_adddata(m24_kbd->scan[6]);
|
m24_kbd_adddata(m24_kbd->scan[6]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user