2017-06-21 00:41:34 -04:00
|
|
|
/*
|
|
|
|
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
|
|
|
|
* running old operating systems and software designed for IBM
|
|
|
|
|
* PC systems and compatibles from 1981 through fairly recent
|
|
|
|
|
* system designs based on the PCI bus.
|
|
|
|
|
*
|
|
|
|
|
* This file is part of the 86Box distribution.
|
|
|
|
|
*
|
|
|
|
|
* Common driver module for MOUSE devices.
|
|
|
|
|
*
|
2017-09-25 04:31:20 -04:00
|
|
|
* Version: @(#)mouse.c 1.0.8 2017/09/24
|
2017-06-21 00:41:34 -04:00
|
|
|
*
|
|
|
|
|
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
|
|
|
|
* Miran Grca, <mgrca8@gmail.com>
|
2017-07-24 18:42:29 +02:00
|
|
|
* TheCollector1995,
|
2017-06-21 00:41:34 -04:00
|
|
|
* Fred N. van Kempen, <decwiz@yahoo.com>
|
|
|
|
|
* Copyright 2008-2017 Sarah Walker.
|
2017-09-25 04:31:20 -04:00
|
|
|
* Copyright 2016,2017 Miran Grca.
|
2017-06-21 00:41:34 -04:00
|
|
|
*/
|
2017-09-25 04:31:20 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <wchar.h>
|
2016-06-26 00:34:39 +02:00
|
|
|
#include "ibm.h"
|
2017-08-27 04:33:47 +01:00
|
|
|
#include "cpu/cpu.h"
|
2017-06-16 16:00:44 -04:00
|
|
|
#include "device.h"
|
2016-06-26 00:34:39 +02:00
|
|
|
#include "mouse.h"
|
2017-09-02 20:39:57 +02:00
|
|
|
#include "machine/machine.h"
|
2017-06-21 00:41:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
static mouse_t mouse_none = {
|
|
|
|
|
"Disabled", "none",
|
|
|
|
|
MOUSE_TYPE_NONE,
|
|
|
|
|
NULL, NULL, NULL
|
|
|
|
|
};
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2017-05-05 01:49:42 +02:00
|
|
|
|
|
|
|
|
static mouse_t *mouse_list[] = {
|
2017-06-21 00:41:34 -04:00
|
|
|
&mouse_none,
|
2017-08-03 14:07:03 -04:00
|
|
|
&mouse_bus_logitech, /* 1 Logitech Bus Mouse 2-button */
|
|
|
|
|
&mouse_bus_msinport, /* 2 Microsoft InPort Mouse */
|
|
|
|
|
&mouse_serial_msystems, /* 3 Mouse Systems Serial Mouse */
|
2017-07-24 18:42:29 +02:00
|
|
|
&mouse_serial_microsoft, /* 4 Microsoft Serial Mouse */
|
|
|
|
|
&mouse_serial_logitech, /* 5 Logitech 3-button Serial Mouse */
|
|
|
|
|
&mouse_serial_mswheel, /* 6 Microsoft Serial Wheel Mouse */
|
2017-08-03 14:07:03 -04:00
|
|
|
&mouse_ps2_2button, /* 7 PS/2 Mouse 2-button */
|
|
|
|
|
&mouse_ps2_intellimouse, /* 8 PS/2 Intellimouse 3-button */
|
2017-07-24 18:42:29 +02:00
|
|
|
&mouse_amstrad, /* 9 Amstrad PC System Mouse */
|
|
|
|
|
&mouse_olim24, /* 10 Olivetti M24 System Mouse */
|
2017-05-29 01:18:32 +02:00
|
|
|
#if 0
|
2017-08-03 14:07:03 -04:00
|
|
|
&mouse_bus_genius, /* 11 Genius Bus Mouse */
|
2017-05-05 01:49:42 +02:00
|
|
|
#endif
|
|
|
|
|
NULL
|
2016-12-23 03:16:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static mouse_t *cur_mouse;
|
|
|
|
|
static void *mouse_p;
|
|
|
|
|
int mouse_type = 0;
|
|
|
|
|
|
2017-05-05 01:49:42 +02:00
|
|
|
|
2017-05-06 17:48:33 +02:00
|
|
|
void
|
|
|
|
|
mouse_emu_init(void)
|
2016-12-23 03:16:24 +01:00
|
|
|
{
|
2017-05-05 01:49:42 +02:00
|
|
|
cur_mouse = mouse_list[mouse_type];
|
2017-06-21 00:41:34 -04:00
|
|
|
|
|
|
|
|
if (cur_mouse == NULL || cur_mouse->init == NULL) return;
|
|
|
|
|
|
2017-05-05 01:49:42 +02:00
|
|
|
mouse_p = cur_mouse->init();
|
2016-12-23 03:16:24 +01:00
|
|
|
}
|
|
|
|
|
|
2017-05-05 01:49:42 +02:00
|
|
|
|
2017-05-06 17:48:33 +02:00
|
|
|
void
|
|
|
|
|
mouse_emu_close(void)
|
2016-12-23 03:16:24 +01:00
|
|
|
{
|
2017-06-21 00:41:34 -04:00
|
|
|
if (cur_mouse == NULL || cur_mouse->close == NULL) return;
|
|
|
|
|
|
|
|
|
|
cur_mouse->close(mouse_p);
|
|
|
|
|
|
2017-05-05 01:49:42 +02:00
|
|
|
cur_mouse = NULL;
|
2017-06-21 00:41:34 -04:00
|
|
|
mouse_p = NULL;
|
2016-12-23 03:16:24 +01:00
|
|
|
}
|
|
|
|
|
|
2017-05-05 01:49:42 +02:00
|
|
|
|
2017-05-06 17:48:33 +02:00
|
|
|
void
|
|
|
|
|
mouse_poll(int x, int y, int z, int b)
|
2016-12-23 03:16:24 +01:00
|
|
|
{
|
2017-06-21 00:41:34 -04:00
|
|
|
if (cur_mouse == NULL || cur_mouse->init == NULL) return;
|
|
|
|
|
|
|
|
|
|
cur_mouse->poll(x, y, z, b, mouse_p);
|
2016-12-23 03:16:24 +01:00
|
|
|
}
|
|
|
|
|
|
2017-05-05 01:49:42 +02:00
|
|
|
|
2017-05-06 17:48:33 +02:00
|
|
|
char *
|
|
|
|
|
mouse_get_name(int mouse)
|
2016-12-23 03:16:24 +01:00
|
|
|
{
|
2017-05-05 01:49:42 +02:00
|
|
|
if (!mouse_list[mouse])
|
|
|
|
|
return(NULL);
|
2017-06-21 00:41:34 -04:00
|
|
|
|
2017-05-05 01:49:42 +02:00
|
|
|
return(mouse_list[mouse]->name);
|
2016-12-23 03:16:24 +01:00
|
|
|
}
|
2017-05-05 01:49:42 +02:00
|
|
|
|
|
|
|
|
|
2017-05-06 17:48:33 +02:00
|
|
|
char *
|
|
|
|
|
mouse_get_internal_name(int mouse)
|
2017-05-05 01:49:42 +02:00
|
|
|
{
|
|
|
|
|
return(mouse_list[mouse]->internal_name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-05-06 17:48:33 +02:00
|
|
|
int
|
|
|
|
|
mouse_get_from_internal_name(char *s)
|
2017-05-05 01:49:42 +02:00
|
|
|
{
|
|
|
|
|
int c = 0;
|
|
|
|
|
|
2017-05-06 17:48:33 +02:00
|
|
|
while (mouse_list[c] != NULL) {
|
2017-05-05 01:49:42 +02:00
|
|
|
if (!strcmp(mouse_list[c]->internal_name, s))
|
|
|
|
|
return(c);
|
|
|
|
|
c++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-05-06 17:48:33 +02:00
|
|
|
int
|
|
|
|
|
mouse_get_type(int mouse)
|
2016-12-23 03:16:24 +01:00
|
|
|
{
|
2017-05-05 01:49:42 +02:00
|
|
|
return(mouse_list[mouse]->type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Return number of MOUSE types we know about. */
|
2017-05-06 17:48:33 +02:00
|
|
|
int
|
|
|
|
|
mouse_get_ndev(void)
|
2017-05-05 01:49:42 +02:00
|
|
|
{
|
|
|
|
|
return(sizeof(mouse_list)/sizeof(mouse_t *) - 1);
|
2016-12-23 03:16:24 +01:00
|
|
|
}
|