So, if you have a passing familiarity with Android, this code will look just fine:

@Override public boolean onGenericMotion(View v, MotionEvent event) { if((event.getButtonState() & MotionEvent.BUTTON_PRIMARY) != 0) codeForLeftClick(); if((event.getButtonState() & MotionEvent.BUTTON_SECONDARY) != 0) codeForRightClick(); if ((event.getButtonState() & MotionEvent.BUTTON_TERTIARY) != 0) codeForMiddleClick(); //Other stuff return true; }

What it does is detect left, right and middle clicks on a mouse that’s connected to a phone or tablet via Bluetooth or a USB OTG cable.

Or at least that’s what it does on most phones and tablets. On the Galaxy Note 10.1 however it doesn’t: It works fine for right clicks (if you keep in mind that this tablet maps them to the back-button even if you indicate you consumed the event and think of filtering out any back-buttons coming from the mouse in onKeyUp(…) ) and middle clicks (with the caveat that middle clicks map to the home button and will minimize your app).

For left clicks, however nothing happens. That’s odd. Well there must be another event that is fired than. ACTION_DOWN maybe? No. Turns out there is actually no event associated with a left click that gets passed to the onGenericMotionListener. At all. (The only events you get are ACTION_HOVER_MOVE and right/middle clicks).

The only way to find out if there was a left click is to use another method (like onTouch(…)) which is inconsistent at least and annoying if you need to debug an app and don’t have any device that behaves like this (like I did this week).