Loading services/inputflinger/reader/EventHub.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -2473,6 +2473,7 @@ void EventHub::openDeviceLocked(const std::string& devicePath) { // See if this device has any stylus buttons that we would want to fuse with touch data. if (!device->classes.any(InputDeviceClass::TOUCH | InputDeviceClass::TOUCH_MT) && !device->classes.any(InputDeviceClass::ALPHAKEY) && std::any_of(STYLUS_BUTTON_KEYCODES.begin(), STYLUS_BUTTON_KEYCODES.end(), [&](int32_t keycode) { return device->hasKeycodeLocked(keycode); })) { device->classes |= InputDeviceClass::EXTERNAL_STYLUS; Loading services/inputflinger/tests/InputReader_test.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -1490,6 +1490,24 @@ TEST_F(InputReaderIntegrationTest, ExternalStylusesButtons) { AllOf(UP, WithKeyCode(AKEYCODE_STYLUS_BUTTON_TERTIARY)))); } TEST_F(InputReaderIntegrationTest, KeyboardWithStylusButtons) { std::unique_ptr<UinputKeyboard> keyboard = createUinputDevice<UinputKeyboard>("KeyboardWithStylusButtons", /*productId=*/99, std::initializer_list<int>{KEY_Q, KEY_W, KEY_E, KEY_R, KEY_T, KEY_Y, BTN_STYLUS, BTN_STYLUS2, BTN_STYLUS3}); ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertInputDevicesChanged()); const auto device = findDeviceByName(keyboard->getName()); ASSERT_TRUE(device.has_value()); // An alphabetical keyboard that reports stylus buttons should not be recognized as a stylus. ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, device->getSources()) << "Unexpected source " << inputEventSourceToString(device->getSources()).c_str(); ASSERT_EQ(AINPUT_KEYBOARD_TYPE_ALPHABETIC, device->getKeyboardType()); } /** * The Steam controller sends BTN_GEAR_DOWN and BTN_GEAR_UP for the two "paddle" buttons * on the back. In this test, we make sure that BTN_GEAR_DOWN / BTN_WHEEL and BTN_GEAR_UP Loading Loading
services/inputflinger/reader/EventHub.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -2473,6 +2473,7 @@ void EventHub::openDeviceLocked(const std::string& devicePath) { // See if this device has any stylus buttons that we would want to fuse with touch data. if (!device->classes.any(InputDeviceClass::TOUCH | InputDeviceClass::TOUCH_MT) && !device->classes.any(InputDeviceClass::ALPHAKEY) && std::any_of(STYLUS_BUTTON_KEYCODES.begin(), STYLUS_BUTTON_KEYCODES.end(), [&](int32_t keycode) { return device->hasKeycodeLocked(keycode); })) { device->classes |= InputDeviceClass::EXTERNAL_STYLUS; Loading
services/inputflinger/tests/InputReader_test.cpp +18 −0 Original line number Diff line number Diff line Loading @@ -1490,6 +1490,24 @@ TEST_F(InputReaderIntegrationTest, ExternalStylusesButtons) { AllOf(UP, WithKeyCode(AKEYCODE_STYLUS_BUTTON_TERTIARY)))); } TEST_F(InputReaderIntegrationTest, KeyboardWithStylusButtons) { std::unique_ptr<UinputKeyboard> keyboard = createUinputDevice<UinputKeyboard>("KeyboardWithStylusButtons", /*productId=*/99, std::initializer_list<int>{KEY_Q, KEY_W, KEY_E, KEY_R, KEY_T, KEY_Y, BTN_STYLUS, BTN_STYLUS2, BTN_STYLUS3}); ASSERT_NO_FATAL_FAILURE(mFakePolicy->assertInputDevicesChanged()); const auto device = findDeviceByName(keyboard->getName()); ASSERT_TRUE(device.has_value()); // An alphabetical keyboard that reports stylus buttons should not be recognized as a stylus. ASSERT_EQ(AINPUT_SOURCE_KEYBOARD, device->getSources()) << "Unexpected source " << inputEventSourceToString(device->getSources()).c_str(); ASSERT_EQ(AINPUT_KEYBOARD_TYPE_ALPHABETIC, device->getKeyboardType()); } /** * The Steam controller sends BTN_GEAR_DOWN and BTN_GEAR_UP for the two "paddle" buttons * on the back. In this test, we make sure that BTN_GEAR_DOWN / BTN_WHEEL and BTN_GEAR_UP Loading