GHOST/Wayland: Add NDOF support

Logic for NDOF devices is shared with X11, process events using
GHOST_NDOFManagerUnix when WITH_INPUT_NDOF is enabled.
This commit is contained in:
Campbell Barton 2022-08-16 12:25:18 +10:00
parent 3a8c57cf9d
commit 8841bd9660
Notes: blender-bot 2024-01-16 18:05:25 +01:00
Referenced by issue #76428, GHOST/Wayland Support
2 changed files with 39 additions and 2 deletions

View File

@ -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*/)

View File

@ -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;