From 04303f8ec14269b0ea2553863553bc7eaadca1f8 Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Sat, 14 Mar 2015 21:57:22 +0100 Subject: [PATCH] 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: Pavel Machek Signed-off-by: Jiri Kosina --- samples/hidraw/Makefile | 2 ++ samples/hidraw/hid-example.c | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/samples/hidraw/Makefile b/samples/hidraw/Makefile index 382eeae77bd6..a9ab96188fbe 100644 --- a/samples/hidraw/Makefile +++ b/samples/hidraw/Makefile @@ -8,3 +8,5 @@ hostprogs-y := hid-example always := $(hostprogs-y) HOSTCFLAGS_hid-example.o += -I$(objtree)/usr/include + +all: hid-example diff --git a/samples/hidraw/hid-example.c b/samples/hidraw/hid-example.c index 512a7e50bcae..92e6c1511910 100644 --- a/samples/hidraw/hid-example.c +++ b/samples/hidraw/hid-example.c @@ -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"); -- 2.34.1