From a7b82e1d297a3a5aa1150ac9556361856e681351 Mon Sep 17 00:00:00 2001 From: "Nathaniel R. Lewis" Date: Wed, 12 Feb 2020 15:40:45 -0800 Subject: Support multiple EventHub devices per InputDevice Some physical devices contain more functions than can be addressed by a single Linux evdev device. Examples of such devices are the Sony DualShock 4 and Wacom Tablets, which appear as multiple evdev devices sharing the same value for the EVIOCGUNIQ ioctl. As more instances of such devices hit the market, apps need a way of figuring out which InputDevices are part of the same physical device. Per conversation with the android input team, a solution proposed to this problem is to merge multiple EventHub devices (which have a 1:1 relation with evdev) into a single android InputDevice. Changes: Decouple the EventHub device id ("eventHubId") from the InputDevice device id ("deviceId"). This requires InputDeviceContext to track the the EventHub devices it represents. Most logic changes are inside InputDeviceContext, so there are minimal changes to InputMappers. Added enum value END_RESERVED_ID to represent the first available id that can be assigned to a normal InputDevice. The android framework assumes specific values for the virtual keyboard and built-in hardware keyboard, so for these two cases, the "deviceId" must match the "eventHubId." Added "EVENTHUB_ID" constants to tests and changed where applicable. Cherry-picked from pa/1475694. Bug: 38511270 Test: atest inputflinger_tests libinput_tests Change-Id: I89df085fadc1c09bc999599ac5db35c9277c4a2a --- include/input/InputDevice.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/input/InputDevice.h') diff --git a/include/input/InputDevice.h b/include/input/InputDevice.h index b6efc82fd4..20a17e3347 100644 --- a/include/input/InputDevice.h +++ b/include/input/InputDevice.h @@ -180,6 +180,8 @@ enum ReservedInputDeviceId : int32_t { VIRTUAL_KEYBOARD_ID = -1, // Device id of the "built-in" keyboard if there is one. BUILT_IN_KEYBOARD_ID = 0, + // First device id available for dynamic devices + END_RESERVED_ID = 1, }; } // namespace android -- cgit v1.2.3-59-g8ed1b