Temporarily reverted to the PCem serial code (but kept waltje's in, optionally enabled by running make with WALTJE=y parameter);
Applied another A20 patch from Greatpsycho.
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "mouse_serial.h"
|
||||
|
||||
|
||||
#ifdef WALTJE
|
||||
#define SERMOUSE_TYPE_MSYSTEMS 1 /* Mouse Systems */
|
||||
#define SERMOUSE_TYPE_MICROSOFT 2 /* Microsoft */
|
||||
#define SERMOUSE_TYPE_LOGITECH 3 /* Logitech */
|
||||
@@ -228,3 +229,195 @@ mouse_t mouse_serial_logitech = {
|
||||
sermouse_close,
|
||||
sermouse_poll
|
||||
};
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
typedef struct mouse_serial_t
|
||||
{
|
||||
int mousepos, mousedelay;
|
||||
int oldb;
|
||||
int type;
|
||||
SERIAL *serial;
|
||||
} mouse_serial_t;
|
||||
|
||||
uint8_t mouse_serial_poll(int x, int y, int z, int b, void *p)
|
||||
{
|
||||
mouse_serial_t *mouse = (mouse_serial_t *)p;
|
||||
SERIAL *serial = mouse->serial;
|
||||
uint8_t mousedat[4];
|
||||
|
||||
if (!(serial->ier & 1))
|
||||
return 0xff;
|
||||
if (!x && !y && b == mouse->oldb)
|
||||
return 0xff;
|
||||
|
||||
mouse->oldb = b;
|
||||
if (x>127) x=127;
|
||||
if (y>127) y=127;
|
||||
if (x<-128) x=-128;
|
||||
if (y<-128) y=-128;
|
||||
|
||||
/*Use Microsoft format*/
|
||||
mousedat[0]=0x40;
|
||||
mousedat[0]|=(((y>>6)&3)<<2);
|
||||
mousedat[0]|=((x>>6)&3);
|
||||
if (b&1) mousedat[0]|=0x20;
|
||||
if (b&2) mousedat[0]|=0x10;
|
||||
mousedat[1]=x&0x3F;
|
||||
mousedat[2]=y&0x3F;
|
||||
|
||||
if (!(serial->mctrl & 0x10))
|
||||
{
|
||||
serial_write_fifo(mouse->serial, mousedat[0]);
|
||||
serial_write_fifo(mouse->serial, mousedat[1]);
|
||||
serial_write_fifo(mouse->serial, mousedat[2]);
|
||||
if ((b&0x04) && mouse->type)
|
||||
{
|
||||
serial_write_fifo(mouse->serial, 0x20);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t mouse_serial_msystems_poll(int x, int y, int z, int b, void *p)
|
||||
{
|
||||
mouse_serial_t *mouse = (mouse_serial_t *)p;
|
||||
SERIAL *serial = mouse->serial;
|
||||
uint8_t mousedat[4];
|
||||
|
||||
if (!(serial->ier & 1))
|
||||
return 0xff;
|
||||
if (!x && !y && b == mouse->oldb)
|
||||
return 0xff;
|
||||
|
||||
y = -y;
|
||||
|
||||
mouse->oldb = b;
|
||||
if (x>127) x=127;
|
||||
if (y>127) y=127;
|
||||
if (x<-128) x=-128;
|
||||
if (y<-128) y=-128;
|
||||
|
||||
/*Use Mouse Systems format*/
|
||||
mousedat[0] = 0x80;
|
||||
mousedat[0] |= (b&0x01) ? 0x00 : 0x04; /* left button */
|
||||
mousedat[0] |= (b&0x02) ? 0x00 : 0x01; /* middle button */
|
||||
mousedat[0] |= (b&0x04) ? 0x00 : 0x02; /* right button */
|
||||
mousedat[1] = x;
|
||||
mousedat[2] = y;
|
||||
mousedat[3] = x; /* same as byte 1 */
|
||||
mousedat[4] = y; /* same as byte 2 */
|
||||
|
||||
if (!(serial->mctrl & 0x10))
|
||||
{
|
||||
serial_write_fifo(mouse->serial, mousedat[0]);
|
||||
serial_write_fifo(mouse->serial, mousedat[1]);
|
||||
serial_write_fifo(mouse->serial, mousedat[2]);
|
||||
serial_write_fifo(mouse->serial, mousedat[3]);
|
||||
serial_write_fifo(mouse->serial, mousedat[4]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mouse_serial_rcr(struct SERIAL *serial, void *p)
|
||||
{
|
||||
mouse_serial_t *mouse = (mouse_serial_t *)p;
|
||||
|
||||
mouse->mousepos = -1;
|
||||
mouse->mousedelay = 5000 * (1 << TIMER_SHIFT);
|
||||
}
|
||||
|
||||
void mousecallback(void *p)
|
||||
{
|
||||
mouse_serial_t *mouse = (mouse_serial_t *)p;
|
||||
|
||||
mouse->mousedelay = 0;
|
||||
if (mouse->mousepos == -1)
|
||||
{
|
||||
mouse->mousepos = 0;
|
||||
if (mouse->type < 2)
|
||||
{
|
||||
serial_write_fifo(mouse->serial, 'M');
|
||||
if (mouse->type == 1)
|
||||
{
|
||||
serial_write_fifo(mouse->serial, '3');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void *mouse_serial_common_init(int type)
|
||||
{
|
||||
mouse_serial_t *mouse = (mouse_serial_t *)malloc(sizeof(mouse_serial_t));
|
||||
memset(mouse, 0, sizeof(mouse_serial_t));
|
||||
|
||||
mouse->serial = &serial1;
|
||||
serial1.rcr_callback = mouse_serial_rcr;
|
||||
serial1.rcr_callback_p = mouse;
|
||||
timer_add(mousecallback, &mouse->mousedelay, &mouse->mousedelay, mouse);
|
||||
|
||||
mouse->type = type;
|
||||
|
||||
return mouse;
|
||||
}
|
||||
|
||||
void *mouse_serial_init()
|
||||
{
|
||||
return mouse_serial_common_init(0);
|
||||
}
|
||||
|
||||
void *mouse_serial_logitech_init()
|
||||
{
|
||||
return mouse_serial_common_init(1);
|
||||
}
|
||||
|
||||
void *mouse_serial_msystems_init()
|
||||
{
|
||||
return mouse_serial_common_init(2);
|
||||
}
|
||||
|
||||
void mouse_serial_close(void *p)
|
||||
{
|
||||
mouse_serial_t *mouse = (mouse_serial_t *)p;
|
||||
|
||||
free(mouse);
|
||||
|
||||
serial1.rcr_callback = NULL;
|
||||
}
|
||||
|
||||
mouse_t mouse_serial_microsoft =
|
||||
{
|
||||
"Microsoft 2-button mouse (serial)",
|
||||
"msserial",
|
||||
MOUSE_TYPE_SERIAL,
|
||||
mouse_serial_init,
|
||||
mouse_serial_close,
|
||||
mouse_serial_poll
|
||||
};
|
||||
|
||||
mouse_t mouse_serial_logitech =
|
||||
{
|
||||
"Logitech 3-button mouse (serial)",
|
||||
"lserial",
|
||||
MOUSE_TYPE_SERIAL | MOUSE_TYPE_3BUTTON,
|
||||
mouse_serial_logitech_init,
|
||||
mouse_serial_close,
|
||||
mouse_serial_poll
|
||||
};
|
||||
|
||||
mouse_t mouse_msystems =
|
||||
{
|
||||
"Mouse Systems Mouse (serial)",
|
||||
"mssystems",
|
||||
MOUSE_TYPE_MSYSTEMS,
|
||||
mouse_serial_msystems_init,
|
||||
mouse_serial_close,
|
||||
mouse_serial_msystems_poll
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user