From 529f8625f58c23ce6118d4ae0dc6a5310f6d24a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mon=20ou=C3=AFe?= Date: Thu, 30 Nov 2023 23:12:39 +0100 Subject: Allow VR keyboard overlay to type into the tracked window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds a new dependency — xdo — but I do not feel too bad about requiring it at compile time, since the readme already recommends using xdotool to select a window from the command line. --- src/main.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 1929193..2559785 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -49,6 +49,8 @@ #include #include +#include + #include #include #include @@ -416,6 +418,7 @@ private: // X compositor VideoBuffers *overlay_buffers = nullptr; GLuint m_unOverlayProgramID = 0; const char *overlay_key = "vr-video-player"; + xdo_t *overlay_xdo = nullptr; }; @@ -1201,6 +1204,8 @@ bool CMainApplication::BInitOverlay() vr::VROverlay()->SetOverlayFromFile( thumbnail_handle, "frog.png"); + overlay_xdo = xdo_new_with_opened_display(x_display, nullptr, 0); + return true; } @@ -1280,6 +1285,9 @@ void CMainApplication::Shutdown() SDL_Quit(); + if (overlay_xdo) + xdo_free(overlay_xdo); + if (x_display) XCloseDisplay(x_display); } @@ -1616,6 +1624,16 @@ void CMainApplication::ProcessVREvent( const vr::VREvent_t & event ) bQuitSignal = true; } break; + + case vr::VREvent_KeyboardCharInput: + if (overlay_xdo && src_window_id != None) { + char text[sizeof(event.data.keyboard.cNewInput) + 1] = {0}; + memcpy(text, event.data.keyboard.cNewInput, + sizeof(event.data.keyboard.cNewInput)); + xdo_enter_text_window(overlay_xdo, src_window_id, text, + 12 * 1000); + } + break; } } -- cgit v1.2.3