Interim cleanup with several small (but, as it turned out, fatal) bugs fixed. This commit mostly cleans the mouse code, but a second commit will finalize those changes.
This commit is contained in:
@@ -997,7 +997,7 @@ int image_open(uint8_t id, wchar_t *fn)
|
|||||||
|
|
||||||
if (!cdrom_image[id].image_inited || cdrom_image[id].image_changed)
|
if (!cdrom_image[id].image_inited || cdrom_image[id].image_changed)
|
||||||
{
|
{
|
||||||
swprintf(cdrom_image[id].image_path, sizeof(cdrom_image[id].image_path)/sizeof(wchar_t), L"%ls", fn);
|
wcscpy(cdrom_image[id].image_path, fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! wcscasecmp(plat_get_extension(fn), L"ISO"))
|
if (! wcscasecmp(plat_get_extension(fn), L"ISO"))
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Configuration file handler.
|
* Configuration file handler.
|
||||||
*
|
*
|
||||||
* Version: @(#)config.c 1.0.26 2017/10/24
|
* Version: @(#)config.c 1.0.27 2017/10/25
|
||||||
*
|
*
|
||||||
* Authors: Sarah Walker,
|
* Authors: Sarah Walker,
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -1126,7 +1126,7 @@ config_load(wchar_t *fn)
|
|||||||
plat_langid = 0x0409;
|
plat_langid = 0x0409;
|
||||||
#endif
|
#endif
|
||||||
scale = 1;
|
scale = 1;
|
||||||
vid_api = 1;
|
vid_api = plat_vidapi("default");;
|
||||||
enable_sync = 1;
|
enable_sync = 1;
|
||||||
joystick_type = 7;
|
joystick_type = 7;
|
||||||
if (hdc_name) {
|
if (hdc_name) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Implementation of the Intel 2 Mbit 8-bit flash devices.
|
* Implementation of the Intel 2 Mbit 8-bit flash devices.
|
||||||
*
|
*
|
||||||
* Version: @(#)intel_flash.c 1.0.9 2017/10/16
|
* Version: @(#)intel_flash.c 1.0.10 2017/10/25
|
||||||
*
|
*
|
||||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -191,11 +191,11 @@ void *intel_flash_init(uint8_t type)
|
|||||||
memset(flash, 0, sizeof(flash_t));
|
memset(flash, 0, sizeof(flash_t));
|
||||||
|
|
||||||
l = strlen(machine_get_internal_name_ex(machine))+1;
|
l = strlen(machine_get_internal_name_ex(machine))+1;
|
||||||
machine_name = (wchar_t *) malloc(l << 1);
|
machine_name = (wchar_t *) malloc(l * sizeof(wchar_t));
|
||||||
mbstowcs(machine_name, machine_get_internal_name_ex(machine), l);
|
mbstowcs(machine_name, machine_get_internal_name_ex(machine), l);
|
||||||
l = wcslen(machine_name)+5;
|
l = wcslen(machine_name)+5;
|
||||||
flash_name = (wchar_t *) malloc(l << 1);
|
flash_name = (wchar_t *)malloc(l*sizeof(wchar_t));
|
||||||
swprintf(flash_name, l, L"%s.bin", machine_name);
|
swprintf(flash_name, l, L"%ls.bin", machine_name);
|
||||||
|
|
||||||
wcscpy(flash_path, flash_name);
|
wcscpy(flash_path, flash_name);
|
||||||
|
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ uint8_t mouse_olim24_poll(int x, int y, int z, int b, void *p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *mouse_olim24_init(void)
|
static void *mouse_olim24_init(mouse_t *info)
|
||||||
{
|
{
|
||||||
mouse_olim24_t *mouse = (mouse_olim24_t *)malloc(sizeof(mouse_olim24_t));
|
mouse_olim24_t *mouse = (mouse_olim24_t *)malloc(sizeof(mouse_olim24_t));
|
||||||
memset(mouse, 0, sizeof(mouse_olim24_t));
|
memset(mouse, 0, sizeof(mouse_olim24_t));
|
||||||
|
|||||||
@@ -22,31 +22,41 @@
|
|||||||
#include "machine.h"
|
#include "machine.h"
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int oldb;
|
||||||
|
} mouse_amstrad_t;
|
||||||
|
|
||||||
|
|
||||||
static uint8_t amstrad_dead;
|
static uint8_t amstrad_dead;
|
||||||
|
static uint8_t mousex, mousey;
|
||||||
|
|
||||||
|
|
||||||
static uint8_t amstrad_read(uint16_t port, void *priv)
|
static uint8_t
|
||||||
|
amstrad_read(uint16_t port, void *priv)
|
||||||
{
|
{
|
||||||
pclog("amstrad_read: %04X\n", port);
|
pclog("amstrad_read: %04X\n", port);
|
||||||
switch (port)
|
|
||||||
{
|
switch (port) {
|
||||||
case 0x379:
|
case 0x379:
|
||||||
return 7;
|
return(7);
|
||||||
|
|
||||||
case 0x37a:
|
case 0x37a:
|
||||||
if (romset == ROM_PC1512) return 0x20;
|
if (romset == ROM_PC1512) return(0x20);
|
||||||
if (romset == ROM_PC200) return 0x80;
|
if (romset == ROM_PC200) return(0x80);
|
||||||
return 0;
|
return(0);
|
||||||
|
|
||||||
case 0xdead:
|
case 0xdead:
|
||||||
return amstrad_dead;
|
return(amstrad_dead);
|
||||||
}
|
}
|
||||||
return 0xff;
|
|
||||||
|
return(0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void amstrad_write(uint16_t port, uint8_t val, void *priv)
|
static void
|
||||||
{
|
amstrad_write(uint16_t port, uint8_t val, void *priv)
|
||||||
switch (port)
|
|
||||||
{
|
{
|
||||||
|
switch (port) {
|
||||||
case 0xdead:
|
case 0xdead:
|
||||||
amstrad_dead = val;
|
amstrad_dead = val;
|
||||||
break;
|
break;
|
||||||
@@ -54,8 +64,8 @@ static void amstrad_write(uint16_t port, uint8_t val, void *priv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uint8_t mousex, mousey;
|
static void
|
||||||
static void amstrad_mouse_write(uint16_t addr, uint8_t val, void *p)
|
amstrad_mouse_write(uint16_t addr, uint8_t val, void *priv)
|
||||||
{
|
{
|
||||||
if (addr == 0x78)
|
if (addr == 0x78)
|
||||||
mousex = 0;
|
mousex = 0;
|
||||||
@@ -63,76 +73,90 @@ static void amstrad_mouse_write(uint16_t addr, uint8_t val, void *p)
|
|||||||
mousey = 0;
|
mousey = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t amstrad_mouse_read(uint16_t addr, void *p)
|
|
||||||
|
static uint8_t
|
||||||
|
amstrad_mouse_read(uint16_t addr, void *priv)
|
||||||
{
|
{
|
||||||
if (addr == 0x78)
|
if (addr == 0x78)
|
||||||
return mousex;
|
return(mousex);
|
||||||
return mousey;
|
|
||||||
|
return(mousey);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct mouse_amstrad_t
|
|
||||||
{
|
|
||||||
int oldb;
|
|
||||||
} mouse_amstrad_t;
|
|
||||||
|
|
||||||
static uint8_t mouse_amstrad_poll(int x, int y, int z, int b, void *p)
|
static uint8_t
|
||||||
|
amstrad_mouse_poll(int x, int y, int z, int b, void *priv)
|
||||||
{
|
{
|
||||||
mouse_amstrad_t *mouse = (mouse_amstrad_t *)p;
|
mouse_amstrad_t *ms = (mouse_amstrad_t *)priv;
|
||||||
|
|
||||||
mousex += x;
|
mousex += x;
|
||||||
mousey -= y;
|
mousey -= y;
|
||||||
|
|
||||||
if ((b & 1) && !(mouse->oldb & 1))
|
if ((b & 1) && !(ms->oldb & 1))
|
||||||
keyboard_send(0x7e);
|
keyboard_send(0x7e);
|
||||||
if ((b & 2) && !(mouse->oldb & 2))
|
if ((b & 2) && !(ms->oldb & 2))
|
||||||
keyboard_send(0x7d);
|
keyboard_send(0x7d);
|
||||||
if (!(b & 1) && (mouse->oldb & 1))
|
if (!(b & 1) && (ms->oldb & 1))
|
||||||
keyboard_send(0xfe);
|
keyboard_send(0xfe);
|
||||||
if (!(b & 2) && (mouse->oldb & 2))
|
if (!(b & 2) && (ms->oldb & 2))
|
||||||
keyboard_send(0xfd);
|
keyboard_send(0xfd);
|
||||||
|
|
||||||
mouse->oldb = b;
|
ms->oldb = b;
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *mouse_amstrad_init(void)
|
static void *
|
||||||
|
amstrad_mouse_init(mouse_t *info)
|
||||||
{
|
{
|
||||||
mouse_amstrad_t *mouse = (mouse_amstrad_t *)malloc(sizeof(mouse_amstrad_t));
|
mouse_amstrad_t *ms = (mouse_amstrad_t *)malloc(sizeof(mouse_amstrad_t));
|
||||||
memset(mouse, 0, sizeof(mouse_amstrad_t));
|
|
||||||
|
|
||||||
return mouse;
|
memset(ms, 0x00, sizeof(mouse_amstrad_t));
|
||||||
|
|
||||||
|
return(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void mouse_amstrad_close(void *p)
|
static void
|
||||||
|
amstrad_mouse_close(void *priv)
|
||||||
{
|
{
|
||||||
mouse_amstrad_t *mouse = (mouse_amstrad_t *)p;
|
mouse_amstrad_t *ms = (mouse_amstrad_t *)priv;
|
||||||
|
|
||||||
free(mouse);
|
free(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mouse_t mouse_amstrad =
|
mouse_t mouse_amstrad = {
|
||||||
{
|
|
||||||
"Amstrad mouse",
|
"Amstrad mouse",
|
||||||
"amstrad",
|
"amstrad",
|
||||||
MOUSE_TYPE_AMSTRAD,
|
MOUSE_TYPE_AMSTRAD,
|
||||||
mouse_amstrad_init,
|
amstrad_mouse_init,
|
||||||
mouse_amstrad_close,
|
amstrad_mouse_close,
|
||||||
mouse_amstrad_poll
|
amstrad_mouse_poll
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void amstrad_init(void)
|
static void
|
||||||
|
amstrad_init(void)
|
||||||
{
|
{
|
||||||
lpt2_remove_ams();
|
lpt2_remove_ams();
|
||||||
|
|
||||||
io_sethandler(0x0078, 0x0001, amstrad_mouse_read, NULL, NULL, amstrad_mouse_write, NULL, NULL, NULL);
|
io_sethandler(0x0078, 1,
|
||||||
io_sethandler(0x007a, 0x0001, amstrad_mouse_read, NULL, NULL, amstrad_mouse_write, NULL, NULL, NULL);
|
amstrad_mouse_read, NULL, NULL,
|
||||||
io_sethandler(0x0379, 0x0002, amstrad_read, NULL, NULL, NULL, NULL, NULL, NULL);
|
amstrad_mouse_write, NULL, NULL, NULL);
|
||||||
io_sethandler(0xdead, 0x0001, amstrad_read, NULL, NULL, amstrad_write, NULL, NULL, NULL);
|
|
||||||
|
io_sethandler(0x007a, 1,
|
||||||
|
amstrad_mouse_read, NULL, NULL,
|
||||||
|
amstrad_mouse_write, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
io_sethandler(0x0379, 2,
|
||||||
|
amstrad_read, NULL, NULL,
|
||||||
|
NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
io_sethandler(0xdead, 1,
|
||||||
|
amstrad_read, NULL, NULL,
|
||||||
|
amstrad_write, NULL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -812,7 +812,7 @@ machine_ps2_common_init(machine_t *model)
|
|||||||
ps2_dma_init();
|
ps2_dma_init();
|
||||||
keyboard_at_init();
|
keyboard_at_init();
|
||||||
keyboard_at_init_ps2();
|
keyboard_at_init_ps2();
|
||||||
mouse_ps2_init();
|
mouse_ps2_init(NULL);
|
||||||
nvr_at_init(8);
|
nvr_at_init(8);
|
||||||
pic2_init();
|
pic2_init();
|
||||||
|
|
||||||
|
|||||||
38
src/mouse.c
38
src/mouse.c
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Common driver module for MOUSE devices.
|
* Common driver module for MOUSE devices.
|
||||||
*
|
*
|
||||||
* Version: @(#)mouse.c 1.0.12 2017/10/24
|
* Version: @(#)mouse.c 1.0.13 2017/10/25
|
||||||
*
|
*
|
||||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -60,8 +60,8 @@ static mouse_t *mouse_list[] = {
|
|||||||
#endif
|
#endif
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
static mouse_t *cur_mouse;
|
static mouse_t *mouse_curr;
|
||||||
static void *mouse_p;
|
static void *mouse_priv;
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -71,23 +71,23 @@ mouse_emu_init(void)
|
|||||||
mouse_x = mouse_y = mouse_z = 0;
|
mouse_x = mouse_y = mouse_z = 0;
|
||||||
mouse_buttons = 0x00;
|
mouse_buttons = 0x00;
|
||||||
|
|
||||||
cur_mouse = mouse_list[mouse_type];
|
mouse_curr = mouse_list[mouse_type];
|
||||||
|
|
||||||
if (cur_mouse == NULL || cur_mouse->init == NULL) return;
|
if (mouse_curr == NULL || mouse_curr->init == NULL) return;
|
||||||
|
|
||||||
mouse_p = cur_mouse->init();
|
mouse_priv = mouse_curr->init(mouse_curr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
mouse_emu_close(void)
|
mouse_emu_close(void)
|
||||||
{
|
{
|
||||||
if (cur_mouse == NULL || cur_mouse->close == NULL) return;
|
if (mouse_curr == NULL || mouse_curr->close == NULL) return;
|
||||||
|
|
||||||
cur_mouse->close(mouse_p);
|
mouse_curr->close(mouse_priv);
|
||||||
|
|
||||||
cur_mouse = NULL;
|
mouse_curr = NULL;
|
||||||
mouse_p = NULL;
|
mouse_priv = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -100,7 +100,8 @@ mouse_process(void)
|
|||||||
|
|
||||||
mouse_poll_host();
|
mouse_poll_host();
|
||||||
|
|
||||||
mouse_poll(mouse_x, mouse_y, mouse_z, mouse_buttons);
|
if (mouse_curr->poll != NULL)
|
||||||
|
mouse_curr->poll(mouse_x,mouse_y,mouse_z,mouse_buttons, mouse_priv);
|
||||||
|
|
||||||
/* Reset mouse deltas. */
|
/* Reset mouse deltas. */
|
||||||
mouse_x = mouse_y = mouse_z = 0;
|
mouse_x = mouse_y = mouse_z = 0;
|
||||||
@@ -109,29 +110,20 @@ mouse_process(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
mouse_poll(int x, int y, int z, int b)
|
|
||||||
{
|
|
||||||
if (cur_mouse == NULL || cur_mouse->init == NULL) return;
|
|
||||||
|
|
||||||
cur_mouse->poll(x, y, z, b, mouse_p);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
mouse_get_name(int mouse)
|
mouse_get_name(int mouse)
|
||||||
{
|
{
|
||||||
if (!mouse_list[mouse])
|
if (!mouse_list[mouse])
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
||||||
return(mouse_list[mouse]->name);
|
return((char *)mouse_list[mouse]->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *
|
char *
|
||||||
mouse_get_internal_name(int mouse)
|
mouse_get_internal_name(int mouse)
|
||||||
{
|
{
|
||||||
return(mouse_list[mouse]->internal_name);
|
return((char *)mouse_list[mouse]->internal_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -141,7 +133,7 @@ mouse_get_from_internal_name(char *s)
|
|||||||
int c = 0;
|
int c = 0;
|
||||||
|
|
||||||
while (mouse_list[c] != NULL) {
|
while (mouse_list[c] != NULL) {
|
||||||
if (!strcmp(mouse_list[c]->internal_name, s))
|
if (!strcmp((char *)mouse_list[c]->internal_name, s))
|
||||||
return(c);
|
return(c);
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
|
|||||||
13
src/mouse.h
13
src/mouse.h
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Definitions for the MOUSE driver.
|
* Definitions for the MOUSE driver.
|
||||||
*
|
*
|
||||||
* Version: @(#)mouse.h 1.0.6 2017/10/24
|
* Version: @(#)mouse.h 1.0.7 2017/10/25
|
||||||
*
|
*
|
||||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -42,11 +42,11 @@
|
|||||||
#define MOUSE_TYPE_3BUTTON (1<<7) /* device has 3+ buttons */
|
#define MOUSE_TYPE_3BUTTON (1<<7) /* device has 3+ buttons */
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct _mouse_ {
|
||||||
char name[80];
|
const char *name;
|
||||||
char internal_name[24];
|
const char *internal_name;
|
||||||
int type;
|
int type;
|
||||||
void *(*init)(void);
|
void *(*init)(struct _mouse_ *);
|
||||||
void (*close)(void *p);
|
void (*close)(void *p);
|
||||||
uint8_t (*poll)(int x, int y, int z, int b, void *p);
|
uint8_t (*poll)(int x, int y, int z, int b, void *p);
|
||||||
} mouse_t;
|
} mouse_t;
|
||||||
@@ -67,12 +67,11 @@ extern mouse_t mouse_ps2_2button;
|
|||||||
extern mouse_t mouse_ps2_intellimouse;
|
extern mouse_t mouse_ps2_intellimouse;
|
||||||
|
|
||||||
|
|
||||||
extern void *mouse_ps2_init(void);
|
extern void *mouse_ps2_init(void *);
|
||||||
|
|
||||||
extern void mouse_emu_init(void);
|
extern void mouse_emu_init(void);
|
||||||
extern void mouse_emu_close(void);
|
extern void mouse_emu_close(void);
|
||||||
|
|
||||||
extern void mouse_poll(int x, int y, int z, int b);
|
|
||||||
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);
|
||||||
|
|||||||
486
src/mouse_bus.c
486
src/mouse_bus.c
@@ -32,10 +32,9 @@
|
|||||||
* Based on an early driver for MINIX 1.5.
|
* Based on an early driver for MINIX 1.5.
|
||||||
* Based on the 86Box PS/2 mouse driver as a framework.
|
* Based on the 86Box PS/2 mouse driver as a framework.
|
||||||
*
|
*
|
||||||
* Version: @(#)mouse_bus.c 1.0.10 2017/10/16
|
* Version: @(#)mouse_bus.c 1.0.20 2017/10/25
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
* TheCollector1995
|
|
||||||
*
|
*
|
||||||
* Copyright 1989-2017 Fred N. van Kempen.
|
* Copyright 1989-2017 Fred N. van Kempen.
|
||||||
*/
|
*/
|
||||||
@@ -62,7 +61,8 @@
|
|||||||
|
|
||||||
/* Our mouse device. */
|
/* Our mouse device. */
|
||||||
typedef struct mouse_bus {
|
typedef struct mouse_bus {
|
||||||
int8_t type;
|
char *name; /* name of this device */
|
||||||
|
int8_t type; /* type of this device */
|
||||||
uint8_t flags; /* device flags */
|
uint8_t flags; /* device flags */
|
||||||
uint16_t port; /* I/O port range start */
|
uint16_t port; /* I/O port range start */
|
||||||
uint16_t portlen; /* length of I/O port range */
|
uint16_t portlen; /* length of I/O port range */
|
||||||
@@ -80,15 +80,16 @@ typedef struct mouse_bus {
|
|||||||
void (*write)(struct mouse_bus *, uint16_t, uint8_t);
|
void (*write)(struct mouse_bus *, uint16_t, uint8_t);
|
||||||
} mouse_bus_t;
|
} mouse_bus_t;
|
||||||
#define MOUSE_ENABLED 0x80 /* device is enabled for use */
|
#define MOUSE_ENABLED 0x80 /* device is enabled for use */
|
||||||
|
#define MOUSE_SCALED 0x40 /* enable delta scaling */
|
||||||
#define MOUSE_FROZEN 0x01 /* do not update counters */
|
#define MOUSE_FROZEN 0x01 /* do not update counters */
|
||||||
|
|
||||||
|
|
||||||
/* Definitions for Logitech. */
|
/* Definitions for Logitech. */
|
||||||
#define LTMOUSE_DATA 0 /* DATA register */
|
#define MOUSE_DATA 0 /* DATA register */
|
||||||
#define LTMOUSE_MAGIC 1 /* signature magic register */
|
#define MOUSE_MAGIC 1 /* signature magic register */
|
||||||
# define MAGIC_BYTE1 0xa5 /* most drivers use this */
|
# define MAGIC_BYTE1 0xa5 /* most drivers use this */
|
||||||
# define MAGIC_BYTE2 0x5a /* some drivers use this */
|
# define MAGIC_BYTE2 0x5a /* some drivers use this */
|
||||||
#define LTMOUSE_CTRL 2 /* CTRL register */
|
#define MOUSE_CTRL 2 /* CTRL register */
|
||||||
# define CTRL_FREEZE 0x80 /* do not sample when set */
|
# define CTRL_FREEZE 0x80 /* do not sample when set */
|
||||||
# define CTRL_RD_Y_HI 0x60 /* plus FREEZE */
|
# define CTRL_RD_Y_HI 0x60 /* plus FREEZE */
|
||||||
# define CTRL_RD_Y_LO 0x40 /* plus FREEZE */
|
# define CTRL_RD_Y_LO 0x40 /* plus FREEZE */
|
||||||
@@ -97,45 +98,31 @@ typedef struct mouse_bus {
|
|||||||
# define CTRL_RD_MASK 0x60
|
# define CTRL_RD_MASK 0x60
|
||||||
# define CTRL_IDIS 0x10
|
# define CTRL_IDIS 0x10
|
||||||
# define CTRL_IENB 0x00
|
# define CTRL_IENB 0x00
|
||||||
#define LTMOUSE_CONFIG 3 /* CONFIG register */
|
#define MOUSE_CONFIG 3 /* CONFIG register */
|
||||||
|
|
||||||
/* Definitions for Microsoft. */
|
|
||||||
#define MSMOUSE_CTRL 0 /* CTRL register */
|
|
||||||
# define MSCTRL_RESET 0x80
|
|
||||||
# define MSCTRL_MODE 0x07
|
|
||||||
# define MSCTRL_RD_Y 0x02
|
|
||||||
# define MSCTRL_RD_X 0x01
|
|
||||||
# define MSCTRL_RD_BUT 0x00
|
|
||||||
#define MSMOUSE_DATA 1 /* DATA register */
|
|
||||||
# define MSDATA_BASE 0x10
|
|
||||||
# define MSDATA_IRQ 0x01
|
|
||||||
#define MSMOUSE_MAGIC 2 /* MAGIC register */
|
|
||||||
# define MAGIC_MSBYTE1 0xde /* indicates MS InPort */
|
|
||||||
# define MAGIC_MSBYTE2 0xad
|
|
||||||
#define MSMOUSE_CONFIG 3 /* CONFIG register */
|
|
||||||
|
|
||||||
|
|
||||||
/* Handle a WRITE to a LOGITECH register. */
|
/* Handle a WRITE to a LOGITECH register. */
|
||||||
static void
|
static void
|
||||||
lt_write(mouse_bus_t *ms, uint16_t port, uint8_t val)
|
lt_write(mouse_bus_t *ms, uint16_t port, uint8_t val)
|
||||||
{
|
{
|
||||||
uint8_t b = (ms->r_ctrl ^ val);
|
uint8_t b;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
pclog("BUSMOUSE: lt_write(%d,%02x)\n", port, val);
|
pclog("BUSMOUSE: lt_write(%d,%02x)\n", port, val);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
switch (port) {
|
switch (port) {
|
||||||
case LTMOUSE_DATA: /* [00] data register */
|
case MOUSE_DATA: /* [00] data register */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LTMOUSE_MAGIC: /* [01] magic data register */
|
case MOUSE_MAGIC: /* [01] magic data register */
|
||||||
if (val == MAGIC_BYTE1 || val == MAGIC_BYTE2) {
|
if (val == MAGIC_BYTE1 || val == MAGIC_BYTE2) {
|
||||||
ms->r_magic = val;
|
ms->r_magic = val;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LTMOUSE_CTRL: /* [02] control register */
|
case MOUSE_CTRL: /* [02] control register */
|
||||||
|
b = (ms->r_ctrl ^ val);
|
||||||
if (b & CTRL_FREEZE) {
|
if (b & CTRL_FREEZE) {
|
||||||
if (val & CTRL_FREEZE) {
|
if (val & CTRL_FREEZE) {
|
||||||
/* Hold the sampling while we do something. */
|
/* Hold the sampling while we do something. */
|
||||||
@@ -159,7 +146,7 @@ lt_write(mouse_bus_t *ms, uint16_t port, uint8_t val)
|
|||||||
ms->r_ctrl = val;
|
ms->r_ctrl = val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LTMOUSE_CONFIG: /* [03] config register */
|
case MOUSE_CONFIG: /* [03] config register */
|
||||||
ms->r_conf = val;
|
ms->r_conf = val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -176,7 +163,7 @@ lt_read(mouse_bus_t *ms, uint16_t port)
|
|||||||
uint8_t r = 0xff;
|
uint8_t r = 0xff;
|
||||||
|
|
||||||
switch (port) {
|
switch (port) {
|
||||||
case LTMOUSE_DATA: /* [00] data register */
|
case MOUSE_DATA: /* [00] data register */
|
||||||
if (! (ms->r_ctrl & CTRL_FREEZE)) {
|
if (! (ms->r_ctrl & CTRL_FREEZE)) {
|
||||||
r = 0x00;
|
r = 0x00;
|
||||||
} else switch(ms->r_ctrl & CTRL_RD_MASK) {
|
} else switch(ms->r_ctrl & CTRL_RD_MASK) {
|
||||||
@@ -228,7 +215,7 @@ lt_read(mouse_bus_t *ms, uint16_t port)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LTMOUSE_MAGIC: /* [01] magic data register */
|
case MOUSE_MAGIC: /* [01] magic data register */
|
||||||
/*
|
/*
|
||||||
* Logitech drivers start out by blasting their magic
|
* Logitech drivers start out by blasting their magic
|
||||||
* value (0xA5) into this register, and then read it
|
* value (0xA5) into this register, and then read it
|
||||||
@@ -239,7 +226,7 @@ lt_read(mouse_bus_t *ms, uint16_t port)
|
|||||||
r = ms->r_magic;
|
r = ms->r_magic;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LTMOUSE_CTRL: /* [02] control register */
|
case MOUSE_CTRL: /* [02] control register */
|
||||||
/*
|
/*
|
||||||
* This is the weird stuff mentioned in the file header
|
* This is the weird stuff mentioned in the file header
|
||||||
* above. Microsoft's "mouse.exe" does some whacky stuff
|
* above. Microsoft's "mouse.exe" does some whacky stuff
|
||||||
@@ -272,7 +259,7 @@ lt_read(mouse_bus_t *ms, uint16_t port)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LTMOUSE_CONFIG: /* [03] config register */
|
case MOUSE_CONFIG: /* [03] config register */
|
||||||
r = ms->r_conf;
|
r = ms->r_conf;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -292,7 +279,7 @@ lt_read(mouse_bus_t *ms, uint16_t port)
|
|||||||
static void
|
static void
|
||||||
lt_init(mouse_bus_t *ms)
|
lt_init(mouse_bus_t *ms)
|
||||||
{
|
{
|
||||||
pclog("Logitech Bus Mouse, I/O=%04x, IRQ=%d\n", ms->port, ms->irq);
|
pclog("BUSMOUSE: %s, I/O=%04x, IRQ=%d\n", ms->name, ms->port, ms->irq);
|
||||||
|
|
||||||
/* Initialize registers. */
|
/* Initialize registers. */
|
||||||
ms->r_magic = 0x00;
|
ms->r_magic = 0x00;
|
||||||
@@ -310,7 +297,7 @@ lt_init(mouse_bus_t *ms)
|
|||||||
|
|
||||||
/* Handle a WRITE operation to one of our registers. */
|
/* Handle a WRITE operation to one of our registers. */
|
||||||
static void
|
static void
|
||||||
busmouse_write(uint16_t port, uint8_t val, void *priv)
|
bm_write(uint16_t port, uint8_t val, void *priv)
|
||||||
{
|
{
|
||||||
mouse_bus_t *ms = (mouse_bus_t *)priv;
|
mouse_bus_t *ms = (mouse_bus_t *)priv;
|
||||||
|
|
||||||
@@ -320,7 +307,7 @@ busmouse_write(uint16_t port, uint8_t val, void *priv)
|
|||||||
|
|
||||||
/* Handle a READ operation from one of our registers. */
|
/* Handle a READ operation from one of our registers. */
|
||||||
static uint8_t
|
static uint8_t
|
||||||
busmouse_read(uint16_t port, void *priv)
|
bm_read(uint16_t port, void *priv)
|
||||||
{
|
{
|
||||||
mouse_bus_t *ms = (mouse_bus_t *)priv;
|
mouse_bus_t *ms = (mouse_bus_t *)priv;
|
||||||
uint8_t r;
|
uint8_t r;
|
||||||
@@ -333,7 +320,7 @@ busmouse_read(uint16_t port, 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 uint8_t
|
static uint8_t
|
||||||
busmouse_poll(int x, int y, int z, int b, void *priv)
|
bm_poll(int x, int y, int z, int b, void *priv)
|
||||||
{
|
{
|
||||||
mouse_bus_t *ms = (mouse_bus_t *)priv;
|
mouse_bus_t *ms = (mouse_bus_t *)priv;
|
||||||
|
|
||||||
@@ -343,10 +330,16 @@ busmouse_poll(int x, int y, int z, int b, void *priv)
|
|||||||
/* If we are not interested, return. */
|
/* If we are not interested, return. */
|
||||||
if (!(ms->flags & MOUSE_ENABLED) || (ms->flags & MOUSE_FROZEN)) return(0);
|
if (!(ms->flags & MOUSE_ENABLED) || (ms->flags & MOUSE_FROZEN)) return(0);
|
||||||
|
|
||||||
#if 0
|
#if 1
|
||||||
pclog("BUSMOUSE: poll(%d,%d,%d, %02x)\n", x, y, z, b);
|
pclog("BUSMOUSE: poll(%d,%d,%d, %02x)\n", x, y, z, b);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (ms->flags & MOUSE_SCALED) {
|
||||||
|
/* Scale down the motion. */
|
||||||
|
if ((x < -1) || (x > 1)) x >>= 1;
|
||||||
|
if ((y < -1) || (y > 1)) y >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Add the delta to our state. */
|
/* Add the delta to our state. */
|
||||||
x += ms->x;
|
x += ms->x;
|
||||||
if (x > 127)
|
if (x > 127)
|
||||||
@@ -365,7 +358,7 @@ busmouse_poll(int x, int y, int z, int b, void *priv)
|
|||||||
ms->but = b;
|
ms->but = b;
|
||||||
|
|
||||||
/* All set, generate an interrupt. */
|
/* All set, generate an interrupt. */
|
||||||
if (! (ms->r_ctrl & CTRL_IDIS))
|
// if (! (ms->r_ctrl & CTRL_IDIS))
|
||||||
picint(1 << ms->irq);
|
picint(1 << ms->irq);
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
@@ -374,13 +367,13 @@ busmouse_poll(int x, int y, int z, int b, void *priv)
|
|||||||
|
|
||||||
/* Release all resources held by the device. */
|
/* Release all resources held by the device. */
|
||||||
static void
|
static void
|
||||||
busmouse_close(void *priv)
|
bm_close(void *priv)
|
||||||
{
|
{
|
||||||
mouse_bus_t *ms = (mouse_bus_t *)priv;
|
mouse_bus_t *ms = (mouse_bus_t *)priv;
|
||||||
|
|
||||||
/* Release our I/O range. */
|
/* Release our I/O range. */
|
||||||
io_removehandler(ms->port, ms->portlen,
|
io_removehandler(ms->port, ms->portlen,
|
||||||
busmouse_read, NULL, NULL, busmouse_write, NULL, NULL, ms);
|
bm_read, NULL, NULL, bm_write, NULL, NULL, ms);
|
||||||
|
|
||||||
free(ms);
|
free(ms);
|
||||||
}
|
}
|
||||||
@@ -388,13 +381,14 @@ busmouse_close(void *priv)
|
|||||||
|
|
||||||
/* Initialize the device for use by the user. */
|
/* Initialize the device for use by the user. */
|
||||||
static void *
|
static void *
|
||||||
busmouse_init(int type)
|
bm_init(mouse_t *info)
|
||||||
{
|
{
|
||||||
mouse_bus_t *ms;
|
mouse_bus_t *ms;
|
||||||
|
|
||||||
|
pclog("BUSMOUSE: initializing as '%s'\n", info->name);
|
||||||
ms = (mouse_bus_t *)malloc(sizeof(mouse_bus_t));
|
ms = (mouse_bus_t *)malloc(sizeof(mouse_bus_t));
|
||||||
memset(ms, 0x00, sizeof(mouse_bus_t));
|
memset(ms, 0x00, sizeof(mouse_bus_t));
|
||||||
ms->type = type;
|
ms->type = info->type;
|
||||||
ms->port = BUSMOUSE_PORT;
|
ms->port = BUSMOUSE_PORT;
|
||||||
ms->portlen = BUSMOUSE_PORTLEN;
|
ms->portlen = BUSMOUSE_PORTLEN;
|
||||||
#if BUSMOUSE_IRQ
|
#if BUSMOUSE_IRQ
|
||||||
@@ -416,423 +410,27 @@ busmouse_init(int type)
|
|||||||
|
|
||||||
/* Request an I/O range. */
|
/* Request an I/O range. */
|
||||||
io_sethandler(ms->port, ms->portlen,
|
io_sethandler(ms->port, ms->portlen,
|
||||||
busmouse_read, NULL, NULL, busmouse_write, NULL, NULL, ms);
|
bm_read, NULL, NULL, bm_write, NULL, NULL, ms);
|
||||||
|
|
||||||
/* Return our private data to the I/O layer. */
|
/* Return our private data to the I/O layer. */
|
||||||
return(ms);
|
return(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *
|
|
||||||
logibus_init(void)
|
|
||||||
{
|
|
||||||
return(busmouse_init(MOUSE_TYPE_LOGIBUS));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void *
|
|
||||||
inport_init(void)
|
|
||||||
{
|
|
||||||
return(busmouse_init(MOUSE_TYPE_LOGIBUS));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
@@@@
|
|
||||||
|
|
||||||
#define BUS_MOUSE_IRQ 5
|
|
||||||
#define IRQ_MASK ((1<<5) >> BUS_MOUSE_IRQ)
|
|
||||||
|
|
||||||
/* MS Inport Bus Mouse Adapter. */
|
|
||||||
#define INP_PORT_CONTROL 0x023C
|
|
||||||
#define INP_PORT_DATA 0x023D
|
|
||||||
#define INP_PORT_SIGNATURE 0x023E
|
|
||||||
#define INP_PORT_CONFIG 0x023F
|
|
||||||
|
|
||||||
#define INP_CTRL_READ_BUTTONS 0x00
|
|
||||||
#define INP_CTRL_READ_X 0x01
|
|
||||||
#define INP_CTRL_READ_Y 0x02
|
|
||||||
#define INP_CTRL_COMMAND 0x07
|
|
||||||
#define INP_CTRL_RAISE_IRQ 0x16
|
|
||||||
#define INP_CTRL_RESET 0x80
|
|
||||||
|
|
||||||
#define INP_HOLD_COUNTER (1 << 5)
|
|
||||||
#define INP_ENABLE_IRQ (1 << 0)
|
|
||||||
|
|
||||||
/* MS/Logictech Standard Bus Mouse Adapter. */
|
|
||||||
#define BUSM_PORT_DATA 0x023C
|
|
||||||
#define BUSM_PORT_SIGNATURE 0x023D
|
|
||||||
#define BUSM_PORT_CONTROL 0x023E
|
|
||||||
#define BUSM_PORT_CONFIG 0x023F
|
|
||||||
|
|
||||||
#define HOLD_COUNTER (1 << 7)
|
|
||||||
#define READ_X (0 << 6)
|
|
||||||
#define READ_Y (1 << 6)
|
|
||||||
#define READ_LOW (0 << 5)
|
|
||||||
#define READ_HIGH (1 << 5)
|
|
||||||
#define DISABLE_IRQ (1 << 4)
|
|
||||||
|
|
||||||
#define READ_X_LOW (READ_X | READ_LOW)
|
|
||||||
#define READ_X_HIGH (READ_X | READ_HIGH)
|
|
||||||
#define READ_Y_LOW (READ_Y | READ_LOW)
|
|
||||||
#define READ_Y_HIGH (READ_Y | READ_HIGH)
|
|
||||||
|
|
||||||
|
|
||||||
/* Our mouse device. */
|
|
||||||
typedef struct mouse_bus_t
|
|
||||||
{
|
|
||||||
int irq;
|
|
||||||
int timer_index;
|
|
||||||
int x_delay;
|
|
||||||
int y_delay;
|
|
||||||
uint8_t mouse_buttons;
|
|
||||||
uint8_t mouse_buttons_last;
|
|
||||||
uint8_t x, y, but;
|
|
||||||
uint8_t command_val;
|
|
||||||
uint8_t control_val;
|
|
||||||
uint8_t config_val;
|
|
||||||
uint8_t sig_val;
|
|
||||||
uint16_t toggle_counter;
|
|
||||||
int interrupts;
|
|
||||||
int is_inport;
|
|
||||||
} mouse_bus_t;
|
|
||||||
|
|
||||||
|
|
||||||
/* Handle a WRITE operation to one of our registers. */
|
|
||||||
static void busmouse_write(uint16_t port, uint8_t val, void *priv)
|
|
||||||
{
|
|
||||||
mouse_bus_t *busmouse = (mouse_bus_t *)priv;
|
|
||||||
|
|
||||||
switch (port)
|
|
||||||
{
|
|
||||||
case BUSM_PORT_CONTROL:
|
|
||||||
busmouse->control_val = val | 0x0f;
|
|
||||||
busmouse->interrupts = (val & DISABLE_IRQ) == 0;
|
|
||||||
picintc(1 << busmouse->irq);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BUSM_PORT_CONFIG:
|
|
||||||
busmouse->config_val = val;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BUSM_PORT_SIGNATURE:
|
|
||||||
busmouse->sig_val = val;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BUSM_PORT_DATA:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Handle a READ operation from one of our registers. */
|
|
||||||
static uint8_t busmouse_read(uint16_t port, void *priv)
|
|
||||||
{
|
|
||||||
mouse_bus_t *busmouse = (mouse_bus_t *)priv;
|
|
||||||
uint8_t r = 0;
|
|
||||||
|
|
||||||
switch (port)
|
|
||||||
{
|
|
||||||
case BUSM_PORT_CONTROL:
|
|
||||||
r = busmouse->control_val;
|
|
||||||
/* This is to allow the driver to see which IRQ the card has "jumpered"
|
|
||||||
only happens if IRQ's are enabled */
|
|
||||||
busmouse->control_val |= 0x0f;
|
|
||||||
|
|
||||||
busmouse->control_val &= ~IRQ_MASK;
|
|
||||||
busmouse->toggle_counter = (busmouse->toggle_counter + 1) & 0x7ff;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BUSM_PORT_DATA:
|
|
||||||
switch (busmouse->control_val & 0x60)
|
|
||||||
{
|
|
||||||
case READ_X_LOW:
|
|
||||||
/* r = busmouse->x & 0x0f; */
|
|
||||||
r = ((busmouse->but ^ 7) << 5) | (busmouse->x & 0x0f);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case READ_X_HIGH:
|
|
||||||
r = (busmouse->x >> 4) & 0x0f;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case READ_Y_LOW:
|
|
||||||
r = busmouse->y & 0x0f;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case READ_Y_HIGH:
|
|
||||||
r = ((busmouse->but ^ 7) << 5) | ((busmouse->y >> 4) & 0x0f);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BUSM_PORT_CONFIG:
|
|
||||||
r = busmouse->config_val;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BUSM_PORT_SIGNATURE:
|
|
||||||
r = busmouse->sig_val;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void inport_write(uint16_t port, uint8_t val, void *priv)
|
|
||||||
{
|
|
||||||
mouse_bus_t *inport = (mouse_bus_t *)priv;
|
|
||||||
|
|
||||||
switch (port)
|
|
||||||
{
|
|
||||||
case INP_PORT_CONTROL:
|
|
||||||
switch (val)
|
|
||||||
{
|
|
||||||
case INP_CTRL_RESET:
|
|
||||||
inport->control_val = 0;
|
|
||||||
inport->command_val = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INP_CTRL_COMMAND:
|
|
||||||
case INP_CTRL_READ_BUTTONS:
|
|
||||||
case INP_CTRL_READ_X:
|
|
||||||
case INP_CTRL_READ_Y:
|
|
||||||
inport->command_val = val;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0x87:
|
|
||||||
inport->control_val = 0;
|
|
||||||
inport->command_val = 0x07;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INP_PORT_DATA:
|
|
||||||
picintc(1 << inport->irq);
|
|
||||||
if (val == INP_CTRL_RAISE_IRQ)
|
|
||||||
{
|
|
||||||
picint(1 << inport->irq);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch (inport->command_val)
|
|
||||||
{
|
|
||||||
case INP_CTRL_COMMAND:
|
|
||||||
inport->control_val = val;
|
|
||||||
inport->interrupts = (val & INP_ENABLE_IRQ) > 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INP_PORT_SIGNATURE:
|
|
||||||
case INP_PORT_CONFIG:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint8_t inport_read(uint16_t port, void *priv)
|
|
||||||
{
|
|
||||||
mouse_bus_t *inport = (mouse_bus_t *)priv;
|
|
||||||
uint8_t r = 0;
|
|
||||||
|
|
||||||
switch (port)
|
|
||||||
{
|
|
||||||
case INP_PORT_CONTROL:
|
|
||||||
r = inport->control_val;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INP_PORT_DATA:
|
|
||||||
switch (inport->command_val)
|
|
||||||
{
|
|
||||||
case INP_CTRL_READ_BUTTONS:
|
|
||||||
r = inport->but;
|
|
||||||
r |= 0x40;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INP_CTRL_READ_X:
|
|
||||||
r = inport->x;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INP_CTRL_READ_Y:
|
|
||||||
r = inport->y;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INP_CTRL_COMMAND:
|
|
||||||
r = inport->control_val;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INP_PORT_SIGNATURE:
|
|
||||||
if (!inport->toggle_counter)
|
|
||||||
{
|
|
||||||
r = 0xde;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
r = 0x12;
|
|
||||||
}
|
|
||||||
inport->toggle_counter ^= 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case INP_PORT_CONFIG:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
void busmouse_update_mouse_data(void *priv)
|
|
||||||
{
|
|
||||||
mouse_bus_t *busmouse = (mouse_bus_t *)priv;
|
|
||||||
|
|
||||||
int delta_x, delta_y;
|
|
||||||
int hold;
|
|
||||||
|
|
||||||
if (busmouse->x_delay > 127) {
|
|
||||||
delta_x = 127;
|
|
||||||
busmouse->x_delay -= 127;
|
|
||||||
} else if (busmouse->x_delay < -128) {
|
|
||||||
delta_x = -128;
|
|
||||||
busmouse->x_delay += 128;
|
|
||||||
} else {
|
|
||||||
delta_x = busmouse->x_delay;
|
|
||||||
busmouse->x_delay = 0;
|
|
||||||
}
|
|
||||||
if (busmouse->y_delay > 127) {
|
|
||||||
delta_y = 127;
|
|
||||||
busmouse->y_delay -= 127;
|
|
||||||
} else if (busmouse->y_delay < -128) {
|
|
||||||
delta_y = -128;
|
|
||||||
busmouse->y_delay += 128;
|
|
||||||
} else {
|
|
||||||
delta_y = busmouse->y_delay;
|
|
||||||
busmouse->y_delay = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (busmouse->is_inport) {
|
|
||||||
hold = (busmouse->control_val & INP_HOLD_COUNTER) > 0;
|
|
||||||
} else {
|
|
||||||
hold = (busmouse->control_val & HOLD_COUNTER) > 0;
|
|
||||||
}
|
|
||||||
if (!hold) {
|
|
||||||
busmouse->x = (uint8_t) delta_x;
|
|
||||||
busmouse->y = (uint8_t) delta_y;
|
|
||||||
busmouse->but = busmouse->mouse_buttons;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Called at 30hz */
|
|
||||||
void busmouse_timer_handler(void *priv)
|
|
||||||
{
|
|
||||||
mouse_bus_t *busmouse = (mouse_bus_t *)priv;
|
|
||||||
|
|
||||||
busmouse->timer_index += ((1000000.0 / 30.0) * TIMER_USEC);
|
|
||||||
|
|
||||||
/* The controller updates the data on every interrupt
|
|
||||||
We just don't copy it to the current_X if the 'hold' bit is set */
|
|
||||||
busmouse_update_mouse_data(busmouse);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The emulator calls us with an update on the host mouse device. */
|
|
||||||
static uint8_t busmouse_poll(int x, int y, int z, int b, void *priv)
|
|
||||||
{
|
|
||||||
mouse_bus_t *busmouse = (mouse_bus_t *)priv;
|
|
||||||
|
|
||||||
/* Return early if nothing to do. */
|
|
||||||
if (!x && !y && !z && (busmouse->mouse_buttons == b)) return(1);
|
|
||||||
|
|
||||||
#if 1
|
|
||||||
pclog("BUSMOUSE: poll(%d,%d,%d, %02x)\n", x, y, z, b);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// scale down the motion
|
|
||||||
if ((x < -1) || (x > 1))
|
|
||||||
x /= 2;
|
|
||||||
if ((y < -1) || (y > 1))
|
|
||||||
y /= 2;
|
|
||||||
|
|
||||||
if (x > 127) x =127;
|
|
||||||
if (y > 127) y =127;
|
|
||||||
if (x < -128) x = -128;
|
|
||||||
if (y < -128) y = -128;
|
|
||||||
|
|
||||||
busmouse->x_delay += x;
|
|
||||||
busmouse->y_delay += y;
|
|
||||||
|
|
||||||
busmouse->mouse_buttons = (uint8_t)(((b & 1) << 2) |
|
|
||||||
((b & 4) >> 1) | ((b & 2) >> 1));
|
|
||||||
|
|
||||||
if (busmouse->is_inport)
|
|
||||||
{
|
|
||||||
if ((busmouse->mouse_buttons & (1<<2)) ||
|
|
||||||
((busmouse->mouse_buttons_last & (1<<2)) && !(busmouse->mouse_buttons & (1<<2))))
|
|
||||||
busmouse->mouse_buttons |= (1<<5);
|
|
||||||
if ((busmouse->mouse_buttons & (1<<1)) ||
|
|
||||||
((busmouse->mouse_buttons_last & (1<<1)) && !(busmouse->mouse_buttons & (1<<1))))
|
|
||||||
busmouse->mouse_buttons |= (1<<4);
|
|
||||||
if ((busmouse->mouse_buttons & (1<<0)) ||
|
|
||||||
((busmouse->mouse_buttons_last & (1<<0)) && !(busmouse->mouse_buttons & (1<<0))))
|
|
||||||
busmouse->mouse_buttons |= (1<<3);
|
|
||||||
busmouse->mouse_buttons_last = busmouse->mouse_buttons;
|
|
||||||
}
|
|
||||||
|
|
||||||
picint(1 << busmouse->irq);
|
|
||||||
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Initialize the device for use by the user. */
|
|
||||||
static void *inport_init(void)
|
|
||||||
{
|
|
||||||
mouse_bus_t *inport;
|
|
||||||
|
|
||||||
inport = (mouse_bus_t *)malloc(sizeof(mouse_bus_t));
|
|
||||||
memset(inport, 0x00, sizeof(mouse_bus_t));
|
|
||||||
|
|
||||||
inport->is_inport = 1;
|
|
||||||
inport->irq = BUS_MOUSE_IRQ;
|
|
||||||
|
|
||||||
/* Initialize registers. */
|
|
||||||
inport->control_val = 0x00; /* The control port value */
|
|
||||||
inport->config_val = 0x00; /* The config port value */
|
|
||||||
|
|
||||||
/* Common. */
|
|
||||||
inport->command_val = 0;
|
|
||||||
inport->toggle_counter = 0;
|
|
||||||
inport->interrupts = 0;
|
|
||||||
|
|
||||||
/* Request an I/O range. */
|
|
||||||
io_sethandler(0x023C, 0x0004, inport_read, NULL, NULL, inport_write, NULL, NULL, inport);
|
|
||||||
timer_add(busmouse_timer_handler, &inport->timer_index, TIMER_ALWAYS_ENABLED, inport);
|
|
||||||
|
|
||||||
/* Return our private data to the I/O layer. */
|
|
||||||
return(inport);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
mouse_t mouse_bus_logitech = {
|
mouse_t mouse_bus_logitech = {
|
||||||
"Logitech Bus Mouse",
|
"Logitech Bus Mouse",
|
||||||
"logibus",
|
"logibus",
|
||||||
MOUSE_TYPE_LOGIBUS,
|
MOUSE_TYPE_LOGIBUS,
|
||||||
logibus_init,
|
bm_init,
|
||||||
busmouse_close,
|
bm_close,
|
||||||
busmouse_poll
|
bm_poll
|
||||||
};
|
};
|
||||||
|
|
||||||
mouse_t mouse_bus_msinport = {
|
mouse_t mouse_bus_msinport = {
|
||||||
"Microsoft Bus Mouse (InPort)",
|
"Microsoft Bus Mouse (InPort)",
|
||||||
"msbus",
|
"msbus",
|
||||||
MOUSE_TYPE_INPORT,
|
MOUSE_TYPE_INPORT,
|
||||||
inport_init,
|
bm_init,
|
||||||
busmouse_close,
|
bm_close,
|
||||||
busmouse_poll
|
bm_poll
|
||||||
};
|
};
|
||||||
|
|||||||
216
src/mouse_ps2.c
216
src/mouse_ps2.c
@@ -9,20 +9,17 @@
|
|||||||
#include "plat_mouse.h"
|
#include "plat_mouse.h"
|
||||||
|
|
||||||
|
|
||||||
int mouse_scan = 0;
|
#define MOUSE_ENABLE 0x20
|
||||||
|
#define MOUSE_SCALE 0x10
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
enum {
|
||||||
MOUSE_STREAM,
|
MOUSE_STREAM,
|
||||||
MOUSE_REMOTE,
|
MOUSE_REMOTE,
|
||||||
MOUSE_ECHO
|
MOUSE_ECHO
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MOUSE_ENABLE 0x20
|
typedef struct {
|
||||||
#define MOUSE_SCALE 0x10
|
|
||||||
|
|
||||||
typedef struct mouse_ps2_t
|
|
||||||
{
|
|
||||||
int mode;
|
int mode;
|
||||||
|
|
||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
@@ -41,57 +38,54 @@ typedef struct mouse_ps2_t
|
|||||||
uint8_t last_data[6];
|
uint8_t last_data[6];
|
||||||
} mouse_ps2_t;
|
} mouse_ps2_t;
|
||||||
|
|
||||||
void mouse_ps2_write(uint8_t val, void *p)
|
|
||||||
{
|
|
||||||
mouse_ps2_t *mouse = (mouse_ps2_t *)p;
|
|
||||||
|
|
||||||
if (mouse->cd)
|
int mouse_scan = 0;
|
||||||
{
|
|
||||||
mouse->cd = 0;
|
|
||||||
switch (mouse->command)
|
static void
|
||||||
|
mouse_ps2_write(uint8_t val, void *priv)
|
||||||
{
|
{
|
||||||
|
mouse_ps2_t *ms = (mouse_ps2_t *)priv;
|
||||||
|
|
||||||
|
if (ms->cd) {
|
||||||
|
ms->cd = 0;
|
||||||
|
switch (ms->command) {
|
||||||
case 0xe8: /*Set mouse resolution*/
|
case 0xe8: /*Set mouse resolution*/
|
||||||
mouse->resolution = val;
|
ms->resolution = val;
|
||||||
keyboard_at_adddata_mouse(0xfa);
|
keyboard_at_adddata_mouse(0xfa);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xf3: /*Set sample rate*/
|
case 0xf3: /*Set sample rate*/
|
||||||
mouse->sample_rate = val;
|
ms->sample_rate = val;
|
||||||
keyboard_at_adddata_mouse(0xfa);
|
keyboard_at_adddata_mouse(0xfa);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
keyboard_at_adddata_mouse(0xfc);
|
keyboard_at_adddata_mouse(0xfc);
|
||||||
|
|
||||||
// default:
|
|
||||||
// fatal("mouse_ps2 : Bad data write %02X for command %02X\n", val, mouse->command);
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
uint8_t temp;
|
uint8_t temp;
|
||||||
|
|
||||||
mouse->command = val;
|
ms->command = val;
|
||||||
switch (mouse->command)
|
switch (ms->command) {
|
||||||
{
|
|
||||||
case 0xe6: /*Set scaling to 1:1*/
|
case 0xe6: /*Set scaling to 1:1*/
|
||||||
mouse->flags &= ~MOUSE_SCALE;
|
ms->flags &= ~MOUSE_SCALE;
|
||||||
keyboard_at_adddata_mouse(0xfa);
|
keyboard_at_adddata_mouse(0xfa);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xe7: /*Set scaling to 2:1*/
|
case 0xe7: /*Set scaling to 2:1*/
|
||||||
mouse->flags |= MOUSE_SCALE;
|
ms->flags |= MOUSE_SCALE;
|
||||||
keyboard_at_adddata_mouse(0xfa);
|
keyboard_at_adddata_mouse(0xfa);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xe8: /*Set mouse resolution*/
|
case 0xe8: /*Set mouse resolution*/
|
||||||
mouse->cd = 1;
|
ms->cd = 1;
|
||||||
keyboard_at_adddata_mouse(0xfa);
|
keyboard_at_adddata_mouse(0xfa);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xe9: /*Status request*/
|
case 0xe9: /*Status request*/
|
||||||
keyboard_at_adddata_mouse(0xfa);
|
keyboard_at_adddata_mouse(0xfa);
|
||||||
temp = mouse->flags;
|
temp = ms->flags;
|
||||||
if (mouse_buttons & 1)
|
if (mouse_buttons & 1)
|
||||||
temp |= 1;
|
temp |= 1;
|
||||||
if (mouse_buttons & 2)
|
if (mouse_buttons & 2)
|
||||||
@@ -99,37 +93,37 @@ void mouse_ps2_write(uint8_t val, void *p)
|
|||||||
if (mouse_buttons & 4)
|
if (mouse_buttons & 4)
|
||||||
temp |= 3;
|
temp |= 3;
|
||||||
keyboard_at_adddata_mouse(temp);
|
keyboard_at_adddata_mouse(temp);
|
||||||
keyboard_at_adddata_mouse(mouse->resolution);
|
keyboard_at_adddata_mouse(ms->resolution);
|
||||||
keyboard_at_adddata_mouse(mouse->sample_rate);
|
keyboard_at_adddata_mouse(ms->sample_rate);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xf2: /*Read ID*/
|
case 0xf2: /*Read ID*/
|
||||||
keyboard_at_adddata_mouse(0xfa);
|
keyboard_at_adddata_mouse(0xfa);
|
||||||
if (mouse->intellimouse_mode)
|
if (ms->intellimouse_mode)
|
||||||
keyboard_at_adddata_mouse(0x03);
|
keyboard_at_adddata_mouse(0x03);
|
||||||
else
|
else
|
||||||
keyboard_at_adddata_mouse(0x00);
|
keyboard_at_adddata_mouse(0x00);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xf3: /*Set sample rate*/
|
case 0xf3: /*Set command mode*/
|
||||||
mouse->cd = 1;
|
ms->cd = 1;
|
||||||
keyboard_at_adddata_mouse(0xfa);
|
keyboard_at_adddata_mouse(0xfa);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xf4: /*Enable*/
|
case 0xf4: /*Enable*/
|
||||||
mouse->flags |= MOUSE_ENABLE;
|
ms->flags |= MOUSE_ENABLE;
|
||||||
keyboard_at_adddata_mouse(0xfa);
|
keyboard_at_adddata_mouse(0xfa);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xf5: /*Disable*/
|
case 0xf5: /*Disable*/
|
||||||
mouse->flags &= ~MOUSE_ENABLE;
|
ms->flags &= ~MOUSE_ENABLE;
|
||||||
keyboard_at_adddata_mouse(0xfa);
|
keyboard_at_adddata_mouse(0xfa);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xff: /*Reset*/
|
case 0xff: /*Reset*/
|
||||||
mouse->mode = MOUSE_STREAM;
|
ms->mode = MOUSE_STREAM;
|
||||||
mouse->flags = 0;
|
ms->flags = 0;
|
||||||
mouse->intellimouse_mode = 0;
|
ms->intellimouse_mode = 0;
|
||||||
keyboard_at_adddata_mouse(0xfa);
|
keyboard_at_adddata_mouse(0xfa);
|
||||||
keyboard_at_adddata_mouse(0xaa);
|
keyboard_at_adddata_mouse(0xaa);
|
||||||
keyboard_at_adddata_mouse(0x00);
|
keyboard_at_adddata_mouse(0x00);
|
||||||
@@ -137,133 +131,123 @@ void mouse_ps2_write(uint8_t val, void *p)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
keyboard_at_adddata_mouse(0xfe);
|
keyboard_at_adddata_mouse(0xfe);
|
||||||
|
|
||||||
// default:
|
|
||||||
// fatal("mouse_ps2 : Bad command %02X\n", val, mouse->command);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mouse->is_intellimouse)
|
if (ms->is_intellimouse) {
|
||||||
{
|
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
for (c = 0; c < 5; c++)
|
for (c = 0; c < 5; c++)
|
||||||
mouse->last_data[c] = mouse->last_data[c+1];
|
ms->last_data[c] = ms->last_data[c+1];
|
||||||
|
ms->last_data[5] = val;
|
||||||
|
|
||||||
mouse->last_data[5] = val;
|
if (ms->last_data[0] == 0xf3 && ms->last_data[1] == 0xc8 &&
|
||||||
|
ms->last_data[2] == 0xf3 && ms->last_data[3] == 0x64 &&
|
||||||
if (mouse->last_data[0] == 0xf3 && mouse->last_data[1] == 0xc8 &&
|
ms->last_data[4] == 0xf3 && ms->last_data[5] == 0x50)
|
||||||
mouse->last_data[2] == 0xf3 && mouse->last_data[3] == 0x64 &&
|
ms->intellimouse_mode = 1;
|
||||||
mouse->last_data[4] == 0xf3 && mouse->last_data[5] == 0x50)
|
|
||||||
mouse->intellimouse_mode = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t mouse_ps2_poll(int x, int y, int z, int b, void *p)
|
|
||||||
|
static uint8_t
|
||||||
|
mouse_ps2_poll(int x, int y, int z, int b, void *priv)
|
||||||
{
|
{
|
||||||
mouse_ps2_t *mouse = (mouse_ps2_t *)p;
|
mouse_ps2_t *ms = (mouse_ps2_t *)priv;
|
||||||
uint8_t packet[3] = {0x08, 0, 0};
|
uint8_t packet[3] = {0x08, 0, 0};
|
||||||
|
|
||||||
if (!x && !y && !z && b == mouse->b)
|
if (!x && !y && !z && b == ms->b) return(0xff);
|
||||||
return(0xff);
|
|
||||||
|
|
||||||
if (!mouse_scan)
|
if (! mouse_scan) return(0xff);
|
||||||
return(0xff);
|
|
||||||
|
|
||||||
mouse->x += x;
|
ms->x += x;
|
||||||
mouse->y -= y;
|
ms->y -= y;
|
||||||
mouse->z -= z;
|
ms->z -= z;
|
||||||
if (mouse->mode == MOUSE_STREAM && (mouse->flags & MOUSE_ENABLE) &&
|
if (ms->mode == MOUSE_STREAM && (ms->flags & MOUSE_ENABLE) &&
|
||||||
((mouse_queue_end - mouse_queue_start) & 0xf) < 13)
|
((mouse_queue_end - mouse_queue_start) & 0xf) < 13) {
|
||||||
{
|
ms->b = b;
|
||||||
mouse->b = b;
|
|
||||||
// pclog("Send packet : %i %i\n", ps2_x, ps2_y);
|
// pclog("Send packet : %i %i\n", ps2_x, ps2_y);
|
||||||
if (mouse->x > 255)
|
if (ms->x > 255)
|
||||||
mouse->x = 255;
|
ms->x = 255;
|
||||||
if (mouse->x < -256)
|
if (ms->x < -256)
|
||||||
mouse->x = -256;
|
ms->x = -256;
|
||||||
if (mouse->y > 255)
|
if (ms->y > 255)
|
||||||
mouse->y = 255;
|
ms->y = 255;
|
||||||
if (mouse->y < -256)
|
if (ms->y < -256)
|
||||||
mouse->y = -256;
|
ms->y = -256;
|
||||||
if (mouse->z < -8)
|
if (ms->z < -8)
|
||||||
mouse->z = -8;
|
ms->z = -8;
|
||||||
if (mouse->z > 7)
|
if (ms->z > 7)
|
||||||
mouse->z = 7;
|
ms->z = 7;
|
||||||
if (mouse->x < 0)
|
if (ms->x < 0)
|
||||||
packet[0] |= 0x10;
|
packet[0] |= 0x10;
|
||||||
if (mouse->y < 0)
|
if (ms->y < 0)
|
||||||
packet[0] |= 0x20;
|
packet[0] |= 0x20;
|
||||||
if (mouse_buttons & 1)
|
if (mouse_buttons & 1)
|
||||||
packet[0] |= 1;
|
packet[0] |= 1;
|
||||||
if (mouse_buttons & 2)
|
if (mouse_buttons & 2)
|
||||||
packet[0] |= 2;
|
packet[0] |= 2;
|
||||||
if ((mouse_buttons & 4) && (mouse_get_type(mouse_type) & MOUSE_TYPE_3BUTTON))
|
if ((mouse_buttons & 4) &&
|
||||||
packet[0] |= 4;
|
(mouse_get_type(mouse_type) & MOUSE_TYPE_3BUTTON)) packet[0] |= 4;
|
||||||
packet[1] = mouse->x & 0xff;
|
packet[1] = ms->x & 0xff;
|
||||||
packet[2] = mouse->y & 0xff;
|
packet[2] = ms->y & 0xff;
|
||||||
|
|
||||||
keyboard_at_adddata_mouse(packet[0]);
|
keyboard_at_adddata_mouse(packet[0]);
|
||||||
keyboard_at_adddata_mouse(packet[1]);
|
keyboard_at_adddata_mouse(packet[1]);
|
||||||
keyboard_at_adddata_mouse(packet[2]);
|
keyboard_at_adddata_mouse(packet[2]);
|
||||||
if (mouse->intellimouse_mode)
|
if (ms->intellimouse_mode)
|
||||||
keyboard_at_adddata_mouse(mouse->z);
|
keyboard_at_adddata_mouse(ms->z);
|
||||||
|
|
||||||
mouse->x = mouse->y = mouse->z = 0;
|
ms->x = ms->y = ms->z = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *mouse_ps2_init()
|
|
||||||
|
/* We also get called from the various machines. */
|
||||||
|
void *
|
||||||
|
mouse_ps2_init(void *arg)
|
||||||
{
|
{
|
||||||
mouse_ps2_t *mouse = (mouse_ps2_t *)malloc(sizeof(mouse_ps2_t));
|
mouse_ps2_t *ms = (mouse_ps2_t *)malloc(sizeof(mouse_ps2_t));
|
||||||
memset(mouse, 0, sizeof(mouse_ps2_t));
|
mouse_t *info = (mouse_t *)arg;
|
||||||
|
|
||||||
// mouse_poll = mouse_ps2_poll;
|
memset(ms, 0x00, sizeof(mouse_ps2_t));
|
||||||
// mouse_write = mouse_ps2_write;
|
|
||||||
mouse->cd = 0;
|
|
||||||
mouse->flags = 0;
|
|
||||||
mouse->mode = MOUSE_STREAM;
|
|
||||||
|
|
||||||
keyboard_at_set_mouse(mouse_ps2_write, mouse);
|
ms->cd = 0;
|
||||||
|
ms->flags = 0;
|
||||||
|
ms->mode = MOUSE_STREAM;
|
||||||
|
if ((info != NULL) && (info->type & MOUSE_TYPE_3BUTTON))
|
||||||
|
ms->is_intellimouse = 1;
|
||||||
|
|
||||||
return mouse;
|
keyboard_at_set_mouse(mouse_ps2_write, ms);
|
||||||
}
|
|
||||||
|
|
||||||
void *mouse_intellimouse_init()
|
return(ms);
|
||||||
{
|
|
||||||
mouse_ps2_t *mouse = mouse_ps2_init();
|
|
||||||
|
|
||||||
mouse->is_intellimouse = 1;
|
|
||||||
|
|
||||||
return mouse;
|
|
||||||
}
|
|
||||||
|
|
||||||
void mouse_ps2_close(void *p)
|
|
||||||
{
|
|
||||||
mouse_ps2_t *mouse = (mouse_ps2_t *)p;
|
|
||||||
|
|
||||||
free(mouse);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mouse_t mouse_ps2_2button =
|
void
|
||||||
|
mouse_ps2_close(void *priv)
|
||||||
{
|
{
|
||||||
|
mouse_ps2_t *ms = (mouse_ps2_t *)priv;
|
||||||
|
|
||||||
|
free(ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mouse_t mouse_ps2_2button = {
|
||||||
"Standard 2-button mouse (PS/2)",
|
"Standard 2-button mouse (PS/2)",
|
||||||
"ps2",
|
"ps2",
|
||||||
MOUSE_TYPE_PS2,
|
MOUSE_TYPE_PS2,
|
||||||
mouse_ps2_init,
|
(void *(*)(mouse_t *))mouse_ps2_init,
|
||||||
mouse_ps2_close,
|
mouse_ps2_close,
|
||||||
mouse_ps2_poll
|
mouse_ps2_poll
|
||||||
};
|
};
|
||||||
|
|
||||||
mouse_t mouse_ps2_intellimouse =
|
mouse_t mouse_ps2_intellimouse = {
|
||||||
{
|
|
||||||
"Microsoft Intellimouse (PS/2)",
|
"Microsoft Intellimouse (PS/2)",
|
||||||
"intellimouse",
|
"intellimouse",
|
||||||
MOUSE_TYPE_PS2 | MOUSE_TYPE_3BUTTON,
|
MOUSE_TYPE_PS2 | MOUSE_TYPE_3BUTTON,
|
||||||
mouse_intellimouse_init,
|
(void *(*)(mouse_t *))mouse_ps2_init,
|
||||||
mouse_ps2_close,
|
mouse_ps2_close,
|
||||||
mouse_ps2_poll
|
mouse_ps2_poll
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
* Based on the 86Box Serial Mouse driver as a framework.
|
* Based on the 86Box Serial Mouse driver as a framework.
|
||||||
*
|
*
|
||||||
* Version: @(#)mouse_serial.c 1.0.9 2017/09/24
|
* Version: @(#)mouse_serial.c 1.0.10 2017/10/25
|
||||||
*
|
*
|
||||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*/
|
*/
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
|
|
||||||
typedef struct mouse_serial_t {
|
typedef struct mouse_serial_t {
|
||||||
|
char *name;
|
||||||
int8_t port,
|
int8_t port,
|
||||||
type;
|
type;
|
||||||
int pos;
|
int pos;
|
||||||
@@ -215,12 +216,13 @@ sermouse_close(void *priv)
|
|||||||
|
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
sermouse_init(int type)
|
sermouse_init(mouse_t *info)
|
||||||
{
|
{
|
||||||
mouse_serial_t *ms = (mouse_serial_t *)malloc(sizeof(mouse_serial_t));
|
mouse_serial_t *ms = (mouse_serial_t *)malloc(sizeof(mouse_serial_t));
|
||||||
memset(ms, 0x00, sizeof(mouse_serial_t));
|
memset(ms, 0x00, sizeof(mouse_serial_t));
|
||||||
|
ms->name = (char *)info->name;
|
||||||
ms->port = SERMOUSE_PORT;
|
ms->port = SERMOUSE_PORT;
|
||||||
ms->type = type;
|
ms->type = info->type;
|
||||||
|
|
||||||
/* Attach a serial port to the mouse. */
|
/* Attach a serial port to the mouse. */
|
||||||
#ifdef WALTJE
|
#ifdef WALTJE
|
||||||
@@ -237,39 +239,11 @@ sermouse_init(int type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void *
|
|
||||||
sermouse_init_msystems(void)
|
|
||||||
{
|
|
||||||
return(sermouse_init(MOUSE_TYPE_MSYSTEMS));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void *
|
|
||||||
sermouse_init_microsoft(void)
|
|
||||||
{
|
|
||||||
return(sermouse_init(MOUSE_TYPE_MICROSOFT));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void *
|
|
||||||
sermouse_init_logitech(void)
|
|
||||||
{
|
|
||||||
return(sermouse_init(MOUSE_TYPE_LOGITECH));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void *
|
|
||||||
sermouse_init_mswheel(void)
|
|
||||||
{
|
|
||||||
return(sermouse_init(MOUSE_TYPE_MSWHEEL));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
mouse_t mouse_serial_msystems = {
|
mouse_t mouse_serial_msystems = {
|
||||||
"Mouse Systems Mouse (serial)",
|
"Mouse Systems Mouse (serial)",
|
||||||
"mssystems",
|
"mssystems",
|
||||||
MOUSE_TYPE_MSYSTEMS | MOUSE_TYPE_3BUTTON,
|
MOUSE_TYPE_MSYSTEMS | MOUSE_TYPE_3BUTTON,
|
||||||
sermouse_init_msystems,
|
sermouse_init,
|
||||||
sermouse_close,
|
sermouse_close,
|
||||||
sermouse_poll
|
sermouse_poll
|
||||||
};
|
};
|
||||||
@@ -279,7 +253,7 @@ mouse_t mouse_serial_microsoft = {
|
|||||||
"Microsoft 2-button mouse (serial)",
|
"Microsoft 2-button mouse (serial)",
|
||||||
"msserial",
|
"msserial",
|
||||||
MOUSE_TYPE_MICROSOFT,
|
MOUSE_TYPE_MICROSOFT,
|
||||||
sermouse_init_microsoft,
|
sermouse_init,
|
||||||
sermouse_close,
|
sermouse_close,
|
||||||
sermouse_poll
|
sermouse_poll
|
||||||
};
|
};
|
||||||
@@ -289,7 +263,7 @@ mouse_t mouse_serial_logitech = {
|
|||||||
"Logitech 3-button mouse (serial)",
|
"Logitech 3-button mouse (serial)",
|
||||||
"lserial",
|
"lserial",
|
||||||
MOUSE_TYPE_LOGITECH | MOUSE_TYPE_3BUTTON,
|
MOUSE_TYPE_LOGITECH | MOUSE_TYPE_3BUTTON,
|
||||||
sermouse_init_logitech,
|
sermouse_init,
|
||||||
sermouse_close,
|
sermouse_close,
|
||||||
sermouse_poll
|
sermouse_poll
|
||||||
};
|
};
|
||||||
@@ -299,7 +273,7 @@ mouse_t mouse_serial_mswheel = {
|
|||||||
"Microsoft wheel mouse (serial)",
|
"Microsoft wheel mouse (serial)",
|
||||||
"mswheel",
|
"mswheel",
|
||||||
MOUSE_TYPE_MSWHEEL | MOUSE_TYPE_3BUTTON,
|
MOUSE_TYPE_MSWHEEL | MOUSE_TYPE_3BUTTON,
|
||||||
sermouse_init_mswheel,
|
sermouse_init,
|
||||||
sermouse_close,
|
sermouse_close,
|
||||||
sermouse_poll
|
sermouse_poll
|
||||||
};
|
};
|
||||||
|
|||||||
6
src/pc.c
6
src/pc.c
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Main emulator module where most things are controlled.
|
* Main emulator module where most things are controlled.
|
||||||
*
|
*
|
||||||
* Version: @(#)pc.c 1.0.33 2017/10/24
|
* Version: @(#)pc.c 1.0.34 2017/10/25
|
||||||
*
|
*
|
||||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
@@ -950,8 +950,8 @@ pc_thread(void *param)
|
|||||||
plat_delay_ms(1);
|
plat_delay_ms(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If needed, hand a screen resize. */
|
/* If needed, handle a screen resize. */
|
||||||
if (!video_fullscreen && doresize && (scrnsz_x>0) && (scrnsz_y>0)) {
|
if (doresize && !video_fullscreen) {
|
||||||
plat_resize(scrnsz_x, scrnsz_y);
|
plat_resize(scrnsz_x, scrnsz_y);
|
||||||
|
|
||||||
doresize = 0;
|
doresize = 0;
|
||||||
|
|||||||
10
src/vnc.c
10
src/vnc.c
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Implement the VNC remote renderer with LibVNCServer.
|
* Implement the VNC remote renderer with LibVNCServer.
|
||||||
*
|
*
|
||||||
* Version: @(#)vnc.c 1.0.7 2017/10/24
|
* Version: @(#)vnc.c 1.0.8 2017/10/25
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
* Based on raw code by RichardG, <richardg867@gmail.com>
|
* Based on raw code by RichardG, <richardg867@gmail.com>
|
||||||
@@ -94,6 +94,10 @@ vnc_clientgone(rfbClientPtr cl)
|
|||||||
if (clients == 0) {
|
if (clients == 0) {
|
||||||
/* No more clients, pause the emulator. */
|
/* No more clients, pause the emulator. */
|
||||||
pclog("VNC: no clients, pausing..\n");
|
pclog("VNC: no clients, pausing..\n");
|
||||||
|
|
||||||
|
/* Disable the mouse. */
|
||||||
|
plat_mouse_capture(0);
|
||||||
|
|
||||||
plat_pause(1);
|
plat_pause(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,6 +119,10 @@ vnc_newclient(rfbClientPtr cl)
|
|||||||
|
|
||||||
/* We now have clients, un-pause the emulator if needed. */
|
/* We now have clients, un-pause the emulator if needed. */
|
||||||
pclog("VNC: unpausing..\n");
|
pclog("VNC: unpausing..\n");
|
||||||
|
|
||||||
|
/* Enable the mouse. */
|
||||||
|
plat_mouse_capture(1);
|
||||||
|
|
||||||
plat_pause(0);
|
plat_pause(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user