Do not allow mouse capturing if no mouse configured.

Fix resetting mouse type to NONE.
This commit is contained in:
waltje
2018-03-18 21:09:07 -05:00
parent d40526144c
commit 110070466a
3 changed files with 10 additions and 15 deletions

View File

@@ -11,7 +11,7 @@
* TODO: Add the Genius bus- and serial mouse. * TODO: Add the Genius bus- and serial mouse.
* Remove the '3-button' flag from mouse types. * Remove the '3-button' flag from mouse types.
* *
* Version: @(#)mouse.c 1.0.2 2018/03/15 * Version: @(#)mouse.c 1.0.3 2018/03/18
* *
* Authors: Fred N. van Kempen, <decwiz@yahoo.com> * Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -124,19 +124,16 @@ mouse_init(void)
void void
mouse_close(void) mouse_close(void)
{ {
if (mouse_type == MOUSE_TYPE_NONE) return;
mouse_priv = NULL; mouse_priv = NULL;
mouse_nbut = 0; mouse_nbut = 0;
mouse_type = MOUSE_TYPE_NONE;
} }
void void
mouse_reset(void) mouse_reset(void)
{ {
/* Abort if already initialized by a machine with internal mouse. */ /* Nothing to do if no mouse, or a machine-internal one. */
if (mouse_type == MOUSE_TYPE_NONE) return; if (mouse_type <= MOUSE_TYPE_INTERNAL) return;
pclog("MOUSE: reset(type=%d, '%s')\n", pclog("MOUSE: reset(type=%d, '%s')\n",
mouse_type, mouse_devices[mouse_type].device->name); mouse_type, mouse_devices[mouse_type].device->name);
@@ -145,9 +142,6 @@ mouse_reset(void)
mouse_x = mouse_y = mouse_z = 0; mouse_x = mouse_y = mouse_z = 0;
mouse_buttons = 0x00; mouse_buttons = 0x00;
/* If no mouse configured, we're done. */
if (mouse_type == 0) return;
/* Copy the (R/O) mouse info. */ /* Copy the (R/O) mouse info. */
if (mouse_devices[mouse_type].device != NULL) { if (mouse_devices[mouse_type].device != NULL) {
memcpy(&mouse_dev, mouse_devices[mouse_type].device, memcpy(&mouse_dev, mouse_devices[mouse_type].device,
@@ -217,9 +211,8 @@ mouse_get_from_internal_name(char *s)
int c = 0; int c = 0;
while (mouse_devices[c].internal_name != NULL) { while (mouse_devices[c].internal_name != NULL) {
if (! strcmp((char *)mouse_devices[c].internal_name, s)) { if (! strcmp((char *)mouse_devices[c].internal_name, s))
return(c); return(c);
}
c++; c++;
} }

View File

@@ -152,7 +152,6 @@ int network_card; /* (C) net interface num */
char network_host[512]; /* (C) host network intf */ char network_host[512]; /* (C) host network intf */
/* Statistics. */ /* Statistics. */
extern int extern int
mmuflush, mmuflush,
@@ -709,8 +708,8 @@ pc_init_modules(void)
cdrom_global_reset(); cdrom_global_reset();
zip_global_reset(); zip_global_reset();
device_init(); device_init();
timer_reset(); timer_reset();
sound_reset(); sound_reset();

View File

@@ -8,7 +8,7 @@
* *
* Implement the user Interface module. * Implement the user Interface module.
* *
* Version: @(#)win_ui.c 1.0.5 2018/03/10 * Version: @(#)win_ui.c 1.0.6 2018/03/18
* *
* Authors: Fred N. van Kempen, <decwiz@yahoo.com> * Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -1088,6 +1088,9 @@ plat_mouse_capture(int on)
{ {
RECT rect; RECT rect;
/* Do not try to capture the mouse if no mouse configured. */
if (mouse_type == MOUSE_TYPE_NONE) return;
if (on && !mouse_capture) { if (on && !mouse_capture) {
/* Enable the in-app mouse. */ /* Enable the in-app mouse. */
GetClipCursor(&oldclip); GetClipCursor(&oldclip);