apps: cam: Highlight default enumerator
Print "[default]" after the default enumerator when listing controls. Example: $ cam -c 1 --list-controls [...] Control: [inout] libcamera::ExposureTimeMode: - ExposureTimeModeAuto (0) [default] - ExposureTimeModeManual (1) Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
fbb67a73c4
commit
90208694c8
1 changed files with 10 additions and 1 deletions
|
@ -10,6 +10,7 @@
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
#include <optional>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include <libcamera/control_ids.h>
|
#include <libcamera/control_ids.h>
|
||||||
|
@ -174,6 +175,11 @@ void CameraSession::listControls() const
|
||||||
std::cout << "Control: " << io.str()
|
std::cout << "Control: " << io.str()
|
||||||
<< id->vendor() << "::" << id->name() << ":"
|
<< id->vendor() << "::" << id->name() << ":"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
|
std::optional<int32_t> def;
|
||||||
|
if (!info.def().isNone())
|
||||||
|
def = info.def().get<int32_t>();
|
||||||
|
|
||||||
for (const auto &value : info.values()) {
|
for (const auto &value : info.values()) {
|
||||||
int32_t val = value.get<int32_t>();
|
int32_t val = value.get<int32_t>();
|
||||||
const auto &it = id->enumerators().find(val);
|
const auto &it = id->enumerators().find(val);
|
||||||
|
@ -183,7 +189,10 @@ void CameraSession::listControls() const
|
||||||
std::cout << "UNKNOWN";
|
std::cout << "UNKNOWN";
|
||||||
else
|
else
|
||||||
std::cout << it->second;
|
std::cout << it->second;
|
||||||
std::cout << " (" << val << ")" << std::endl;
|
|
||||||
|
std::cout << " (" << val << ")"
|
||||||
|
<< (val == def ? " [default]" : "")
|
||||||
|
<< std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue