マウスをサポートする Android デバイスの場合、左右のボタンの両方でスペースをドラッグしたり、システム ジェスチャに応答したりできます。現在の要件は、マウスの右ボタンのスライド イベントをブロックし、マウスの左ボタンのスライドにのみ応答することです。
この問題を解決するには、次の定数を知っておく必要があります。
AMOTION_EVENT_BUTTON_PRIMARY を左クリック
AMOTION_EVENT_BUTTON_SECONDARYを右クリック
AMOTION_EVENT_BUTTON_TERTIARY 補助ボタン
具体的な変更点は以下の通りです。
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;
右クリック移動イベントをブロックします。