Android bt hid(bluedroid)和linux HID-subsystem



Android采用bluedroid后,stack运行在用户空间,那bthid如何与linux HID-subsystem联系呢?

答案就是UHID


UHID - User-space I/O driver support forHID subsystem

详情参考:

\kernel\Documentation\hid\uhid.txt

 

Bluedroid

\android\external\bluetooth\bluedroid\btif\co\bta_hh_co.c

 

Open uhid

const char *dev_path ="/dev/uhid";

p_dev->fd = open(dev_path, O_RDWR |O_CLOEXEC);

 

create hid dev

   ev.type = UHID_CREATE;

    result =uhid_write(p_dev->fd, &ev);

 

hid_report

   ev.type = UHID_INPUT;

    returnuhid_write(fd, &ev);

 

destroy hid dev

    ev.type = UHID_DESTROY;

   uhid_write(fd, &ev);

 

close uhid

    close(fd);

你可能感兴趣的:(android,linux)