linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "François-Xavier Carton" <fx.carton91@gmail.com>
To: Ethan Lee <flibitijibibo@gmail.com>
Cc: "Bastien Nocera" <hadess@hadess.net>,
	"François-Xavier Carton" <fx.carton91@gmail.com>,
	linux-input@vger.kernel.org
Subject: Re: [PATCH 1/3] HID: gamecube-adapter: add nintendo gamecube adapter
Date: Tue, 12 May 2020 01:23:31 +0200	[thread overview]
Message-ID: <20200511231806.GA31481@pc-fx> (raw)
In-Reply-To: <0e4f2671-00e8-b5d3-f309-8355bc92f118@gmail.com>

On Mon, May 11, 2020 at 10:09:28AM -0400, Ethan Lee wrote:
> Looks just like the SDL hidapi driver so this should be okay! The only 
> thing I'm unsure of is the axis inversion, in SDL we read the axes 
> directly and invert them in the SDL_GameController configuration. 
> Someone also added a bunch of dead zone work after I wrote the driver, 
> but unfortunately I don't know the details of that.
> 
> The meat of our driver is here...
> 
> https://hg.libsdl.org/SDL/file/4298bf108b06/src/joystick/hidapi/SDL_hidapi_gamecube.c#l226
> 

Thanks for the review and pointer to the SDL driver! I think the dead
zone min/max code is a better way to solve the dead zone issue than what
I did in the 3rd commit, as it is an automated solution. I'll implement
something like this.

> ... and the SDL_GameController config is here:
> 
> https://hg.libsdl.org/SDL/file/4298bf108b06/src/joystick/SDL_gamecontrollerdb.h#l614
> 
> The '~' char denotes an input value that is flipped after it is read 
> from the joystick; the vendor/product/version matchup may cause this 
> config to accidentally flip the axes twice when using the kernel driver.
> 

I tested this on my system and the axes are not getting inverted twice.
This is because the version component of the GUID doesn't match the one
in the db file. The db file has 00016800, whereas "sdl2-jstest --list"
reports 10010000 for my gamepad. Because the GUIDs don't match, the axes
are correct in sdl2-jstest. If I add an entry with my gamepad's GUID,
then the axes are indeed inverted twice.

I don't know why the first part is different (0001 != 1001), but the
second part is different because the SDL hidapi driver adds an 'h'
(0x68) to indicate that it's a hidapi device. See:

https://hg.libsdl.org/SDL/file/4298bf108b06/src/joystick/hidapi/SDL_hidapijoystick.c#l712

So as long as this code is here, the entry in the db file won't get
picked up if the kernel driver is used.

Also, I don't know much about SDL, but looking at sdl2-jstest, it seems
that there are two APIs: joysticks and gamepads. If the db file is only
used for the gamepad API, that means that the axes won't get inverted in
the joystick API if using the SDL hidapi driver. Is that the intended
behaviour?

-François-Xavier

  reply	other threads:[~2020-05-11 23:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06  0:47 [PATCH 1/3] HID: gamecube-adapter: add nintendo gamecube adapter François-Xavier Carton
2020-05-06  0:48 ` [PATCH 2/3] HID: gamecube-adapter: add rumble support François-Xavier Carton
2020-05-06  0:48 ` [PATCH 3/3] HID: gamecube-adapter: make axis limits parameters François-Xavier Carton
2020-05-09 23:50 ` [PATCH 1/3] HID: gamecube-adapter: add nintendo gamecube adapter François-Xavier Carton
2020-05-10 12:45 ` Bastien Nocera
2020-05-11 14:09   ` Ethan Lee
2020-05-11 23:23     ` François-Xavier Carton [this message]
2020-05-12  0:22       ` Ethan Lee
2020-05-12  2:27         ` François-Xavier Carton

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=20200511231806.GA31481@pc-fx \
    --to=fx.carton91@gmail.com \
    --cc=flibitijibibo@gmail.com \
    --cc=hadess@hadess.net \
    --cc=linux-input@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).