Support plugging and unplugging joypads while running

Found a bug? Please report it, but remember to follow the bug reporting guidelines.
Missing a sane feature? Let us know!
But please do NOT request ports to other systems.

Moderator: ZSNES Mods

Post Reply
Dwedit
Rookie
Posts: 12
Joined: Thu Apr 28, 2005 6:37 pm

Support plugging and unplugging joypads while running

Post by Dwedit »

From what I've noticed, when you unplug a USB controller while ZSNES is running, then plug it back in again, it will not recognize the controller until you restart the program. That gets annoying. I'd like to see ZSNES able to recognize controllers as they are plugged in.

Maybe it would be possible to check if a controller matches a previously inserted-and-removed controller and auto-map the buttons to the previous joystick. Would be handy if you played with a joystick for a while, unplugged it, set up the configuration to use the keyboard, then re-plugged in the joystick. Or if you moved the joystick from one USB port to another.
"We are merely sprites that dance at the beck and call of our button pressing overlord."
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

That "might" be done when we rework joystick support. On the other hand, that doesn't quite solve how it will properly interface with joystick->key/button mapping. It should be plugged in when you start ZSNES regardless.
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
Panzer88
Inmate
Posts: 1485
Joined: Thu Jan 11, 2007 4:28 am
Location: Salem, Oregon
Contact:

Post by Panzer88 »

maybe you could emulate an unplugged controller too. Like some games say, "Please insert controller 1"
[quote="byuu"]Seriously, what kind of asshole makes an old-school 2D emulator that requires a Core 2 to get full speed? [i]>:([/i] [/quote]
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

Panzer88 wrote:maybe you could emulate an unplugged controller too. Like some games say, "Please insert controller 1"
I think that's already emulated, but nevertheless, I don't see any reason why one would want to hot plugging a different controller, while running an app that is using the controller. In most of those apps, they do the gampad detection on load, not while the app is running. I can understand if the gamepad is loose, and stops getting detected.. that would be worthwhile to fix.

However, with the current system, it is very difficult to implement a hot-swap controller option. It just simply won't work (read the source if you wish, so this becomes clearer to you).
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
franpa
Gecko snack
Posts: 2374
Joined: Sun Aug 21, 2005 11:06 am
Location: Australia, QLD
Contact:

Post by franpa »

yea it is, just set all inputs to none when playing a game.
Core i7 920 @ 2.66GHZ | ASUS P6T Motherboard | 8GB DDR3 1600 RAM | Gigabyte Geforce 760 4GB | Windows 10 Pro x64
Panzer88
Inmate
Posts: 1485
Joined: Thu Jan 11, 2007 4:28 am
Location: Salem, Oregon
Contact:

Post by Panzer88 »

could you assign it to a hotkey?
[quote="byuu"]Seriously, what kind of asshole makes an old-school 2D emulator that requires a Core 2 to get full speed? [i]>:([/i] [/quote]
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

Panzer88 wrote:could you assign it to a hotkey?
Assign what?
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
byuu

Post by byuu »

Enumeration of joypads is a difficult thing to do at runtime, and is very expensive timewise. You technically can do it, but you'd need a special event timer so that it's only done once every few seconds.

And then there's the problem of what to do when joypad IDs change. It's even more difficult to identify which joypad was plugged in and map keys appropriately. Most likely what would happen if you switched joypads would be that the key mapping would change and your buttons would be out of order. The best you could do is store joypad configuration data with the unique ID of the gamepad and rely on that for joypad key transformation.

So it would require two very annoying to implement functions, but is technically possible.
franpa
Gecko snack
Posts: 2374
Joined: Sun Aug 21, 2005 11:06 am
Location: Australia, QLD
Contact:

Post by franpa »

And then there's the problem of what to do when joypad IDs change. It's even more difficult to identify which joypad was plugged in and map keys appropriately. Most likely what would happen if you switched joypads would be that the key mapping would change and your buttons would be out of order.
but... you would normally expect different joysticks to set there buttons up differently so you shouldnt need to combat this...

all we want is for it to not require us to restart it to detect joypads... it doesnt matter if there different cause then yes they get buttons assigned based on another controllers layout and this is a problem, but it is a expected problem that doesnt need to be resolved...
Core i7 920 @ 2.66GHZ | ASUS P6T Motherboard | 8GB DDR3 1600 RAM | Gigabyte Geforce 760 4GB | Windows 10 Pro x64
sweener2001
Inmate
Posts: 1751
Joined: Mon Dec 06, 2004 7:47 am
Location: WA

Post by sweener2001 »

i don't see this as a problem.

i personally don't think the devs should bother themselves too much with this one.
[img]http://i26.photobucket.com/albums/c128/sweener2001/StewieSIGPIC.png[/img]
SquareHead
Veteran
Posts: 970
Joined: Fri Jan 21, 2005 11:15 am
Location: Montana, United States

Post by SquareHead »

sweener2001 wrote:i don't see this as a problem.

i personally don't think the devs should bother themselves too much with this one.
I have to agree there.

I know of plenty of commercial games that you have to restart if a controller is unplugged while in play. Hell I used to have wireless controls that were a bitch if they lost signal for a second, then I'd have to sync up again and restart the game.
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

franpa wrote:
And then there's the problem of what to do when joypad IDs change. It's even more difficult to identify which joypad was plugged in and map keys appropriately. Most likely what would happen if you switched joypads would be that the key mapping would change and your buttons would be out of order.
but... you would normally expect different joysticks to set there buttons up differently so you shouldnt need to combat this...
Uh, yes you do have to combat that. You cannot always guarentee that two controllers have the same button configuration being processed. If it happens that they are the same controller(or similar), well then, it doesn't really matter.
all we want is for it to not require us to restart it to detect joypads... it doesnt matter if there different cause then yes they get buttons assigned based on another controllers layout and this is a problem, but it is a expected problem that doesnt need to be resolved...
It's not even factoring layout, it has more to do with how the joystick enumeration maps to internal keypressing in ZSNES. As I said, read the source as it will make this clear to you (or if you can't, just stop complaining).
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
Post Reply