Difference between revisions of "SDL Controls"
From Pandora Wiki
(Created page with "== Gaming buttons == The pandora gaming buttons are mapped to certain keyboards keys. Here is the list : {|class="wikitable sortable" border="1" cellpadding="1" cellspacing="0" ...") |
(→Finding the nub using SDL) |
||
Line 81: | Line 81: | ||
// Joystick vars | // Joystick vars | ||
#ifdef PANDORA | #ifdef PANDORA | ||
− | static SDL_Joystick * | + | static SDL_Joystick *left_nub = NULL; |
− | static SDL_Joystick * | + | static SDL_Joystick *right_nub = NULL; |
#endif | #endif | ||
Line 91: | Line 91: | ||
for( i = 0; i < SDL_NumJoysticks(); i++) { | for( i = 0; i < SDL_NumJoysticks(); i++) { | ||
if (!strcmp(SDL_JoystickName(i), "nub0")) | if (!strcmp(SDL_JoystickName(i), "nub0")) | ||
− | + | left_nub = SDL_JoystickOpen(i); | |
+ | |||
else if (!strcmp(SDL_JoystickName(i), "nub1")) | else if (!strcmp(SDL_JoystickName(i), "nub1")) | ||
− | + | right_nub = SDL_JoystickOpen(i); | |
} | } | ||
#endif | #endif | ||
</source> | </source> |
Latest revision as of 04:38, 17 August 2012
Contents
Gaming buttons
The pandora gaming buttons are mapped to certain keyboards keys. Here is the list :
Button | SDLK key code |
---|---|
A | SDLK_HOME |
B | SDLK_END |
X | SDLK_PAGEDOWN |
Y | SDLK_PAGEUP |
START | SDLK_LALT |
SELECT | SDLK_LCTRL |
L | SDLK_RSHIFT |
R | SDLK_RCTRL |
Working with the nubs
The nubs can be used as mouse or as joystick and can be set independly one from the other. Here is the list of available mode :
Mode | Description |
---|---|
mouse | For mouse mouvements |
mbuttons | Mouse buttons |
scroll | like a 4d mouse wheel |
absolute | Joystick mode |
for more informations see the Nubs.
Changing nub status in a start script
Here is the best way to set the nubs in joystick mode :
export NUB0MODE=`cat /proc/pandora/nub0/mode`
export NUB1MODE=`cat /proc/pandora/nub1/mode`
if [ -e /usr/pandora/scripts/op_nubchange.sh ]; then
/usr/pandora/scripts/op_nubchange.sh absolute absolute
else
echo absolute > /proc/pandora/nub0/mode
echo absolute > /proc/pandora/nub1/mode
fi
# start your app here
# now revert them to the original state
if [ -e /usr/pandora/scripts/op_nubchange.sh ]; then
/usr/pandora/scripts/op_nubchange.sh $NUB0MODE $NUB1MODE
else
echo $NUB0MODE > /proc/pandora/nub0/mode
echo $NUB1MODE > /proc/pandora/nub1/mode
fi
Finding the nub using SDL
// Joystick vars
#ifdef PANDORA
static SDL_Joystick *left_nub = NULL;
static SDL_Joystick *right_nub = NULL;
#endif
// Initialisation code
#ifdef PANDORA
int i = 0;
for( i = 0; i < SDL_NumJoysticks(); i++) {
if (!strcmp(SDL_JoystickName(i), "nub0"))
left_nub = SDL_JoystickOpen(i);
else if (!strcmp(SDL_JoystickName(i), "nub1"))
right_nub = SDL_JoystickOpen(i);
}
#endif