Add additional ways to recognize an external stylus

Recognize a keyboard device as an external stylus if it can produce any
of the stylus key codes.

Additionally, add the ability to configure an input device as an
external stylus using an IDC file. This will be necessary to classify
external styluses that report buttons as custom HID usages, since we
don't have a way to tell which HID usages a device supports from
userspace yet.

Bug: 246394583
Test: atest inputflinger_tests
Test: manual, with a Lenovo Precision Pen 3
Change-Id: Ief22aac9537cd168dd43d2a9d63bc0a65f6ba3dc
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index 9d14a86..e15d09f 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -2437,8 +2437,8 @@
     const auto device = findDeviceByName(stylus->getName());
     ASSERT_TRUE(device.has_value());
 
-    // An external stylus with buttons should be recognized as a keyboard.
-    ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, device->getSources())
+    // An external stylus with buttons should also be recognized as a keyboard.
+    ASSERT_EQ(AINPUT_SOURCE_KEYBOARD | AINPUT_SOURCE_STYLUS, device->getSources())
             << "Unexpected source " << inputEventSourceToString(device->getSources()).c_str();
     ASSERT_EQ(AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC, device->getKeyboardType());