Blender
V2.93
intern
ghost
intern
GHOST_XrEvent.cpp
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or
3
* modify it under the terms of the GNU General Public License
4
* as published by the Free Software Foundation; either version 2
5
* of the License, or (at your option) any later version.
6
*
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
11
*
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software Foundation,
14
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15
*/
16
21
#include <iostream>
22
23
#include "
GHOST_C-api.h
"
24
#include "
GHOST_XrContext.h
"
25
#include "
GHOST_Xr_intern.h
"
26
27
static
bool
GHOST_XrEventPollNext
(XrInstance instance, XrEventDataBuffer &r_event_data)
28
{
29
/* (Re-)initialize as required by specification. */
30
r_event_data.type = XR_TYPE_EVENT_DATA_BUFFER;
31
r_event_data.next =
nullptr
;
32
33
return
(xrPollEvent(instance, &r_event_data) == XR_SUCCESS);
34
}
35
36
GHOST_TSuccess
GHOST_XrEventsHandle
(GHOST_XrContextHandle xr_contexthandle)
37
{
38
if
(xr_contexthandle ==
nullptr
) {
39
return
GHOST_kFailure
;
40
}
41
42
GHOST_XrContext
&xr_context = *(
GHOST_XrContext
*)xr_contexthandle;
43
XrEventDataBuffer event_buffer;
/* Structure big enough to hold all possible events. */
44
45
while
(
GHOST_XrEventPollNext
(xr_context.
getInstance
(), event_buffer)) {
46
XrEventDataBaseHeader *
event
= (XrEventDataBaseHeader *)&event_buffer;
47
48
switch
(event->type) {
49
case
XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED:
50
xr_context.
handleSessionStateChange
((XrEventDataSessionStateChanged &)*event);
51
return
GHOST_kSuccess
;
52
case
XR_TYPE_EVENT_DATA_INSTANCE_LOSS_PENDING:
53
GHOST_XrContextDestroy
(xr_contexthandle);
54
return
GHOST_kSuccess
;
55
default
:
56
if
(xr_context.
isDebugMode
()) {
57
printf(
"Unhandled event: %i\n"
, event->type);
58
}
59
return
GHOST_kFailure
;
60
}
61
}
62
63
return
GHOST_kFailure
;
64
}
GHOST_C-api.h
GHOST C-API function and type declarations.
GHOST_TSuccess
GHOST_TSuccess
Definition:
GHOST_Types.h:91
GHOST_kFailure
@ GHOST_kFailure
Definition:
GHOST_Types.h:91
GHOST_kSuccess
@ GHOST_kSuccess
Definition:
GHOST_Types.h:91
GHOST_XrContext.h
GHOST_XrEventPollNext
static bool GHOST_XrEventPollNext(XrInstance instance, XrEventDataBuffer &r_event_data)
Definition:
GHOST_XrEvent.cpp:27
GHOST_XrEventsHandle
GHOST_TSuccess GHOST_XrEventsHandle(GHOST_XrContextHandle xr_contexthandle)
Definition:
GHOST_XrEvent.cpp:36
GHOST_XrContextDestroy
void GHOST_XrContextDestroy(GHOST_XrContextHandle xr_contexthandle)
Definition:
GHOST_Xr.cpp:50
GHOST_Xr_intern.h
GHOST_XrContext
Main GHOST container to manage OpenXR through.
Definition:
GHOST_XrContext.h:64
GHOST_XrContext::getInstance
XrInstance getInstance() const
Definition:
GHOST_XrContext.cpp:585
GHOST_XrContext::handleSessionStateChange
void handleSessionStateChange(const XrEventDataSessionStateChanged &lifecycle)
Definition:
GHOST_XrContext.cpp:525
GHOST_XrContext::isDebugMode
bool isDebugMode() const
Definition:
GHOST_XrContext.cpp:590
Generated on Tue Jan 31 2023 14:37:24 for Blender by
doxygen
1.9.1