diff options
author | Dmitry Petrov <dpetroff@gmail.com> | 2021-12-13 23:12:01 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-01-20 10:37:52 +0100 |
commit | d61cc47055e27b007005ac2355728ce54cbbb50b (patch) | |
tree | 4359aab608b0880795f3c97ac11dac6b994eee08 /Kernel/Devices/HID | |
parent | 1afb6d5eca4c8f09768e5437139fe2e73ab0583c (diff) | |
download | serenity-d61cc47055e27b007005ac2355728ce54cbbb50b.zip |
Kernel: Add horizontal mouse scroll support
Diffstat (limited to 'Kernel/Devices/HID')
-rw-r--r-- | Kernel/Devices/HID/MouseDevice.cpp | 2 | ||||
-rw-r--r-- | Kernel/Devices/HID/PS2MouseDevice.cpp | 12 |
2 files changed, 12 insertions, 2 deletions
diff --git a/Kernel/Devices/HID/MouseDevice.cpp b/Kernel/Devices/HID/MouseDevice.cpp index 87441315fa..53d8f90dd9 100644 --- a/Kernel/Devices/HID/MouseDevice.cpp +++ b/Kernel/Devices/HID/MouseDevice.cpp @@ -35,7 +35,7 @@ ErrorOr<size_t> MouseDevice::read(OpenFileDescription&, u64, UserOrKernelBuffer& lock.unlock(); dbgln_if(MOUSE_DEBUG, "Mouse Read: Buttons {:x}", packet.buttons); - dbgln_if(MOUSE_DEBUG, "PS2 Mouse: X {}, Y {}, Z {}, Relative {}", packet.x, packet.y, packet.z, packet.buttons); + dbgln_if(MOUSE_DEBUG, "PS2 Mouse: X {}, Y {}, Z {}, W {}, Relative {}", packet.x, packet.y, packet.z, packet.w, packet.buttons); dbgln_if(MOUSE_DEBUG, "PS2 Mouse Read: Filter packets"); size_t bytes_read_from_packet = min(remaining_space_in_buffer, sizeof(MousePacket)); diff --git a/Kernel/Devices/HID/PS2MouseDevice.cpp b/Kernel/Devices/HID/PS2MouseDevice.cpp index fbf8a282b7..57b48c7e76 100644 --- a/Kernel/Devices/HID/PS2MouseDevice.cpp +++ b/Kernel/Devices/HID/PS2MouseDevice.cpp @@ -89,6 +89,7 @@ MousePacket PS2MouseDevice::parse_data_packet(const RawPacket& raw_packet) int x = raw_packet.bytes[1]; int y = raw_packet.bytes[2]; int z = 0; + int w = 0; if (m_has_wheel) { // FIXME: For non-Intellimouse, this is a full byte. // However, for now, m_has_wheel is only set for Intellimouse. @@ -97,6 +98,14 @@ MousePacket PS2MouseDevice::parse_data_packet(const RawPacket& raw_packet) // -1 in 4 bits if (z == 15) z = -1; + + if ((raw_packet.bytes[3] & 0xc0) == 0x40) { + // FIXME: Scroll only functions correctly when the sign is flipped there + w = -z; + z = 0; + } else { + w = 0; + } } bool x_overflow = raw_packet.bytes[0] & 0x40; bool y_overflow = raw_packet.bytes[0] & 0x80; @@ -114,6 +123,7 @@ MousePacket PS2MouseDevice::parse_data_packet(const RawPacket& raw_packet) packet.x = x; packet.y = y; packet.z = z; + packet.w = w; packet.buttons = raw_packet.bytes[0] & 0x07; if (m_has_five_buttons) { @@ -125,7 +135,7 @@ MousePacket PS2MouseDevice::parse_data_packet(const RawPacket& raw_packet) packet.is_relative = true; dbgln_if(PS2MOUSE_DEBUG, "PS2 Relative Mouse: Buttons {:x}", packet.buttons); - dbgln_if(PS2MOUSE_DEBUG, "Mouse: X {}, Y {}, Z {}", packet.x, packet.y, packet.z); + dbgln_if(PS2MOUSE_DEBUG, "Mouse: X {}, Y {}, Z {}, W {}", packet.x, packet.y, packet.z, packet.w); return packet; } |