BUG: Re: SDL joystick ranges have change (Ubuntu)

hello,

I posted a bug at ubuntu here:
https://bugs.launchpad.net/ubuntu/+source/libsdl1.2/+bug/376537

I haven’t posted it to bugzilla.libsdl.org … there’s heaps of joystick
related bugs listed there already. However it doesn’t seem bugs are getting
any attention for SDL 1.2 at this time… so maybe more chance of getting a
ubuntu maintainer to patch their SDL.
http://bugzilla.libsdl.org/buglist.cgi?quicksearch=joystick

Below is a test program in C to show it’s broken (from pymike on the pygame
mailing list). Results from running program are below the C source.

I don’t currently have a joystick to do any further debugging/patching
myself. However will try and pick one up. I stupidly gave mine away when I
last moved! damn.

Maybe this will help someone with a joystick to debug it.

#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;

}

Results from running program:

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

cu,On Sat, Jan 24, 2009 at 8:41 AM, Donny Viszneki <donny.viszneki at gmail.com>wrote:

On Fri, Jan 23, 2009 at 5:19 PM, stuartreynolds wrote:

I do auto calibration also within my app in order to deal with small
variations. There’s a couple of things wrong here though. I can
understand
the need to recalibrate for a different joystick, or for wear on a
joystick.
But this is not what has happened. I shouldn’t need different calibration
if
my app runs with the same hardware. I need to recalibrate here, not
because
of wear and tear or manufacturing variances, but because the software
somewhere between the kernel and SDL changed.

Have you asked Ubuntu people for help?

What’s really screwed up my app is that the calibration routine I broke
because SDL_JoystickGetAxis no longer produces what its docs says it
produces. The docs said it outputs -ve and +ve values, now it only
outputs
+ve values. I’ve fixed my the calibration to workaround this new
behavior.
However, now I get the effect that if I assume my initial best guess of
what
centered was (x=0,y=0) (given valid values from the range (-32768 to

), then this translates into pushing hard along the diagonal if the
actual
range is (0, 255). The result is wacky behavior before the user moves the
joystick.

Is there a commandline interface to dump the raw joystick data? This
might help determine where the problem was introduced.

I kinda feel like this is a driver level issue and that the app shouldn’t
have to deal with it. Providing an abstraction layer is, after all, kind
of
the point of SDL, right?

If Ubuntu has a good reason to force some kind of weird change that
would cause the problems you’re describing, that’s a good reason for
SDL to compensate for it. But I doubt that’s the case.


http://codebad.com/


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

How come you didn’t show axes? On your bug at launchpad.net, you
report that hats and axes are not recognized.On Sat, May 23, 2009 at 3:29 AM, Ren? Dudfield wrote:

I posted a bug at ubuntu here:
https://bugs.launchpad.net/ubuntu/+source/libsdl1.2/+bug/376537

??? 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));
Name of joystick: Logitech Logitech Dual Action
Number of hats: 0
Number of buttons: 12
Number of balls: 0


http://codebad.com/

hi,

indeed! it looks like axes ARE in fact working.

Only hats have stopped working. The bug report has been updated.

cheers,On Sat, May 23, 2009 at 5:33 PM, Donny Viszneki <donny.viszneki at gmail.com> wrote:

On Sat, May 23, 2009 at 3:29 AM, Ren? Dudfield <@Rene_Dudfield> wrote:

I posted a bug at ubuntu here:
https://bugs.launchpad.net/ubuntu/+source/libsdl1.2/+bug/376537

??? 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));
Name of joystick: Logitech Logitech Dual Action
Number of hats: 0
Number of buttons: 12
Number of balls: 0

How come you didn’t show axes? On your bug at launchpad.net, you
report that hats and axes are not recognized.


http://codebad.com/

Can you please confirm the bug with the SDL test program testjoystick?On Sun, May 24, 2009 at 1:40 AM, Ren? Dudfield wrote:

indeed! ?it looks like axes ARE in fact working.

Only hats have stopped working. ?The bug report has been updated.


http://codebad.com/