void JoystickKeyboardController::process_event(const SDL_Event& event) { switch(event.type) { case SDL_KEYUP: case SDL_KEYDOWN: process_key_event(event.key); break; case SDL_JOYAXISMOTION: process_axis_event(event.jaxis); break; case SDL_JOYHATMOTION: process_hat_event(event.jhat); break; case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP: process_button_event(event.jbutton); break; default: break; } }
void GameSession::update(const Input::Event& event) { GUIScreen::update(event); //std::cout << "Events: " << event.get_type () << std::endl; switch (event.type) { case Input::BUTTON_EVENT_TYPE: { const Input::ButtonEvent& ev = event.button; if (ev.state == Input::BUTTON_PRESSED) { if (ev.name >= Input::ACTION_1_BUTTON && ev.name <= Input::ACTION_10_BUTTON) { button_panel->set_button(ev.name - Input::ACTION_1_BUTTON); } else if (ev.name == Input::ACTION_DOWN_BUTTON) { button_panel->next_action(); } else if (ev.name == Input::ACTION_UP_BUTTON) { button_panel->previous_action(); } } } break; case Input::POINTER_EVENT_TYPE: // Ignore, is handled in GUIScreen break; case Input::AXIS_EVENT_TYPE: // ??? process_axis_event (event.axis); break; case Input::SCROLLER_EVENT_TYPE: process_scroll_event(event.scroll); break; case Input::KEYBOARD_EVENT_TYPE: break; default: // unhandled event std::cout << "GameSession::process_events (): unhandled event: " << event.type << std::endl; break; } }