mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-02-16 02:30:05 +00:00
t/cli: Use xrt_instance_create_system call
This commit is contained in:
parent
1b8cbfd226
commit
d642848bb1
src/xrt/targets/cli
|
@ -10,6 +10,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "xrt/xrt_instance.h"
|
#include "xrt/xrt_instance.h"
|
||||||
|
#include "xrt/xrt_system.h"
|
||||||
#include "xrt/xrt_device.h"
|
#include "xrt/xrt_device.h"
|
||||||
#include "xrt/xrt_prober.h"
|
#include "xrt/xrt_prober.h"
|
||||||
#include "cli_common.h"
|
#include "cli_common.h"
|
||||||
|
@ -31,8 +32,8 @@ do_exit(struct xrt_instance **xi_ptr, int ret)
|
||||||
int
|
int
|
||||||
cli_cmd_probe(int argc, const char **argv)
|
cli_cmd_probe(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
struct xrt_device *xdevs[NUM_XDEVS] = {0};
|
|
||||||
struct xrt_instance *xi = NULL;
|
struct xrt_instance *xi = NULL;
|
||||||
|
xrt_result_t xret = XRT_SUCCESS;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
// Initialize the prober.
|
// Initialize the prober.
|
||||||
|
@ -44,11 +45,20 @@ cli_cmd_probe(int argc, const char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Need to prime the prober with devices before dumping and listing.
|
// Need to prime the prober with devices before dumping and listing.
|
||||||
printf(" :: Probing and selecting!\n");
|
printf(" :: Creating system devices!\n");
|
||||||
|
|
||||||
ret = xrt_instance_select(xi, xdevs, NUM_XDEVS);
|
struct xrt_system_devices *xsysd = NULL;
|
||||||
if (ret != 0) {
|
xret = xrt_instance_create_system( //
|
||||||
return do_exit(&xi, ret);
|
xi, // Instance
|
||||||
|
&xsysd, // System devices.
|
||||||
|
NULL); // System compositor.
|
||||||
|
if (xret != XRT_SUCCESS) {
|
||||||
|
printf("\tCall to xrt_instance_create_system failed! '%i'\n", xret);
|
||||||
|
return do_exit(&xi, -1);
|
||||||
|
}
|
||||||
|
if (xsysd == NULL) {
|
||||||
|
printf("\tNo xrt_system_devices returned!\n");
|
||||||
|
return do_exit(&xi, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct xrt_prober *xp = NULL;
|
struct xrt_prober *xp = NULL;
|
||||||
|
@ -99,27 +109,12 @@ cli_cmd_probe(int argc, const char **argv)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf(" :: Destroying probed devices\n");
|
printf(" :: Destroying probed devices\n");
|
||||||
for (size_t i = 0; i < NUM_XDEVS; i++) {
|
|
||||||
if (xdevs[i] == NULL) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("\tDestroying '%s' [%s]\n", xdevs[i]->str, xdevs[i]->serial);
|
xrt_system_devices_destroy(&xsysd);
|
||||||
xrt_device_destroy(&xdevs[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// End of program
|
// End of program
|
||||||
printf(" :: All ok, shutting down.\n");
|
printf(" :: All ok, shutting down.\n");
|
||||||
|
|
||||||
for (size_t i = 0; i < NUM_XDEVS; i++) {
|
|
||||||
if (xdevs[i] == NULL) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("\tDestroying '%s' [%s]\n", xdevs[i]->str, xdevs[i]->serial);
|
|
||||||
xrt_device_destroy(&xdevs[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally done
|
// Finally done
|
||||||
return do_exit(&xi, 0);
|
return do_exit(&xi, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "xrt/xrt_instance.h"
|
#include "xrt/xrt_instance.h"
|
||||||
|
#include "xrt/xrt_system.h"
|
||||||
#include "xrt/xrt_prober.h"
|
#include "xrt/xrt_prober.h"
|
||||||
#include "cli_common.h"
|
#include "cli_common.h"
|
||||||
|
|
||||||
|
@ -29,8 +30,8 @@ do_exit(struct xrt_instance **xi_ptr, int ret)
|
||||||
int
|
int
|
||||||
cli_cmd_test(int argc, const char **argv)
|
cli_cmd_test(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
struct xrt_device *xdevs[NUM_XDEVS] = {0};
|
|
||||||
struct xrt_instance *xi = NULL;
|
struct xrt_instance *xi = NULL;
|
||||||
|
xrt_result_t xret = XRT_SUCCESS;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
// Initialize the prober.
|
// Initialize the prober.
|
||||||
|
@ -70,37 +71,59 @@ cli_cmd_test(int argc, const char **argv)
|
||||||
|
|
||||||
// Regardless of whether xrt_prober is used, we can find and select
|
// Regardless of whether xrt_prober is used, we can find and select
|
||||||
// (multiple) devices.
|
// (multiple) devices.
|
||||||
printf(" :: Probing and selecting devices!\n");
|
printf(" :: Creating system devices!\n");
|
||||||
|
|
||||||
ret = xrt_instance_select(xi, xdevs, NUM_XDEVS);
|
struct xrt_system_devices *xsysd = NULL;
|
||||||
if (ret != 0) {
|
xret = xrt_instance_create_system( //
|
||||||
return do_exit(&xi, ret);
|
xi, // Instance
|
||||||
|
&xsysd, // System devices.
|
||||||
|
NULL); // System compositor.
|
||||||
|
if (xret != XRT_SUCCESS) {
|
||||||
|
printf("\tCall to xrt_instance_create_system failed! '%i'\n", xret);
|
||||||
|
return do_exit(&xi, -1);
|
||||||
}
|
}
|
||||||
if (xdevs[0] == NULL) {
|
if (xsysd == NULL) {
|
||||||
|
printf("\tNo xrt_system_devices returned!\n");
|
||||||
|
return do_exit(&xi, -1);
|
||||||
|
}
|
||||||
|
if (xsysd->xdevs[0] == NULL) {
|
||||||
printf("\tNo HMD found! :(\n");
|
printf("\tNo HMD found! :(\n");
|
||||||
return do_exit(&xi, -1);
|
return do_exit(&xi, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf(" :: Listing created devices!\n");
|
||||||
|
|
||||||
for (size_t i = 0; i < NUM_XDEVS; i++) {
|
for (uint32_t i = 0; i < XRT_SYSTEM_MAX_DEVICES; i++) {
|
||||||
if (xdevs[i] == NULL) {
|
if (xsysd->xdevs[i] == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\tFound '%s'\n", xdevs[i]->str);
|
printf("\t%2u: %s\n", i, xsysd->xdevs[i]->str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf(" :: Listing role assignments!\n");
|
||||||
|
|
||||||
|
#define PRINT_ROLE(ROLE, PAD) \
|
||||||
|
do { \
|
||||||
|
if (xsysd->roles.ROLE == NULL) { \
|
||||||
|
printf("\t" #ROLE ": " PAD "<none>\n"); \
|
||||||
|
} else { \
|
||||||
|
printf("\t" #ROLE ": " PAD "%s\n", xsysd->roles.ROLE->str); \
|
||||||
|
} \
|
||||||
|
} while (false)
|
||||||
|
|
||||||
|
PRINT_ROLE(head, " ");
|
||||||
|
PRINT_ROLE(left, " ");
|
||||||
|
PRINT_ROLE(right, " ");
|
||||||
|
PRINT_ROLE(gamepad, " ");
|
||||||
|
PRINT_ROLE(hand_tracking.left, " ");
|
||||||
|
PRINT_ROLE(hand_tracking.right, "");
|
||||||
|
|
||||||
|
|
||||||
// End of program
|
// End of program
|
||||||
printf(" :: All ok, shutting down.\n");
|
printf(" :: All ok, shutting down.\n");
|
||||||
|
|
||||||
for (size_t i = 0; i < NUM_XDEVS; i++) {
|
xrt_system_devices_destroy(&xsysd);
|
||||||
if (xdevs[i] == NULL) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("\tDestroying '%s'\n", xdevs[i]->str);
|
|
||||||
xrt_device_destroy(&xdevs[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally done
|
// Finally done
|
||||||
return do_exit(&xi, 0);
|
return do_exit(&xi, 0);
|
||||||
|
|
Loading…
Reference in a new issue