Deleted Added
full compact
descr.c (192992) descr.c (205728)
1/* $NetBSD: descr.c,v 1.9 2000/09/24 02:13:24 augustss Exp $ */
2
3/*
4 * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 13 unchanged lines hidden (view full) ---

22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
1/* $NetBSD: descr.c,v 1.9 2000/09/24 02:13:24 augustss Exp $ */
2
3/*
4 * Copyright (c) 1999 Lennart Augustsson <augustss@netbsd.org>
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 13 unchanged lines hidden (view full) ---

22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/lib/libusbhid/descr.c 192992 2009-05-28 20:21:01Z thompsa $");
30__FBSDID("$FreeBSD: head/lib/libusbhid/descr.c 205728 2010-03-27 08:00:16Z kaiw $");
31
32#include <sys/types.h>
33
34#include <assert.h>
35#include <errno.h>
36#include <stdlib.h>
37#include <string.h>
38#include <unistd.h>
39#include <sys/time.h>
40#include <sys/ioctl.h>
31
32#include <sys/types.h>
33
34#include <assert.h>
35#include <errno.h>
36#include <stdlib.h>
37#include <string.h>
38#include <unistd.h>
39#include <sys/time.h>
40#include <sys/ioctl.h>
41
42#include <dev/usb/usb_ioctl.h>
43
44#include "usbhid.h"
45#include "usbvar.h"
46
47int
48hid_set_immed(int fd, int enable)
49{

--- 4 unchanged lines hidden (view full) ---

54 ret = hid_set_immed_compat7(fd, enable);
55#endif
56 return (ret);
57}
58
59int
60hid_get_report_id(int fd)
61{
41#include <dev/usb/usb_ioctl.h>
42
43#include "usbhid.h"
44#include "usbvar.h"
45
46int
47hid_set_immed(int fd, int enable)
48{

--- 4 unchanged lines hidden (view full) ---

53 ret = hid_set_immed_compat7(fd, enable);
54#endif
55 return (ret);
56}
57
58int
59hid_get_report_id(int fd)
60{
61 report_desc_t rep;
62 hid_data_t d;
63 hid_item_t h;
64 int kindset;
62 int temp = -1;
63 int ret;
64
65 int temp = -1;
66 int ret;
67
68 if ((rep = hid_get_report_desc(fd)) == NULL)
69 goto use_ioctl;
70 kindset = 1 << hid_input | 1 << hid_output | 1 << hid_feature;
71 for (d = hid_start_parse(rep, kindset, 0); hid_get_item(d, &h); ) {
72 /* Return the first report ID we met. */
73 if (h.report_ID != 0) {
74 temp = h.report_ID;
75 break;
76 }
77 }
78 hid_end_parse(d);
79 hid_dispose_report_desc(rep);
80
81 if (temp > 0)
82 return (temp);
83
84use_ioctl:
65 ret = ioctl(fd, USB_GET_REPORT_ID, &temp);
66#ifdef HID_COMPAT7
67 if (ret < 0)
68 ret = hid_get_report_id_compat7(fd);
69 else
70#endif
71 ret = temp;
72

--- 77 unchanged lines hidden ---
85 ret = ioctl(fd, USB_GET_REPORT_ID, &temp);
86#ifdef HID_COMPAT7
87 if (ret < 0)
88 ret = hid_get_report_id_compat7(fd);
89 else
90#endif
91 ret = temp;
92

--- 77 unchanged lines hidden ---