本文整理汇总了C++中IDirectFB::EnumInputDevices方法的典型用法代码示例。如果您正苦于以下问题:C++ IDirectFB::EnumInputDevices方法的具体用法?C++ IDirectFB::EnumInputDevices怎么用?C++ IDirectFB::EnumInputDevices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDirectFB
的用法示例。
在下文中一共展示了IDirectFB::EnumInputDevices方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: open
static void *input_thread(void *data)
{
int uinput;
int i;
struct input_event u;
struct uinput_user_dev ud;
FILE *f;
DFBResult err;
IDirectFB *dfb = (IDirectFB *)data;
fprintf(stderr, "DFB input converter thread starting...\n");
/* modprobe does not complain if the module is already loaded... */
system("/sbin/modprobe uinput");
system("/sbin/modprobe evdev");
uinput = open("/dev/misc/uinput", O_WRONLY|O_NDELAY);
if (uinput < 0)
{
fprintf(stderr, "DFB input thread: unable to open /dev/misc/uinput (%m)\n");
return NULL;
}
memset(&u, 0, sizeof(u));
fcntl(uinput, F_SETFD, FD_CLOEXEC);
/* configure the device */
memset(&ud, 0, sizeof(ud));
strncpy(ud.name, "Neutrino TD to Input Device converter", UINPUT_MAX_NAME_SIZE);
ud.id.version = 0x42;
ud.id.vendor = 0x1234;
ud.id.product = 0x5678;
ud.id.bustype = BUS_I2C; /* ?? */
write(uinput, &ud, sizeof(ud));
ioctl(uinput, UI_SET_EVBIT, EV_KEY);
ioctl(uinput, UI_SET_EVBIT, EV_REP);
/* register keys */
for (i = 0; key_list[i] != -1; i++)
ioctl(uinput, UI_SET_KEYBIT, key_list[i]);
if (ioctl(uinput, UI_DEV_CREATE))
{
perror("DFB input thread UI_DEV_CREATE");
close(uinput);
return NULL;
}
/* this is ugly: parse the new input device from /proc/...devices
* and symlink it to /dev/input/nevis_ir... */
#define DEVLINE "I: Bus=0018 Vendor=1234 Product=5678 Version=0042"
f = fopen("/proc/bus/input/devices", "r");
if (f)
{
int found = 0;
int evdev = -1;
size_t n = 0;
char *line = NULL;
char *p;
char newdev[20];
while (getline(&line, &n, f) != -1)
{
switch(line[0])
{
case 'I':
if (strncmp(line, DEVLINE, strlen(DEVLINE)) == 0)
found = 1;
break;
case 'H':
if (! found)
break;
p = strstr(line, " event");
if (! p)
{
evdev = -1;
break;
}
evdev = atoi(p + 6);
sprintf(newdev, "event%d", evdev);
fprintf(stderr, "DFB input thread: symlink /dev/input/nevis_ir to %s\n", newdev);
unlink("/dev/input/nevis_ir");
symlink(newdev, "/dev/input/nevis_ir");
break;
default:
break;
}
if (evdev != -1)
break;
}
fclose(f);
free(line);
}
u.type = EV_KEY;
u.value = 0; /* initialize: first event wil be a key press */
dfb->EnumInputDevices(dfb, enum_input_device, &inputs);
DFBCHECK(dfb->CreateInputEventBuffer(dfb, DICAPS_ALL, DFB_FALSE, &events));
thread_running = 1;
while (thread_running)
{
//.........这里部分代码省略.........