···133133 return igButton(tmp, button_dims);
134134}
135135136136+void
137137+mode_selected_so_continue(struct gui_scene *scene, struct gui_program *p)
138138+{
139139+ struct video_select *vs = (struct video_select *)scene;
140140+ gui_scene_calibrate(p, vs->xfctx, vs->xfs, vs->settings);
141141+142142+ // We should not clean these up, zero them out.
143143+ vs->settings = NULL;
144144+ vs->xfctx = NULL;
145145+ vs->xfs = NULL;
146146+147147+ // Schedule us to be deleted when it's safe.
148148+ gui_scene_delete_me(p, scene);
149149+}
150150+136151static void
137152scene_render(struct gui_scene *scene, struct gui_program *p)
138153{
···158173 igText("No modes found on '%s'!", vs->xfs->name);
159174 }
160175161161- // We have selected a stream device and it has modes.
162162- for (size_t i = 0; i < vs->num_modes; i++) {
163163- if (!render_mode(&vs->modes[i])) {
164164- continue;
165165- }
166166-167167- vs->settings->camera_mode = i;
168168-169169- // User selected this mode, create the next scene.
170170- gui_scene_calibrate(p, vs->xfctx, vs->xfs, vs->settings);
176176+ // We have selected a stream device and it has only one mode - user doesn't need to care what that is; proceed
177177+ // immediately
178178+ if (vs->num_modes == 1) {
179179+ vs->settings->camera_mode = 0;
180180+ mode_selected_so_continue(scene, p);
181181+ } else {
182182+ // We have selected a stream device and it has multiple modes - let user decide which to use
183183+ for (size_t i = 0; i < vs->num_modes; i++) {
184184+ if (!render_mode(&vs->modes[i])) {
185185+ continue;
186186+ }
171187172172- // We should not clean these up, zero them out.
173173- vs->settings = NULL;
174174- vs->xfctx = NULL;
175175- vs->xfs = NULL;
176176-177177- // Schedule us to be deleted when it's safe.
178178- gui_scene_delete_me(p, scene);
188188+ vs->settings->camera_mode = i;
189189+ mode_selected_so_continue(scene, p);
190190+ }
179191 }
180192181193 igSeparator();