> 文章列表 > RK3568 11 鼠标右键Menu功能

RK3568 11 鼠标右键Menu功能

RK3568 11 鼠标右键Menu功能

  • 定义menu
    frameworks/native/include/android/input.h/*** Constants that identify buttons that are associated with motion events.* Refer to the documentation on the MotionEvent class for descriptions of each button.*/
    enum {/** primary */AMOTION_EVENT_BUTTON_PRIMARY = 1 << 0,/** secondary */AMOTION_EVENT_BUTTON_SECONDARY = 1 << 1,/** tertiary */AMOTION_EVENT_BUTTON_TERTIARY = 1 << 2,/** back */AMOTION_EVENT_BUTTON_BACK = 1 << 3,/** forward */AMOTION_EVENT_BUTTON_FORWARD = 1 << 4,AMOTION_EVENT_BUTTON_STYLUS_PRIMARY = 1 << 5,AMOTION_EVENT_BUTTON_STYLUS_SECONDARY = 1 << 6,AMTION_EVENT_BUTTON_MENU = 1 << 7,    //menu by qhj ++
    };
    frameworks/native/services/inputflinger/reader/mapper/TouchCursorInputMapperCommon.hstatic void synthesizeButtonKeys(InputReaderContext* context, int32_t action, nsecs_t when,int32_t deviceId, uint32_t source, int32_t displayId,uint32_t policyFlags, int32_t lastButtonState,int32_t currentButtonState) {synthesizeButtonKey(context, action, when, deviceId, source, displayId, policyFlags,lastButtonState, currentButtonState, AMOTION_EVENT_BUTTON_BACK,AKEYCODE_BACK);synthesizeButtonKey(context, action, when, deviceId, source, displayId, policyFlags,lastButtonState, currentButtonState, AMOTION_EVENT_BUTTON_FORWARD,AKEYCODE_FORWARD);synthesizeButtonKey(context, action, when, deviceId, source, displayId, policyFlags,lastButtonState, currentButtonState, AMTION_EVENT_BUTTON_MENU, AKEYCODE_MENU);//menu ++ by qhj}
  • 实现鼠标右键 menu
    framework/native/services/inputflinger/reader/mapper/accumulator/CursorButtonAccumulator.cppuint32_t CursorButtonAccumulator::getButtonState() const {uint32_t result = 0;if (mBtnLeft) {result |= AMOTION_EVENT_BUTTON_PRIMARY;}if (mBtnOk) {char mKeyMouseState[PROPERTY_VALUE_MAX] = {0};property_get("sys.KeyMouse.mKeyMouseState", mKeyMouseState, "off");if (strcmp(mKeyMouseState, "on") == 0) {result |= AMOTION_EVENT_BUTTON_PRIMARY;}}if (mBtnRight) {char targetProduct[PROPERTY_VALUE_MAX] = {0};property_get("ro.target.product", targetProduct, "");if (strcmp(targetProduct, "box") == 0 || strcmp(targetProduct, "atv") == 0) {result |= AMTION_EVENT_BUTTON_MENU; // menu by qhj ++} else {//result |= AMOTION_EVENT_BUTTON_SECONDARY;result |= AMTION_EVENT_BUTTON_MENU; / menu by qhj ++}}if (mBtnMiddle) {result |= AMOTION_EVENT_BUTTON_TERTIARY;}if (mBtnBack || mBtnSide) {result |= AMOTION_EVENT_BUTTON_BACK;}if (mBtnForward || mBtnExtra) {result |= AMOTION_EVENT_BUTTON_FORWARD;}return result;
    }