[2/2] apps: cam: Print control array sizes
diff mbox series

Message ID 20240911153523.1756554-3-paul.elder@ideasonboard.com
State Superseded
Headers show
Series
  • Add array information to ControlId
Related show

Commit Message

Paul Elder Sept. 11, 2024, 3:35 p.m. UTC
Now that controls can be queried for array information, print it in
--list-controls when applicable.

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
---
 src/apps/cam/camera_session.cpp | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Kieran Bingham Sept. 11, 2024, 4 p.m. UTC | #1
Quoting Paul Elder (2024-09-11 16:35:23)
> Now that controls can be queried for array information, print it in
> --list-controls when applicable.
> 
> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
> ---
>  src/apps/cam/camera_session.cpp | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp
> index 37de6c9f3..9c7f84993 100644
> --- a/src/apps/cam/camera_session.cpp
> +++ b/src/apps/cam/camera_session.cpp
> @@ -169,6 +169,11 @@ void CameraSession::listControls() const
>                                 std::cout << "  - " << id->enumToString(val) << " (" << val << ")" << std::endl;
>                         }
>                 }
> +
> +               if (id->isArray()) {
> +                       std::size_t size = id->size();
> +                       std::cout << "   Size: " << (size == std::numeric_limits<std::size_t>::max() ? "n" : std::to_string(size)) << std::endl;

That's a long line... but it doesn't break down easily ...

		std::cout << "   Size: "
			  << (size == std::numeric_limits<std::size_t>::max() ? "n" : std::to_string(size))
			  << std::endl;
but maybe that doesn't help much.

Either way, printing the control information is very helpful. And I'm
looking forward to when applciations can use this to interogate the
controls from UI implementations or otherwise at runtime.

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>


> +               }
>         }
>  }
>  
> -- 
> 2.39.2
>

Patch
diff mbox series

diff --git a/src/apps/cam/camera_session.cpp b/src/apps/cam/camera_session.cpp
index 37de6c9f3..9c7f84993 100644
--- a/src/apps/cam/camera_session.cpp
+++ b/src/apps/cam/camera_session.cpp
@@ -169,6 +169,11 @@  void CameraSession::listControls() const
 				std::cout << "  - " << id->enumToString(val) << " (" << val << ")" << std::endl;
 			}
 		}
+
+		if (id->isArray()) {
+			std::size_t size = id->size();
+			std::cout << "   Size: " << (size == std::numeric_limits<std::size_t>::max() ? "n" : std::to_string(size)) << std::endl;
+		}
 	}
 }