Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct ClassName
- {
- static SDL_Joystick* controller;
- static Sint16 axis_x, axis_y;
- inline static void set_axis(const SDL_Event& e)
- {
- if(e.jaxis.which == 0) {
- axis_x = SDL_JoystickGetAxis(controller, 0); // 0 indicates x
- axis_y = SDL_JoystickGetAxis(controller, 1); // 1 indicates y
- }
- }
- };
- while(SDL_PollEvent(&e)) {
- // ..
- if(ClassName::controller)
- if(e.type == SDL_JOYAXISMOTION) ClassName::set_axis(e);
- }
- printf("X: %d Y: %dn", ClassName::axis_x, ClassName::axis_y);
Add Comment
Please, Sign In to add comment