Welcome! Log In Create A New Profile

Advanced

Wii SDL non-hat wiimote dpad?

Posted by Cypri 
Wii SDL non-hat wiimote dpad?
September 09, 2010 05:33PM
Okay, so I'm porting a old game of mine to the Wii, and having some problems. I'm trying to get the dpad to work on the Wiimote when no other devices are plugged into it. Right now it works for up and down, but not left and right. and when I plug in a nunchuck up and down work as if they were left and right. This is the code I got so far:

SDL_Event event;
        while (SDL_PollEvent(&event))
        {
            // Close window : exit
            if( event.type == SDL_QUIT )
                    done = true ;

            else if (event.type == SDL_KEYDOWN )
            {
    	    	keys[event.key.keysym.sym] = true;
            }

            else if (event.type == SDL_KEYUP )
            {
    			keys[event.key.keysym.sym] = false;
            } 
            
            else if(event.type == SDL_JOYBUTTONDOWN){
                 
                if(event.jbutton.button == 3)
                    keys[WPAD_BUTTON_2] = true;
                     
                if(event.jbutton.button == 2)
                    keys[WPAD_BUTTON_1] = true;
                     
                if(event.jbutton.button == 5)
                    keys[WPAD_BUTTON_PLUS] = true;
					 
				if(event.jbutton.button == 6)
                    keys[WPAD_BUTTON_HOME] = true;
            }
            
            else if(event.type == SDL_JOYBUTTONUP){
                 
                if(event.jbutton.button == 3)
                    keys[WPAD_BUTTON_2] = false;
                     
                if(event.jbutton.button == 2)
                    keys[WPAD_BUTTON_1] = false;
                     
                if(event.jbutton.button == 5)
                    keys[WPAD_BUTTON_PLUS] = false;
					 
				if(event.jbutton.button == 6)
                    keys[WPAD_BUTTON_HOME] = false;
            }
            
            else if(event.type == SDL_JOYHATMOTION){
                if(event.jhat.value & SDL_HAT_LEFT)
                    keys[WPAD_BUTTON_LEFT] = true;
                    
                else
                    keys[WPAD_BUTTON_LEFT] = false;  
           
                if(event.jhat.value & SDL_HAT_RIGHT)
                    keys[WPAD_BUTTON_RIGHT] = true;
                    
                else
                    keys[WPAD_BUTTON_RIGHT] = false;
                    
                if(event.jhat.value & SDL_HAT_UP)
                    keys[WPAD_BUTTON_UP] = true;
                    
                else
                    keys[WPAD_BUTTON_UP] = false;
                    
                if(event.jhat.value & SDL_HAT_DOWN)
                    keys[WPAD_BUTTON_DOWN] = true;
                    
                else
                    keys[WPAD_BUTTON_DOWN] = false;  
            }
            
           
        }
Sorry, only registered users may post in this forum.

Click here to login