title: Uinput virtual device is detected as physical keyboard on android
body: <p>I've created a simple native library in C that allows the user to create a device using uinput module. The code seems to work, but there's a problem:
  my virtual device is detected as physical keyboard and, when I need to write some text, the soft keyboard doesn't appear since android detects a real keyboard connected.</p>
  
  <p>How to set this device virtual? If i don't set the keybits it is not detected as a physical keyboard, but I need the keys enabled. </p>
  
  <pre><code>#include &lt;string.h&gt;
  #include &lt;jni.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sys/stat.h&gt;
  #include &lt;fcntl.h&gt;
  
  #include "input.h"
  #include "uinput.h"
  
  static int fd;
  static struct uinput_user_dev dev;
  
  
  jint Java_com_vektor_amapper_util_InputDeviceManager_CreateVirtualDevice(
      JNIEnv* env, jobject thiz, jstring param) {
  int aux;
  fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
  if (fd &lt; 0)
      return -1;
  if (ioctl(fd, UI_SET_EVBIT, EV_KEY)&lt;0)
          return -2;
  if (ioctl(fd, UI_SET_EVBIT, EV_REL)&lt;0)
      return -3;
  if (ioctl(fd, UI_SET_EVBIT, EV_ABS)&lt;0)
      return -4;
  if (ioctl(fd, UI_SET_EVBIT, EV_SYN)&lt;0)
      return -5;
  if (ioctl(fd, UI_SET_EVBIT, EV_REP)&lt;0)
      return -6;
  
      for(aux = KEY_1; aux &lt;= KEY_F10; aux++){
      if(ioctl(fd,UI_SET_KEYBIT,aux)!=0) return -10;
  }
  
  ioctl(fd, UI_SET_KEYBIT, BTN_MOUSE);
  ioctl(fd, UI_SET_KEYBIT, BTN_TOUCH);
      ioctl(fd, UI_SET_KEYBIT, BTN_LEFT);
  ioctl(fd, UI_SET_KEYBIT, BTN_MIDDLE);
  ioctl(fd, UI_SET_KEYBIT, BTN_RIGHT);
  ioctl(fd, UI_SET_KEYBIT, BTN_FORWARD);
  ioctl(fd, UI_SET_KEYBIT, BTN_BACK);
  
      ioctl(fd, UI_SET_RELBIT, REL_X);
  ioctl(fd, UI_SET_RELBIT, REL_Y);
  
  ioctl (fd, UI_SET_ABSBIT, ABS_X);
  ioctl (fd, UI_SET_ABSBIT, ABS_Y);
      ioctl (fd, UI_SET_ABSBIT, ABS_Z);
  
  ioctl (fd, UI_SET_ABSBIT, ABS_RX);
  ioctl (fd, UI_SET_ABSBIT, ABS_RY);
  ioctl (fd, UI_SET_ABSBIT, ABS_RZ);
  
  
      memset(&amp;dev, 0, sizeof(dev));
  const char *cparam = (*env)-&gt;GetStringUTFChars(env, param, 0);
  snprintf(dev.name, UINPUT_MAX_NAME_SIZE, cparam);
  (*env)-&gt;ReleaseStringUTFChars(env, param, cparam);
  dev.id.bustype = BUS_VIRTUAL;
  dev.id.vendor = 0x1234;
  dev.id.product = 0xFEDC;
  dev.id.version = 1;
  
      if (write(fd, &amp;dev, sizeof(dev)) &lt; 0)
      return -7;
  
  if (ioctl(fd, UI_DEV_CREATE) &lt; 0)
          return -8;
  
  return 0;
  
  }
  
  jint Java_com_vektor_amapper_util_InputDeviceManager_DestroyVirtualDevice(
      JNIEnv* env, jobject thiz) {
  if (ioctl(fd, UI_DEV_DESTROY) &lt; 0)
      return -1;
  close(fd);
  return 0;
  }
  </code></pre>