Guest User

Untitled

a guest
Jan 21st, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. struct ClassName
  2. {
  3. static SDL_Joystick* controller;
  4. static Sint16 axis_x, axis_y;
  5.  
  6. inline static void set_axis(const SDL_Event& e)
  7. {
  8. if(e.jaxis.which == 0) {
  9. axis_x = SDL_JoystickGetAxis(controller, 0); // 0 indicates x
  10. axis_y = SDL_JoystickGetAxis(controller, 1); // 1 indicates y
  11. }
  12. }
  13. };
  14.  
  15. while(SDL_PollEvent(&e)) {
  16. // ..
  17. if(ClassName::controller)
  18. if(e.type == SDL_JOYAXISMOTION) ClassName::set_axis(e);
  19. }
  20.  
  21. printf("X: %d Y: %dn", ClassName::axis_x, ClassName::axis_y);
Add Comment
Please, Sign In to add comment