Example usage for android.view InputDevice SOURCE_TOUCHPAD

List of usage examples for android.view InputDevice SOURCE_TOUCHPAD

Introduction

In this page you can find the example usage for android.view InputDevice SOURCE_TOUCHPAD.

Prototype

int SOURCE_TOUCHPAD

To view the source code for android.view InputDevice SOURCE_TOUCHPAD.

Click Source Link

Document

The input source is a touch pad or digitizer tablet that is not associated with a display (unlike #SOURCE_TOUCHSCREEN ).

Usage

From source file:Main.java

@SuppressLint("InlinedApi")
public static String getSourcesString(int sources) {
    List<String> names = new ArrayList<String>();
    addString(sources, InputDevice.SOURCE_KEYBOARD, names);
    addString(sources, InputDevice.SOURCE_DPAD, names);
    addString(sources, InputDevice.SOURCE_GAMEPAD, names);
    addString(sources, InputDevice.SOURCE_TOUCHSCREEN, names);
    addString(sources, InputDevice.SOURCE_MOUSE, names);
    addString(sources, InputDevice.SOURCE_STYLUS, names);
    addString(sources, InputDevice.SOURCE_TOUCHPAD, names);
    addString(sources, InputDevice.SOURCE_JOYSTICK, names);
    return TextUtils.join(", ", names);
}

From source file:Main.java

/**
 * Gets the name of the source performing an action.
 * //  w w w . j  a  v a 2 s .  c  o  m
 * @param source A number representing the source.
 * 
 * @return The name of the source.
 */
public static String getSourceName(int source) {
    switch (source) {
    case InputDevice.SOURCE_CLASS_BUTTON:
        return "BUTTON";
    case InputDevice.SOURCE_CLASS_POINTER:
        return "POINTER";
    case InputDevice.SOURCE_CLASS_TRACKBALL:
        return "TRACKBALL";
    case InputDevice.SOURCE_CLASS_POSITION:
        return "POSITION";
    case InputDevice.SOURCE_CLASS_JOYSTICK:
        return "JOYSTICK";
    case InputDevice.SOURCE_DPAD:
        return "dpad";
    case InputDevice.SOURCE_GAMEPAD:
        return "gamepad";
    case InputDevice.SOURCE_JOYSTICK:
        return "joystick";
    case InputDevice.SOURCE_KEYBOARD:
        return "keyboard";
    case InputDevice.SOURCE_MOUSE:
        return "mouse";
    case InputDevice.SOURCE_STYLUS:
        return "stylus";
    case InputDevice.SOURCE_TOUCHPAD:
        return "touchpad";
    case InputDevice.SOURCE_TOUCHSCREEN:
        return "touchscreen";
    case InputDevice.SOURCE_TRACKBALL:
        return "trackball";
    case InputDevice.SOURCE_UNKNOWN:
        return "unknown";
    default:
        return "source_" + source;
    }
}

From source file:org.ulteo.ovd.AndRdpActivity.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    AudioManager audioManager;/*from w ww . ja  v  a  2  s.c o m*/

    if (Config.DEBUG)
        Log.i(Config.TAG, "AndRdpActivity.dispatchKeyEvent " + event);

    // Disable keypress if it is from a mouse or touchpad.
    if (event.getDeviceId() >= 0) {
        InputDevice dev = InputDevice.getDevice(event.getDeviceId());
        if (dev.getSources() == InputDevice.SOURCE_MOUSE || dev.getSources() == InputDevice.SOURCE_TOUCHPAD)
            return true;
    }

    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_MENU:
            OnThreeFingers(null);
            return true;
        case KeyEvent.KEYCODE_BACK:
            Log.i(Config.TAG, "Back key pressed");
            askLogoutDialog();
            return true;
        case KeyEvent.KEYCODE_VOLUME_UP:
            audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
            audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE,
                    AudioManager.FLAG_SHOW_UI);
            return true;
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
            audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_LOWER,
                    AudioManager.FLAG_SHOW_UI);
            return true;
        }
    } else if (event.getAction() == KeyEvent.ACTION_UP) {
        switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_MENU:
        case KeyEvent.KEYCODE_BACK:
        case KeyEvent.KEYCODE_VOLUME_UP:
        case KeyEvent.KEYCODE_VOLUME_DOWN:
            return true;
        }
    }

    if (isLoggedIn() && rdp.dispatchKeyEvent(event))
        return true;

    return super.dispatchKeyEvent(event);
}