From f5474cf9ec90c101db3d627ccd625d08938839d4 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Fri, 14 Aug 2015 14:37:21 -0400 Subject: [PATCH] Add first implementation of etekcity Signed-off-by: Benjamin Tissoires --- src/Makefile.am | 1 + src/etekcity.c | 43 +++++++++++++++++++++++++++++++++++++++++ src/libratbag-private.h | 5 +++++ src/libratbag.c | 2 ++ 4 files changed, 51 insertions(+) create mode 100644 src/etekcity.c diff --git a/src/Makefile.am b/src/Makefile.am index 4ab3708a..1b2e4a7c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,6 +4,7 @@ include_HEADERS = \ libratbag.h libratbag_la_SOURCES = \ + etekcity.c \ libratbag.c \ libratbag.h \ libratbag-util.c \ diff --git a/src/etekcity.c b/src/etekcity.c new file mode 100644 index 00000000..52760b61 --- /dev/null +++ b/src/etekcity.c @@ -0,0 +1,43 @@ +/* + * Copyright © 2015 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "config.h" +#include +#include + +#include "libratbag-private.h" + +static const struct ratbag_id etekcity_table[] = { + {.id = { .bustype = BUS_USB, + .vendor = USB_VENDOR_ID_ETEKCITY, + .product = USB_DEVICE_ID_ETEKCITY_SCROLL_ALPHA, + .version = VERSION_ANY }, + }, + + { }, +}; + +struct ratbag_driver etekcity_driver = { + .name = "EtekCity", + .table_ids = etekcity_table, +}; diff --git a/src/libratbag-private.h b/src/libratbag-private.h index 255f9843..38990e56 100644 --- a/src/libratbag-private.h +++ b/src/libratbag-private.h @@ -29,6 +29,8 @@ #include "libratbag.h" #include "libratbag-util.h" +#define USB_VENDOR_ID_ETEKCITY 0x1ea7 +#define USB_DEVICE_ID_ETEKCITY_SCROLL_ALPHA 0x4011 #define BUS_ANY 0xffff #define VENDOR_ANY 0xffff @@ -74,5 +76,8 @@ void log_msg(struct libratbag *libratbag, #define log_bug_libratbag(li_, ...) log_msg((li_), LIBRATBAG_LOG_PRIORITY_ERROR, "libratbag bug: " __VA_ARGS__) #define log_bug_client(li_, ...) log_msg((li_), LIBRATBAG_LOG_PRIORITY_ERROR, "client bug: " __VA_ARGS__) +/* list of all supported drivers */ +struct ratbag_driver etekcity_driver; + #endif /* LIBRATBAG_PRIVATE_H */ diff --git a/src/libratbag.c b/src/libratbag.c index d5b57a3f..aa60573f 100644 --- a/src/libratbag.c +++ b/src/libratbag.c @@ -194,6 +194,8 @@ libratbag_create_context(void) libratbag->log_handler = libratbag_default_log_func; libratbag->log_priority = LIBRATBAG_LOG_PRIORITY_DEBUG; + ratbag_register_driver(libratbag, &etekcity_driver); + return libratbag; }