From patchwork Tue Mar 22 20:29:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darren Salt X-Patchwork-Id: 653481 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2MKaHlq001788 for ; Tue, 22 Mar 2011 20:36:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755219Ab1CVUgQ (ORCPT ); Tue, 22 Mar 2011 16:36:16 -0400 Received: from lon1-post-3.mail.demon.net ([195.173.77.150]:65251 "EHLO lon1-post-3.mail.demon.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750969Ab1CVUgQ (ORCPT ); Tue, 22 Mar 2011 16:36:16 -0400 Received: from youmustbejoking.demon.co.uk ([80.176.152.238] helo=pentagram.youmustbejoking.demon.co.uk) by lon1-post-3.mail.demon.net with esmtp (Exim 4.69) id 1Q28Im-0005Hw-co; Tue, 22 Mar 2011 20:36:14 +0000 Received: from [192.168.0.5] (helo=flibble.youmustbejoking.demon.co.uk) by pentagram.youmustbejoking.demon.co.uk with esmtp (Exim 4.72) (envelope-from ) id 1Q28Il-0008Is-A1; Tue, 22 Mar 2011 20:35:39 +0000 Date: Tue, 22 Mar 2011 20:29:49 +0000 From: Darren Salt To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH v2 2.6.38] Mode button quirk for Saitek Cyborg R.A.T. 7 Message-ID: <51BD8E4644%ds@youmustbejoking.demon.co.uk> In-Reply-To: References: Mail-Followup-To: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com, linux-kernel@vger.kernel.org, Darren Salt User-Agent: Messenger-Pro/2.66.6.3353 (Qt/4.6.3) (Linux-x86_64) X-No-Archive: no X-Orwell-Date: Tue, 9608 Dec 1984 20:29:49 +0000 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 192.168.0.5 X-SA-Exim-Mail-From: linux@youmustbejoking.demon.co.uk X-SA-Exim-Scanned: No (on pentagram.youmustbejoking.demon.co.uk); SAEximRunCond expanded to false Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 22 Mar 2011 20:36:18 +0000 (UTC) diff -ur linux-2.6.38.orig/drivers/hid/hid-ids.h linux-2.6.38/drivers/hid/hid-ids.h --- linux-2.6.38.orig/drivers/hid/hid-ids.h 2011-03-22 17:27:45.628320449 +0000 +++ linux-2.6.38/drivers/hid/hid-ids.h 2011-03-22 17:29:01.844925858 +0000 @@ -502,6 +502,7 @@ #define USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS 0x2cf6 #define USB_VENDOR_ID_SAITEK 0x06a3 +#define USB_DEVICE_ID_SAITEK_RAT7 0x0ccb #define USB_DEVICE_ID_SAITEK_RUMBLEPAD 0xff17 #define USB_VENDOR_ID_SAMSUNG 0x0419 diff -ur linux-2.6.38.orig/drivers/hid/hid-input.c linux-2.6.38/drivers/hid/hid-input.c --- linux-2.6.38.orig/drivers/hid/hid-input.c 2011-03-22 17:27:45.644319741 +0000 +++ linux-2.6.38/drivers/hid/hid-input.c 2011-03-22 20:07:20.254290914 +0000 @@ -790,6 +790,22 @@ if ((field->flags & HID_MAIN_ITEM_RELATIVE) && (usage->type == EV_KEY)) input_event(input, usage->type, usage->code, 0); + + /* hack for Saitek RAT mice which report release events for their + * mode button on the NEXT press event: instant release + */ + if ((*quirks & HID_QUIRK_RAT_BROKEN_BUTTON_RELEASE) && + value && usage->type == EV_KEY && + usage->code >= BTN_MOUSE + 8 && usage->code <= BTN_MOUSE + 10 && + test_bit(usage->code, input->key)) { + input_event(input, usage->type, usage->code, 0); + /* we'll get a real release event from the mouse anyway, and + * userspace should cope with the extra input-layer + * button-up events anyway; just re-set the bit to stop + * spurious button-down events + */ + set_bit(usage->code, input->key); + } } void hidinput_report_event(struct hid_device *hid, struct hid_report *report) diff -ur linux-2.6.38.orig/drivers/hid/usbhid/hid-quirks.c linux-2.6.38/drivers/hid/usbhid/hid-quirks.c --- linux-2.6.38.orig/drivers/hid/usbhid/hid-quirks.c 2011-03-22 17:27:45.652319385 +0000 +++ linux-2.6.38/drivers/hid/usbhid/hid-quirks.c 2011-03-22 17:29:01.844925858 +0000 @@ -85,6 +85,8 @@ { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_MULTI_TOUCH, HID_QUIRK_MULTI_INPUT }, { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS, HID_QUIRK_MULTI_INPUT }, + + { USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_RAT7, HID_QUIRK_RAT_BROKEN_BUTTON_RELEASE }, { 0, 0 } }; diff -ur linux-2.6.38.orig/include/linux/hid.h linux-2.6.38/include/linux/hid.h --- linux-2.6.38.orig/include/linux/hid.h 2011-03-22 17:27:45.692317595 +0000 +++ linux-2.6.38/include/linux/hid.h 2011-03-22 17:29:01.884924059 +0000 @@ -312,6 +312,7 @@ #define HID_QUIRK_BADPAD 0x00000020 #define HID_QUIRK_MULTI_INPUT 0x00000040 #define HID_QUIRK_HIDINPUT_FORCE 0x00000080 +#define HID_QUIRK_RAT_BROKEN_BUTTON_RELEASE 0x00000100 #define HID_QUIRK_SKIP_OUTPUT_REPORTS 0x00010000 #define HID_QUIRK_FULLSPEED_INTERVAL 0x10000000 #define HID_QUIRK_NO_INIT_REPORTS 0x20000000