Fixed PS/2 mouse driver.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12876 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
d9152a2dfe
commit
56c6492868
@ -28,14 +28,14 @@
|
||||
* A packet read from the mouse data port is composed of
|
||||
* three bytes:
|
||||
* byte 0: status byte, where
|
||||
* - bit 0: Y overflow (1 = true)
|
||||
* - bit 1: X overflow (1 = true)
|
||||
* - bit 2: MSB of Y offset
|
||||
* - bit 3: MSB of X offset
|
||||
* - bit 4: Syncronization bit (always 1)
|
||||
* - bit 5: Middle button (1 = down)
|
||||
* - bit 6: Right button (1 = down)
|
||||
* - bit 7: Left button (1 = down)
|
||||
* - bit 4: Y overflow (1 = true)
|
||||
* - bit 6: X overflow (1 = true)
|
||||
* - bit 5: MSB of Y offset
|
||||
* - bit 4: MSB of X offset
|
||||
* - bit 3: Syncronization bit (always 1)
|
||||
* - bit 2: Middle button (1 = down)
|
||||
* - bit 1: Right button (1 = down)
|
||||
* - bit 0: Left button (1 = down)
|
||||
* byte 1: X position change, since last probed (-127 to +127)
|
||||
* byte 2: Y position change, since last probed (-127 to +127)
|
||||
*
|
||||
@ -171,6 +171,10 @@ ps2_packet_to_movement(uint8 packet[], mouse_movement *pos)
|
||||
}
|
||||
}
|
||||
|
||||
// dprintf("packet: %02x %02x %02x %02x: xd %d, yd %d, 0x%x (%d), w-xd %d, w-yd %d\n",
|
||||
// packet[0], packet[1], packet[2], packet[3],
|
||||
// xDelta, yDelta, buttons, sClickCount, wheel_xdelta, wheel_ydelta);
|
||||
|
||||
if (pos) {
|
||||
pos->xdelta = xDelta;
|
||||
pos->ydelta = yDelta;
|
||||
@ -206,6 +210,9 @@ ps2_mouse_read(mouse_movement *userMovement)
|
||||
TRACE(("error copying buffer\n"));
|
||||
return status;
|
||||
}
|
||||
|
||||
if (!(packet[0] & 8))
|
||||
panic("ps2_hid: got broken data from packet_buffer_read\n");
|
||||
|
||||
ps2_packet_to_movement(packet, &movement);
|
||||
|
||||
@ -242,27 +249,27 @@ set_mouse_enabled(bool enable)
|
||||
*/
|
||||
|
||||
static int32
|
||||
handle_mouse_interrupt(void* data)
|
||||
handle_mouse_interrupt(void* cookie)
|
||||
{
|
||||
int8 read = gIsa->read_io_8(PS2_PORT_CTRL);
|
||||
if (read < 0) {
|
||||
TRACE(("Interrupt was not generated by the ps2 mouse\n"));
|
||||
uint8 data = gIsa->read_io_8(PS2_PORT_CTRL);
|
||||
if (!(data & PS2_STATUS_OUTPUT_BUFFER_FULL)) {
|
||||
TRACE(("no ps2 mouse data available\n"));
|
||||
return B_UNHANDLED_INTERRUPT;
|
||||
}
|
||||
|
||||
read = gIsa->read_io_8(PS2_PORT_DATA);
|
||||
data = gIsa->read_io_8(PS2_PORT_DATA);
|
||||
TRACE(("mouse interrupt : byte %x\n", data));
|
||||
|
||||
TRACE(("mouse interrupt : byte %x\n", read));
|
||||
while (packet_buffer_write(sMouseBuffer, &read, sizeof(read)) == 0) {
|
||||
// we start dropping packets when the buffer is full
|
||||
packet_buffer_flush(sMouseBuffer, sPacketSize);
|
||||
}
|
||||
|
||||
if (sSync == 0 && !(read & 8)) {
|
||||
if (sSync == 0 && !(data & 8)) {
|
||||
TRACE(("mouse resynched, bad data\n"));
|
||||
return B_HANDLED_INTERRUPT;
|
||||
}
|
||||
|
||||
while (packet_buffer_write(sMouseBuffer, &data, sizeof(data)) == 0) {
|
||||
// we start dropping packets when the buffer is full
|
||||
packet_buffer_flush(sMouseBuffer, sPacketSize);
|
||||
}
|
||||
|
||||
if (++sSync == sPacketSize) {
|
||||
TRACE(("mouse synched\n"));
|
||||
sSync = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user