Blender
V4.3
intern
ghost
intern
GHOST_XrEvent.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2020-2023 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
9
#include <iostream>
10
11
#include "
GHOST_C-api.h
"
12
#include "
GHOST_XrContext.hh
"
13
#include "
GHOST_Xr_intern.hh
"
14
15
static
bool
GHOST_XrEventPollNext
(XrInstance instance, XrEventDataBuffer &r_event_data)
16
{
17
/* (Re-)initialize as required by specification. */
18
r_event_data.type = XR_TYPE_EVENT_DATA_BUFFER;
19
r_event_data.next =
nullptr
;
20
21
return
(xrPollEvent(instance, &r_event_data) == XR_SUCCESS);
22
}
23
24
GHOST_TSuccess
GHOST_XrEventsHandle
(GHOST_XrContextHandle xr_contexthandle)
25
{
26
if
(xr_contexthandle ==
nullptr
) {
27
return
GHOST_kFailure
;
28
}
29
30
GHOST_XrContext
&xr_context = *(
GHOST_XrContext
*)xr_contexthandle;
31
XrEventDataBuffer event_buffer;
/* Structure big enough to hold all possible events. */
32
33
while
(
GHOST_XrEventPollNext
(xr_context.
getInstance
(), event_buffer)) {
34
XrEventDataBaseHeader *
event
= (XrEventDataBaseHeader *)&event_buffer;
35
36
switch
(event->type) {
37
case
XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED:
38
xr_context.
handleSessionStateChange
((XrEventDataSessionStateChanged &)*event);
39
return
GHOST_kSuccess
;
40
case
XR_TYPE_EVENT_DATA_INSTANCE_LOSS_PENDING:
41
GHOST_XrContextDestroy
(xr_contexthandle);
42
return
GHOST_kSuccess
;
43
default
:
44
if
(xr_context.
isDebugMode
()) {
45
printf
(
"Unhandled event: %i\n"
, event->type);
46
}
47
return
GHOST_kFailure
;
48
}
49
}
50
51
return
GHOST_kFailure
;
52
}
GHOST_C-api.h
GHOST C-API function and type declarations.
GHOST_TSuccess
GHOST_TSuccess
Definition
GHOST_Types.h:87
GHOST_kFailure
@ GHOST_kFailure
Definition
GHOST_Types.h:87
GHOST_kSuccess
@ GHOST_kSuccess
Definition
GHOST_Types.h:87
GHOST_XrContext.hh
GHOST_XrEventPollNext
static bool GHOST_XrEventPollNext(XrInstance instance, XrEventDataBuffer &r_event_data)
Definition
GHOST_XrEvent.cc:15
GHOST_XrEventsHandle
GHOST_TSuccess GHOST_XrEventsHandle(GHOST_XrContextHandle xr_contexthandle)
Definition
GHOST_XrEvent.cc:24
GHOST_XrContextDestroy
void GHOST_XrContextDestroy(GHOST_XrContextHandle xr_contexthandle)
Definition
GHOST_Xr.cc:38
GHOST_Xr_intern.hh
GHOST_XrContext
Main GHOST container to manage OpenXR through.
Definition
GHOST_XrContext.hh:60
GHOST_XrContext::getInstance
XrInstance getInstance() const
Definition
GHOST_XrContext.cc:639
GHOST_XrContext::handleSessionStateChange
void handleSessionStateChange(const XrEventDataSessionStateChanged &lifecycle)
Definition
GHOST_XrContext.cc:557
GHOST_XrContext::isDebugMode
bool isDebugMode() const
Definition
GHOST_XrContext.cc:644
printf
#define printf
Generated on Thu Feb 6 2025 07:36:39 for Blender by
doxygen
1.11.0