Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac - Both controllers are mapped together #4215

Closed
danzel opened this issue Dec 11, 2016 · 15 comments
Closed

Mac - Both controllers are mapped together #4215

danzel opened this issue Dec 11, 2016 · 15 comments

Comments

@danzel
Copy link
Contributor

danzel commented Dec 11, 2016

On MacOS I have multiple controllers (2x 8bitdo SFC30, Xbox controller, DS4).
When I connect more than one of them, retroarch configures them all as controller #0 (Or sometimes all as #1 if controllers with different names are plugged in).
This means during gameplay, all players are controlled by all controllers.

If I go to Settings > Input > Input User X Binds > User X Device Index there is only one entry, which has the name of whatever the latest controller to be plugged in/out is.
I think they are meant to appear in this list as separate controllers?

Happy to have a go at building and debugging under xcode if you can point me at likely source files to throw breakpoints in.
Thanks!

Related/dupe #2694
Forum thread of same complaint https://libretro.com/forums/showthread.php?t=6731
Maybe related to #4204

Input Driver: cocoa
Joypad Driver: hid

@Ryunam
Copy link
Contributor

Ryunam commented Dec 11, 2016

Referencing also #3415, which illustrates an identical problem I had with two Xbox360 controllers on MacOS (El Capitan), through the unofficial 360Controller driver.

@danzel
Copy link
Contributor Author

danzel commented Dec 11, 2016

Took a quick look at this, will continue later.

When a joypad_connection_t is allocated to the first controller in joypad_connection.c by pad_connection_find_vacant_pad and pad_connection_pad_init the connected state is never set to true.
This means when the second pad is connected, it is also allocated the same pad index/joypad_connection.

I'm not sure where connected is meant to be set, there is a block that does it in pad_connection_pad_init if the name matches one in pad_map.

Will read through the code a bit more later and see what other platforms do.

@Silanda
Copy link

Silanda commented Dec 14, 2016

I may be having an analogous problem in Windows. Every controller I attach seems to be assigned the same device number.

@danzel
Copy link
Contributor Author

danzel commented Dec 14, 2016

From using lakka on a rpi3 (where multiple controllers works correctly) it looks like the #0 text that appears in the controllers name is just the number for controllers with that name.
So if you plug in two different controllers you will get:

Controller Type A (#0)
Controller Type B (#0)

But they will have separate items in the controller select box, and will control separate players (once configured).
This is correct behaviour and not what this issue is about FYI.

@Silanda
Copy link

Silanda commented Dec 14, 2016

Ah I see. The issue I'm having actually seems to be with regards to one controller's configuration affecting the other. I will do some research and open a separate issue if necessary (assuming it's not related to #4204).

@danzel
Copy link
Contributor Author

danzel commented Dec 14, 2016

Cool, I think that one will be related.

@danzel
Copy link
Contributor Author

danzel commented Dec 15, 2016

@twinaphex is there a reason that iohidmanager_hid.c uses the joypad_connection.h/c methods for assigning pad numbers?

It looks like pad_connection_pad_init will never succeed in finding a pad from its static list, so it'll return 0 and not set s->connected (causing it to return 0 again when a second pad is plugged in - leading to this bug)
Thanks :)

@danzel
Copy link
Contributor Author

danzel commented Dec 15, 2016

Dupe of #2808 too by the looks

@danzel
Copy link
Contributor Author

danzel commented Dec 15, 2016

I'm working on converting iomanager_hid over to be a joypad instead, and not using the joypad_connection bits.
Will take me a few days

@inactive123
Copy link
Contributor

inactive123 commented Dec 15, 2016

@danzel Yeah looking back on it, previously it only worked with low-level input HID joypad drivers (the ones you can find inside input/connect). I'm not really proud of that code to be honest and it is overdue for a good cleaning up. We are kinda stuck here in that regard and the HID input part has been neglected a bit since only platforms like the Mac and consoles like the Wii rely heavily on it. It would be awesome to see others take a crack at fixing this.

The whole assigning of 'slots' (the bits in joypad_connection.h) in retrospect don't really make sense and you can simply chalk it up to legacy codebase warts, I simply refactored @meancoot's old code there. We should probably move away from it and figure out some other way to assign joypad indices.

I'll await to see what you can come up with. I do think we should not throw the baby out with the bathwater though (with regards to joypad_connection) just because it has a few bugs. However, if it can be made more modular and not solely rely on joypad_connection (and therefore we wouldn't have to specifically write a new 'connect' driver for every new gamepad that arrives, that'd be an improvement yeah.

Looking forward to a few more Mac-native developers hacking away at RetroArch.

@danzel
Copy link
Contributor Author

danzel commented Dec 15, 2016

Thanks for your feedback!

I think we have two ways to go:

  1. Keep using joypad_connection on mac. We'll need to make it assign a joypad even in the lookup table in pad_connection_pad_init doesn't find a matching one (which will be easy I think).

  2. Stop using joypad_connection and convert the iohidmanager_hid driver from being a hid driver to being a joypad driver.

After a bit more reading through the code, it seems like (1) is the way to go.
Will look at getting this going, should be a small change.

@inactive123
Copy link
Contributor

Yeah I think (1) is the more practical way to go about it. Very much looking forward to seeing what you're going to come up with, appreciated.

@danzel
Copy link
Contributor Author

danzel commented Dec 15, 2016

I noticed that if you plug and unplug a single controller, the "User 1 Device Index" text for that slot doesn't get reset back to "N/A" on mac.
Is it meant to?
And if so, what causes it to reset back, then I can fix that on mac too :)

(Screenshot from after plugging and unplugging a gamepad)
screen shot 2016-12-16 at 8 48 15 am

@inactive123
Copy link
Contributor

It is not meant to, yeah.

It is supposed to default back to N/A. I guess this was never properly implemented through the joypad_connection interface.

@frranck
Copy link

frranck commented Jan 6, 2017

I've got the same problem with iBuffalo gamepads...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants