Improvements to PS/2 mouse emulation.
This commit is contained in:
parent
b5a498683a
commit
0bf3e231e5
3 changed files with 41 additions and 30 deletions
|
|
@ -52,48 +52,52 @@ int mouse_queue_start = 0, mouse_queue_end = 0;
|
|||
void keyboard_at_poll()
|
||||
{
|
||||
keybsenddelay += (1000 * TIMER_USEC);
|
||||
if (keyboard_at.out_new != -1)
|
||||
|
||||
if (keyboard_at.out_new != -1 && !keyboard_at.last_irq)
|
||||
{
|
||||
keyboard_at.wantirq = 0;
|
||||
if (keyboard_at.mem[0] & 0x01)
|
||||
picint(2);
|
||||
keyboard_at.out = keyboard_at.out_new;
|
||||
keyboard_at.out_new = -1;
|
||||
keyboard_at.status |= STAT_OFULL;
|
||||
keyboard_at.status &= ~STAT_IFULL;
|
||||
// pclog("keyboard_at : take IRQ\n");
|
||||
keyboard_at.last_irq = 2;
|
||||
if (keyboard_at.out_new & 0x100)
|
||||
{
|
||||
if (keyboard_at.mem[0] & 0x02)
|
||||
picint(0x1000);
|
||||
keyboard_at.out = keyboard_at.out_new & 0xff;
|
||||
keyboard_at.out_new = -1;
|
||||
keyboard_at.status |= STAT_OFULL;
|
||||
keyboard_at.status &= ~STAT_IFULL;
|
||||
keyboard_at.status |= STAT_MFULL;
|
||||
// pclog("keyboard_at : take IRQ12\n");
|
||||
keyboard_at.last_irq = 0x1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (keyboard_at.mem[0] & 0x01)
|
||||
picint(2);
|
||||
keyboard_at.out = keyboard_at.out_new;
|
||||
keyboard_at.out_new = -1;
|
||||
keyboard_at.status |= STAT_OFULL;
|
||||
keyboard_at.status &= ~STAT_IFULL;
|
||||
keyboard_at.status &= ~STAT_MFULL;
|
||||
// pclog("keyboard_at : take IRQ1\n");
|
||||
keyboard_at.last_irq = 2;
|
||||
}
|
||||
}
|
||||
else if (keyboard_at.wantirq12)
|
||||
{
|
||||
keyboard_at.wantirq12 = 0;
|
||||
picint(0x1000);
|
||||
// pclog("keyboard_at : take IRQ 12\n");
|
||||
keyboard_at.last_irq = 0x1000;
|
||||
}
|
||||
if (!(keyboard_at.status & STAT_OFULL) && !(keyboard_at.mem[0] & 0x10) &&
|
||||
|
||||
if (!(keyboard_at.status & STAT_OFULL) && keyboard_at.out_new == -1 && /*!(keyboard_at.mem[0] & 0x20) &&*/
|
||||
mouse_queue_start != mouse_queue_end)
|
||||
{
|
||||
// pclog("Reading %02X from the mouse queue at %i\n", keyboard_at.out, key_queue_start);
|
||||
keyboard_at.out = mouse_queue[mouse_queue_start];
|
||||
keyboard_at.out_new = mouse_queue[mouse_queue_start] | 0x100;
|
||||
mouse_queue_start = (mouse_queue_start + 1) & 0xf;
|
||||
keyboard_at.status |= STAT_OFULL | STAT_MFULL;
|
||||
keyboard_at.status &= ~STAT_IFULL;
|
||||
if (keyboard_at.mem[0] & 0x02)
|
||||
keyboard_at.wantirq12 = 1;
|
||||
}
|
||||
else if (!(keyboard_at.status & STAT_OFULL) && keyboard_at.out_new == -1 &&
|
||||
!(keyboard_at.mem[0] & 0x10) && key_queue_start != key_queue_end)
|
||||
{
|
||||
keyboard_at.out_new = key_queue[key_queue_start];
|
||||
// pclog("Reading %02X from the key queue at %i\n", keyboard_at.out, key_queue_start);
|
||||
key_queue_start = (key_queue_start + 1) & 0xf;
|
||||
}
|
||||
else if (keyboard_at.out_new == -1 && !(keyboard_at.status & STAT_OFULL) &&
|
||||
key_ctrl_queue_start != key_ctrl_queue_end)
|
||||
{
|
||||
keyboard_at.out_new = key_ctrl_queue[key_ctrl_queue_start];
|
||||
// pclog("Reading %02X from the key ctrl_queue at %i\n", keyboard_at.out, key_ctrl_queue_start);
|
||||
key_ctrl_queue_start = (key_ctrl_queue_start + 1) & 0xf;
|
||||
}
|
||||
}
|
||||
|
|
@ -168,6 +172,7 @@ void keyboard_at_write(uint16_t port, uint8_t val, void *priv)
|
|||
keyboard_at.wantirq = 1;
|
||||
if (!(val & 1) && keyboard_at.wantirq)
|
||||
keyboard_at.wantirq = 0;
|
||||
mouse_scan = !(val & 0x20);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -318,6 +323,7 @@ void keyboard_at_write(uint16_t port, uint8_t val, void *priv)
|
|||
break;
|
||||
|
||||
case 0xa7: /*Disable mouse port*/
|
||||
mouse_scan = 0;
|
||||
break;
|
||||
|
||||
case 0xa9: /*Test mouse port*/
|
||||
|
|
@ -349,7 +355,7 @@ void keyboard_at_write(uint16_t port, uint8_t val, void *priv)
|
|||
break;
|
||||
|
||||
case 0xc0: /*Read input port*/
|
||||
keyboard_at_adddata(keyboard_at.input_port);
|
||||
keyboard_at_adddata(keyboard_at.input_port | 4);
|
||||
keyboard_at.input_port = ((keyboard_at.input_port + 1) & 3) | (keyboard_at.input_port & 0xfc);
|
||||
break;
|
||||
|
||||
|
|
@ -415,19 +421,18 @@ uint8_t keyboard_at_read(uint16_t port, void *priv)
|
|||
{
|
||||
case 0x60:
|
||||
temp = keyboard_at.out;
|
||||
keyboard_at.status &= ~(STAT_OFULL | STAT_MFULL);
|
||||
keyboard_at.status &= ~(STAT_OFULL/* | STAT_MFULL*/);
|
||||
picintc(keyboard_at.last_irq);
|
||||
keyboard_at.last_irq = 0;
|
||||
break;
|
||||
|
||||
case 0x61:
|
||||
if (ppispeakon) return (ppi.pb&~0xC0)|0x20;
|
||||
return ppi.pb&~0xC0;
|
||||
break;
|
||||
return ppi.pb&~0xe0;
|
||||
|
||||
case 0x64:
|
||||
temp = keyboard_at.status;
|
||||
keyboard_at.status &= ~(STAT_RTIMEOUT | STAT_TTIMEOUT);
|
||||
keyboard_at.status &= ~(STAT_RTIMEOUT/* | STAT_TTIMEOUT*/);
|
||||
break;
|
||||
}
|
||||
// if (port != 0x61) pclog("%02X %08X\n", temp, rammask);
|
||||
|
|
|
|||
|
|
@ -4,3 +4,4 @@ void keyboard_at_poll();
|
|||
|
||||
void (*mouse_write)(uint8_t val);
|
||||
extern int mouse_queue_start, mouse_queue_end;
|
||||
extern int mouse_scan;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#include "mouse_ps2.h"
|
||||
#include "plat-mouse.h"
|
||||
|
||||
int mouse_scan = 0;
|
||||
|
||||
enum
|
||||
{
|
||||
MOUSE_STREAM,
|
||||
|
|
@ -105,6 +107,9 @@ void mouse_ps2_poll(int x, int y, int b)
|
|||
{
|
||||
uint8_t packet[3] = {0x08, 0, 0};
|
||||
if (!x && !y && b == ps2_b) return;
|
||||
|
||||
if (!mouse_scan)
|
||||
return;
|
||||
ps2_x += x;
|
||||
ps2_y -= y;
|
||||
if (mouse_ps2.mode == MOUSE_STREAM && (mouse_ps2.flags & MOUSE_ENABLE) &&
|
||||
|
|
|
|||
Loading…
Reference in a new issue