提交 04303f8e 编写于 作者: P Pavel Machek 提交者: Jiri Kosina

HID: samples/hidraw: make it possible to select device

Makefile that can actually build the example, and allow selecting device to
work on.
Signed-off-by: NPavel Machek <pavel@ucw.cz>
Signed-off-by: NJiri Kosina <jkosina@suse.cz>
上级 f3dddf24
......@@ -8,3 +8,5 @@ hostprogs-y := hid-example
always := $(hostprogs-y)
HOSTCFLAGS_hid-example.o += -I$(objtree)/usr/include
all: hid-example
......@@ -46,10 +46,14 @@ int main(int argc, char **argv)
char buf[256];
struct hidraw_report_descriptor rpt_desc;
struct hidraw_devinfo info;
char *device = "/dev/hidraw0";
if (argc > 1)
device = argv[1];
/* Open the Device with non-blocking reads. In real life,
don't use a hard coded path; use libudev instead. */
fd = open("/dev/hidraw0", O_RDWR|O_NONBLOCK);
fd = open(device, O_RDWR|O_NONBLOCK);
if (fd < 0) {
perror("Unable to open device");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册