Gamecontroller and Joystick events not working! (v2.0.3 & |
blueshogun96
|
Okay, first I want to say thanks to all the hard work everyone has put into SDL 2.0. I written a fairly complex and large engine and SDL helped make much of the portability prospects a reality. It's indeed a privilege to have such a great library available for use!
But right now, I really need to find out why gamecontroller and joystick events aren't being triggered. I don't know why this doesn't work, especially when the documentation tells me exactly how it's done. It appears to me that SDL events don't always work; I mean, I've had instances where NONE of the event types would be processesed for a few days, then suddenly start working again. I dunno, what the frell is going on? This should be rather straight forward, but I guess not. This is the code I use to handle gamepads and such...
And my event handler:
If you want to see my engine's full source code, then take a look at https://github.com/blueshogun96/KunaiEngine Now, I didn't add any code to deal with the joystick part (the non gamepads) because I wanted to add breakpoints into my IDE and see if the events are actually being fired. I've inserted breakpoints at every controller event, and the only one that gets triggered is SDL_CONTROLLERDEVICEADDED. When I remove a controller, nothing happens, but when I reattach the same one, I get that message triggered. Button presses and axis movement also doesn't work. I've also had this problem with mouse input, but then all of a sudden, it started working. Maybe this will happen with my gamepad code too. Anyone else experiencing this? Devices I tried using: Xbox 360 and PS4 controllers and a Microsoft Sidewinder Freestyle Pro. OSes I've tried: Windows 7 and 8.1 (going to try MacOSX today). SDL versions used: 2.0.4 (June 27, 2015) and 2.0.3. Shogun. |
|||||||||||||||
|
blueshogun96
|
Nevermind, it's my own code causing the problem. The deconstructor in my gamepad handle class gets called after adding it to the vector due to it going out of scope. I should have used a smart pointer instead to delay that. Thanks for reading.
Shogun. |
|||||||||||
|