summaryrefslogtreecommitdiffstats
path: root/samples/hidraw/hid-example.c
diff options
context:
space:
mode:
authorPavel Machek <pavel@ucw.cz>2015-03-14 21:57:22 +0100
committerJiri Kosina <jkosina@suse.cz>2015-03-15 15:11:21 +0100
commit04303f8ec14269b0ea2553863553bc7eaadca1f8 (patch)
treea814df06fe760b693693071b60f8ab6205998a2d /samples/hidraw/hid-example.c
parentHID: map telephony usage page (diff)
downloadlinux-04303f8ec14269b0ea2553863553bc7eaadca1f8.tar.xz
linux-04303f8ec14269b0ea2553863553bc7eaadca1f8.zip
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/hidraw/hid-example.c')
-rw-r--r--samples/hidraw/hid-example.c6
1 files changed, 5 insertions, 1 deletions
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");