1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 02:17:34 +00:00

PS2MouseDevice: Use dbg() instead of dbgprintf()

This commit is contained in:
Liav A 2020-02-24 16:58:59 +02:00 committed by Andreas Kling
parent fcb1426a2b
commit 5cd58adfa9

View file

@ -89,7 +89,7 @@ void PS2MouseDevice::handle_vmmouse_absolute_pointer()
VMWareBackdoor::the().send(command); VMWareBackdoor::the().send(command);
if (command.ax == 0xFFFF0000) { if (command.ax == 0xFFFF0000) {
#ifdef PS2MOUSE_DEBUG #ifdef PS2MOUSE_DEBUG
dbgprintf("Reset vmmouse.\n"); dbg() << "Reset vmmouse.";
#endif #endif
VMWareBackdoor::the().disable_absolute_vmmouse(); VMWareBackdoor::the().disable_absolute_vmmouse();
VMWareBackdoor::the().enable_absolute_vmmouse(); VMWareBackdoor::the().enable_absolute_vmmouse();
@ -109,8 +109,8 @@ void PS2MouseDevice::handle_vmmouse_absolute_pointer()
int z = (command.dx); int z = (command.dx);
#ifdef PS2MOUSE_DEBUG #ifdef PS2MOUSE_DEBUG
dbgprintf("Absolute Mouse: Buttons %x\n", buttons); dbg() << "Absolute Mouse: Buttons " << String::format("%x", buttons);
dbgprintf("Mouse: X %d, Y %d, Z %d\n", x, y, z); dbg() << "Mouse: X " << x << ", Y " << y << ", Z " << z);
#endif #endif
MousePacket packet; MousePacket packet;
packet.x = x; packet.x = x;
@ -134,14 +134,14 @@ void PS2MouseDevice::handle_irq(RegisterState&)
if (VMWareBackdoor::the().vmmouse_is_absolute()) { if (VMWareBackdoor::the().vmmouse_is_absolute()) {
#ifdef PS2MOUSE_DEBUG #ifdef PS2MOUSE_DEBUG
dbgprintf("Handling PS2 vmmouse.\n"); dbg() << "Handling PS2 vmmouse.";
#endif #endif
IO::in8(I8042_BUFFER); IO::in8(I8042_BUFFER);
handle_vmmouse_absolute_pointer(); handle_vmmouse_absolute_pointer();
return; return;
} }
#ifdef PS2MOUSE_DEBUG #ifdef PS2MOUSE_DEBUG
dbgprintf("Handling classical PS2 mouse.\n"); dbg() << "Handling classical PS2 mouse.";
#endif #endif
for (;;) { for (;;) {
u8 status = IO::in8(I8042_STATUS); u8 status = IO::in8(I8042_STATUS);
@ -154,12 +154,7 @@ void PS2MouseDevice::handle_irq(RegisterState&)
auto commit_packet = [&] { auto commit_packet = [&] {
m_data_state = 0; m_data_state = 0;
#ifdef PS2MOUSE_DEBUG #ifdef PS2MOUSE_DEBUG
dbgprintf("PS2Mouse: %d, %d %s %s (buffered: %u)\n", dbg() << ("PS2Mouse: " << m_data[1] << ", " << m_data[2] << " " << ((m_data[0] & 1) ? "Left" : "") << " " << ((m_data[0] & 2) ? "Right" : "") << " (buffered: " << m_queue.size() << ")";
m_data[1],
m_data[2],
(m_data[0] & 1) ? "Left" : "",
(m_data[0] & 2) ? "Right" : "",
m_queue.size());
#endif #endif
parse_data_packet(); parse_data_packet();
}; };
@ -167,7 +162,7 @@ void PS2MouseDevice::handle_irq(RegisterState&)
switch (m_data_state) { switch (m_data_state) {
case 0: case 0:
if (!(data & 0x08)) { if (!(data & 0x08)) {
dbgprintf("PS2Mouse: Stream out of sync.\n"); dbg() << "PS2Mouse: Stream out of sync.";
break; break;
} }
++m_data_state; ++m_data_state;
@ -216,8 +211,8 @@ void PS2MouseDevice::parse_data_packet()
packet.buttons = m_data[0] & 0x07; packet.buttons = m_data[0] & 0x07;
packet.is_relative = true; packet.is_relative = true;
#ifdef PS2MOUSE_DEBUG #ifdef PS2MOUSE_DEBUG
dbgprintf("PS2 Relative Mouse: Buttons %x\n", packet.buttons); dbg() << "PS2 Relative Mouse: Buttons " << String::format("%x", packet.buttons);
dbgprintf("Mouse: X %d, Y %d, Z %d\n", packet.x, packet.y, packet.z); dbg() << "Mouse: X " << packet.x << ", Y " << packet.y << ", Z " << packet.z;
#endif #endif
m_queue.enqueue(packet); m_queue.enqueue(packet);
} }
@ -369,9 +364,9 @@ ssize_t PS2MouseDevice::read(FileDescription&, u8* buffer, ssize_t size)
while (!m_queue.is_empty() && remaining_space_in_buffer) { while (!m_queue.is_empty() && remaining_space_in_buffer) {
auto packet = m_queue.dequeue(); auto packet = m_queue.dequeue();
#ifdef PS2MOUSE_DEBUG #ifdef PS2MOUSE_DEBUG
dbgprintf("PS2 Mouse Read: Buttons %x\n", packet.buttons); dbg() << "PS2 Mouse Read: Buttons " << String::format("%x", packet.buttons);
dbgprintf("PS2 Mouse Read: X %d, Y %d, Z %d, Relative %d\n", packet.x, packet.y, packet.z, packet.buttons); dbg() << "PS2 Mouse: X " << packet.x << ", Y " << packet.y << ", Z " << packet.z << " Relative " << packet.buttons;
dbgprintf("PS2 Mouse Read: Filter packets\n"); dbg() << "PS2 Mouse Read: Filter packets";
#endif #endif
size_t bytes_read_from_packet = min(remaining_space_in_buffer, sizeof(MousePacket)); size_t bytes_read_from_packet = min(remaining_space_in_buffer, sizeof(MousePacket));
memcpy(buffer + nread, &packet, bytes_read_from_packet); memcpy(buffer + nread, &packet, bytes_read_from_packet);