forked from jackburton79/ocs-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScreens.cpp
58 lines (50 loc) · 1.15 KB
/
Screens.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Screens.cpp
*
* Created on: 15/lug/2015
* Author: Stefano Ceccherini
*/
#include "Screens.h"
#include "EDID.h"
#include "Support.h"
#include <iostream>
#include <string>
struct pnp_id {
const char* manufacturer;
const char* id;
};
static const struct pnp_id kPNPIDs[] = {
#include "pnp_ids.h"
};
Screens::Screens()
{
if (CommandExists("find")) {
CommandStreamBuffer buf("find /sys/devices/ -name edid", "r");
std::istream stream(&buf);
std::string line;
while (std::getline(stream, line)) {
screen_info info;
edid_info edidInfo;
info.name = line;
if (get_edid_info(line.c_str(), &edidInfo) == 0) {
info.description = edidInfo.description;
info.manufacturer = GetManufacturerFromID(edidInfo.manufacturer);
info.type = edidInfo.type;
info.model = edidInfo.model;
info.serial_number = edidInfo.serial_number;
fItems.push_back(info);
}
}
}
Rewind();
}
std::string
GetManufacturerFromID(const std::string& string)
{
// TODO: Improve
for (size_t i = 0; i < sizeof(kPNPIDs) / sizeof(kPNPIDs[0]); i++) {
if (string.compare(kPNPIDs[i].id) == 0)
return kPNPIDs[i].manufacturer;
}
return string;
}