Connect HID gadget device dynamically
Connecting HID gadget device statically from the beginning of this
service causes an issue on WHLK test. To prevent the issue, this
commit changes the HID gadget device handling as dynamic so that
the HID gadget device can be connected when this service has at
least one KVM client.
Tested: /dev/hidg0 and /dev/hidg1 created only when at least one
KVM client is connected.
Change-Id: I5f6596b9e4e297fb6b507000499fc041460659f7
Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@intel.com>
diff --git a/ikvm_input.hpp b/ikvm_input.hpp
index 2adc7c1..aae7cef 100644
--- a/ikvm_input.hpp
+++ b/ikvm_input.hpp
@@ -2,6 +2,8 @@
#include <rfb/rfb.h>
+#include <filesystem>
+#include <fstream>
#include <map>
#include <string>
@@ -29,6 +31,10 @@
Input(Input&&) = default;
Input& operator=(Input&&) = default;
+ /* @brief Connects HID gadget to host */
+ void connect();
+ /* @brief Disconnects HID gadget from host */
+ void disconnect();
/*
* @brief RFB client key event handler
*
@@ -72,6 +78,12 @@
0x04, // left alt
0x40 // right alt
};
+ /* @brief Path to the HID gadget UDC */
+ static constexpr const char* hidUdcPath =
+ "/sys/kernel/config/usb_gadget/obmc_hid/UDC";
+ /* @brief Path to the USB virtual hub */
+ static constexpr const char* usbVirtualHubPath =
+ "/sys/bus/platform/devices/1e6a0000.usb-vhub";
/*
* @brief Translates a RFB-specific key code to HID modifier bit
*
@@ -109,6 +121,8 @@
* of which keys are down
*/
std::map<int, int> keysDown;
+ /* @brief Handle of the HID gadget UDC */
+ std::ofstream hidUdcStream;
};
} // namespace ikvm