Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-08-16 05:25:18 +0300
committerCampbell Barton <campbell@blender.org>2022-08-16 05:27:42 +0300
commit8841bd96605122340c9ea2e743b44463998eb16d (patch)
tree4999b50aa7c5eacaa82a2bdb11c82785940e44c1
parent3a8c57cf9dd46087ebb9cb3aa8ef195153405d41 (diff)
GHOST/Wayland: Add NDOF support
Logic for NDOF devices is shared with X11, process events using GHOST_NDOFManagerUnix when WITH_INPUT_NDOF is enabled.
-rw-r--r--intern/ghost/intern/GHOST_SystemWayland.cpp39
-rw-r--r--intern/ghost/intern/GHOST_SystemWayland.h2
2 files changed, 39 insertions, 2 deletions
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 6a90cf5c71e..df9f2a899e0 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -19,6 +19,10 @@
#include "GHOST_ContextEGL.h"
+#ifdef WITH_INPUT_NDOF
+# include "GHOST_NDOFManagerUnix.h"
+#endif
+
#ifdef WITH_GHOST_WAYLAND_DYNLOAD
# include <wayland_dynload_API.h> /* For `ghost_wl_dynload_libraries`. */
#endif
@@ -2987,9 +2991,36 @@ GHOST_SystemWayland::~GHOST_SystemWayland()
display_destroy(d);
}
+GHOST_TSuccess GHOST_SystemWayland::init()
+{
+ GHOST_TSuccess success = GHOST_System::init();
+
+ if (success) {
+#ifdef WITH_INPUT_NDOF
+ m_ndofManager = new GHOST_NDOFManagerUnix(*this);
+#endif
+ return GHOST_kSuccess;
+ }
+
+ return GHOST_kFailure;
+}
+
bool GHOST_SystemWayland::processEvents(bool waitForEvent)
{
- const bool fired = getTimerManager()->fireTimers(getMilliSeconds());
+ bool any_processed = false;
+
+ if (getTimerManager()->fireTimers(getMilliSeconds())) {
+ any_processed = true;
+ }
+
+#ifdef WITH_INPUT_NDOF
+ if (static_cast<GHOST_NDOFManagerUnix *>(m_ndofManager)->processEvents()) {
+ /* As NDOF bypasses WAYLAND event handling,
+ * never wait for an event when an NDOF event was found. */
+ waitForEvent = false;
+ any_processed = true;
+ }
+#endif /* WITH_INPUT_NDOF */
if (waitForEvent) {
wl_display_dispatch(d->display);
@@ -2998,7 +3029,11 @@ bool GHOST_SystemWayland::processEvents(bool waitForEvent)
wl_display_roundtrip(d->display);
}
- return fired || (getEventManager()->getNumEvents() > 0);
+ if ((getEventManager()->getNumEvents() > 0)) {
+ any_processed = true;
+ }
+
+ return any_processed;
}
int GHOST_SystemWayland::setConsoleWindowState(GHOST_TConsoleWindowState /*action*/)
diff --git a/intern/ghost/intern/GHOST_SystemWayland.h b/intern/ghost/intern/GHOST_SystemWayland.h
index bdf5f2fc273..632f4bf28d8 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.h
+++ b/intern/ghost/intern/GHOST_SystemWayland.h
@@ -93,6 +93,8 @@ class GHOST_SystemWayland : public GHOST_System {
~GHOST_SystemWayland() override;
+ GHOST_TSuccess init();
+
bool processEvents(bool waitForEvent) override;
int setConsoleWindowState(GHOST_TConsoleWindowState action) override;