diff --git a/src/machine/m_amstrad.c b/src/machine/m_amstrad.c
index e3b73ca06..5a70bf906 100644
--- a/src/machine/m_amstrad.c
+++ b/src/machine/m_amstrad.c
@@ -32,7 +32,7 @@
* in alpha mode, but in highres ("ECD350") mode, it displays
* some semi-random junk. Video-memory pointer maybe?
*
- * Version: @(#)m_amstrad.c 1.0.7 2018/01/28
+ * Version: @(#)m_amstrad.c 1.0.9 2018/01/29
*
* Authors: Sarah Walker,
* Miran Grca,
@@ -1266,6 +1266,7 @@ machine_amstrad_init(machine_t *model)
keyboard_scan = 1;
/* Tell mouse driver about our internal mouse. */
+ mouse_reset();
mouse_set_poll(ms_poll, ams);
if (joystick_type != 7)
diff --git a/src/machine/m_olivetti_m24.c b/src/machine/m_olivetti_m24.c
index 2bc8257a8..9492af865 100644
--- a/src/machine/m_olivetti_m24.c
+++ b/src/machine/m_olivetti_m24.c
@@ -8,7 +8,7 @@
*
* Emulation of the Olivetti M24.
*
- * Version: @(#)m_olivetti_m24.c 1.0.9 2018/01/16
+ * Version: @(#)m_olivetti_m24.c 1.0.10 2018/01/29
*
* Authors: Sarah Walker,
* Miran Grca,
@@ -842,6 +842,7 @@ machine_olim24_init(machine_t *model)
timer_add(kbd_poll, &keyboard_delay, TIMER_ALWAYS_ENABLED, m24);
/* Tell mouse driver about our internal mouse. */
+ mouse_reset();
mouse_set_poll(ms_poll, m24);
if (joystick_type != 7)
diff --git a/src/mouse.c b/src/mouse.c
index 92136fa7d..7c11c6389 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -11,7 +11,7 @@
* TODO: Add the Genius bus- and serial mouse.
* Remove the '3-button' flag from mouse types.
*
- * Version: @(#)mouse.c 1.0.20 2018/01/26
+ * Version: @(#)mouse.c 1.0.21 2018/01/29
*
* Authors: Miran Grca,
* Fred N. van Kempen,
@@ -106,12 +106,12 @@ mouse_close(void)
void
mouse_reset(void)
{
+ if (mouse_curr != NULL)
+ return; /* Mouse already initialized. */
+
pclog("MOUSE: reset(type=%d, '%s')\n",
mouse_type, mouse_devices[mouse_type].device->name);
- /* Close previous mouse, if open. */
- mouse_close();
-
/* Clear local data. */
mouse_x = mouse_y = mouse_z = 0;
mouse_buttons = 0x00;
diff --git a/src/mouse.h b/src/mouse.h
index a2a5dd4f7..84a6c5ec4 100644
--- a/src/mouse.h
+++ b/src/mouse.h
@@ -8,7 +8,7 @@
*
* Definitions for the mouse driver.
*
- * Version: @(#)mouse.h 1.0.13 2018/01/26
+ * Version: @(#)mouse.h 1.0.14 2018/01/29
*
* Authors: Miran Grca,
* Fred N. van Kempen,
@@ -58,6 +58,7 @@ extern device_t mouse_ps2_device;
#endif
extern void mouse_init(void);
+extern void mouse_close(void);
extern void mouse_reset(void);
extern void mouse_set_buttons(int buttons);
extern void mouse_process(void);
diff --git a/src/pc.c b/src/pc.c
index f7d6c0374..0ac95cd4f 100644
--- a/src/pc.c
+++ b/src/pc.c
@@ -749,6 +749,8 @@ pc_reset_hard_close(void)
machine_close();
+ mouse_close();
+
device_close_all();
midi_close();
@@ -791,13 +793,6 @@ pc_reset_hard_init(void)
serial_init();
#endif
- /*
- * This has to be after the serial initialization so that
- * serial_init() doesn't break the serial mouse by resetting
- * the RCR callback to NULL.
- */
- mouse_reset();
-
/* Initialize the actual machine and its basic modules. */
machine_init();
@@ -822,6 +817,13 @@ pc_reset_hard_init(void)
shadowbios = 0;
keyboard_at_reset();
+ /*
+ * This has to be after the serial initialization so that
+ * serial_init() doesn't break the serial mouse by resetting
+ * the RCR callback to NULL.
+ */
+ mouse_reset();
+
/* Reset the video card. */
video_reset(gfxcard);