Skip to content

Commit

Permalink
Add rM2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Eeems committed Jul 4, 2023
1 parent 0d0aee6 commit 979061c
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions shared/liboxide/power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,15 @@ void _setup(){
_chargers->append(battery);
}
}
if(deviceSettings.getDeviceType() == Oxide::DeviceSettings::RM1){
auto deviceType = deviceSettings.getDeviceType();
if(deviceType != Oxide::DeviceSettings::Unknown){
O_DEBUG("Looking for usbs...");
dir.setPath("/sys/bus/platform/devices");
for(QString& path : dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable)){
if(!path.endsWith(".usbphy")){
continue;
}
O_DEBUG((" Checking " + path + "...").toStdString().c_str());
SysObject item(dir.path() + "/" + path);
if(!item.hasProperty("uevent")){
O_DEBUG(" Missing uevent property");
continue;
}
O_DEBUG(" Found USB!");
_usbs->append(item);
}
}else if(deviceSettings.getDeviceType() == Oxide::DeviceSettings::RM2){
O_DEBUG("Looking for usbs...");
dir.setPath("/sys/bus/platform/devices");
for(QString& path : dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable)){
if(!path.startsWith("usbphy")){
if(
(deviceType == Oxide::DeviceSettings::RM1 && !path.endsWith(".usbphy")) ||
(deviceType == Oxide::DeviceSettings::RM2 && !path.startsWith("usbphy"))
){
continue;
}
O_DEBUG((" Checking " + path + "...").toStdString().c_str());
Expand All @@ -92,6 +80,8 @@ void _setup(){
O_DEBUG(" Found USB!");
_usbs->append(item);
}
}else{
O_WARNING("Unable to detect usbs due to unknown device type");
}
}
int _batteryInt(const QString& property){
Expand Down Expand Up @@ -212,9 +202,9 @@ namespace Oxide::Power {
if(batteryCharging() || _chargerInt("online")){
return true;
}
if(deviceSettings.getDeviceType() == DeviceSettings::DeviceType::RM1){
return _usbPropIs("USB_CHARGER_STATE", "USB_CHARGER_PRESENT");
if(deviceSettings.getDeviceType() == DeviceSettings::DeviceType::Unknown){
return false;
}
return false;
return _usbPropIs("USB_CHARGER_STATE", "USB_CHARGER_PRESENT");
}
}

0 comments on commit 979061c

Please sign in to comment.