Java Code Examples for android.view.InputDevice#getVendorId()

The following examples show how to use android.view.InputDevice#getVendorId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeyListener.java    From yubikit-android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
    InputDevice device = event.getDevice();
    if (device.getVendorId() != YUBICO_VID) {
        // do not handle anything that not from yubikey
        return false;
    }

    if (event.getAction() == KeyEvent.ACTION_UP) {
        // use id of keyboard device to distinguish current input device
        // in case of multiple keys inserted
        final int deviceId = event.getDeviceId();
        final StringBuilder otpBuffer = inputBuffers.get(deviceId, new StringBuilder());
        if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER || event.getKeyCode() == KeyEvent.KEYCODE_NUMPAD_ENTER) {
            // Carriage return seen. Assume this is the end of the OTP credential and notify immediately.
            listener.onOtpReceived(otpBuffer.toString());
            inputBuffers.delete(deviceId);
        } else {
            if (otpBuffer.length() == 0) {
                // in case if we never get keycode enter (which is pretty generic scenario) we set timer for 1 sec
                // upon expiration we assume that we have no more input from key
                handler.postDelayed(new InputTimerTask(deviceId), DEFAULT_KEY_DELAY_MS);
            }
            otpBuffer.append((char) event.getUnicodeChar());
            inputBuffers.put(deviceId, otpBuffer);
        }
    }
    return true;
}
 
Example 2
Source File: ControllerMappingHelper.java    From citra_android with GNU General Public License v3.0 4 votes vote down vote up
private boolean isDualShock4(InputDevice inputDevice)
{
  // Sony DualShock 4 controller
  return inputDevice.getVendorId() == 0x54c && inputDevice.getProductId() == 0x9cc;
}
 
Example 3
Source File: ControllerMappingHelper.java    From citra_android with GNU General Public License v3.0 4 votes vote down vote up
private boolean isXboxOneWireless(InputDevice inputDevice)
{
  // Microsoft Xbox One controller
  return inputDevice.getVendorId() == 0x45e && inputDevice.getProductId() == 0x2e0;
}
 
Example 4
Source File: ControllerMappingHelper.java    From citra_android with GNU General Public License v3.0 4 votes vote down vote up
private boolean isMogaPro2Hid(InputDevice inputDevice)
{
  // Moga Pro 2 HID
  return inputDevice.getVendorId() == 0x20d6 && inputDevice.getProductId() == 0x6271;
}