Skip to content

Commit 04303f8

Browse files
pavelmachekJiri Kosina
authored and
Jiri Kosina
committed
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 <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent f3dddf2 commit 04303f8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

samples/hidraw/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ hostprogs-y := hid-example
88
always := $(hostprogs-y)
99

1010
HOSTCFLAGS_hid-example.o += -I$(objtree)/usr/include
11+
12+
all: hid-example

samples/hidraw/hid-example.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,14 @@ int main(int argc, char **argv)
4646
char buf[256];
4747
struct hidraw_report_descriptor rpt_desc;
4848
struct hidraw_devinfo info;
49+
char *device = "/dev/hidraw0";
50+
51+
if (argc > 1)
52+
device = argv[1];
4953

5054
/* Open the Device with non-blocking reads. In real life,
5155
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);
5357

5458
if (fd < 0) {
5559
perror("Unable to open device");

0 commit comments

Comments
 (0)