From b6294d4f93e1a86088556e074b94f3519a2d643f Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 28 Apr 2016 14:51:39 +1000 Subject: [PATCH] Add a new header for PID/VIDs that we need to care about Beats having the same #define in multiple places Signed-off-by: Peter Hutterer --- src/Makefile.am | 6 ++++-- src/driver-hidpp10.c | 3 +-- src/liblur.c | 6 +++--- src/usb-ids.h | 29 +++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 src/usb-ids.h diff --git a/src/Makefile.am b/src/Makefile.am index 56640e2a..8ad3b162 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -19,7 +19,8 @@ libratbag_la_SOURCES = \ libratbag-hidraw.h \ libratbag-private.h \ libratbag-test.c \ - libratbag-test.h + libratbag-test.h \ + usb-ids.h libratbag_la_LIBADD = \ libhidpp.la \ @@ -66,7 +67,8 @@ libhidpp_la_SOURCES = \ hidpp10.h \ hidpp10.c \ hidpp20.h \ - hidpp20.c + hidpp20.c \ + usb-ids.h libhidpp_la_LDFLAGS = -lm libutil_la_SOURCES = \ libratbag-util.c \ diff --git a/src/driver-hidpp10.c b/src/driver-hidpp10.c index 71e74590..73202eef 100644 --- a/src/driver-hidpp10.c +++ b/src/driver-hidpp10.c @@ -35,8 +35,6 @@ #include "config.h" -#define USB_VENDOR_ID_LOGITECH 0x046d - #include #include #include @@ -45,6 +43,7 @@ #include #include "hidpp10.h" +#include "usb-ids.h" #include "libratbag-private.h" #include "libratbag-hidraw.h" diff --git a/src/liblur.c b/src/liblur.c index e2149ce8..1bb5cb54 100644 --- a/src/liblur.c +++ b/src/liblur.c @@ -30,13 +30,13 @@ #include #include +#include "usb-ids.h" #include "hidpp10.h" #include "libratbag-util.h" #include "liblur.h" #define _EXPORT_ __attribute__ ((visibility("default"))) #define MAX_DEVICES 6 -#define VENDOR_ID_LOGITECH 0x046d struct lur_receiver { int refcount; @@ -113,7 +113,7 @@ lur_device_disconnect(struct lur_device *dev) _EXPORT_ int lur_is_receiver(uint16_t vid, uint16_t pid) { - return (vid == VENDOR_ID_LOGITECH && (pid == 0xc52b || pid == 0xc532)); + return (vid == USB_VENDOR_ID_LOGITECH && (pid == 0xc52b || pid == 0xc532)); } static bool @@ -232,7 +232,7 @@ lur_receiver_enumerate(struct lur_receiver *lur, lur_receiver_ref(lur); dev->refcount = 1; dev->name = strdup_safe(name); - dev->vid = VENDOR_ID_LOGITECH; + dev->vid = USB_VENDOR_ID_LOGITECH; dev->pid = wpid; dev->type = type; dev->serial = serial; diff --git a/src/usb-ids.h b/src/usb-ids.h new file mode 100644 index 00000000..f69273e3 --- /dev/null +++ b/src/usb-ids.h @@ -0,0 +1,29 @@ +/* + * Copyright © 2016 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#ifndef USB_IDS_H +#define USB_IDS_H + +#define USB_VENDOR_ID_LOGITECH 0x046d + +#endif +