Add Connector::get_mode(const std::string &mode), remove const char * variant
[android/external-libkmsxx.git] / libkms++ / connector.cpp
index ee14af9388c34b0741b6cba3d33a2a0ceab899d6..8ff5a5f8f4a264661084ce22289c37d3f54b6b02 100644 (file)
@@ -89,7 +89,18 @@ Videomode Connector::get_default_mode() const
        return drm_mode_to_video_mode(drmmode);
 }
 
-bool Connector::connected()
+Videomode Connector::get_mode(const string& mode) const
+{
+       auto c = m_priv->drm_connector;
+
+       for (int i = 0; i < c->count_modes; i++)
+                if (mode == c->modes[i].name)
+                        return drm_mode_to_video_mode(c->modes[i]);
+
+        throw invalid_argument(mode + ": mode not found");
+}
+
+bool Connector::connected() const
 {
        return m_priv->drm_connector->connection == DRM_MODE_CONNECTED;
 }