diff options
author | Pavel Machek <pavel@ucw.cz> | 2015-03-14 16:57:22 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2015-03-15 10:11:21 -0400 |
commit | 04303f8ec14269b0ea2553863553bc7eaadca1f8 (patch) | |
tree | a814df06fe760b693693071b60f8ab6205998a2d /samples | |
parent | f3dddf2432e3123ef34b470129295641f7513d26 (diff) |
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 <pavel@ucw.cz>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'samples')
-rw-r--r-- | samples/hidraw/Makefile | 2 | ||||
-rw-r--r-- | samples/hidraw/hid-example.c | 6 |
2 files changed, 7 insertions, 1 deletions
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 | |||
8 | always := $(hostprogs-y) | 8 | always := $(hostprogs-y) |
9 | 9 | ||
10 | HOSTCFLAGS_hid-example.o += -I$(objtree)/usr/include | 10 | HOSTCFLAGS_hid-example.o += -I$(objtree)/usr/include |
11 | |||
12 | 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) | |||
46 | char buf[256]; | 46 | char buf[256]; |
47 | struct hidraw_report_descriptor rpt_desc; | 47 | struct hidraw_report_descriptor rpt_desc; |
48 | struct hidraw_devinfo info; | 48 | struct hidraw_devinfo info; |
49 | char *device = "/dev/hidraw0"; | ||
50 | |||
51 | if (argc > 1) | ||
52 | device = argv[1]; | ||
49 | 53 | ||
50 | /* Open the Device with non-blocking reads. In real life, | 54 | /* Open the Device with non-blocking reads. In real life, |
51 | don't use a hard coded path; use libudev instead. */ | 55 | don't use a hard coded path; use libudev instead. */ |
52 | fd = open("/dev/hidraw0", O_RDWR|O_NONBLOCK); | 56 | fd = open(device, O_RDWR|O_NONBLOCK); |
53 | 57 | ||
54 | if (fd < 0) { | 58 | if (fd < 0) { |
55 | perror("Unable to open device"); | 59 | perror("Unable to open device"); |