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:
@@ -28,14 +28,14 @@
|
|||||||
* A packet read from the mouse data port is composed of
|
* A packet read from the mouse data port is composed of
|
||||||
* three bytes:
|
* three bytes:
|
||||||
* byte 0: status byte, where
|
* byte 0: status byte, where
|
||||||
* - bit 0: Y overflow (1 = true)
|
* - bit 4: Y overflow (1 = true)
|
||||||
* - bit 1: X overflow (1 = true)
|
* - bit 6: X overflow (1 = true)
|
||||||
* - bit 2: MSB of Y offset
|
* - bit 5: MSB of Y offset
|
||||||
* - bit 3: MSB of X offset
|
* - bit 4: MSB of X offset
|
||||||
* - bit 4: Syncronization bit (always 1)
|
* - bit 3: Syncronization bit (always 1)
|
||||||
* - bit 5: Middle button (1 = down)
|
* - bit 2: Middle button (1 = down)
|
||||||
* - bit 6: Right button (1 = down)
|
* - bit 1: Right button (1 = down)
|
||||||
* - bit 7: Left button (1 = down)
|
* - bit 0: Left button (1 = down)
|
||||||
* byte 1: X position change, since last probed (-127 to +127)
|
* byte 1: X position change, since last probed (-127 to +127)
|
||||||
* byte 2: Y 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) {
|
if (pos) {
|
||||||
pos->xdelta = xDelta;
|
pos->xdelta = xDelta;
|
||||||
pos->ydelta = yDelta;
|
pos->ydelta = yDelta;
|
||||||
@@ -206,6 +210,9 @@ ps2_mouse_read(mouse_movement *userMovement)
|
|||||||
TRACE(("error copying buffer\n"));
|
TRACE(("error copying buffer\n"));
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(packet[0] & 8))
|
||||||
|
panic("ps2_hid: got broken data from packet_buffer_read\n");
|
||||||
|
|
||||||
ps2_packet_to_movement(packet, &movement);
|
ps2_packet_to_movement(packet, &movement);
|
||||||
|
|
||||||
@@ -242,27 +249,27 @@ set_mouse_enabled(bool enable)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static int32
|
static int32
|
||||||
handle_mouse_interrupt(void* data)
|
handle_mouse_interrupt(void* cookie)
|
||||||
{
|
{
|
||||||
int8 read = gIsa->read_io_8(PS2_PORT_CTRL);
|
uint8 data = gIsa->read_io_8(PS2_PORT_CTRL);
|
||||||
if (read < 0) {
|
if (!(data & PS2_STATUS_OUTPUT_BUFFER_FULL)) {
|
||||||
TRACE(("Interrupt was not generated by the ps2 mouse\n"));
|
TRACE(("no ps2 mouse data available\n"));
|
||||||
return B_UNHANDLED_INTERRUPT;
|
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));
|
if (sSync == 0 && !(data & 8)) {
|
||||||
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)) {
|
|
||||||
TRACE(("mouse resynched, bad data\n"));
|
TRACE(("mouse resynched, bad data\n"));
|
||||||
return B_HANDLED_INTERRUPT;
|
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) {
|
if (++sSync == sPacketSize) {
|
||||||
TRACE(("mouse synched\n"));
|
TRACE(("mouse synched\n"));
|
||||||
sSync = 0;
|
sSync = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user