aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMon ouïe <mon.ouie@gmail.com>2023-11-30 23:12:39 +0100
committerMon ouïe <mon.ouie@gmail.com>2023-11-30 23:12:39 +0100
commit529f8625f58c23ce6118d4ae0dc6a5310f6d24a2 (patch)
tree9c0d2acab5dfc89d2d8b32398e38e9ddda0e0c9b /src
parent99fee8244657bf047abab813e630d2ea6b08757e (diff)
Allow VR keyboard overlay to type into the tracked window
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.
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp18
1 files changed, 18 insertions, 0 deletions
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 <X11/Xlib.h>
#include <X11/extensions/Xfixes.h>
+#include <xdo.h>
+
#include <stdio.h>
#include <string>
#include <cstdlib>
@@ -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;
}
}