Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void InputCore::OnEvent(SDL_Event* pEvent)
- {
- //When this function is called, pEvent will be filled with information regarding
- //an event. By checking the type, we can call our respective virtual functions
- //to make life simpler =D!
- switch(pEvent->type)
- {
- // basically my problem is, that I'm not sure how to implement OnKeyPress()
- case SDL_KEYDOWN:
- OnKeyPress(pEvent->key.keysym.sym, pEvent->key.keysym.mod,
- pEvent->key.keysym.unicode);
- break;
- case SDL_KEYUP:
- OnKeyRelease(pEvent->key.keysym.sym, pEvent->key.keysym.mod,
- pEvent->key.keysym.unicode);
- break;
- case SDL_MOUSEMOTION:
- OnMouseMotion(pEvent->motion.x, pEvent->motion.y,
- pEvent->motion.xrel, pEvent->motion.yrel,
- (pEvent->motion.state & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0,
- (pEvent->motion.state & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0,
- (pEvent->motion.state & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0);
- break;
- case SDL_MOUSEBUTTONDOWN:
- OnMousePress(pEvent->button.button, pEvent->button.x, pEvent->button.y);
- break;
- case SDL_MOUSEBUTTONUP:
- OnMouseRelease(pEvent->button.button, pEvent->button.x, pEvent->button.y);
- break;
- case SDL_ACTIVEEVENT:
- OnFocusChange(pEvent->active.state, pEvent->active.gain);
- break;
- case SDL_VIDEORESIZE:
- OnResize(pEvent->resize.w, pEvent->resize.h);
- break;
- case SDL_QUIT:
- OnExit();
- break;
- default:;
- }
- }
- //this is from my application where I hande input
- void Application::TakeInput(SDL_Event* pEvent)
- {
- //We'll use this function to take input from the user and act upon it
- while(SDL_PollEvent(pEvent))
- {
- OnEvent(pEvent);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement