Provides APIs for listening for mouse events. The
IMouseInputService interface allows you to respond to
right-click events. This API is for use when the Cius is docked into the media station.
Example Code
For a more in depth look at these methods please refer to the RightClickSample Application included in the add-on.
The example code below will show you how to listen for the mouse events.
First, you must bind to the
IMouseInputService
public boolean init() {
boolean ret = true;
mConn = new MouseServiceConnection();
ret = bindService(new Intent(IMouseInputService.class.getName()),
mConn, Context.BIND_AUTO_CREATE);
if (ret == false) {
Log.e(LOG_TAG, "initService() bound with " + ret);
return ret;
}
if (ret == false) {
Log.e(LOG_TAG, "initService() bound with " + ret);
return ret;
}
return ret;
}
Next, you need to add the code to register the right mouse button listener.
private class MouseServiceConnection implements ServiceConnection {
private IMouseInputService myMouseService;
public void onServiceConnected(ComponentName name, IBinder boundService) {
Log.d(LOG_TAG, "onServiceConnected() connected");
myMouseService = IMouseInputService.Stub.asInterface((IBinder) boundService);
try {
myMouseService.registerMouseRightButtonListener(new IMouseInputListener.Stub() {
public void OnMouseEvent(MotionEvent mouseEvent) throws RemoteException {
if(mouseEvent.getAction() == 1) {
Message msg = new Message();
msg.arg1 = 2;
mHandler.sendMessage(msg);
}
}
});
} catch (RemoteException e) {
e.printStackTrace();
}
}
public void onServiceDisconnected(ComponentName name) {
Log.d(LOG_TAG, "onServiceDisconnected() disconnected");
}
};
Interfaces
Classes