2013-10-04 48 views
0

大家下午好,虛擬觸摸屏設備未報告對X或Y軸的支持?

我正在嘗試在rooted Android手機中使用uinput創建虛擬觸摸屏。

即使我能夠創建設備,

New device: id=88, fd=170, path='/dev/input/event6', name='uinput-eve', 
    classes=0x4, configuration='', keyLayout='', keyCharacterMap='', 
    builtinKeyboard=false, usingSuspendBlockIoctl=true, usingClockIoctl=false 

    Touch device 'uinput-eve' did not report support for X or Y axis! 
    The device will be inoperable. 

    Device added: id=88, name='uinput-eve', sources=0x00002002 

我不能因爲設備不能工作正確地創建它。跳過任何人都可以擺脫一些光。

這是我的許多嘗試之一,總是導致這個消息。

struct uinput_user_dev uidev; 
struct input_event ev; 
int dx, dy; 

int fd; 
fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK); 
if (fd < 0) { 
    die("error: open"); 
} 

memset(&uidev, 0, sizeof(uidev)); 
snprintf(uidev.name, UINPUT_MAX_NAME_SIZE, "uinput-eve"); 
uidev.id.bustype = BUS_VIRTUAL; 
uidev.id.vendor = 0x1; 
uidev.id.product = 0x1; 
uidev.id.version = 1; 

if (write(fd, &uidev, sizeof(uidev)) < 0) { 
    die("error: write"); 
} 
/* touch screen event */ 
    ioctl(fd, UI_SET_EVBIT, EV_ABS); 
    ioctl(fd, UI_SET_ABSBIT, ABS_X); 
    ioctl(fd, UI_SET_ABSBIT, ABS_Y); 
    ioctl(fd, UI_SET_EVBIT, EV_KEY); 
    ioctl(fd, UI_SET_KEYBIT, BTN_TOUCH); 


if (ioctl(fd, UI_DEV_CREATE,0) < 0) { 
    die("error: ioctl"); 
} 

EDIT1: 挖得更深一些,問題是,aparently mRawPointerAxes未設置,任何人 有任何想法如何設置呢?接下來的代碼來自services/input/InputReader.cpp。

// Ensure we have valid X and Y axes. 
if (!mRawPointerAxes.x.valid || !mRawPointerAxes.y.valid) { 
    LOGW(INDENT "Touch device '%s' did not report support for X or Y axis! " 
      "The device will be inoperable.", getDeviceName().string()); 
    mDeviceMode = DEVICE_MODE_DISABLED; 
    return; 
} 

預先感謝您的時間。

+0

它看起來像x/y軸是從設備資源建立的。它看起來像從這裏查看一些觸摸屏驅動程序代碼:http://lxr.free-electrons.com/source/drivers/input/touchscreen/?a=arm –

回答

1

對於絕對座標軸,您需要在結構體uinput_user_dev中定義它們的範圍。如果absmin和absmax相等,Android會拒絕一個軸不「有效」。 (參見EventHub.cpp EventHub :: getAbsoluteAxisInfo)

既然你沒有定義absmax也不absmin,他們都爲0嘗試增加:

uidev.absmax[ABS_X] = 1024; 
uidev.absmax[ABS_Y] = 1024; 

更改1024到你想要的實際分辨率。

+0

謝謝你的工作,我現在有一個不同的問題。我似乎無法將事件注入此虛擬設備。我注入觸摸,因爲我會在真正的觸摸屏上,它不會複製觸摸。有任何想法嗎? – andre

+0

您需要使用SYN_REPORT結束序列,否則不會處理任何內容。有關更多詳細信息,請參閱https://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txt。 – VincentP