mirror of
https://github.com/lbgos/rift-s-linux.git
synced 2026-10-26 21:02:11 +01:00
st/oxr: Getting vendor id/name from server
This commit is contained in:
1 parent
42047ef157
commit
039ef1ed90
13 files changed
+67
-6
No files matched your search
@@ -16,6 +16,7 @@
|
||||
#include "util/u_misc.h"
|
||||
#include "util/u_logging.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
*
|
||||
@@ -213,3 +214,11 @@ u_system_set_system_compositor(struct u_system *usys, struct xrt_system_composit
|
||||
|
||||
usys->xsysc = xsysc;
|
||||
}
|
||||
|
||||
void
|
||||
u_system_fill_properties(struct u_system *usys, const char *name)
|
||||
{
|
||||
usys->base.properties.vendor_id = 42;
|
||||
// The magical 247 number, is to silence warnings.
|
||||
snprintf(usys->base.properties.name, XRT_MAX_SYSTEM_NAME_SIZE, "Monado: %.*s", 247, name);
|
||||
}
|
||||
@@ -109,6 +109,15 @@ u_system_broadcast_event(struct u_system *usys, const union xrt_session_event *x
|
||||
void
|
||||
u_system_set_system_compositor(struct u_system *usys, struct xrt_system_compositor *xsysc);
|
||||
|
||||
/*!
|
||||
* Fill system properties.
|
||||
*
|
||||
* @public @memberof u_system
|
||||
* @ingroup aux_util
|
||||
*/
|
||||
void
|
||||
u_system_fill_properties(struct u_system *usys, const char *name);
|
||||
|
||||
/*!
|
||||
* Destroy an @ref u_system_create allocated @ref u_system - helper function.
|
||||
*
|
||||
|
||||
@@ -32,6 +32,19 @@ struct xrt_session_info;
|
||||
*
|
||||
*/
|
||||
|
||||
#define XRT_SYSTEM_ID 1
|
||||
|
||||
#define XRT_MAX_SYSTEM_NAME_SIZE 256
|
||||
|
||||
/*!
|
||||
* Properties provided by the system.
|
||||
*/
|
||||
struct xrt_system_properties
|
||||
{
|
||||
uint32_t vendor_id;
|
||||
char name[XRT_MAX_SYSTEM_NAME_SIZE];
|
||||
};
|
||||
|
||||
/*!
|
||||
* A system is a collection of devices, policies and optionally a compositor
|
||||
* that is organised into a chosive group that is usable by one user, most of
|
||||
@@ -69,6 +82,8 @@ struct xrt_system
|
||||
* @param xsys Pointer to self
|
||||
*/
|
||||
void (*destroy)(struct xrt_system *xsys);
|
||||
|
||||
struct xrt_system_properties properties;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "ipc_client_generated.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
/*!
|
||||
* IPC client implementation of @ref xrt_system.
|
||||
@@ -134,6 +135,8 @@ struct xrt_system *
|
||||
ipc_client_system_create(struct ipc_connection *ipc_c, struct xrt_system_compositor *xsysc)
|
||||
{
|
||||
struct ipc_client_system *icsys = U_TYPED_CALLOC(struct ipc_client_system);
|
||||
xrt_result_t xret = ipc_call_system_get_properties(ipc_c, &icsys->base.properties);
|
||||
assert(xret == XRT_SUCCESS);
|
||||
icsys->base.create_session = ipc_client_system_create_session;
|
||||
icsys->base.destroy = ipc_client_system_destroy;
|
||||
icsys->ipc_c = ipc_c;
|
||||
|
||||
@@ -461,6 +461,9 @@ ipc_server_handle_failure(struct ipc_server *vs);
|
||||
*/
|
||||
void
|
||||
ipc_server_handle_shutdown_signal(struct ipc_server *vs);
|
||||
|
||||
xrt_result_t
|
||||
ipc_server_get_system_properties(struct ipc_server *vs, struct xrt_system_properties *out_properties);
|
||||
//! @}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1143,6 +1143,14 @@ ipc_handle_system_get_clients(volatile struct ipc_client_state *_ics, struct ipc
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
xrt_result_t
|
||||
ipc_handle_system_get_properties(volatile struct ipc_client_state *_ics, struct xrt_system_properties *out_properties)
|
||||
{
|
||||
struct ipc_server *s = _ics->server;
|
||||
|
||||
return ipc_server_get_system_properties(s, out_properties);
|
||||
}
|
||||
|
||||
xrt_result_t
|
||||
ipc_handle_system_get_client_info(volatile struct ipc_client_state *_ics,
|
||||
uint32_t client_id,
|
||||
|
||||
@@ -965,6 +965,13 @@ ipc_server_handle_client_connected(struct ipc_server *vs, xrt_ipc_handle_t ipc_h
|
||||
os_mutex_unlock(&vs->global_state.lock);
|
||||
}
|
||||
|
||||
xrt_result_t
|
||||
ipc_server_get_system_properties(struct ipc_server *vs, struct xrt_system_properties *out_properties)
|
||||
{
|
||||
memcpy(out_properties, &vs->xsys->properties, sizeof(*out_properties));
|
||||
return XRT_SUCCESS;
|
||||
}
|
||||
|
||||
#ifndef XRT_OS_ANDROID
|
||||
int
|
||||
ipc_server_main(int argc, char **argv)
|
||||
|
||||
@@ -11,6 +11,12 @@
|
||||
]
|
||||
},
|
||||
|
||||
"system_get_properties": {
|
||||
"out": [
|
||||
{"name": "properties", "type": "struct xrt_system_properties"}
|
||||
]
|
||||
},
|
||||
|
||||
"system_get_client_info": {
|
||||
"in": [
|
||||
{"name": "id", "type": "uint32_t"}
|
||||
|
||||
@@ -350,7 +350,7 @@ oxr_instance_create(struct oxr_logger *log,
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = oxr_system_fill_in(log, inst, 1, &inst->system);
|
||||
ret = oxr_system_fill_in(log, inst, XRT_SYSTEM_ID, &inst->system);
|
||||
if (ret != XR_SUCCESS) {
|
||||
oxr_instance_destroy(log, &inst->handle);
|
||||
return ret;
|
||||
|
||||
@@ -83,7 +83,7 @@ oxr_system_select(struct oxr_logger *log,
|
||||
XrResult
|
||||
oxr_system_verify_id(struct oxr_logger *log, const struct oxr_instance *inst, XrSystemId systemId)
|
||||
{
|
||||
if (systemId != 1) {
|
||||
if (systemId != XRT_SYSTEM_ID) {
|
||||
return oxr_error(log, XR_ERROR_SYSTEM_INVALID, "Invalid system %" PRIu64, systemId);
|
||||
}
|
||||
return XR_SUCCESS;
|
||||
@@ -272,14 +272,12 @@ oxr_system_get_force_feedback_support(struct oxr_logger *log, struct oxr_instanc
|
||||
XrResult
|
||||
oxr_system_get_properties(struct oxr_logger *log, struct oxr_system *sys, XrSystemProperties *properties)
|
||||
{
|
||||
properties->vendorId = 42;
|
||||
properties->systemId = sys->systemId;
|
||||
properties->vendorId = sys->xsys->properties.vendor_id;
|
||||
memcpy(properties->systemName, sys->xsys->properties.name, sizeof(properties->systemName));
|
||||
|
||||
struct xrt_device *xdev = GET_XDEV_BY_ROLE(sys, head);
|
||||
|
||||
// The magical 247 number, is to silence warnings.
|
||||
snprintf(properties->systemName, XR_MAX_SYSTEM_NAME_SIZE, "Monado: %.*s", 247, xdev->str);
|
||||
|
||||
// Get from compositor.
|
||||
struct xrt_system_compositor_info *info = sys->xsysc ? &sys->xsysc->info : NULL;
|
||||
|
||||
|
||||
@@ -86,6 +86,7 @@ t_instance_create_system(struct xrt_instance *xinst,
|
||||
}
|
||||
|
||||
struct xrt_device *head = xsysd->static_roles.head;
|
||||
u_system_fill_properties(usys, head->str);
|
||||
|
||||
bool use_null = debug_get_bool_option_use_null();
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ t_instance_create_system(struct xrt_instance *xinst,
|
||||
return xret;
|
||||
}
|
||||
|
||||
u_system_fill_properties(usys, xsysd->static_roles.head->str);
|
||||
*out_xsys = &usys->base;
|
||||
*out_xsysd = xsysd;
|
||||
*out_xso = xso;
|
||||
|
||||
@@ -82,6 +82,7 @@ sdl_instance_create_system(struct xrt_instance *xinst,
|
||||
|
||||
struct sdl_program *sp = from_xinst(xinst);
|
||||
|
||||
u_system_fill_properties(sp->usys, sp->xsysd_base.static_roles.head->str);
|
||||
*out_xsys = &sp->usys->base;
|
||||
*out_xsysd = &sp->xsysd_base;
|
||||
*out_xso = sp->xso;
|
||||
|
||||
Reference in new issue
Block a user