From ee3106db4ac63184a207d741a3ba7c03e562eb12 Mon Sep 17 00:00:00 2001 From: Rob Gill Date: Mon, 14 Jan 2019 14:58:32 +0000 Subject: [PATCH] Fix for Bug #14822 Apps/Devices ACPI button handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Patch checks for pathless results, and in cases where acpi/hid is returned uses the hid element. In case of any non-hid nodes returning no path, a separate "unknown" entry is also added. * Also disables one "not implemented" message in line with https://review.haiku-os.org/c/haiku/+/696 Change-Id: I7ac92c7f3c5cb03401b9502aa345a86f117a5a20 Reviewed-on: https://review.haiku-os.org/c/879 Reviewed-by: Axel Dörfler --- src/apps/devices/DeviceACPI.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/apps/devices/DeviceACPI.cpp b/src/apps/devices/DeviceACPI.cpp index 291d341877..ced12b23b4 100644 --- a/src/apps/devices/DeviceACPI.cpp +++ b/src/apps/devices/DeviceACPI.cpp @@ -1,8 +1,9 @@ /* - * Copyright 2008-2010 Haiku Inc. All rights reserved. + * Copyright 2008-2019 Haiku Inc. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: + * Rob Gill * Alexander von Gluck (kallisti5) */ @@ -36,8 +37,10 @@ DeviceACPI::InitFromAttributes() BString outlineName; BString nodeACPIPath; BString rootACPIPath; + BString nodeACPIHid; rootACPIPath = nodeACPIPath = GetAttribute("acpi/path").fValue; + nodeACPIHid = GetAttribute("acpi/hid").fValue; // Grab just the root node info // We grab 6 characters to not identify sub nodes of root node @@ -60,16 +63,28 @@ DeviceACPI::InitFromAttributes() outlineName << string.String(); } else if (rootACPIPath == "\\_SI_") { outlineName = B_TRANSLATE("ACPI System Indicator"); - } else { + } else if (nodeACPIPath != "") { // This allows to localize apostrophes, too BString string(B_TRANSLATE("ACPI node '%1'")); string.ReplaceFirst("%1", nodeACPIPath); outlineName << string.String(); - } + } else if (nodeACPIPath == "" && nodeACPIHid != "") { + // Handle ACPI HID entries that do not return a path + nodeACPIHid.Remove(0, nodeACPIHid.FindLast("_") + 1); + BString string(B_TRANSLATE("ACPI Button '%1'")); + string.ReplaceFirst("%1", nodeACPIHid); + outlineName << string.String(); + } else { + BString string(B_TRANSLATE("ACPI ")); + outlineName << string.String(); + } SetAttribute(B_TRANSLATE("Device name"), outlineName.String()); +#if 0 + // These are a source of confusion for users. + // Until we can display something useful, let's not show the lines at all. SetAttribute(B_TRANSLATE("Manufacturer"), B_TRANSLATE("Not implemented")); - +#endif SetText(outlineName.String()); }