M-.-n posted on May 25 2006 at 11:14 AM said:
I don't know about FW1.4 .. but It seems I've lost the L&R shoulder in SDL_JoysticGetButton(). can anyone confirm ?
Just tested it, all the buttons register. I'm not sure why, but the physical buttons don't seem to be mapped according to the code.
The code says that the first four buttons are UP, UP_LEFT, UP_RIGHT, DOWN whereas when reading them with JoystickGetButton() they are in the order UP, UP_LEFT, LEFT, DOWN_LEFT (and continue anti-clockwise). Other buttons appear to be in different places too... Strange.
The order I'm getting is:
Updated - I was compiling against a different version
0 = UP; 1 = UP_LEFT, 2 = LEFT, 3 = DOWN_LEFT
4 = DOWN, 5 = DOWN_RIGHT, 6 = RIGHT, 7 = UP-RIGHT
8 = START, 9 = SELECT, 10 = R_SHOULDER, 11 = L_SHOULDER
12 = A, 13 = B, 14 = Y, 15 = X,
16 = VOL+, 17 = VOL-, 18 = JOY_PUSH
This conforms to GPH's latest SDL version.
Also if you download as of now, I've added the code to switch backlight on/off (you'll also need to get
this header file and copy it over to ${GP2XDEV}/include/SDL/ or where ever you keep SDL's includes.
The new function is SDL_SYS_JoystickGp2xSys(joystick0, cmd); where joystick0 is the value returned from SDL_JoystickOpen(0), and cmd is either BACK_LIGHT_ON or BACK_LIGHT_OFF. You
must open joystick(0) for this to work, else you'll crash you're program!
The reason it's tied to joystick0 is that it uses /dev/GPIO which joystick(0) also uses. Plus you need to open the joystick to pretty much anything anyway
Also you can pass BATT_LED_ON or BATT_LED_OFF to turn the red LED on and off.
And as a real bonus it can change the clock speed too if you pass one of:
FCLK_200, FCLK_166, FCLK_133, FCLK_100, FCLK_78, FCLK_64, or FCLK_DEFAULT
I've been meaning to put these in for ages but kept forgetting, fw2.0's SDL has implemented them so I've used the same function & defines (although they have SDL_SYS_JoystickBackLight() which is exactly the same, I've not used that name as it doesn't make sense if you're not adjusting the backlight.)