Merge pull request #26312 from garbear/update-controllers
[xbmc.git] / xbmc / windowing / X11 / XRandR.h
blob6f5f74cf8395e10990c94ecab76102511aaef430
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include <map>
12 #include <string>
13 #include <vector>
15 class XMode
17 public:
18 XMode()
20 hz=0.0f;
21 isPreferred=false;
22 isCurrent=false;
23 w=h=0;
25 bool operator==(XMode& mode) const
27 if (id != mode.id)
28 return false;
29 if (name != mode.name)
30 return false;
31 if (hz != mode.hz)
32 return false;
33 if (isPreferred != mode.isPreferred)
34 return false;
35 if (isCurrent != mode.isCurrent)
36 return false;
37 if (w != mode.w)
38 return false;
39 if (h != mode.h)
40 return false;
41 return true;
43 bool IsInterlaced()
45 return name.back() == 'i';
47 std::string id;
48 std::string name;
49 float hz;
50 bool isPreferred;
51 bool isCurrent;
52 unsigned int w;
53 unsigned int h;
56 class XOutput
58 public:
59 XOutput()
61 isConnected = false;
62 w = h = x = y = wmm = hmm = 0;
64 std::string name;
65 bool isConnected;
66 int screen;
67 int w;
68 int h;
69 int x;
70 int y;
71 int crtc;
72 int wmm;
73 int hmm;
74 std::vector<XMode> modes;
75 bool isRotated;
78 class CXRandR
80 public:
81 explicit CXRandR(bool query=false);
82 bool Query(bool force=false, bool ignoreoff=true);
83 bool Query(bool force, int screennum, bool ignoreoff=true);
84 std::vector<XOutput> GetModes(void);
85 XMode GetCurrentMode(const std::string& outputName);
86 XMode GetPreferredMode(const std::string& outputName);
87 XOutput *GetOutput(const std::string& outputName);
88 bool SetMode(const XOutput& output, const XMode& mode);
89 void LoadCustomModeLinesToAllOutputs(void);
90 void SaveState();
91 void SetNumScreens(unsigned int num);
92 bool IsOutputConnected(const std::string& name);
93 bool TurnOffOutput(const std::string& name);
94 bool TurnOnOutput(const std::string& name);
95 int GetCrtc(int x, int y, float &hz);
96 //bool Has1080i();
97 //bool Has1080p();
98 //bool Has720p();
99 //bool Has480p();
101 private:
102 bool m_bInit;
103 std::vector<XOutput> m_outputs;
104 std::string m_currentOutput;
105 std::string m_currentMode;
106 unsigned int m_numScreens;
109 extern CXRandR g_xrandr;