Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib Update for uhidev(4) changes.
details: https://anonhg.NetBSD.org/src/rev/13a093b75fb9
branches: trunk
changeset: 519840:13a093b75fb9
user: augustss <augustss%NetBSD.org@localhost>
date: Fri Dec 28 17:45:25 2001 +0000
description:
Update for uhidev(4) changes.
Also rename libusb to libusbhid (which is a much better name).
diffstat:
lib/libusb/Makefile | 26 -
lib/libusb/data.c | 97 ---
lib/libusb/descr.c | 77 ---
lib/libusb/parse.c | 406 ---------------
lib/libusb/shlib_version | 5 -
lib/libusb/usage.c | 237 ---------
lib/libusb/usb.3 | 214 --------
lib/libusb/usb.h | 96 ---
lib/libusb/usb_hid_usages | 1078 ------------------------------------------
lib/libusb/usbvar.h | 33 -
lib/libusbhid/Makefile | 27 +
lib/libusbhid/data.c | 97 +++
lib/libusbhid/descr.c | 77 +++
lib/libusbhid/parse.c | 461 +++++++++++++++++
lib/libusbhid/shlib_version | 5 +
lib/libusbhid/usage.c | 237 +++++++++
lib/libusbhid/usb_hid_usages | 1078 ++++++++++++++++++++++++++++++++++++++++++
lib/libusbhid/usbhid.3 | 215 ++++++++
lib/libusbhid/usbhid.h | 100 +++
lib/libusbhid/usbvar.h | 33 +
20 files changed, 2330 insertions(+), 2269 deletions(-)
diffs (truncated from 4679 to 300 lines):
diff -r bfd88c576822 -r 13a093b75fb9 lib/libusb/Makefile
--- a/lib/libusb/Makefile Fri Dec 28 17:39:19 2001 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-# $NetBSD: Makefile,v 1.5 1999/07/23 09:44:38 mrg Exp $
-
-LIB= usb
-MAN= usb.3
-
-MLINKS= usb.3 libusb.3 usb.3 hid_get_report_desc.3 \
- usb.3 hid_dispose_report_desc.3 \
- usb.3 hid_start_parse.3 usb.3 hid_end_parse.3 \
- usb.3 hid_get_item.3 usb.3 hid_report_size.3 usb.3 hid_locate.3 \
- usb.3 hid_usage_page.3 usb.3 hid_usage_in_page.3 usb.3 hid_init.3 \
- usb.3 hid_get_data.3 usb.3 hid_set_data.3
-
-SRCS= descr.c parse.c usage.c data.c
-
-INCS= usb.h
-INCSDIR=/usr/include
-
-.include <bsd.own.mk>
-
-.if ${MKSHARE} != "no"
-FILES= usb_hid_usages
-FILESDIR=/usr/share/misc
-.endif
-
-.include <bsd.lib.mk>
-
diff -r bfd88c576822 -r 13a093b75fb9 lib/libusb/data.c
--- a/lib/libusb/data.c Fri Dec 28 17:39:19 2001 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-/* $NetBSD: data.c,v 1.8 2000/04/02 11:10:53 augustss Exp $ */
-
-/*
- * Copyright (c) 1999 Lennart Augustsson <augustss%netbsd.org@localhost>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <assert.h>
-#include <stdlib.h>
-#include "usb.h"
-
-int
-hid_get_data(const void *p, const hid_item_t *h)
-{
- const unsigned char *buf;
- unsigned int hpos;
- unsigned int hsize;
- int data;
- int i, end, offs;
-
- _DIAGASSERT(p != NULL);
- _DIAGASSERT(h != NULL);
-
- buf = p;
- hpos = h->pos; /* bit position of data */
- hsize = h->report_size; /* bit length of data */
-
- if (hsize == 0)
- return (0);
- offs = hpos / 8;
- end = (hpos + hsize) / 8 - offs;
- data = 0;
- for (i = 0; i <= end; i++)
- data |= buf[offs + i] << (i*8);
- data >>= hpos % 8;
- data &= (1 << hsize) - 1;
- if (h->logical_minimum < 0) {
- /* Need to sign extend */
- hsize = sizeof data * 8 - hsize;
- data = (data << hsize) >> hsize;
- }
- return (data);
-}
-
-void
-hid_set_data(void *p, const hid_item_t *h, int data)
-{
- unsigned char *buf;
- unsigned int hpos;
- unsigned int hsize;
- int i, end, offs, mask;
-
- _DIAGASSERT(p != NULL);
- _DIAGASSERT(h != NULL);
-
- buf = p;
- hpos = h->pos; /* bit position of data */
- hsize = h->report_size; /* bit length of data */
-
- if (hsize != 32) {
- mask = (1 << hsize) - 1;
- data &= mask;
- } else
- mask = ~0;
-
- data <<= (hpos % 8);
- mask <<= (hpos % 8);
- mask = ~mask;
-
- offs = hpos / 8;
- end = (hpos + hsize) / 8 - offs;
-
- for (i = 0; i <= end; i++)
- buf[offs + i] = (buf[offs + i] & (mask >> (i*8))) |
- ((data >> (i*8)) & 0xff);
-}
diff -r bfd88c576822 -r 13a093b75fb9 lib/libusb/descr.c
--- a/lib/libusb/descr.c Fri Dec 28 17:39:19 2001 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/* $NetBSD: descr.c,v 1.9 2000/09/24 02:13:24 augustss Exp $ */
-
-/*
- * Copyright (c) 1999 Lennart Augustsson <augustss%netbsd.org@localhost>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-
-#include <assert.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
-
-#include <dev/usb/usb.h>
-
-#include "usb.h"
-#include "usbvar.h"
-
-report_desc_t
-hid_get_report_desc(int fd)
-{
- struct usb_ctl_report_desc rep;
-
- _DIAGASSERT(fd != -1);
-
- rep.size = 0;
- if (ioctl(fd, USB_GET_REPORT_DESC, &rep) < 0)
- return (NULL);
-
- return hid_use_report_desc(rep.data, (unsigned int)rep.size);
-}
-
-report_desc_t
-hid_use_report_desc(unsigned char *data, unsigned int size)
-{
- report_desc_t r;
-
- r = malloc(sizeof(*r) + size);
- if (r == 0) {
- errno = ENOMEM;
- return (NULL);
- }
- r->size = size;
- memcpy(r->data, data, size);
- return (r);
-}
-
-void
-hid_dispose_report_desc(report_desc_t r)
-{
-
- free(r);
-}
diff -r bfd88c576822 -r 13a093b75fb9 lib/libusb/parse.c
--- a/lib/libusb/parse.c Fri Dec 28 17:39:19 2001 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,406 +0,0 @@
-/* $NetBSD: parse.c,v 1.11 2000/09/24 02:19:54 augustss Exp $ */
-
-/*
- * Copyright (c) 1999 Lennart Augustsson <augustss%netbsd.org@localhost>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/time.h>
-
-#include <dev/usb/usb.h>
-#include <dev/usb/usbhid.h>
-
-#include "usb.h"
-#include "usbvar.h"
-
-#define MAXUSAGE 100
-struct hid_data {
- u_char *start;
- u_char *end;
- u_char *p;
- hid_item_t cur;
- unsigned int usages[MAXUSAGE];
- int nusage;
- int minset;
- int multi;
- int multimax;
- int kindset;
-
- /* Absolute data position (bits) for input/output/feature.
- Assumes that hid_input, hid_output and hid_feature have
- values 0, 1 and 2. */
- unsigned int kindpos[3];
-};
-
-static int min(int x, int y) { return x < y ? x : y; }
-
-static void
-hid_clear_local(hid_item_t *c)
-{
-
- _DIAGASSERT(c != NULL);
-
- c->usage = 0;
- c->usage_minimum = 0;
- c->usage_maximum = 0;
- c->designator_index = 0;
- c->designator_minimum = 0;
- c->designator_maximum = 0;
- c->string_index = 0;
- c->string_minimum = 0;
- c->string_maximum = 0;
- c->set_delimiter = 0;
-}
-
-hid_data_t
-hid_start_parse(report_desc_t d, int kindset)
-{
- struct hid_data *s;
-
- _DIAGASSERT(d != NULL);
Home |
Main Index |
Thread Index |
Old Index