All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frank Praznik <frank.praznik@gmail.com>
To: simon@mungewell.org, linux-input@vger.kernel.org
Cc: Frank Praznik <frank.praznik@oh.rr.com>
Subject: Re: Handling Controllers with Acc/Gyro/Mag via HID system
Date: Mon, 08 Jun 2015 18:43:23 -0400	[thread overview]
Message-ID: <55761A8B.2080908@gmail.com> (raw)
In-Reply-To: <195dff9bd065db7e618280cb7c6eb5a9.squirrel@mungewell.org>

On 6/8/2015 11:41, simon@mungewell.org wrote:
> Hi all,
> I'm in the process of fixing the HID descriptor for the PS3 Move
> Controller. which has a particularly convoluted layout for it's
> Accelormeters, Gyros and Magnetometers involving 2 sets of data per output
> report.
>
> https://github.com/nitsch/moveonpc/wiki/Input-report
>
> The plan is/was to massage the HID descriptor so the first set of
> Accels/Gyro/Mag appear in a set a axis, as a simple way of getting to this
> data.
>
> The Magnetometers are only 12 bits, and if 'we' want the HID system to be
> able to process these as an axis the data needs to be shuffled. Previously
> for the Sony SixAxis Accels was done in 'sony_raw_event'.
>
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/hid/hid-sony.c?id=refs/tags/v4.1-rc7#n1035
>
>
> My reshuffle would be:
> ---
>                  /* Need to fix order and shared nibble of 12bit Temp/Mags */
>                  /* 8e 4. .. .. .. .. -> Temp = 0x08E4 */
>                  /* .. .1 51 .. .. .. -> MagX = 0x0151 */
>                  /* .. .. .. 02 1. .. -> MagZ = 0x0021 */
>                  /* .. .. .. .. .2 98 -> MagY = 0x0298 */
>
>                  __u8 tmp;
>                  tmp = rd[38];
>                  rd[38] = (((rd[37] & 0xF0) >> 4) | ((rd[39] & 0x0F) << 4));
>                  rd[37] = (((tmp & 0xF0) >> 4) | ((rd[37] & 0x0F) << 4));
>                  rd[39] = (((rd[39] & 0xF0) >> 4) | ((tmp & 0x0F) << 4));
>
>                  tmp = rd[41];
>                  rd[41] = (((rd[40] & 0xF0) >> 4) | ((rd[42] & 0x0F) << 4));
>                  rd[40] = (((tmp & 0xF0) >> 4) | ((rd[40] & 0x0F) << 4));
>                  rd[42] = (((rd[42] & 0xF0) >> 4) | ((tmp & 0x0F) << 4));
> ---
>
> This works, however I have noticed that this affects/reshuffles the output
> of '/dev/hidraw0', which would 'corrupt' the data going into the existing
> user-mode drivers (such as psmoveapi).
>
> Is there a 'better' place/way to reshuffle this data, or is this just how
> it needs to be?
>
> Given that more controllers are coming with 'motion' controls, is there a
> framework in place for unifying support?
>
> Cheers,
> Simon.
>

Hmm, perhaps remove the mappings for the motion controls in the HID 
descriptor and add the motion axis flags in the input device creation 
callback as is currently done with the touchpad axes on the DS4.  Then 
you can parse the motion data and fire off motion events manually in the 
raw event function (again, same as the touch events on the DS4) and the 
raw data in the packet will pass through unchanged for userspace drivers.

Regards,
Frank

  reply	other threads:[~2015-06-08 22:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-08 15:41 Handling Controllers with Acc/Gyro/Mag via HID system simon
2015-06-08 22:43 ` Frank Praznik [this message]
2015-06-11 14:48 ` [RFC] HID: hid-sony: Add basic iio-subsystem reading of SixAxis Accelerometers Simon Wood
     [not found] ` <195dff9bd065db7e618280cb7c6eb5a9.squirrel-wM4F9T/ekXmXDw4h08c5KA@public.gmane.org>
2015-06-11 14:54   ` Simon Wood
2015-06-11 14:54     ` Simon Wood
2015-06-11 15:07     ` Bastien Nocera
2015-06-14 14:53     ` Jonathan Cameron
2015-06-14 17:25       ` simon
     [not found]         ` <d6702f5d19d2baea80132666fcf7654a.squirrel-wM4F9T/ekXmXDw4h08c5KA@public.gmane.org>
2015-06-14 17:57           ` Jonathan Cameron
2015-06-14 17:57             ` Jonathan Cameron
2015-06-15 18:14             ` Srinivas Pandruvada
     [not found]               ` <1434392064.2353.77.camel-hINH/TbAiWqaJgj69oe+EDMJUdESFZ8XQQ4Iyu8u01E@public.gmane.org>
2015-06-21 13:16                 ` Jonathan Cameron
2015-06-21 13:16                   ` Jonathan Cameron
2015-06-18  6:15             ` simon
     [not found]               ` <a740eca098128c7a830db825d7c0288c.squirrel-wM4F9T/ekXmXDw4h08c5KA@public.gmane.org>
2015-06-21 13:12                 ` Jonathan Cameron
2015-06-21 13:12                   ` Jonathan Cameron
2015-06-09  2:38 Handling Controllers with Acc/Gyro/Mag via HID system simon
     [not found] ` <02179134fef3a932cff19b793006f020.squirrel-wM4F9T/ekXmXDw4h08c5KA@public.gmane.org>
2015-06-09  9:54   ` Bastien Nocera
2015-06-09  9:54     ` Bastien Nocera
     [not found]     ` <1433843657.12204.18.camel-0MeiytkfxGOsTnJN9+BGXg@public.gmane.org>
2015-06-09 17:12       ` simon-wM4F9T/ekXmXDw4h08c5KA
2015-06-09 17:12         ` simon

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=55761A8B.2080908@gmail.com \
    --to=frank.praznik@gmail.com \
    --cc=frank.praznik@oh.rr.com \
    --cc=linux-input@vger.kernel.org \
    --cc=simon@mungewell.org \
    /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.