From patchwork Sat Aug 27 13:24:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Achatz X-Patchwork-Id: 1103732 X-Patchwork-Delegate: jikos@jikos.cz Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7RDPUiu029201 for ; Sat, 27 Aug 2011 13:25:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752474Ab1H0NZF (ORCPT ); Sat, 27 Aug 2011 09:25:05 -0400 Received: from mail-in-08.arcor-online.net ([151.189.21.48]:44953 "EHLO mail-in-08.arcor-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751807Ab1H0NYy (ORCPT ); Sat, 27 Aug 2011 09:24:54 -0400 Received: from mail-in-06-z2.arcor-online.net (mail-in-06-z2.arcor-online.net [151.189.8.18]) by mx.arcor.de (Postfix) with ESMTP id 1AE331FB4DF; Sat, 27 Aug 2011 15:24:53 +0200 (CEST) Received: from mail-in-10.arcor-online.net (mail-in-10.arcor-online.net [151.189.21.50]) by mail-in-06-z2.arcor-online.net (Postfix) with ESMTP id 172561575CC; Sat, 27 Aug 2011 15:24:53 +0200 (CEST) Received: from [192.168.0.7] (dslb-188-105-218-067.pools.arcor-ip.net [188.105.218.67]) (Authenticated sender: screamingfist@arcor.de) by mail-in-10.arcor-online.net (Postfix) with ESMTPSA id E6D382D6714; Sat, 27 Aug 2011 15:24:52 +0200 (CEST) X-DKIM: Sendmail DKIM Filter v2.8.2 mail-in-10.arcor-online.net E6D382D6714 Subject: [PATCH 5/5] HID: roccat: Kone now reports external profile changes via roccat device From: Stefan Achatz Reply-To: erazor_de@users.sourceforge.net To: Jiri Kosina , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Date: Sat, 27 Aug 2011 15:24:51 +0200 Message-ID: <1314451491.24216.76.camel@neuromancer.tessier-ashpool> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 (2.30.3-1.fc13) 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 (demeter2.kernel.org [140.211.167.43]); Sat, 27 Aug 2011 13:25:30 +0000 (UTC) Profile changes were only reported when issued mouse internal. Now all changes are reported. Signed-off-by: Stefan Achatz --- drivers/hid/hid-roccat-kone.c | 16 +++++++++++++++- 1 files changed, 15 insertions(+), 1 deletions(-) diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c index c931d00..e2072af 100644 --- a/drivers/hid/hid-roccat-kone.c +++ b/drivers/hid/hid-roccat-kone.c @@ -43,6 +43,15 @@ static void kone_profile_activated(struct kone_device *kone, uint new_profile) kone->actual_dpi = kone->profiles[new_profile - 1].startup_dpi; } +static void kone_profile_report(struct kone_device *kone, uint new_profile) +{ + struct kone_roccat_report roccat_report; + roccat_report.event = kone_mouse_event_switch_profile; + roccat_report.value = new_profile; + roccat_report.key = 0; + roccat_report_event(kone->chrdev_minor, (uint8_t *)&roccat_report); +} + static int kone_receive(struct usb_device *usb_dev, uint usb_command, void *data, uint size) { @@ -289,7 +298,7 @@ static ssize_t kone_sysfs_write_settings(struct file *fp, struct kobject *kobj, container_of(kobj, struct device, kobj)->parent->parent; struct kone_device *kone = hid_get_drvdata(dev_get_drvdata(dev)); struct usb_device *usb_dev = interface_to_usbdev(to_usb_interface(dev)); - int retval = 0, difference; + int retval = 0, difference, old_profile; /* I need to get my data in one piece */ if (off != 0 || count != sizeof(struct kone_settings)) @@ -305,9 +314,13 @@ static ssize_t kone_sysfs_write_settings(struct file *fp, struct kobject *kobj, return retval; } + old_profile = kone->settings.startup_profile; memcpy(&kone->settings, buf, sizeof(struct kone_settings)); kone_profile_activated(kone, kone->settings.startup_profile); + + if (kone->settings.startup_profile != old_profile) + kone_profile_report(kone, kone->settings.startup_profile); } mutex_unlock(&kone->kone_lock); @@ -554,6 +567,7 @@ static ssize_t kone_sysfs_set_startup_profile(struct device *dev, /* changing the startup profile immediately activates this profile */ kone_profile_activated(kone, new_startup_profile); + kone_profile_report(kone, new_startup_profile); mutex_unlock(&kone->kone_lock); return size;