Re: [PATCH 1/3] HID: gamecube-adapter: add nintendo gamecube adapter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux