Wii SDL non-hat wiimote dpad? September 09, 2010 05:33PM | Registered: 14 years ago Posts: 29 |
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; } }