The device_t available/poll union is now gone, mouse poll is now set using mouse_set_poll(), and mouse_curr is now also gone.

This commit is contained in:
OBattler
2025-02-13 00:23:35 +01:00
parent af476f957c
commit 4806519388
10 changed files with 33 additions and 44 deletions

View File

@@ -103,7 +103,7 @@ static const device_t cdrom_interface_none_device = {
.init = NULL, .init = NULL,
.close = NULL, .close = NULL,
.reset = NULL, .reset = NULL,
{ .available = NULL }, .available = NULL,
.speed_changed = NULL, .speed_changed = NULL,
.force_redraw = NULL, .force_redraw = NULL,
.config = NULL .config = NULL

View File

@@ -61,7 +61,7 @@ static const device_t mouse_none_device = {
.init = NULL, .init = NULL,
.close = NULL, .close = NULL,
.reset = NULL, .reset = NULL,
{ .poll = NULL }, .available = NULL,
.speed_changed = NULL, .speed_changed = NULL,
.force_redraw = NULL, .force_redraw = NULL,
.config = NULL .config = NULL
@@ -75,7 +75,7 @@ static const device_t mouse_internal_device = {
.init = NULL, .init = NULL,
.close = NULL, .close = NULL,
.reset = NULL, .reset = NULL,
{ .poll = NULL }, .available = NULL,
.speed_changed = NULL, .speed_changed = NULL,
.force_redraw = NULL, .force_redraw = NULL,
.config = NULL .config = NULL
@@ -111,7 +111,6 @@ static atomic_int mouse_buttons;
static int mouse_delta_b; static int mouse_delta_b;
static int mouse_old_b; static int mouse_old_b;
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_raw; static int mouse_raw;
@@ -537,17 +536,10 @@ mouse_get_abs_coords(double *x_abs, double *y_abs)
void void
mouse_process(void) mouse_process(void)
{ {
if (mouse_curr == NULL)
return;
if ((mouse_input_mode >= 1) && mouse_poll_ex) if ((mouse_input_mode >= 1) && mouse_poll_ex)
mouse_poll_ex(); mouse_poll_ex();
else if ((mouse_input_mode == 0) && ((mouse_dev_poll != NULL) || (mouse_curr->poll != NULL))) { else if ((mouse_input_mode == 0) && (mouse_dev_poll != NULL))
if (mouse_curr->poll != NULL)
mouse_curr->poll(mouse_priv);
else
mouse_dev_poll(mouse_priv); mouse_dev_poll(mouse_priv);
}
} }
void void
@@ -559,9 +551,6 @@ mouse_set_poll_ex(void (*poll_ex)(void))
void void
mouse_set_poll(int (*func)(void *), void *arg) mouse_set_poll(int (*func)(void *), void *arg)
{ {
if (mouse_type != MOUSE_TYPE_INTERNAL)
return;
mouse_dev_poll = func; mouse_dev_poll = func;
mouse_priv = arg; mouse_priv = arg;
} }
@@ -629,7 +618,7 @@ mouse_set_raw(int raw)
void void
mouse_reset(void) mouse_reset(void)
{ {
if (mouse_curr != NULL) if (mouse_priv != NULL)
return; /* Mouse already initialized. */ return; /* Mouse already initialized. */
mouse_log("MOUSE: reset(type=%d, '%s')\n", mouse_log("MOUSE: reset(type=%d, '%s')\n",
@@ -651,19 +640,13 @@ mouse_reset(void)
sample_rate = 100.0; sample_rate = 100.0;
timer_on_auto(&mouse_timer, 1000000.0 / sample_rate); timer_on_auto(&mouse_timer, 1000000.0 / sample_rate);
mouse_curr = mouse_devices[mouse_type].device; if ((mouse_type > 1) && (mouse_devices[mouse_type].device != NULL))
mouse_priv = device_add(mouse_devices[mouse_type].device);
if ((mouse_type > 1) && (mouse_curr != NULL))
mouse_priv = device_add(mouse_curr);
} }
void void
mouse_close(void) mouse_close(void)
{ {
if (mouse_curr == NULL)
return;
mouse_curr = NULL;
mouse_priv = NULL; mouse_priv = NULL;
mouse_nbut = 0; mouse_nbut = 0;
mouse_dev_poll = NULL; mouse_dev_poll = NULL;
@@ -680,7 +663,6 @@ mouse_init(void)
mouse_clear_buttons(); mouse_clear_buttons();
mouse_type = MOUSE_TYPE_NONE; mouse_type = MOUSE_TYPE_NONE;
mouse_curr = NULL;
mouse_priv = NULL; mouse_priv = NULL;
mouse_nbut = 0; mouse_nbut = 0;
mouse_dev_poll = NULL; mouse_dev_poll = NULL;

View File

@@ -680,6 +680,8 @@ bm_init(const device_t *info)
mouse_set_sample_rate(0.0); mouse_set_sample_rate(0.0);
mouse_set_poll(bm_poll, dev);
return dev; return dev;
} }
@@ -818,7 +820,7 @@ const device_t mouse_logibus_device = {
.init = bm_init, .init = bm_init,
.close = bm_close, .close = bm_close,
.reset = NULL, .reset = NULL,
.poll = bm_poll, .available = NULL,
.speed_changed = NULL, .speed_changed = NULL,
.force_redraw = NULL, .force_redraw = NULL,
.config = lt_config .config = lt_config
@@ -832,7 +834,7 @@ const device_t mouse_logibus_onboard_device = {
.init = bm_init, .init = bm_init,
.close = bm_close, .close = bm_close,
.reset = NULL, .reset = NULL,
.poll = bm_poll, .available = NULL,
.speed_changed = NULL, .speed_changed = NULL,
.force_redraw = NULL, .force_redraw = NULL,
.config = NULL .config = NULL
@@ -846,7 +848,7 @@ const device_t mouse_msinport_device = {
.init = bm_init, .init = bm_init,
.close = bm_close, .close = bm_close,
.reset = NULL, .reset = NULL,
.poll = bm_poll, .available = NULL,
.speed_changed = NULL, .speed_changed = NULL,
.force_redraw = NULL, .force_redraw = NULL,
.config = ms_config .config = ms_config

View File

@@ -525,6 +525,7 @@ mtouch_init(UNUSED(const device_t *info))
mouse_input_mode = device_get_config_int("crosshair") + 1; mouse_input_mode = device_get_config_int("crosshair") + 1;
mouse_set_buttons(2); mouse_set_buttons(2);
mouse_set_poll(mtouch_poll, dev);
mouse_set_poll_ex(mtouch_poll_global); mouse_set_poll_ex(mtouch_poll_global);
mtouch_inst = dev; mtouch_inst = dev;
@@ -605,7 +606,7 @@ const device_t mouse_mtouch_device = {
.init = mtouch_init, .init = mtouch_init,
.close = mtouch_close, .close = mtouch_close,
.reset = NULL, .reset = NULL,
.poll = mtouch_poll, .available = NULL,
.speed_changed = NULL, .speed_changed = NULL,
.force_redraw = NULL, .force_redraw = NULL,
.config = mtouch_config .config = mtouch_config

View File

@@ -352,6 +352,8 @@ mouse_ps2_init(const device_t *info)
if (dev->port != NULL) if (dev->port != NULL)
kbc_at_dev_reset(dev, 0); kbc_at_dev_reset(dev, 0);
mouse_set_poll(ps2_poll, dev);
/* Return our private data to the I/O layer. */ /* Return our private data to the I/O layer. */
return dev; return dev;
} }
@@ -397,7 +399,7 @@ const device_t mouse_ps2_device = {
.init = mouse_ps2_init, .init = mouse_ps2_init,
.close = ps2_close, .close = ps2_close,
.reset = NULL, .reset = NULL,
.poll = ps2_poll, .available = NULL,
.speed_changed = NULL, .speed_changed = NULL,
.force_redraw = NULL, .force_redraw = NULL,
.config = ps2_config .config = ps2_config

View File

@@ -909,6 +909,8 @@ sermouse_init(const device_t *info)
/* Tell them how many buttons we have. */ /* Tell them how many buttons we have. */
mouse_set_buttons(dev->but); mouse_set_buttons(dev->but);
mouse_set_poll(sermouse_poll, dev);
/* Return our private data to the I/O layer. */ /* Return our private data to the I/O layer. */
return dev; return dev;
} }
@@ -1075,7 +1077,7 @@ const device_t mouse_mssystems_device = {
.init = sermouse_init, .init = sermouse_init,
.close = sermouse_close, .close = sermouse_close,
.reset = NULL, .reset = NULL,
.poll = sermouse_poll, .available = NULL,
.speed_changed = sermouse_speed_changed, .speed_changed = sermouse_speed_changed,
.force_redraw = NULL, .force_redraw = NULL,
.config = msssermouse_config .config = msssermouse_config
@@ -1089,7 +1091,7 @@ const device_t mouse_msserial_device = {
.init = sermouse_init, .init = sermouse_init,
.close = sermouse_close, .close = sermouse_close,
.reset = NULL, .reset = NULL,
.poll = sermouse_poll, .available = NULL,
.speed_changed = sermouse_speed_changed, .speed_changed = sermouse_speed_changed,
.force_redraw = NULL, .force_redraw = NULL,
.config = mssermouse_config .config = mssermouse_config
@@ -1103,7 +1105,7 @@ const device_t mouse_ltserial_device = {
.init = sermouse_init, .init = sermouse_init,
.close = sermouse_close, .close = sermouse_close,
.reset = NULL, .reset = NULL,
.poll = sermouse_poll, .available = NULL,
.speed_changed = sermouse_speed_changed, .speed_changed = sermouse_speed_changed,
.force_redraw = NULL, .force_redraw = NULL,
.config = ltsermouse_config .config = ltsermouse_config

View File

@@ -662,8 +662,10 @@ wacom_init(const device_t *info)
if (dev->tablet_type->type == WACOM_TYPE_IV) { if (dev->tablet_type->type == WACOM_TYPE_IV) {
wacom_reset_artpad(dev); wacom_reset_artpad(dev);
wacom_process_settings_dword(dev, 0xE2018000); wacom_process_settings_dword(dev, 0xE2018000);
} } else
else wacom_reset(dev); wacom_reset(dev);
mouse_set_poll(wacom_poll, dev);
return dev; return dev;
} }
@@ -721,7 +723,7 @@ const device_t mouse_wacom_device = {
.init = wacom_init, .init = wacom_init,
.close = wacom_close, .close = wacom_close,
.reset = NULL, .reset = NULL,
.poll = wacom_poll, .available = NULL,
.speed_changed = wacom_speed_changed, .speed_changed = wacom_speed_changed,
.force_redraw = NULL, .force_redraw = NULL,
.config = wacom_config .config = wacom_config
@@ -735,7 +737,7 @@ const device_t mouse_wacom_artpad_device = {
.init = wacom_init, .init = wacom_init,
.close = wacom_close, .close = wacom_close,
.reset = NULL, .reset = NULL,
.poll = wacom_poll, .available = NULL,
.speed_changed = wacom_speed_changed, .speed_changed = wacom_speed_changed,
.force_redraw = NULL, .force_redraw = NULL,
.config = wacom_config .config = wacom_config

View File

@@ -366,7 +366,7 @@ const device_t serial_passthrough_device = {
.init = serial_passthrough_dev_init, .init = serial_passthrough_dev_init,
.close = serial_passthrough_dev_close, .close = serial_passthrough_dev_close,
.reset = NULL, .reset = NULL,
.poll = NULL, .available = NULL,
.speed_changed = serial_passthrough_speed_changed, .speed_changed = serial_passthrough_speed_changed,
.force_redraw = NULL, .force_redraw = NULL,
.config = serial_passthrough_config .config = serial_passthrough_config

View File

@@ -165,10 +165,8 @@ typedef struct _device_ {
}; };
void (*close)(void *priv); void (*close)(void *priv);
void (*reset)(void *priv); void (*reset)(void *priv);
union {
int (*available)(void); int (*available)(void);
int (*poll)(void *priv); int (*poll)(void *priv);
};
void (*speed_changed)(void *priv); void (*speed_changed)(void *priv);
void (*force_redraw)(void *priv); void (*force_redraw)(void *priv);

View File

@@ -1621,7 +1621,7 @@ const device_t modem_device = {
.init = modem_init, .init = modem_init,
.close = modem_close, .close = modem_close,
.reset = NULL, .reset = NULL,
.poll = NULL, .available = NULL,
.speed_changed = modem_speed_changed, .speed_changed = modem_speed_changed,
.force_redraw = NULL, .force_redraw = NULL,
.config = modem_config .config = modem_config