Blender  V3.3
GHOST_XrEvent.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include <iostream>
8 
9 #include "GHOST_C-api.h"
10 #include "GHOST_XrContext.h"
11 #include "GHOST_Xr_intern.h"
12 
13 static bool GHOST_XrEventPollNext(XrInstance instance, XrEventDataBuffer &r_event_data)
14 {
15  /* (Re-)initialize as required by specification. */
16  r_event_data.type = XR_TYPE_EVENT_DATA_BUFFER;
17  r_event_data.next = nullptr;
18 
19  return (xrPollEvent(instance, &r_event_data) == XR_SUCCESS);
20 }
21 
22 GHOST_TSuccess GHOST_XrEventsHandle(GHOST_XrContextHandle xr_contexthandle)
23 {
24  if (xr_contexthandle == nullptr) {
25  return GHOST_kFailure;
26  }
27 
28  GHOST_XrContext &xr_context = *(GHOST_XrContext *)xr_contexthandle;
29  XrEventDataBuffer event_buffer; /* Structure big enough to hold all possible events. */
30 
31  while (GHOST_XrEventPollNext(xr_context.getInstance(), event_buffer)) {
32  XrEventDataBaseHeader *event = (XrEventDataBaseHeader *)&event_buffer;
33 
34  switch (event->type) {
35  case XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED:
36  xr_context.handleSessionStateChange((XrEventDataSessionStateChanged &)*event);
37  return GHOST_kSuccess;
38  case XR_TYPE_EVENT_DATA_INSTANCE_LOSS_PENDING:
39  GHOST_XrContextDestroy(xr_contexthandle);
40  return GHOST_kSuccess;
41  default:
42  if (xr_context.isDebugMode()) {
43  printf("Unhandled event: %i\n", event->type);
44  }
45  return GHOST_kFailure;
46  }
47  }
48 
49  return GHOST_kFailure;
50 }
GHOST C-API function and type declarations.
GHOST_TSuccess
Definition: GHOST_Types.h:74
@ GHOST_kFailure
Definition: GHOST_Types.h:74
@ GHOST_kSuccess
Definition: GHOST_Types.h:74
static bool GHOST_XrEventPollNext(XrInstance instance, XrEventDataBuffer &r_event_data)
GHOST_TSuccess GHOST_XrEventsHandle(GHOST_XrContextHandle xr_contexthandle)
void GHOST_XrContextDestroy(GHOST_XrContextHandle xr_contexthandle)
Definition: GHOST_Xr.cpp:36
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object instance
Main GHOST container to manage OpenXR through.
XrInstance getInstance() const
void handleSessionStateChange(const XrEventDataSessionStateChanged &lifecycle)
bool isDebugMode() const