Skip to content

Commit

Permalink
Enable BUTTON_FORWARD and BUTTON_BACK mouse buttons on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
m4gr3d committed Aug 13, 2024
1 parent a7a124a commit 90959ca
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions platform/android/android_input_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ void AndroidInputHandler::process_mouse_event(int p_event_action, int p_event_an
case AMOTION_EVENT_ACTION_HOVER_MOVE: // hover move
case AMOTION_EVENT_ACTION_HOVER_ENTER: // hover enter
case AMOTION_EVENT_ACTION_HOVER_EXIT: { // hover exit
// Release any remaining touches or mouse event
_release_mouse_event_info();
_release_all_touch();

// https://developer.android.com/reference/android/view/MotionEvent.html#ACTION_HOVER_ENTER
Ref<InputEventMouseMotion> ev;
ev.instantiate();
Expand All @@ -314,6 +318,14 @@ void AndroidInputHandler::process_mouse_event(int p_event_action, int p_event_an
ev->set_relative_screen_position(ev->get_relative());
Input::get_singleton()->parse_input_event(ev);
hover_prev_pos = p_event_pos;

if (_button_index_from_mask(event_buttons_mask) != MouseButton::NONE) {
// Some mouse buttons are dispatched through the hover events
// e.g: AMOTION_EVENT_BUTTON_BACK, AMOTION_EVENT_BUTTON_FORWARD
mouse_event_info.valid = true;
mouse_event_info.pos = p_event_pos;
_parse_mouse_event_info(event_buttons_mask, true, false, p_double_click, p_source_mouse_relative);
}
} break;

case AMOTION_EVENT_ACTION_DOWN:
Expand Down

0 comments on commit 90959ca

Please sign in to comment.