CPP/SDL2/Windows - No Reaction to SDL_JOYHATMOTION


#1

Good Evening.
Asked allrdy on Stackoverflow, not sure if they can Help:
Got a mainloop, one event is a eventhandler (Pollevent, handling the events with a switch). While i’m under linux, everything is fine, nice, and working as intended. Under Windows, everything works - except of reacting to the SDL_JOYHATMOTION-Event.
My Initialisation of the Gamepad:

SDL_Joystick* Pad1 = NULL;

`Pad1 = SDL_JoystickOpen( 0 );` 

Part of my EventHandler:

 switch( event.type ){
 //Button-Event, as an example:
    case SDL_JOYBUTTONDOWN:
        //printf("Button: %d", event.jbutton.button, " ");
        if(event.jbutton.button==ControllP1.MoveLeftButton)
            MoveLeft=true;
 //lot of other cases

        case SDL_JOYHATMOTION:
            if(event.jhat.value==SDL_HAT_UP){MoveUp=true;MoveLeft=false; MoveRight=false; MoveDown=false;}
            if(event.jhat.value==SDL_HAT_DOWN){MoveDown=true;MoveUp=false; MoveLeft=false; MoveRight=false;}
            if(event.jhat.value==SDL_HAT_LEFT){MoveLeft=true; MoveDown=false; MoveUp=false; MoveRight=false;}
            if(event.jhat.value==SDL_HAT_RIGHT){MoveRight=true;MoveDown=false; MoveUp=false; MoveLeft=false; }
            if(event.jhat.value==SDL_HAT_CENTERED){MoveDown=false; MoveUp=false; MoveLeft=false; MoveRight=false;}
            if(event.jhat.value==SDL_HAT_LEFTUP){MoveDown=false; MoveUp=true; MoveLeft=true; MoveRight=false;}
            if(event.jhat.value==SDL_HAT_RIGHTUP){MoveDown=false; MoveUp=true; MoveLeft=false; MoveRight=true;}
            if(event.jhat.value==SDL_HAT_RIGHTDOWN){MoveDown=true; MoveUp=false; MoveLeft=false; MoveRight=true;}
            if(event.jhat.value==SDL_HAT_LEFTDOWN){MoveDown=true; MoveUp=false; MoveLeft=true; MoveRight=false;}
            break;

Any Idea what could cause such a problem? Again: Reading out Buttonpresses, Axis-Events, or Key/Mouse-Events in the very same pattern does work fine.

Thanks and Greetings
Mumbo


#2

Hi.
Problem Solved: An Update of the SDL2.dll on the target machine made my Hat working as intended.

Greetings Mumbo