Add Mouse Wheel Scroll Events
This commit add support for mouse wheel scroll events in KVM.
It supports for mouse scroll up/down buttons, by which user can use
mouse wheel functionality.
Testing:
Tested mouse wheel functionality.
Verified mouse wheel scroll up/down functions.
Signed-off-by: Tejas Patil <tejaspp@ami.com>
Change-Id: I7f53f0f203a81b55f2377982571e8f415ed99df2
diff --git a/create_usbhid.sh b/create_usbhid.sh
index d1b9841..12eebd0 100644
--- a/create_usbhid.sh
+++ b/create_usbhid.sh
@@ -67,7 +67,7 @@
mkdir functions/hid.1
echo 2 > functions/hid.1/protocol # 2: mouse
- echo 5 > functions/hid.1/report_length
+ echo 6 > functions/hid.1/report_length
echo 1 > functions/hid.1/subclass
# Binary HID mouse descriptor (absolute coordinate)
@@ -99,9 +99,17 @@
# 0x75, 0x10, // REPORT_SIZE (16)
# 0x95, 0x02, // REPORT_COUNT (2)
# 0x81, 0x02, // INPUT (Data,Var,Abs)
+ # 0x09, 0x38, // Usage (Wheel)
+ # 0x15, 0xff, // LOGICAL_MINIMUM (-1)
+ # 0x25, 0x01, // LOGICAL_MAXIMUM (1)
+ # 0x35, 0x00, // PHYSICAL_MINIMUM (-127)
+ # 0x45, 0x00, // PHYSICAL_MAXIMUM (127)
+ # 0x75, 0x08, // REPORT_SIZE (8)
+ # 0x95, 0x01, // REPORT_COUNT (1)
+ # 0x81, 0x06, // INPUT (Data,Var,Rel)
# 0xc0, // END_COLLECTION
# 0xc0 // END_COLLECTION
- echo -ne '\x05\x01\x09\x02\xa1\x01\x09\x01\xa1\x00\x05\x09\x19\x01\x29\x03\x15\x00\x25\x01\x95\x03\x75\x01\x81\x02\x95\x01\x75\x05\x81\x03\x05\x01\x09\x30\x09\x31\x35\x00\x46\xff\x7f\x15\x00\x26\xff\x7f\x65\x11\x55\x00\x75\x10\x95\x02\x81\x02\xc0\xc0' > functions/hid.1/report_desc
+ echo -ne '\x05\x01\x09\x02\xa1\x01\x09\x01\xa1\x00\x05\x09\x19\x01\x29\x03\x15\x00\x25\x01\x95\x03\x75\x01\x81\x02\x95\x01\x75\x05\x81\x03\x05\x01\x09\x30\x09\x31\x35\x00\x46\xff\x7f\x15\x00\x26\xff\x7f\x65\x11\x55\x00\x75\x10\x95\x02\x81\x02\x09\x38\x15\xff\x25\x01\x35\x00\x45\x00\x75\x08\x95\x01\x81\x06\xc0\xc0' > functions/hid.1/report_desc
# Create configuration
mkdir configs/c.1
diff --git a/ikvm_input.cpp b/ikvm_input.cpp
index 6e8ab26..cbbfdc4 100644
--- a/ikvm_input.cpp
+++ b/ikvm_input.cpp
@@ -213,8 +213,24 @@
return;
}
- input->pointerReport[0] = ((buttonMask & 0x4) >> 1) |
- ((buttonMask & 0x2) << 1) | (buttonMask & 0x1);
+ if (buttonMask > 4)
+ {
+ input->pointerReport[0] = 0;
+ if (buttonMask == 8)
+ {
+ input->pointerReport[5] = 1;
+ }
+ else if (buttonMask == 16)
+ {
+ input->pointerReport[5] = 0xff;
+ }
+ }
+ else
+ {
+ input->pointerReport[0] = ((buttonMask & 0x4) >> 1) |
+ ((buttonMask & 0x2) << 1) | (buttonMask & 0x1);
+ input->pointerReport[5] = 0;
+ }
if (x >= 0 && (unsigned int)x < video.getWidth())
{
diff --git a/ikvm_input.hpp b/ikvm_input.hpp
index 558251d..ac54220 100644
--- a/ikvm_input.hpp
+++ b/ikvm_input.hpp
@@ -61,7 +61,7 @@
private:
static constexpr int NUM_MODIFIER_BITS = 4;
static constexpr int KEY_REPORT_LENGTH = 8;
- static constexpr int PTR_REPORT_LENGTH = 5;
+ static constexpr int PTR_REPORT_LENGTH = 6;
/* @brief HID modifier bits mapped to shift and control key codes */
static constexpr uint8_t shiftCtrlMap[NUM_MODIFIER_BITS] = {