All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Herrmann <dh.herrmann@gmail.com>
To: linux-input@vger.kernel.org
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Jiri Kosina <jkosina@suse.cz>,
	Peter Hutterer <peter.hutterer@who-t.net>,
	Benjamin Tissoires <benjamin.tissoires@gmail.com>,
	David Herrmann <dh.herrmann@gmail.com>
Subject: [PATCH 05/13] HID: wiimote: add hid_wiimote.legacy parameter
Date: Fri,  1 Nov 2013 21:16:16 +0100	[thread overview]
Message-ID: <1383336984-26601-6-git-send-email-dh.herrmann@gmail.com> (raw)
In-Reply-To: <1383336984-26601-1-git-send-email-dh.herrmann@gmail.com>

The first hid-wiimote driver had horrible default mappings which we have
to support now for compatibility reasons. This was no big problem as the
wiimote needs special user-space drivers to really make sense, anyway.

However, there are several wiimote extensions which can be used on their
own (especially the gamepads). To allow new mappings which comply to the
common gamepad rules, we introduce the hid_wiimote.legacy parameter so
users can get the old behavior back, if they need it.

This patch only introduces the module parameter, the following patches
will change the mappings.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/hid/hid-wiimote-core.c | 9 +++++++++
 drivers/hid/hid-wiimote.h      | 1 +
 2 files changed, 10 insertions(+)

diff --git a/drivers/hid/hid-wiimote-core.c b/drivers/hid/hid-wiimote-core.c
index 1446f52..89ca031 100644
--- a/drivers/hid/hid-wiimote-core.c
+++ b/drivers/hid/hid-wiimote-core.c
@@ -20,6 +20,9 @@
 #include "hid-ids.h"
 #include "hid-wiimote.h"
 
+/* set to 1 to enable legacy-mode and old reports */
+static unsigned int wiimote_legacy = 0;
+
 /* output queue handling */
 
 static int wiimote_hid_send(struct hid_device *hdev, __u8 *buffer,
@@ -1731,6 +1734,9 @@ static struct wiimote_data *wiimote_create(struct hid_device *hdev)
 	wdata->hdev = hdev;
 	hid_set_drvdata(hdev, wdata);
 
+	if (wiimote_legacy)
+		wdata->state.flags |= WIIPROTO_FLAG_LEGACY;
+
 	spin_lock_init(&wdata->queue.lock);
 	INIT_WORK(&wdata->queue.worker, wiimote_queue_worker);
 
@@ -1873,6 +1879,9 @@ static struct hid_driver wiimote_hid_driver = {
 };
 module_hid_driver(wiimote_hid_driver);
 
+MODULE_PARM_DESC(legacy, "Enable legacy mode and reports");
+module_param_named(legacy, wiimote_legacy, int, 0600);
+
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("David Herrmann <dh.herrmann@gmail.com>");
 MODULE_DESCRIPTION("Driver for Nintendo Wii / Wii U peripherals");
diff --git a/drivers/hid/hid-wiimote.h b/drivers/hid/hid-wiimote.h
index 03065f1..6f70823 100644
--- a/drivers/hid/hid-wiimote.h
+++ b/drivers/hid/hid-wiimote.h
@@ -47,6 +47,7 @@
 #define WIIPROTO_FLAG_BUILTIN_MP	0x010000
 #define WIIPROTO_FLAG_NO_MP		0x020000
 #define WIIPROTO_FLAG_PRO_CALIB_DONE	0x040000
+#define WIIPROTO_FLAG_LEGACY		0x080000
 
 #define WIIPROTO_FLAGS_LEDS (WIIPROTO_FLAG_LED1 | WIIPROTO_FLAG_LED2 | \
 					WIIPROTO_FLAG_LED3 | WIIPROTO_FLAG_LED4)
-- 
1.8.4.1


  parent reply	other threads:[~2013-11-01 20:16 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-01 20:16 [PATCH 00/13] Input/HID: Bits and Pieces David Herrmann
2013-11-01 20:16 ` [PATCH 01/13] Input: uinput: add full absinfo support David Herrmann
2013-11-01 20:16 ` [PATCH 02/13] Input: introduce ABS_MAX2/CNT2 and friends David Herrmann
2013-11-05 22:29   ` David Herrmann
2013-11-01 20:16 ` [PATCH 03/13] Input: remove ambigious gamepad comment David Herrmann
2013-11-01 20:16 ` [PATCH 04/13] Input: add motion-tracking ABS_* bits and docs David Herrmann
2013-11-15 10:11   ` Antonio Ospite
2013-11-15 10:17     ` David Herrmann
2013-11-16 17:53       ` Antonio Ospite
2013-11-16 18:07         ` David Herrmann
2013-11-01 20:16 ` David Herrmann [this message]
2013-11-01 20:16 ` [PATCH 06/13] HID: wiimote: adjust button-mapping to gamepad rules David Herrmann
2013-11-01 20:16 ` [PATCH 07/13] HID: wiimote: map nunchuk as real gamepad David Herrmann
2013-11-01 20:16 ` [PATCH 08/13] HID: wiimote: map classic controller as gamepad David Herrmann
2013-11-01 20:16 ` [PATCH 09/13] HID: wiimote: use ABS_ACCEL_* for accelerometer David Herrmann
2013-11-01 20:16 ` [PATCH 10/13] HID: wiimote: use ABS_GYRO_* bits for MP David Herrmann
2013-11-01 20:16 ` [PATCH 11/13] Input: introduce BTN/ABS bits for drums and guitars David Herrmann
2013-11-01 20:16 ` [PATCH 12/13] HID: wiimote: add support for Guitar-Hero drums David Herrmann
2013-11-01 20:16 ` [PATCH 13/13] HID: wiimote: add support for Guitar-Hero guitars David Herrmann
2013-11-04 13:04 ` [PATCH 00/13] Input/HID: Bits and Pieces Jiri Kosina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1383336984-26601-6-git-send-email-dh.herrmann@gmail.com \
    --to=dh.herrmann@gmail.com \
    --cc=benjamin.tissoires@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=peter.hutterer@who-t.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.