From patchwork Thu Mar 28 03:34:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Henrie X-Patchwork-Id: 10874453 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-2.web.codeaurora.org (Postfix) with ESMTP id D091B1390 for ; Thu, 28 Mar 2019 03:34:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDC202874B for ; Thu, 28 Mar 2019 03:34:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0F85288D2; Thu, 28 Mar 2019 03:34:42 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 4C5C82874B for ; Thu, 28 Mar 2019 03:34:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727270AbfC1Del (ORCPT ); Wed, 27 Mar 2019 23:34:41 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:52517 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726108AbfC1Del (ORCPT ); Wed, 27 Mar 2019 23:34:41 -0400 Received: by mail-it1-f194.google.com with SMTP id g17so3727532ita.2 for ; Wed, 27 Mar 2019 20:34:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RSLeKtUHujUH0wIjEbHHFy+t3VZrcyVtR9w41AyjSWo=; b=djuAhO02ijHiiAO+Vrrc/Nx9utUAuqqJ6QARnnj+RAuHKfQZjsryZKqBz+qtR0DUQz Av+DMPyhIghmXuYog3dNF5NIY9TWqaH7E4Y6F9qy9Q1i8PEOi0x5t5tpGoxdSJztZDQ2 W9NFA7GyrhCN/Ri122Oii5kaJYX2xlLL/SXI77CA/xND9gUQfJEUN10gkmpmImYOqnYH z4I9bUeaamEIgl9FWAJOiZ1ZrjlvjV7PJni7HxnhSGDhnYnmSAPh3eZhav7OI2PmWfNW vaGBwDS0tkPa3G59JclnkTBKe/dUX1TWvj+w5Ib0T39hcNsvE0RzhTRGfPK9r023dSAH FKpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RSLeKtUHujUH0wIjEbHHFy+t3VZrcyVtR9w41AyjSWo=; b=Jnih/RpROwF4qsl9vBLale2xF5pmezD0DqlvD6QugFStEqGZSyzMunifmziWNwrSlG TU4dgb2iG9iDH3duJzmgPRy+tM/fic63hZfdzhYlXc8ykl8ASa1z+yudC7HjsTUpD6oP x6Hna7YOtnM7i0/bgb4ybbRJIE1wwIGiuy6qxPZ7rP6IBTaeGWnSf6EvWvDBFBdbJ/k9 Xqzl+LVfcWDtdcfVNYB4ZPmeQKAiVcJJiIXiPqI31m29AQ8/MColLm6YiLBiyKfoz8Ej MfU0JjkeLrpjYaBYB33DYB+1zo1Myoo1UN7Lt8d6WXt6fOiTjycen7k3Dnk0TBG/ZAt7 xeXg== X-Gm-Message-State: APjAAAXuyFfuvD7Rxzp3A7zlTmT5J4uBQO8XSw1/1eua6SZeYHAENk5M 5O8L/Ny7LnhVNIm9MwklvmVOdyHo X-Google-Smtp-Source: APXvYqxJohqJkrY758Z63b1jOntrC/LRkeFRjvwakJKTXiRXTAiBcoBhWn0FFJ5+2Vs570P9P6qM6g== X-Received: by 2002:a24:703:: with SMTP id f3mr6243420itf.164.1553744079992; Wed, 27 Mar 2019 20:34:39 -0700 (PDT) Received: from xavier.hsd1.ut.comcast.net ([2601:681:4100:375e:f2d5:bfff:fecd:8741]) by smtp.gmail.com with ESMTPSA id t25sm10164732ioc.37.2019.03.27.20.34.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Mar 2019 20:34:39 -0700 (PDT) From: Alex Henrie To: linux-input@vger.kernel.org, jikos@kernel.org, benjamin.tissoires@redhat.com, dmlambea@gmail.com Cc: Alex Henrie Subject: [PATCH 2/2] HID: macally: Add support for Macally QKEY keyboard Date: Wed, 27 Mar 2019 21:34:35 -0600 Message-Id: <20190328033435.17931-2-alexhenrie24@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190328033435.17931-1-alexhenrie24@gmail.com> References: <20190328033435.17931-1-alexhenrie24@gmail.com> MIME-Version: 1.0 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 This enables the brightness-down and brightness-up keys on the Macally QKEY keyboard. Similar workarounds are probably needed for quite a few Macally keyboard models. Based on the key translation code in the Apple keyboard driver. Signed-off-by: Alex Henrie --- drivers/hid/Kconfig | 1 + drivers/hid/hid-ids.h | 3 +++ drivers/hid/hid-macally.c | 57 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index aef4a2a690e1..082900477df5 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig @@ -239,6 +239,7 @@ config HID_MACALLY supported devices: - Macally ikey keyboard + - Macally QKEY keyboard config HID_PRODIKEYS tristate "Prodikeys PC-MIDI Keyboard support" diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index aacc7534b076..5afc3b7fe8ca 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -776,6 +776,9 @@ #define USB_DEVICE_ID_CRYSTALTOUCH 0x0006 #define USB_DEVICE_ID_CRYSTALTOUCH_DUAL 0x0007 +#define USB_VENDOR_ID_MACALLY 0x2222 +#define USB_DEVICE_ID_MACALLY_QKEY_KEYBOARD 0x0039 + #define USB_VENDOR_ID_MADCATZ 0x0738 #define USB_DEVICE_ID_MADCATZ_BEATPAD 0x4540 #define USB_DEVICE_ID_MADCATZ_RAT5 0x1705 diff --git a/drivers/hid/hid-macally.c b/drivers/hid/hid-macally.c index 6f62f059b795..2567babe8200 100644 --- a/drivers/hid/hid-macally.c +++ b/drivers/hid/hid-macally.c @@ -31,9 +31,64 @@ static __u8 *macally_report_fixup(struct hid_device *hdev, __u8 *rdesc, return rdesc; } +struct macally_key_translation +{ + u16 from; + u16 to; +}; + +static const struct macally_key_translation qkey_brightness_keys[] = +{ + { KEY_SCROLLLOCK, KEY_BRIGHTNESSDOWN }, + { KEY_PAUSE, KEY_BRIGHTNESSUP }, + { } +}; + +static int macally_event(struct hid_device *hdev, struct hid_field *field, + struct hid_usage *usage, __s32 value) +{ + const struct macally_key_translation *trans; + + switch (hdev->product) { + case USB_DEVICE_ID_MACALLY_QKEY_KEYBOARD: + trans = qkey_brightness_keys; + break; + default: + trans = NULL; + } + + if (trans) { + while (trans->from) { + if (trans->from == usage->code) { + input_event(field->hidinput->input, usage->type, + trans->to, value); + return 1; + } + trans++; + } + } + + return 0; +} + +static int macally_input_mapping(struct hid_device *hdev, struct hid_input *hi, + struct hid_field *field, struct hid_usage *usage, + unsigned long **bit, int *max) +{ + const struct macally_key_translation *trans; + + /* Enable all needed keys */ + for (trans = qkey_brightness_keys; trans->from; trans++) + set_bit(trans->to, hi->input->keybit); + + return 0; +} + static struct hid_device_id macally_id_table[] = { { HID_USB_DEVICE(USB_VENDOR_ID_SOLID_YEAR, USB_DEVICE_ID_MACALLY_IKEY_KEYBOARD) }, + { HID_USB_DEVICE(USB_VENDOR_ID_MACALLY, + USB_DEVICE_ID_MACALLY_QKEY_KEYBOARD) }, { } }; MODULE_DEVICE_TABLE(hid, macally_id_table); @@ -42,6 +97,8 @@ static struct hid_driver macally_driver = { .name = "macally", .id_table = macally_id_table, .report_fixup = macally_report_fixup, + .event = macally_event, + .input_mapping = macally_input_mapping, }; module_hid_driver(macally_driver);