From patchwork Fri Nov 1 20:16:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 3127631 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C6426BEEB3 for ; Fri, 1 Nov 2013 20:17:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0C109204D2 for ; Fri, 1 Nov 2013 20:17:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0CB30204C9 for ; Fri, 1 Nov 2013 20:17:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753287Ab3KAUQ6 (ORCPT ); Fri, 1 Nov 2013 16:16:58 -0400 Received: from mail-ee0-f47.google.com ([74.125.83.47]:41988 "EHLO mail-ee0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753223Ab3KAUQ6 (ORCPT ); Fri, 1 Nov 2013 16:16:58 -0400 Received: by mail-ee0-f47.google.com with SMTP id c13so3196eek.34 for ; Fri, 01 Nov 2013 13:16:57 -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=Y55VASIx/WBrV6lXLyauZKHoEnlkfEJQAB8ne1ZpCQE=; b=hBGM066av6TkSJOQTLkAO0PlqHwXZqGdY01Rf5WJ9rsijWqBHXdLhYjhu4GNPZCR23 +ydnilSlBAfe4WvONELWhjHHCF5TaXh11PpBbkVpxMX8hTSjgBvleUYsRIIVRswQiKhW s2Rukstd9m/XBLNgo7KLaKGPrEyrebsY5K0dqLvJXLvaYIJZLTQfClyCIon7OpjsG2xF amWlvOVs4AaY+U8vbco7InAdhAJBMPov4hEYyH7/wOXItYj6Wcmc7AkK9HyAzYYcvCun Xz5oej74REBFKXH/y64lwmyzPYfhSUJrojWziKCB/VhSOa1BoGcXnhWZP+1eIQHsTKuh n9JQ== X-Received: by 10.15.111.202 with SMTP id cj50mr2342622eeb.71.1383337017354; Fri, 01 Nov 2013 13:16:57 -0700 (PDT) Received: from localhost.localdomain (stgt-5f719f65.pool.mediaWays.net. [95.113.159.101]) by mx.google.com with ESMTPSA id i1sm11797335eeg.0.2013.11.01.13.16.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Nov 2013 13:16:56 -0700 (PDT) From: David Herrmann To: linux-input@vger.kernel.org Cc: Dmitry Torokhov , Jiri Kosina , Peter Hutterer , Benjamin Tissoires , David Herrmann Subject: [PATCH 09/13] HID: wiimote: use ABS_ACCEL_* for accelerometer Date: Fri, 1 Nov 2013 21:16:20 +0100 Message-Id: <1383336984-26601-10-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.8.4.1 In-Reply-To: <1383336984-26601-1-git-send-email-dh.herrmann@gmail.com> References: <1383336984-26601-1-git-send-email-dh.herrmann@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use the new ABS_ACCEL_* bits for accelerometer data _iff_ legacy mode is not selected. ABS_R? is confusing and ambigiuous. ABS_ACCEL_* was introduced exactly for accelerometers like the one of the wiimote. Signed-off-by: David Herrmann --- drivers/hid/hid-wiimote-modules.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/drivers/hid/hid-wiimote-modules.c b/drivers/hid/hid-wiimote-modules.c index f3de94e..777f932 100644 --- a/drivers/hid/hid-wiimote-modules.c +++ b/drivers/hid/hid-wiimote-modules.c @@ -477,9 +477,16 @@ static void wiimod_accel_in_accel(struct wiimote_data *wdata, y |= (accel[1] >> 4) & 0x2; z |= (accel[1] >> 5) & 0x2; - input_report_abs(wdata->accel, ABS_RX, x - 0x200); - input_report_abs(wdata->accel, ABS_RY, y - 0x200); - input_report_abs(wdata->accel, ABS_RZ, z - 0x200); + if (wdata->state.flags & WIIPROTO_FLAG_LEGACY) { + input_report_abs(wdata->accel, ABS_RX, x - 0x200); + input_report_abs(wdata->accel, ABS_RY, y - 0x200); + input_report_abs(wdata->accel, ABS_RZ, z - 0x200); + } else { + input_report_abs(wdata->accel, ABS_ACCEL_X, x - 0x200); + input_report_abs(wdata->accel, ABS_ACCEL_Y, y - 0x200); + input_report_abs(wdata->accel, ABS_ACCEL_Z, z - 0x200); + } + input_sync(wdata->accel); } @@ -525,12 +532,25 @@ static int wiimod_accel_probe(const struct wiimod_ops *ops, wdata->accel->name = WIIMOTE_NAME " Accelerometer"; set_bit(EV_ABS, wdata->accel->evbit); - set_bit(ABS_RX, wdata->accel->absbit); - set_bit(ABS_RY, wdata->accel->absbit); - set_bit(ABS_RZ, wdata->accel->absbit); - input_set_abs_params(wdata->accel, ABS_RX, -500, 500, 2, 4); - input_set_abs_params(wdata->accel, ABS_RY, -500, 500, 2, 4); - input_set_abs_params(wdata->accel, ABS_RZ, -500, 500, 2, 4); + + if (wdata->state.flags & WIIPROTO_FLAG_LEGACY) { + set_bit(ABS_RX, wdata->accel->absbit); + set_bit(ABS_RY, wdata->accel->absbit); + set_bit(ABS_RZ, wdata->accel->absbit); + input_set_abs_params(wdata->accel, ABS_RX, -500, 500, 2, 4); + input_set_abs_params(wdata->accel, ABS_RY, -500, 500, 2, 4); + input_set_abs_params(wdata->accel, ABS_RZ, -500, 500, 2, 4); + } else { + set_bit(ABS_ACCEL_X, wdata->accel->absbit); + set_bit(ABS_ACCEL_Y, wdata->accel->absbit); + set_bit(ABS_ACCEL_Z, wdata->accel->absbit); + input_set_abs_params(wdata->accel, ABS_ACCEL_X, + -500, 500, 2, 4); + input_set_abs_params(wdata->accel, ABS_ACCEL_Y, + -500, 500, 2, 4); + input_set_abs_params(wdata->accel, ABS_ACCEL_Z, + -500, 500, 2, 4); + } ret = input_register_device(wdata->accel); if (ret) {