From patchwork Thu Jul 7 01:58:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuxuan Shui X-Patchwork-Id: 9217713 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EF303607D9 for ; Thu, 7 Jul 2016 01:58:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE17C28604 for ; Thu, 7 Jul 2016 01:58:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D270B28603; Thu, 7 Jul 2016 01:58:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A76228603 for ; Thu, 7 Jul 2016 01:58:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753440AbcGGB6p (ORCPT ); Wed, 6 Jul 2016 21:58:45 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:35003 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751635AbcGGB6p (ORCPT ); Wed, 6 Jul 2016 21:58:45 -0400 Received: by mail-qk0-f194.google.com with SMTP id s7so489451qkf.2 for ; Wed, 06 Jul 2016 18:58:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LOgJk6vaCrEhTiRoAoxftkbhu6sB3FPvbFi+r1F3VyY=; b=iDHmn7/Fm/KOAHbh7twbUUue/KeJF8fsRD/NzspaA5AkGkxTdpeV9CaLCkAyP0tBB/ 34HJiJAmWn7XYeCSDi9EXHPMNJ+SglFp5c3er6aNf/+bhQzWuezHhhq72fJhLnSgQ3+Y iKktbnA/Z+994j5kmV3ex25UqIRC29chqNP9OIhyseX8xVE8qH52Vxqcz8qTJ2EH3ajL 72wiFjFXSBWtkzsJcf3ANEpE1xwLWQre5V+dps5pqvVXjNsFopyfTk5RU0BoEW7eXq7s vsDhBxngklnFiXGXZz/TFXQB+iFJOaR4kg2qySC77dfza4tWdVluvjAPsMk4CxZ9dF63 D3VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LOgJk6vaCrEhTiRoAoxftkbhu6sB3FPvbFi+r1F3VyY=; b=Rw6nXAbb8RrlyGP1CvqgMpRJs9ouoMKLKQ4yVjXm2QzQTtG9r/oD5ZgH4rojWWLD33 0AZ+9ExnjwdnKx50s348+bTbKWwt70k4w2h4tjGiu5jFRnw8+5Ftu6F10Q8rypnTsULX ocre0rJ9P5HOBVD0te0nUh5p3zwTtJE+/PoANJKjY7ZA759o8NmyDCkML7ZHYyzOH71i N4n9gSpkBpS6xLCQ/GNvDyR5ewVK/516M8osar3DtSS1F1QuLxPnkLtNEBTyDuICfONp P0+HvPuw8BjIDIrqgQSutAhQ3uWKCJI5MTOkTbxj7ywjVnYK1xT2QIEjJWdWDTLUfRoB irZg== X-Gm-Message-State: ALyK8tILB8nFIIzAA1GWsqvBxRedzs0pa3LV3xdtC6/Ngm96qY9aJkxQ004CrlsfMSqDGA== X-Received: by 10.55.163.144 with SMTP id m138mr33231989qke.21.1467856724091; Wed, 06 Jul 2016 18:58:44 -0700 (PDT) Received: from localhost.localdomain ([130.245.128.158]) by smtp.gmail.com with ESMTPSA id a67sm409005qkc.24.2016.07.06.18.58.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jul 2016 18:58:43 -0700 (PDT) From: Yuxuan Shui To: yshuiv7@gmail.com Cc: linux-input@vger.kernel.org Subject: [PATCH] hid: Add support for the Elecom DEFT trackball Date: Wed, 6 Jul 2016 21:58:25 -0400 Message-Id: <20160707015825.17915-2-yshuiv7@gmail.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160707015825.17915-1-yshuiv7@gmail.com> References: <20160707015825.17915-1-yshuiv7@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The DEFT trackball has three non-standard buttons at the top which is not supported by the hid-generic driver. This patch add a driver that modifies the HID report, so those three buttons can be supported like standard buttons. --- drivers/hid/Kconfig | 6 ++++++ drivers/hid/Makefile | 1 + drivers/hid/hid-deft.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/hid/hid-ids.h | 2 ++ 4 files changed, 61 insertions(+) create mode 100644 drivers/hid/hid-deft.c diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 5646ca4..9c3ee05 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -263,6 +263,12 @@ config HID_ELECOM ---help--- Support for the ELECOM BM084 (bluetooth mouse). +config HID_ELECOM_DEFT + tristate "ELECOM DEFT trackball" + depends on HID + ---help--- + Support for the Fn keys found on ELECOM DEFT trackball. + config HID_ELO tristate "ELO USB 4000/4500 touchscreen" depends on USB_HID diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index a2fb562..3cc582e 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile @@ -37,6 +37,7 @@ obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o obj-$(CONFIG_HID_DRAGONRISE) += hid-dr.o obj-$(CONFIG_HID_EMS_FF) += hid-emsff.o obj-$(CONFIG_HID_ELECOM) += hid-elecom.o +obj-$(CONFIG_HID_ELECOM_DEFT) += hid-deft.o obj-$(CONFIG_HID_ELO) += hid-elo.o obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o obj-$(CONFIG_HID_GEMBIRD) += hid-gembird.o diff --git a/drivers/hid/hid-deft.c b/drivers/hid/hid-deft.c new file mode 100644 index 0000000..4e2621d --- /dev/null +++ b/drivers/hid/hid-deft.c @@ -0,0 +1,52 @@ +/* + * HID driver for Elecom DEFT (trackball). + * Extend the number of buttons to 8, and + * remove a non-standard item in the HID + * descriptor. + * (This module is based on "hid-elecom".) + * + * Copyright (c) 2016 Yuxuan Shui + */ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#include +#include +#include + +#include "hid-ids.h" + +static __u8 *deft_report_fixup(struct hid_device *hdev, __u8 *rdesc, + unsigned int *rsize) +{ + if (*rsize >= 34 && rdesc[20] == 0x29 && rdesc[21] == 0x05) { + hid_info(hdev, "Fixing up Elecom DEFT report descriptor %x\n", rdesc[13]); + rdesc[21] = 0x08; + rdesc[13] = 0x08; + + memmove(rdesc+28, rdesc+34, *rsize-34); + *rsize -= 6; + } + return rdesc; +} + +static const struct hid_device_id deft_devices[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT)}, + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFTW)}, + { } +}; +MODULE_DEVICE_TABLE(hid, deft_devices); + +static struct hid_driver deft_driver = { + .name = "elecom-deft", + .id_table = deft_devices, + .report_fixup = deft_report_fixup, +}; +module_hid_driver(deft_driver); + +MODULE_LICENSE("GPL"); diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 3eec09a1..534ae73 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -332,6 +332,8 @@ #define USB_VENDOR_ID_ELECOM 0x056e #define USB_DEVICE_ID_ELECOM_BM084 0x0061 +#define USB_DEVICE_ID_ELECOM_DEFT 0x00fe +#define USB_DEVICE_ID_ELECOM_DEFTW 0x00ff #define USB_VENDOR_ID_DREAM_CHEEKY 0x1d34