Hi,

I've posted your test program to the ubuntu bug, and also sent it along to
the SDL mailing list.

The best chance of getting joystick working in the short term(6-12 months)
however is to include a python joystick implementation in pygame.

I know there's been some implementations floating around...  I'll ask Simon
Wittber if he wants to contribute what he has done to pygame... and maybe we
can modify that to work well enough.


My mission tomorrow will be to buy another joystick, so I can debug it
myself... damn... I had two of them last time I moved... and also 6 dance
mats... but now nothing.



cu.




On Sat, May 16, 2009 at 1:58 AM, pymike <[email protected]> wrote:

> It's definitely SDL. I made a demo that checks for hats, hat presses, and
> button presses. Output:
>
> Name of joystick: Logitech Logitech Dual Action
> Number of hats: 0
> Number of buttons: 12
> Number of balls: 0
> 1 was released
> 2 was released
> 1 was pressed
> 1 was released
> 2 was pressed
> 2 was released
>
> Here's the code:
>
> #include "SDL/SDL.h"
>
> int main() {
>     SDL_Init(SDL_INIT_JOYSTICK|SDL_INIT_VIDEO);
>     SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);
>     SDL_Joystick *joy;
>     joy = SDL_JoystickOpen(0);
>     printf("Name of joystick: %s\n", SDL_JoystickName(0));
>     printf("Number of hats: %d\n", SDL_JoystickNumHats(joy));
>     printf("Number of buttons: %d\n", SDL_JoystickNumButtons(joy));
>     printf("Number of balls: %d\n", SDL_JoystickNumBalls(joy));
>
>     SDL_Event event;
>     Uint8 hat_state;
>
>     int running = 1;
>     while( running ) {
>
>         SDL_JoystickUpdate();
>
>         hat_state = SDL_JoystickGetHat(0, 0);
>         if( hat_state == SDL_HAT_UP )
>             printf("Hat is pointing up");
>
>         while(SDL_PollEvent(&event)) {
>             switch(event.type) {
>                 case SDL_QUIT:
>                     running = 0;
>                     break;
>                 case SDL_KEYDOWN:
>                     switch(event.key.keysym.sym) {
>                         case SDLK_ESCAPE:
>                             running = 0;
>                             break;
>                         default:
>                             break;
>                     }
>
>                     break;
>                 case SDL_JOYBUTTONDOWN:
>                     switch(event.jbutton.button) {
>                         case 1:
>                             printf("1 was pressed\n");
>                             break;
>                         case 2:
>                             printf("2 was pressed\n");
>                             break;
>                     }
>
>                     break;
>                 case SDL_JOYBUTTONUP:
>                     switch(event.jbutton.button) {
>                         case 1:
>                             printf("1 was released\n");
>                             break;
>                         case 2:
>                             printf("2 was released\n");
>                             break;
>                     }
>
>                     break;
>             }
>         }
>     }
>
>     SDL_Quit();
>     return 1;
> }
>
>
> --
> - pymike
>

Reply via email to