Example usage for android.hardware.input InputManager getInputDeviceIds

List of usage examples for android.hardware.input InputManager getInputDeviceIds

Introduction

In this page you can find the example usage for android.hardware.input InputManager getInputDeviceIds.

Prototype

public int[] getInputDeviceIds() 

Source Link

Document

Gets the ids of all input devices in the system.

Usage

From source file:org.gearvrf.weartouchpad.WearInputService.java

@Override
public void onCreate() {
    super.onCreate();
    apiClient = new GoogleApiClient.Builder(this).addApi(Wearable.API).build();
    apiClient.connect();//  w  w  w  . ja  v  a 2 s  .  c o  m
    nodes = new HashSet<Node>();
    receiveMessenger = new Messenger(new IncomingMsgHandler());
    broadcastManager = LocalBroadcastManager.getInstance(this);
    localBinder = new LocalBinder();
    connectedToWatch = false;
    int touchScreenDeviceId = 0;
    InputManager im = (InputManager) getSystemService(Context.INPUT_SERVICE);
    for (int inputDevId : im.getInputDeviceIds()) {
        InputDevice inputDevice = im.getInputDevice(inputDevId);
        if ((inputDevice.getSources() & InputDevice.SOURCE_TOUCHSCREEN) == InputDevice.SOURCE_TOUCHSCREEN) {
            touchScreenDeviceId = inputDevId;
            break;
        }
    }
    motionEventGenerator = new MotionEventGenerator(touchScreenDeviceId);
}