From df6630ae1fb3ae9e64454b7ef87df75674665d09 Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Wed, 18 May 2022 13:34:55 -0700 Subject: Require CONFIG_HID_PLAYSTATION for DualSense key layout Some olders kernels don't yet support HID_PLAYSTATION. While they are working on supporting this driver, provide this temporary solution. Before this patch, if the key layout is loaded, but there is no HID_PLAYSTATION, then the mappings on the device will be incorrect. With this patch, this key layout will not be loaded unless there is a CONFIG_HID_PLAYSTATION enabled on the device. Instead, when the main layout cannot be loaded, we make another attempt to load a fallback layout. This way, the mappings on DualSense can be correct even if the HID_PLAYSTATION module is not loaded. In this CL, the fallback layout was tested using controllerTester. Bug: 228005926 Test: tested mappings with a DualSense controller on a device that does not have CONFIG_HID_PLAYSTATION Change-Id: I7e46ae1943cd2c63b8c0b03fdf5d71adeea89f6f --- tools/validatekeymaps/Main.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tools/validatekeymaps/Main.cpp') diff --git a/tools/validatekeymaps/Main.cpp b/tools/validatekeymaps/Main.cpp index 817effd24a2d..0d7d5f949a08 100644 --- a/tools/validatekeymaps/Main.cpp +++ b/tools/validatekeymaps/Main.cpp @@ -141,6 +141,11 @@ static bool validateFile(const char* filename) { } base::Result> ret = KeyLayoutMap::load(filename); if (!ret.ok()) { + if (ret.error().message() == "Missing kernel config") { + // It means the layout is valid, but won't be loaded on this device because + // this layout requires a certain kernel config. + return true; + } error("Error %s parsing key layout file.\n\n", ret.error().message().c_str()); return false; } -- cgit v1.2.3-59-g8ed1b From 0caeab98806cc1cd5e90d37a4a5cf6299396688d Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Wed, 23 Nov 2022 12:49:29 -0800 Subject: Print the text error instead of number Currently, we just print a number, which is not helpful. Let's print an actual error message instead. Bug: 260115731 Test: m && validatekeymaps input.idc Change-Id: Iad9f4ecd0f9cd847bbc2d4a2e34a64182bced6dc --- tools/validatekeymaps/Main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools/validatekeymaps/Main.cpp') diff --git a/tools/validatekeymaps/Main.cpp b/tools/validatekeymaps/Main.cpp index 0d7d5f949a08..0fa13b81c4ea 100644 --- a/tools/validatekeymaps/Main.cpp +++ b/tools/validatekeymaps/Main.cpp @@ -167,8 +167,8 @@ static bool validateFile(const char* filename) { android::base::Result> propertyMap = PropertyMap::load(String8(filename)); if (!propertyMap.ok()) { - error("Error %d parsing input device configuration file.\n\n", - propertyMap.error().code()); + error("Error parsing input device configuration file: %s.\n\n", + propertyMap.error().message().c_str()); return false; } break; -- cgit v1.2.3-59-g8ed1b