MTK Android12 修改鼠标右键为返回键

MTK Android12 修改鼠标右键为返回键

需求

复制代码
项目中未添加TP功能,需要用鼠标进行操作,将鼠标右键赋予返回功能。

解决

复制代码
路径:frameworks/native/services/inputflinger/reader/mapper/accumulator/CursorButtonAccumulator.cpp
xml 复制代码
diff --git a/frameworks/native/services/inputflinger/reader/mapper/accumulator/CursorButtonAccumulator.cpp b/frameworks/native/services/inputflinger/reader/mapper/accumulator/CursorButtonAccumulator.cpp
index 2d7d73b..d6fdce5 100644 (file)
--- a/frameworks/native/services/inputflinger/reader/mapper/accumulator/CursorButtonAccumulator.cpp
+++ b/frameworks/native/services/inputflinger/reader/mapper/accumulator/CursorButtonAccumulator.cpp
@@ -84,7 +84,8 @@ uint32_t CursorButtonAccumulator::getButtonState() const {
         result |= AMOTION_EVENT_BUTTON_PRIMARY;
     }
     if (mBtnRight) {
-        result |= AMOTION_EVENT_BUTTON_SECONDARY;
+        //result |= AMOTION_EVENT_BUTTON_SECONDARY;
+               result |= AMOTION_EVENT_BUTTON_BACK;
     }
     if (mBtnMiddle) {
         result |= AMOTION_EVENT_BUTTON_TERTIARY;
相关推荐
爱吃水蜜桃的奥特曼9 分钟前
玩Android Harmony next版,通过项目了解harmony项目快速搭建开发
android·harmonyos
shaominjin12314 分钟前
Android 中 RecyclerView 与 ListView 的深度对比:从设计到实践
android
vocal30 分钟前
【我的AOSP第一课】AOSP 下载、编译与运行
android
Lei活在当下1 小时前
【业务场景架构实战】8. 订单状态流转在 UI 端的呈现设计
android·设计模式·架构
小趴菜82271 小时前
Android中加载unity aar包实现方案
android·unity·游戏引擎
qq_252924191 小时前
PHP 8.0+ 现代Web开发实战指南 引
android·前端·php
Jeled1 小时前
Android 本地存储方案深度解析:SharedPreferences、DataStore、MMKV 全面对比
android·前端·缓存·kotlin·android studio·android jetpack
2501_915918418 小时前
掌握 iOS 26 App 运行状况,多工具协作下的监控策略
android·ios·小程序·https·uni-app·iphone·webview
2501_9159090611 小时前
iOS 混淆实战,多工具组合完成 IPA 混淆与加固(源码 + 成品 + 运维一体化方案)
android·运维·ios·小程序·uni-app·iphone·webview