From 867968530ecb8548245f895eb2a0e83b287dd0b0 Mon Sep 17 00:00:00 2001 From: Siarhei Vishniakou Date: Thu, 17 May 2018 07:28:21 -0700 Subject: [PATCH] Remap PS key to BUTTON_MODE on DS4 joystick Currently, the PS key on the DS4 joystick maps to HOME, which means that this key will not be delivered to apps. However, such apps as Remote Play require access to this key for proper operation. Map it to BUTTON_MODE here to allow the apps to handle it. Also, map the touchpad click to BUTTON_1, which is a generic gamepad button. The mapping to HOME is not specified in Android. By the Linux spec, it is more correct to generate BUTTON_MODE for this button (even though it is drawn slighly above the two sticks in the spec, and it is physically located more in-line or slightly below these). The historical reason for this mapping was the fact that the touchpad generated a click, which meant that touchpad click was more aligned with the Linux spec. In addition, on some other controllers, this button actually has a "house" drawn on it, which would make it consistent with "HOME", and it is currently mapped to HOME. On this (and several others) joystick, however, there is no such drawing, and BUTTON_MODE is appropriate. In Q, this will be addressed by changing the branded buttons on other controllers to also generate "BUTTON_MODE", and then changing the Generic fallback mapping for BUTTON_MODE to HOME. Bug: 79881694 Test: connected DS4 joystick. Made a test app that overrides dispatchKeyEvent and dumps out every event to the logcat. Then pressed every button to ensure that the keys are generated as expected. In the long run, this will be tested in the CTS test input.cts.tests.AsusGamepadTestCase. Change-Id: I33e922a2c52582f44d65f20024d7dca1f9d05a5e --- data/keyboards/Vendor_054c_Product_05c4.kl | 8 ++++++-- data/keyboards/Vendor_054c_Product_09cc.kl | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/data/keyboards/Vendor_054c_Product_05c4.kl b/data/keyboards/Vendor_054c_Product_05c4.kl index f46573376ade3..a1284a49dad62 100644 --- a/data/keyboards/Vendor_054c_Product_05c4.kl +++ b/data/keyboards/Vendor_054c_Product_05c4.kl @@ -62,6 +62,10 @@ key 0x138 BUTTON_SELECT key 0x139 BUTTON_START # PS key -key 0x13c HOME +key 0x13c BUTTON_MODE + # Touchpad press -key 0x13d BUTTON_MODE +# The touchpad for this joystick will become a separate input device in future releases +# and this button will be equivalent to left mouse button +# Therefore, map it to KEYCODE_BUTTON_1 here to allow apps to still handle this on earlier versions +key 0x13d BUTTON_1 diff --git a/data/keyboards/Vendor_054c_Product_09cc.kl b/data/keyboards/Vendor_054c_Product_09cc.kl index f46573376ade3..a1284a49dad62 100644 --- a/data/keyboards/Vendor_054c_Product_09cc.kl +++ b/data/keyboards/Vendor_054c_Product_09cc.kl @@ -62,6 +62,10 @@ key 0x138 BUTTON_SELECT key 0x139 BUTTON_START # PS key -key 0x13c HOME +key 0x13c BUTTON_MODE + # Touchpad press -key 0x13d BUTTON_MODE +# The touchpad for this joystick will become a separate input device in future releases +# and this button will be equivalent to left mouse button +# Therefore, map it to KEYCODE_BUTTON_1 here to allow apps to still handle this on earlier versions +key 0x13d BUTTON_1