[SDL] game controller axes misbehaving at application startup
Artem Baguinski
artm at v2.nl
Fri Oct 6 11:13:56 PDT 2006
hmm... anybody using joysticks with SDL at all?
to make it easy on everyone, here is my test program and its output
(in reaction to my pushing the joystick left, relasing, right,
releasing, up, releasing, down, releasing).
could somebody test it and send the output?
----(sdljoy.c)----
#include <stdio.h>
#include <assert.h>
#include <SDL.h>
int
main(int argc,char**argv)
{
assert (SDL_Init(SDL_INIT_VIDEO|// need video for events
SDL_INIT_JOYSTICK) == 0);
atexit(SDL_Quit);
SDL_Joystick * joy = NULL;
if(SDL_NumJoysticks()>0){
joy = SDL_JoystickOpen(0);
assert(joy);
SDL_JoystickEventState(SDL_ENABLE);
}
while(1) {
SDL_Event ev;
while(SDL_PollEvent(&ev)) {
switch(ev.type) {
case SDL_KEYDOWN:
switch(ev.key.keysym.sym) {
case SDLK_ESCAPE:
exit(0);
break;
}
case SDL_JOYAXISMOTION:
printf("jaxis: which=%u axis=%u value=%d\n", ev.jaxis.which,
ev.jaxis.axis, ev.jaxis.value);
break;
}
}
}
}
----(output of ./sdljoy)----
jaxis: which=0 axis=0 value=0
jaxis: which=0 axis=0 value=-32768
jaxis: which=0 axis=0 value=32767
jaxis: which=0 axis=0 value=32254
jaxis: which=0 axis=0 value=32767
jaxis: which=0 axis=0 value=128
jaxis: which=0 axis=0 value=-32768
jaxis: which=0 axis=0 value=128
jaxis: which=0 axis=0 value=32767
jaxis: which=0 axis=0 value=128
jaxis: which=0 axis=1 value=0
jaxis: which=0 axis=1 value=-32768
jaxis: which=0 axis=1 value=32767
jaxis: which=0 axis=1 value=32254
jaxis: which=0 axis=1 value=32767
jaxis: which=0 axis=1 value=128
jaxis: which=0 axis=1 value=-32768
jaxis: which=0 axis=1 value=128
jaxis: which=0 axis=1 value=32767
jaxis: which=0 axis=1 value=128
On 5 Oct 2006, at 01:44, Artem Baguinski wrote:
> hi
>
> i'm trying to add game controller support to my sdl based game and
> I'm more or less done except for the following:
>
> each time the program starts up and i push the stick, say, left
> (axis 0 reads -32767) and then release it, the axis 0 reads 32767 -
> as if i pushed it right all the way. only after I also pushed the
> stick right does it seem to figure out where the center is and
> settle to some number close to zero.
>
> the same is true for the vertical axis and other order (first push
> right).
>
> i'm using SDL 1.2.11 form darwin ports on mac os. my game
> controller is speedlink's Hornet Force Pad Touch Edition (SL-6526)
>
> http://www.nobilis-informatika.hr/php/proizvod.php?
> kat_id=83&pro_id=1843
>
> (can't find it at speedlink website)
>
> is this normal behaviour? can i work around it?
>
>
More information about the SDL
mailing list