Joystick wird nicht erkannt ? - Bin am verzweifeln


scachi

Member
Joined
Dec 28, 2005
Messages
451
Hallo Leute,

ich kappiere es nicht. Ich verbringe jetzt schon Tage damit herumzubasteln damit ich unter Linux einen cross compiler habe mit dem ich diese Teil da unten als static kompilieren kann und es den Joystick auf der gp2x erkennt.
Was muss ich beim cross-compilieren von SDL anstellen damit der Joystick funktionert ?
Oder ist der Code falsch ?
Das ganze kompiliert ohne Fehler, nur will der Stick nicht.

Bitte erlöst mich von meinem Leiden ;)
Code:
#include <SDL.h>
#include <stdio.h>

#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#define SCREEN_DEPTH 8

SDL_Joystick *stick;

int main(int argc, char *argv[]) {
    fprintf(stdout,"starte programm\n");
     SDL_Surface *screen;
     Uint8       *p;
     int         x = 10; //x coordinate of our pixel
     int         y = 20; //y coordinate of our pixel
     
     /* Initialize SDL */
    fprintf(stdout,"init sdl\n");
     SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK);
     
     /* Initialize the screen / window */
    fprintf(stdout,"init screen\n");
     screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_DEPTH, SDL_SWSURFACE);
     
     /* update the screen (aka double buffering) */
    fprintf(stdout,"flip screen \n");
     SDL_Flip(screen);
    fprintf(stdout,"oeffne joysticks\n");
    stick=SDL_JoystickOpen(0);
    fprintf(stdout,"Found %d joysticks\n",SDL_NumJoysticks());
    return 0;
}
 
I put your code into j.c, then ran
Code:
luteijn@dollar:~/devel/gp2x/test$ /opt/local/gp2x/bin/arm-linux-gcc -static -o j.gpe  j.c  -I /opt/local/gp2x/include/SDL/ -L /opt/local/gp2x/lib/ -lSDL -lpthread

(you'll have to adjust the paths for your environment)

I copied the thing from my linux machine to gp2x, connected over usb-serial, and ran it:
Code:
bash-2.05a# ./j.gpe

starte programm
init sdl
SDL_SYS_JoystickInit
init screen
flip screen
oeffne joysticks
Found 1 joysticks
bash-2.05a#

So it does work; maybe you're not linking statically and the SDL lib on your device is not supporting the stick?

P.
 
Ich glaube die SDL Lib kann den Stick nicht, zumindest bei mir klappt es auch nicht. Meine Empfehlung: Einfach nicht die SDL verwenden, sondern rlyeh's Minilib...
 
Octoate said:
Der Joystick wird beim GP2x nicht als Joystick erkannt. Er verhaelt sich fuer SDL genau wie ganz normale Tasten einer Tastatur.

That's not really accurate; it is detected as a joystick, but with 0 axis, and 19 fire-buttons (so not keys lie on a keyboard) so you do use joystick functions with it, and you should get '1' joystick detected, as in my example build. The events generated are SDL_JOYBUTTONDOWN/UP events, not SDL_KEYDOWN/UP events.

P.
 
Vielen vielen vielen... Dank .

habe nun aus den theoddbot-libs die SDL genommen
und nun scheint es zu funktionieren.
Es wird erfolgreich 1 Joystick erkannt.
:)
 
Back
Top