Joystick hot plug

For issues with communication ports, protocols, etc.
Post Reply
AWPStar
Posts: 55
Joined: May 03, 2009 21:47

Joystick hot plug

Post by AWPStar »

Hello. I got a question. If my gamepad is plugged in and I run program I can detect its connection/disconnection.

Code: Select all

if GETJOYSTICK(n)=0 then 
But if I run program before I connect my gamepad, than I can't detect it.
I can use raw inputs but there's too much work to do. And we don't have some HID functions and structures to do this easily.

Is there a way to init gamepad on plug?
misterc
Posts: 22
Joined: Sep 04, 2018 18:41

Re: Joystick hot plug

Post by misterc »

Is SDL2 event polling on added/removed handles an option? If you are OK using SDL2 it might work.
AWPStar
Posts: 55
Joined: May 03, 2009 21:47

Re: Joystick hot plug

Post by AWPStar »

misterc wrote: May 19, 2025 23:42 Is SDL2 event polling on added/removed handles an option? If you are OK using SDL2 it might work.
Thanks. It's very small project - I don't want to use any frameworks like SDL2.
For now I just capture events from raw inputs and show notification "Here's your gamepad, restart the game, bla-bla..." to player.
Post Reply