st/gui: Make it possible to pass in remote address from the command line

This commit is contained in:
Jakob Bornecrantz 2022-06-01 14:44:51 +01:00
parent b782478571
commit 3c1576fc44
4 changed files with 10 additions and 5 deletions

View file

@ -224,10 +224,11 @@ gui_scene_record(struct gui_program *p, const char *camera);
/*!
* Remote control debugging UI.
*
* @param Optional address.
* @ingroup gui
*/
void
gui_scene_remote(struct gui_program *p);
gui_scene_remote(struct gui_program *p, const char *address);
/*!
* Given the frameserver runs the calibration code on it.

View file

@ -74,7 +74,7 @@ scene_render(struct gui_scene *scene, struct gui_program *p)
if (igButton("Remote", button_dims)) {
gui_scene_delete_me(p, scene);
gui_scene_remote(p);
gui_scene_remote(p, NULL);
}
igSeparator();

View file

@ -387,7 +387,7 @@ scene_destroy(struct gui_scene *scene, struct gui_program *p)
*/
void
gui_scene_remote(struct gui_program *p)
gui_scene_remote(struct gui_program *p, const char *address)
{
struct gui_remote *gr = U_TYPED_CALLOC(struct gui_remote);
@ -396,7 +396,11 @@ gui_scene_remote(struct gui_program *p)
gr->rc.fd = -1;
// GUI input defaults.
snprintf(gr->address, sizeof(gr->address), "localhost");
if (address != NULL) {
snprintf(gr->address, sizeof(gr->address), "%s", address);
} else {
snprintf(gr->address, sizeof(gr->address), "localhost");
}
gr->port = 4242;
gui_scene_push_front(p, &gr->base);

View file

@ -47,7 +47,7 @@ main(int argc, char **argv)
} else if (argc >= 2 && strcmp("record", argv[1]) == 0) {
gui_scene_record(&p.base, argc >= 3 ? argv[2] : NULL);
} else if (argc >= 2 && strcmp("remote", argv[1]) == 0) {
gui_scene_remote(&p.base);
gui_scene_remote(&p.base, argc >= 3 ? argv[2] : NULL);
} else {
gui_scene_main_menu(&p.base);
}