This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/intern/ghost/intern/GHOST_XrEvent.cpp
Campbell Barton c434782e3a File headers: SPDX License migration
Use a shorter/simpler license convention, stops the header taking so
much space.

Follow the SPDX license specification: https://spdx.org/licenses

- C/C++/objc/objc++
- Python
- Shell Scripts
- CMake, GNUmakefile

While most of the source tree has been included

- `./extern/` was left out.
- `./intern/cycles` & `./intern/atomic` are also excluded because they
  use different header conventions.

doc/license/SPDX-license-identifiers.txt has been added to list SPDX all
used identifiers.

See P2788 for the script that automated these edits.

Reviewed By: brecht, mont29, sergey

Ref D14069
2022-02-11 09:14:36 +11:00

51 lines
1.4 KiB
C++

/* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup GHOST
*/
#include <iostream>
#include "GHOST_C-api.h"
#include "GHOST_XrContext.h"
#include "GHOST_Xr_intern.h"
static bool GHOST_XrEventPollNext(XrInstance instance, XrEventDataBuffer &r_event_data)
{
/* (Re-)initialize as required by specification. */
r_event_data.type = XR_TYPE_EVENT_DATA_BUFFER;
r_event_data.next = nullptr;
return (xrPollEvent(instance, &r_event_data) == XR_SUCCESS);
}
GHOST_TSuccess GHOST_XrEventsHandle(GHOST_XrContextHandle xr_contexthandle)
{
if (xr_contexthandle == nullptr) {
return GHOST_kFailure;
}
GHOST_XrContext &xr_context = *(GHOST_XrContext *)xr_contexthandle;
XrEventDataBuffer event_buffer; /* Structure big enough to hold all possible events. */
while (GHOST_XrEventPollNext(xr_context.getInstance(), event_buffer)) {
XrEventDataBaseHeader *event = (XrEventDataBaseHeader *)&event_buffer;
switch (event->type) {
case XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED:
xr_context.handleSessionStateChange((XrEventDataSessionStateChanged &)*event);
return GHOST_kSuccess;
case XR_TYPE_EVENT_DATA_INSTANCE_LOSS_PENDING:
GHOST_XrContextDestroy(xr_contexthandle);
return GHOST_kSuccess;
default:
if (xr_context.isDebugMode()) {
printf("Unhandled event: %i\n", event->type);
}
return GHOST_kFailure;
}
}
return GHOST_kFailure;
}