[Bf-blender-cvs] [8841bd96605] master: GHOST/Wayland: Add NDOF support

Campbell Barton noreply at git.blender.org
Tue Aug 16 04:28:06 CEST 2022


Commit: 8841bd96605122340c9ea2e743b44463998eb16d
Author: Campbell Barton
Date:   Tue Aug 16 12:25:18 2022 +1000
Branches: master
https://developer.blender.org/rB8841bd96605122340c9ea2e743b44463998eb16d

GHOST/Wayland: Add NDOF support

Logic for NDOF devices is shared with X11, process events using
GHOST_NDOFManagerUnix when WITH_INPUT_NDOF is enabled.

===================================================================

M	intern/ghost/intern/GHOST_SystemWayland.cpp
M	intern/ghost/intern/GHOST_SystemWayland.h

===================================================================

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;



More information about the Bf-blender-cvs mailing list