diff options
| author | Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> | 2019-02-20 15:03:17 -0800 |
|---|---|---|
| committer | Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com> | 2019-02-20 15:03:17 -0800 |
| commit | eaf5c5b643c821ca9ca8d9ce7a6d3c91601aa7d0 (patch) | |
| tree | a16fb1b7c9c2ecb07655cb6a01342fff4e0d8887 | |
| parent | c943938114d34bf0fb13ee099a211d2a97c5b39c (diff) | |
| download | obmc-ikvm-eaf5c5b643c821ca9ca8d9ce7a6d3c91601aa7d0.tar.gz obmc-ikvm-eaf5c5b643c821ca9ca8d9ce7a6d3c91601aa7d0.zip | |
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>
| -rw-r--r-- | ikvm_input.cpp | 44 |
1 files changed, 34 insertions, 10 deletions
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::pointerEvent(int buttonMask, int x, int y, rfbClientPtr cl) 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); - 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))); + } + } - 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))); + } } } |

