From patchwork Tue May 18 16:31:04 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Achatz X-Patchwork-Id: 100526 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4IGVB3T013302 for ; Tue, 18 May 2010 16:31:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755372Ab0ERQbK (ORCPT ); Tue, 18 May 2010 12:31:10 -0400 Received: from mail-in-09.arcor-online.net ([151.189.21.49]:46722 "EHLO mail-in-09.arcor-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755216Ab0ERQbJ (ORCPT ); Tue, 18 May 2010 12:31:09 -0400 Received: from mail-in-15-z2.arcor-online.net (mail-in-15-z2.arcor-online.net [151.189.8.32]) by mx.arcor.de (Postfix) with ESMTP id A9D1E197824; Tue, 18 May 2010 18:31:06 +0200 (CEST) Received: from mail-in-13.arcor-online.net (mail-in-13.arcor-online.net [151.189.21.53]) by mail-in-15-z2.arcor-online.net (Postfix) with ESMTP id 906DC726BA5; Tue, 18 May 2010 18:31:06 +0200 (CEST) Received: from [192.168.0.1] (dslb-088-067-009-174.pools.arcor-ip.net [88.67.9.174]) by mail-in-13.arcor-online.net (Postfix) with ESMTPS id 7CB12212470; Tue, 18 May 2010 18:31:05 +0200 (CEST) X-DKIM: Sendmail DKIM Filter v2.8.2 mail-in-13.arcor-online.net 7CB12212470 Subject: [PATCH 4/5] HID: refactored special event handling in Roccat Kone From: Stefan Achatz Reply-To: erazor_de@users.sourceforge.net To: Jiri Kosina , Stephane Chatty , wylda@volny.cz, Jussi Kivilinna , Tejun Heo , linux-input@vger.kernel.org, Jerome Vidal , linux-kernel@vger.kernel.org, Stefan Achatz Date: Tue, 18 May 2010 18:31:04 +0200 Message-ID: <1274200264.2243.4.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 (2.28.3-1.fc12) 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.3 (demeter.kernel.org [140.211.167.41]); Tue, 18 May 2010 16:31:11 +0000 (UTC) diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c index 0b1db24..66e6940 100644 --- a/drivers/hid/hid-roccat-kone.c +++ b/drivers/hid/hid-roccat-kone.c @@ -912,6 +912,24 @@ static void kone_remove(struct hid_device *hdev) hid_hw_stop(hdev); } +/* handle special events and keep actual profile and dpi values up to date */ +static void kone_keep_values_up_to_date(struct kone_device *kone, + struct kone_mouse_event const *event) +{ + switch (event->event) { + case kone_mouse_event_switch_profile: + case kone_mouse_event_osd_profile: + kone->actual_profile = event->value; + kone->actual_dpi = kone->profiles[kone->actual_profile - 1]. + startup_dpi; + break; + case kone_mouse_event_switch_dpi: + case kone_mouse_event_osd_dpi: + kone->actual_dpi = event->value; + break; + } +} + /* * Is called for keyboard- and mousepart. * Only mousepart gets informations about special events in its extended event @@ -938,41 +956,9 @@ static int kone_raw_event(struct hid_device *hdev, struct hid_report *report, else memset(&event->tilt, 0, 5); - /* - * handle special events and keep actual profile and dpi values - * up to date - */ - switch (event->event) { - case kone_mouse_event_osd_dpi: - dev_dbg(&hdev->dev, "osd dpi event. actual dpi %d\n", - event->value); - return 1; /* return 1 if event was handled */ - case kone_mouse_event_switch_dpi: - kone->actual_dpi = event->value; - dev_dbg(&hdev->dev, "switched dpi to %d\n", event->value); - return 1; - case kone_mouse_event_osd_profile: - dev_dbg(&hdev->dev, "osd profile event. actual profile %d\n", - event->value); - return 1; - case kone_mouse_event_switch_profile: - kone->actual_profile = event->value; - kone->actual_dpi = kone->profiles[kone->actual_profile - 1]. - startup_dpi; - dev_dbg(&hdev->dev, "switched profile to %d\n", event->value); - return 1; - case kone_mouse_event_call_overlong_macro: - dev_dbg(&hdev->dev, "overlong macro called, button %d %s/%s\n", - event->macro_key, - kone->profiles[kone->actual_profile - 1]. - button_infos[event->macro_key].macro_set_name, - kone->profiles[kone->actual_profile - 1]. - button_infos[event->macro_key].macro_name - ); - return 1; - } + kone_keep_values_up_to_date(kone, event); - return 0; /* do further processing */ + return 0; /* always do further processing */ } static const struct hid_device_id kone_devices[] = {