#include "OVR_Platform.h"
#include <stdio.h>
int main() {
// initialize the platform SDK
ovrPlatformInitializeResult initializeResult = ovr_PlatformInitializeWindows("PUT_YOUR_APP_ID_HERE");
// quit if initialization failed
if (initializeResult < 0) {
puts("Initialization failed");
return 1;
}
// get the logged in user's id
// this is not a request, so it returns the data directly
ovrID loggedInUserID = ovr_GetLoggedInUserID();
if (loggedInUserID == 0) {
puts("No logged in user");
return 1;
}
// initiate a request to get the logged in users's information
// this is a request, so the response is returned on the message queue
ovr_User_Get(loggedInUserID);
// main loop
for (;;) {
// pop messages off of the message queue until it is empty
for(;;) {
ovrMessageHandle message = ovr_PopMessage();
if (message == NULL) {
break;
}
// first check for errors
if (ovr_Message_IsError(message)) {
ovrErrorHandle error = ovr_Message_GetError(message);
puts("Got an error");
puts(ovr_Error_GetMessage(error));
return 1;
}
// get the message type
ovrMessageType messageType = ovr_Message_GetType(message);
// handle the response
if (messageType == ovrMessage_User_Get) {
ovrUserHandle user = ovr_Message_GetUser(message);
puts("Got a user");
printf("Username: %s", ovr_User_GetOculusID(user));
} else {
// Normally, you would handle other message types, but we'll just ignore them
// for this example
}
ovr_FreeMessage(message);
}
}
}