Mouse: Add support to swap mouse primary button

Bug: 359349392
Bug: 352598211
Test: atest CursorInputMapperUnitTest

Flag: com.android.hardware.input.mouse_swap_primary_button

Change-Id: I37d70bc0ce37fc0832e6733a0a1c8936cab36ab1
diff --git a/services/inputflinger/include/InputReaderBase.h b/services/inputflinger/include/InputReaderBase.h
index 69ae587..756a29b 100644
--- a/services/inputflinger/include/InputReaderBase.h
+++ b/services/inputflinger/include/InputReaderBase.h
@@ -96,7 +96,8 @@
         // The key remapping has changed.
         KEY_REMAPPING = 1u << 14,
 
-        // The mouse settings changed, this includes mouse reverse vertical scrolling.
+        // The mouse settings changed, this includes mouse reverse vertical scrolling and swap
+        // primary button.
         MOUSE_SETTINGS = 1u << 15,
 
         // All devices must be reopened.
@@ -259,6 +260,11 @@
     // wheel downwards scrolls the content upwards.
     bool mouseReverseVerticalScrollingEnabled;
 
+    // True if the connected mouse should have its primary button (default: left click) swapped,
+    // so that the right click will be the primary action button and the left click will be the
+    // secondary action.
+    bool mouseSwapPrimaryButtonEnabled;
+
     InputReaderConfiguration()
           : virtualKeyQuietTime(0),
             defaultPointerDisplayId(ui::LogicalDisplayId::DEFAULT),
@@ -290,7 +296,8 @@
             touchpadRightClickZoneEnabled(false),
             stylusButtonMotionEventsEnabled(true),
             stylusPointerIconEnabled(false),
-            mouseReverseVerticalScrollingEnabled(false) {}
+            mouseReverseVerticalScrollingEnabled(false),
+            mouseSwapPrimaryButtonEnabled(false) {}
 
     std::optional<DisplayViewport> getDisplayViewportByType(ViewportType type) const;
     std::optional<DisplayViewport> getDisplayViewportByUniqueId(const std::string& uniqueDisplayId)