我已经在C语言中创建了一个简单的本机库,该库允许用户使用uinput模块创建设备.该代码似乎可以工作,但是有一个问题:
我的虚拟设备被检测为物理键盘,并且当我需要编写一些文本时,软键盘没有出现,因为android检测到已连接的真实键盘.
如何将此设备设置为虚拟?如果我未设置键位,则不会检测为物理键盘,但是我需要启用键.
#include
#include
#include
#include
#include
#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 < 0)
return -1;
if (ioctl(fd, UI_SET_EVBIT, EV_KEY)<0)
return -2;
if (ioctl(fd, UI_SET_EVBIT, EV_REL)<0)
return -3;
if (ioctl(fd, UI_SET_EVBIT, EV_ABS)<0)
return -4;
if (ioctl(fd, UI_SET_EVBIT, EV_SYN)<