Send a keyboard event too for a wake-up event
This commit adds a keyboard event sending for waking up the host.
So both keyboard and mouse events will be triggered for a case
when the host is in mode that doesn't support mouse.
Change-Id: I90d9a1e53706cd860340dfd8be688128fa95c4fc
Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
diff --git a/ikvm_input.cpp b/ikvm_input.cpp
index 6c17296..ce88f40 100644
--- a/ikvm_input.cpp
+++ b/ikvm_input.cpp
@@ -156,21 +156,45 @@
void Input::sendWakeupPacket()
{
- uint8_t wakeupReport[PTR_REPORT_LENGTH] = {0};
- uint16_t xy = SHRT_MAX / 2;
+ uint8_t wakeupReport[KEY_REPORT_LENGTH] = {0};
- if (pointerFd < 0)
+ if (pointerFd >= 0)
{
- return;
+ uint16_t xy = SHRT_MAX / 2;
+
+ memcpy(&wakeupReport[1], &xy, 2);
+ memcpy(&wakeupReport[3], &xy, 2);
+
+ if (write(pointerFd, wakeupReport, PTR_REPORT_LENGTH) !=
+ PTR_REPORT_LENGTH)
+ {
+ log<level::ERR>("Failed to write pointer report",
+ entry("ERROR=%s", strerror(errno)));
+ }
}
- memcpy(&wakeupReport[1], &xy, 2);
- memcpy(&wakeupReport[3], &xy, 2);
-
- if (write(pointerFd, wakeupReport, PTR_REPORT_LENGTH) != PTR_REPORT_LENGTH)
+ if (keyboardFd >= 0)
{
- log<level::ERR>("Failed to write report",
- entry("ERROR=%s", strerror(errno)));
+ memset(&wakeupReport[0], 0, KEY_REPORT_LENGTH);
+
+ wakeupReport[0] = keyToMod(XK_Shift_L);
+
+ if (write(keyboardFd, wakeupReport, KEY_REPORT_LENGTH) !=
+ KEY_REPORT_LENGTH)
+ {
+ log<level::ERR>("Failed to write keyboard report",
+ entry("ERROR=%s", strerror(errno)));
+ return;
+ }
+
+ wakeupReport[0] = 0;
+
+ if (write(keyboardFd, wakeupReport, KEY_REPORT_LENGTH) !=
+ KEY_REPORT_LENGTH)
+ {
+ log<level::ERR>("Failed to write keyboard report",
+ entry("ERROR=%s", strerror(errno)));
+ }
}
}