summaryrefslogtreecommitdiff
path: root/libkms++
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@iki.fi>2015-10-03 18:05:55 +0300
committerTomi Valkeinen <tomi.valkeinen@iki.fi>2015-10-03 18:05:55 +0300
commitd0effe834f1600f233a772520c4eb3339f49571f (patch)
tree5cb298737ae102cc197d625487c09fba7efb1852 /libkms++
parent42bc208e6b0a35c68e9bb156c8d463d1a9a946b9 (diff)
cleanup connector strings
Diffstat (limited to 'libkms++')
-rw-r--r--libkms++/connector.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/libkms++/connector.cpp b/libkms++/connector.cpp
index d00f3c7..0d6d4d7 100644
--- a/libkms++/connector.cpp
+++ b/libkms++/connector.cpp
@@ -9,12 +9,12 @@
using namespace std;
-#define DEF_CONN(c) [DRM_MODE_CONNECTOR_##c] = #c
-
namespace kms
{
-static const char * connector_names[] = {
+
+static const map<int, string> connector_names = {
+#define DEF_CONN(c) { DRM_MODE_CONNECTOR_##c, #c }
DEF_CONN(Unknown),
DEF_CONN(VGA),
DEF_CONN(DVII),
@@ -32,13 +32,14 @@ static const char * connector_names[] = {
DEF_CONN(eDP),
DEF_CONN(VIRTUAL),
DEF_CONN(DSI),
+#undef DEF_CONN
};
-static const char *connection_str[] = {
- [0] = "<unknown>",
- [DRM_MODE_CONNECTED] = "Connected",
- [DRM_MODE_DISCONNECTED] = "Disconnected",
- [DRM_MODE_UNKNOWNCONNECTION] = "Unknown",
+static const map<int, string> connection_str = {
+ { 0, "<unknown>" },
+ { DRM_MODE_CONNECTED, "Connected" },
+ { DRM_MODE_DISCONNECTED, "Disconnected" },
+ { DRM_MODE_UNKNOWNCONNECTION, "Unknown" },
};
struct ConnectorPriv
@@ -54,8 +55,8 @@ Connector::Connector(Card &card, uint32_t id, uint32_t idx)
m_priv->drm_connector = drmModeGetConnector(this->card().fd(), this->id());
assert(m_priv->drm_connector);
- auto name = connector_names[m_priv->drm_connector->connector_type];
- m_fullname = std::string(string(name) + std::to_string(m_priv->drm_connector->connector_type_id));
+ const auto& name = connector_names.at(m_priv->drm_connector->connector_type);
+ m_fullname = name + to_string(m_priv->drm_connector->connector_type_id);
}
@@ -89,7 +90,7 @@ void Connector::print_short() const
auto c = m_priv->drm_connector;
printf("Connector %d, %s, %dx%dmm, %s\n", id(), m_fullname.c_str(),
- c->mmWidth, c->mmHeight, connection_str[c->connection]);
+ c->mmWidth, c->mmHeight, connection_str.at(c->connection).c_str());
}
Videomode Connector::get_default_mode() const