All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ethan Lee <flibitijibibo@gmail.com>
To: Bastien Nocera <hadess@hadess.net>, linux-input@vger.kernel.org
Subject: Re: [PATCH 1/3] HID: gamecube-adapter: add nintendo gamecube adapter
Date: Mon, 11 May 2020 20:22:44 -0400	[thread overview]
Message-ID: <bc392ac3-f70c-be0c-c7f2-a6f69279152b@gmail.com> (raw)
In-Reply-To: <20200511231806.GA31481@pc-fx>

Oh good, that hidapi char should indeed prevent any conflicts - forgot 
that Sam had that in there. Once this driver is merged we can add a new 
entry to the database right away.

The way the gamepad system works in SDL is that there is SDL_Joystick, 
which provides direct access to devices, and SDL_GameController, which 
tries to take known hardware from SDL_Joystick and maps them to an 
Xbox-style button layout. For us it's generally considered okay for 
joysticks to not follow any standards, since you typically only access 
them for very specific kinds of devices (flight sim controllers, stuff 
like that) and those developers will often want their data as untouched 
as humanly possible, while most game developers will only touch 
SDL_GameController, which wrangles all the quirks of each device and the 
specifics won't matter as much.

-Ethan

On 5/11/20 19:23, François-Xavier Carton wrote:
> 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-12  0:22 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
2020-05-12  0:22       ` Ethan Lee [this message]
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=bc392ac3-f70c-be0c-c7f2-a6f69279152b@gmail.com \
    --to=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 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.