Android12 Framework blocks mouse left/right button sliding events

For Android devices that support a mouse, both the left and right buttons can drag space or respond to system gestures. The current requirement is to block the sliding event of the right mouse button and only respond to the sliding of the left mouse button.

To correct this problem you need to know the following constants.

AMOTION_EVENT_BUTTON_PRIMARY left click

AMOTION_EVENT_BUTTON_SECONDARY right click

AMOTION_EVENT_BUTTON_TERTIARY Auxiliary button

The specific changes are as follows:

diff --git a/services/inputflinger/reader/mapper/CursorInputMapper.cpp b/services/inputflinger/reader/mapper/CursorInputMapper.cpp
index edf4573218..7b29de98be 100644
--- a/services/inputflinger/reader/mapper/CursorInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/CursorInputMapper.cpp
@@ -417,7 +417,8 @@ void CursorInputMapper::sync(nsecs_t when, nsecs_t readTime) {
                          mSource, displayId, policyFlags, lastButtonState, currentButtonState);
 
     // Send motion event.
-    if (downChanged || moved || scrolled || buttonsChanged) {
+    if (downChanged || (moved && mCursorButtonAccumulator.getButtonState() != AMOTION_EVENT_BUTTON_SECONDARY) 
+        || scrolled || buttonsChanged) {
         int32_t metaState = getContext()->getGlobalMetaState();
         int32_t buttonState = lastButtonState;
         int32_t motionEventAction;

Block the right-click move event.

Guess you like

Origin blog.csdn.net/guanmingyuangmy/article/details/132407109