The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

st/gui: skip mode selection if there's only one mode

authored by

Moses Turner and committed by
Jakob Bornecrantz
dfd576e0 c8b9bff3

+29 -17
+29 -17
src/xrt/state_trackers/gui/gui_scene_video.c
··· 133 133 return igButton(tmp, button_dims); 134 134 } 135 135 136 + void 137 + mode_selected_so_continue(struct gui_scene *scene, struct gui_program *p) 138 + { 139 + struct video_select *vs = (struct video_select *)scene; 140 + gui_scene_calibrate(p, vs->xfctx, vs->xfs, vs->settings); 141 + 142 + // We should not clean these up, zero them out. 143 + vs->settings = NULL; 144 + vs->xfctx = NULL; 145 + vs->xfs = NULL; 146 + 147 + // Schedule us to be deleted when it's safe. 148 + gui_scene_delete_me(p, scene); 149 + } 150 + 136 151 static void 137 152 scene_render(struct gui_scene *scene, struct gui_program *p) 138 153 { ··· 158 173 igText("No modes found on '%s'!", vs->xfs->name); 159 174 } 160 175 161 - // We have selected a stream device and it has modes. 162 - for (size_t i = 0; i < vs->num_modes; i++) { 163 - if (!render_mode(&vs->modes[i])) { 164 - continue; 165 - } 166 - 167 - vs->settings->camera_mode = i; 168 - 169 - // User selected this mode, create the next scene. 170 - gui_scene_calibrate(p, vs->xfctx, vs->xfs, vs->settings); 176 + // We have selected a stream device and it has only one mode - user doesn't need to care what that is; proceed 177 + // immediately 178 + if (vs->num_modes == 1) { 179 + vs->settings->camera_mode = 0; 180 + mode_selected_so_continue(scene, p); 181 + } else { 182 + // We have selected a stream device and it has multiple modes - let user decide which to use 183 + for (size_t i = 0; i < vs->num_modes; i++) { 184 + if (!render_mode(&vs->modes[i])) { 185 + continue; 186 + } 171 187 172 - // We should not clean these up, zero them out. 173 - vs->settings = NULL; 174 - vs->xfctx = NULL; 175 - vs->xfs = NULL; 176 - 177 - // Schedule us to be deleted when it's safe. 178 - gui_scene_delete_me(p, scene); 188 + vs->settings->camera_mode = i; 189 + mode_selected_so_continue(scene, p); 190 + } 179 191 } 180 192 181 193 igSeparator();