Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8662103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:39:16+00:00 2026-06-12T16:39:16+00:00

Well, the question is rather simple – how can i handle left/right/middle click, wheel

  • 0

Well, the question is rather simple – how can i handle left/right/middle click, wheel and (!)hover move in android 2/3/4.

I’ve been digging on this topic and found the following

  • in api 14 we can handle almost anything with fancy new MotionEvent
  • we also have Open Accessory that seems to be ok with USB mouse since api 12 (still missing bluetooth) (UPD OA backported to 2.3.4)
  • mouse actually works well on tablets with ICS and Honeycomb and cyanogen 2.3.7, but act like just single touch on every button.I wonder is there a way to intercept mouse messages.

Help me please to understand how i can handle bluetooth and usb mouse in most simple and right way in each version of android. Or say its impossible.

UPD2: seems like USB Host only in 3.1+, while USB Accessory useless for this task

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:39:17+00:00Added an answer on June 12, 2026 at 4:39 pm

    These are my findings:

    For Api Level < 9:

    • External mouse primary button is handled just as a normal finger touch. There seems to be no way to detect the mouse.
    • Secondary button is dispatched trough a KeyEvent with KeyEvent.KEYCODE_BACK. No way to distinguish between actual “Back” presses and secondary button presses.

    For Api Level 9+:

    • A new method has been added MotionEvent.getSource(). I use this one to detect if input is from mouse.
    • Secondary button is still dispatched through a KeyEvent with KeyEvent.KEYCODE_BACK. On some devices the KeyEvent.getSource() returns InputDevice.SOURCE_MOUSE, so secondary button detection works in some cases.

    For Api Level 12+:

    • OnGenericMotionListener has been added. I use this one to detect mouse moves with ACTION_HOVER_MOVE and wheel changes with ACTION_SCROLL.

    For Api Level 14+:

    • New method MotionEvent.getButtonState(). I track this one to distinguish if a primary, secondary, tertiary mouse button is pressed when the MotionEvent.getActionMasked() is ACTION_MOVE, ACTION_DOWN or ACTION_UP.

    I haven’t looked into Api Level 15/16 or the tool type, because I’m able to track all mouse events with what I described above. Would be interesting if anybody has additional information or if I’ missing out with 15/16/tooltypes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a rather simple question can anyone tell me why this is
Well looks too simple a question to be asked but i asked after going
I have a fairly simple question about natural/surrogate key usage in a well-defined context
A rather simple question really. I'm working on a project where I need to
I am just started with PHP and have a rather simple problem I can't
I'm pretty sure this is a rather simple and straightforward question for anyone that
Question is rather simple, and somewhat pointless I understand, but still... Database is on
This is probably a really newbie question (well, I'm pretty sure it is), but
Sorry this is not a very well defined question, I am thinking about an
Sorry for the non-technical title, but I think it summarizes my question well. If

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.