All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Herrmann <dh.herrmann@googlemail.com>
To: linux-input@vger.kernel.org
Cc: jkosina@suse.cz, padovan@profusion.mobi, oliver@neukum.org,
	David Herrmann <dh.herrmann@googlemail.com>
Subject: [PATCH 13/14] HID: wiimote: Add status request
Date: Mon, 29 Aug 2011 15:38:10 +0200	[thread overview]
Message-ID: <1314625091-1405-14-git-send-email-dh.herrmann@googlemail.com> (raw)
In-Reply-To: <1314625091-1405-1-git-send-email-dh.herrmann@googlemail.com>

The wiimote does not send status reports continuously so this adds a helper
function to request a status report and parses the battery charge level.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
---
 drivers/hid/hid-wiimote.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/drivers/hid/hid-wiimote.c b/drivers/hid/hid-wiimote.c
index 6658398..48198cb 100644
--- a/drivers/hid/hid-wiimote.c
+++ b/drivers/hid/hid-wiimote.c
@@ -41,6 +41,7 @@ struct wiimote_state {
 	__u32 opt;
 
 	/* results of synchronous requests */
+	__u8 cmd_battery;
 	__u8 cmd_err;
 };
 
@@ -83,6 +84,7 @@ enum wiiproto_reqs {
 	WIIPROTO_REQ_LED = 0x11,
 	WIIPROTO_REQ_DRM = 0x12,
 	WIIPROTO_REQ_IR1 = 0x13,
+	WIIPROTO_REQ_SREQ = 0x15,
 	WIIPROTO_REQ_WMEM = 0x16,
 	WIIPROTO_REQ_RMEM = 0x17,
 	WIIPROTO_REQ_IR2 = 0x1a,
@@ -354,6 +356,17 @@ static void wiiproto_req_drm(struct wiimote_data *wdata, __u8 drm)
 	wiimote_queue(wdata, cmd, sizeof(cmd));
 }
 
+static void wiiproto_req_status(struct wiimote_data *wdata)
+{
+	__u8 cmd[2];
+
+	cmd[0] = WIIPROTO_REQ_SREQ;
+	cmd[1] = 0;
+
+	wiiproto_keep_rumble(wdata, &cmd[1]);
+	wiimote_queue(wdata, cmd, sizeof(cmd));
+}
+
 static void wiiproto_req_accel(struct wiimote_data *wdata, __u8 accel)
 {
 	accel = !!accel;
@@ -805,6 +818,11 @@ static void handler_status(struct wiimote_data *wdata, const __u8 *payload)
 
 	/* on status reports the drm is reset so we need to resend the drm */
 	wiiproto_req_drm(wdata, WIIPROTO_REQ_NULL);
+
+	if (wiimote_cmd_pending(wdata, WIIPROTO_REQ_SREQ, 0)) {
+		wdata->state.cmd_battery = payload[5];
+		wiimote_cmd_complete(wdata);
+	}
 }
 
 static void handler_data(struct wiimote_data *wdata, const __u8 *payload)
-- 
1.7.6.1


  parent reply	other threads:[~2011-08-29 13:38 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-29 13:37 [PATCH 00/14] Extended Wiimote Support David Herrmann
2011-08-29 13:37 ` [PATCH 01/14] HID: wiimote: Support rumble device David Herrmann
2011-08-29 13:37 ` [PATCH 02/14] HID: wiimote: Add force-feedback support David Herrmann
2011-08-29 13:38 ` [PATCH 03/14] HID: wiimote: Add accelerometer input device David Herrmann
2011-08-29 13:38 ` [PATCH 04/14] HID: wiimote: Parse accelerometer data David Herrmann
2011-08-29 13:38 ` [PATCH 05/14] HID: wiimote: Add IR input device David Herrmann
2011-08-29 13:38 ` [PATCH 06/14] HID: wiimote: Parse IR data David Herrmann
2011-08-29 13:38 ` [PATCH 07/14] HID: wiimote: Add missing extension DRM handlers David Herrmann
2011-08-29 13:38 ` [PATCH 08/14] HID: wiimote: Add register/eeprom memory support David Herrmann
2011-08-29 13:38 ` [PATCH 09/14] HID: wiimote: Helper functions for synchronous requests David Herrmann
2011-08-29 13:38 ` [PATCH 10/14] HID: wiimote: Add write-register helpers David Herrmann
2011-08-29 13:38 ` [PATCH 11/14] HID: wiimote: Add IR initializer David Herrmann
2011-08-29 13:38 ` [PATCH 12/14] HID: wiimote: Initialize IR cam on request David Herrmann
2011-08-29 13:38 ` David Herrmann [this message]
2011-08-29 13:38 ` [PATCH 14/14] HID: wiimote: Read wiimote battery charge level David Herrmann
2011-08-29 14:28   ` Oliver Neukum
2011-08-29 14:41     ` David Herrmann

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=1314625091-1405-14-git-send-email-dh.herrmann@googlemail.com \
    --to=dh.herrmann@googlemail.com \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=oliver@neukum.org \
    --cc=padovan@profusion.mobi \
    /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.