Skip to content

Commit

Permalink
HID: samples/hidraw: make it possible to select device
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
pavelmachek authored and Jiri Kosina committed Mar 15, 2015
1 parent f3dddf2 commit 04303f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions samples/hidraw/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ hostprogs-y := hid-example
always := $(hostprogs-y)

HOSTCFLAGS_hid-example.o += -I$(objtree)/usr/include

all: hid-example
6 changes: 5 additions & 1 deletion samples/hidraw/hid-example.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 04303f8

Please sign in to comment.