SDL2.0.3 GameControllerGetButton args |
Julian Winter
Guest
|
Hello SDL community,
I know this is a draft: https://wiki.libsdl.org/SDL_GameControllerGetButton BUT, how and why can this function expect an enum as an argument? For me, a simple integer (which represents SDL_CONTROLLER_BUTTON_Y for example) would make more sense. (Still, compile error says: "... invalid conversion from ‘int’ to ‘SDL_GameControllerButton’) Where (/in which file of the SDL source) is SDL_GameControllerButton defined anyway? Thanks a lot in advance. Cheers Julian |
|||||||||||
|
SDL2.0.3 GameControllerGetButton args |
Sik
|
include/SDL_gamecontroller.h
What's wrong with an enum anyway? You're *only* supposed to pass values from that enum anyway. If you ever attempt to pass something else you're asking for trouble. The enum is there explicitly to state the valid values. The only place where using an integer would make sense is to store the value in a file, and in that case you can do an explicit cast (assuming C++, since in C an implicit cast would be valid). For the record, this is the enum: typedef enum { SDL_CONTROLLER_BUTTON_INVALID = -1, SDL_CONTROLLER_BUTTON_A, SDL_CONTROLLER_BUTTON_B, SDL_CONTROLLER_BUTTON_X, SDL_CONTROLLER_BUTTON_Y, SDL_CONTROLLER_BUTTON_BACK, SDL_CONTROLLER_BUTTON_GUIDE, SDL_CONTROLLER_BUTTON_START, SDL_CONTROLLER_BUTTON_LEFTSTICK, SDL_CONTROLLER_BUTTON_RIGHTSTICK, SDL_CONTROLLER_BUTTON_LEFTSHOULDER, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, SDL_CONTROLLER_BUTTON_DPAD_UP, SDL_CONTROLLER_BUTTON_DPAD_DOWN, SDL_CONTROLLER_BUTTON_DPAD_LEFT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, SDL_CONTROLLER_BUTTON_MAX } SDL_GameControllerButton; _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||
|
SDL2.0.3 GameControllerGetButton args |
Julian Winter
Guest
|
Ok, so you recommend doing something like this:
... bool getButtonState(unsigned short int button) { return ( SDL_GameControllerGetButton( this->gamecontroller, (SDL_GameControllerButton)button )>0); } ??
Am 12.10.2014 um 19:25 schrieb Sik the hedgehog:
|
|||||||||||||||||||
|
SDL2.0.3 GameControllerGetButton args |
Sik
|
OK I think I know what's your actual problem.
2014-10-12 14:55 GMT-03:00, Julian Winter:
The Game Controller API is made *specifically* for those controllers that are based around the XBox and PlayStation ones - mostly so SDL manages the mappings for you. If you want to support any other kind of controller, you should be using the Joystick API instead, which indeed has no limits on number of buttons, axes or hats (but then you have to figure out the mappings yourself, although you can use both together to get mappings for most common controllers while still supporting other ones). _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
SDL2.0.3 GameControllerGetButton args |
Julian Winter
Guest
|
@ Sik: Thanks!
Am 12.10.2014 um 23:10 schrieb Sik the hedgehog:
_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||||
|