Example usage for android.hardware.input InputManager getInputDevice

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

Introduction

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

Prototype

public InputDevice getInputDevice(int id) 

Source Link

Document

Gets information about the input device with the specified id.

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();/*from  w w w  .  jav a2 s . co  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);
}