Guest User

Untitled

a guest
Oct 21st, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1.  
  2. void LocalEvent::HandleJoystickAxisEvent(SDL_JoyAxisEvent & event) {
  3. int step;
  4. int value = event.value >> 8;
  5.  
  6. if (event.axis != 0 && event.axis != 1)
  7. return;
  8.  
  9. if (value > 0x20)
  10. step = value - 0x20;
  11. else if (value < -0x20)
  12. step = value + 0x20;
  13. else
  14. step = 0;
  15.  
  16. if (event.axis == 0)
  17. emulate_joy_step_x = step;
  18. else
  19. emulate_joy_step_y = step;
  20. }
  21.  
  22. bool LocalEvent::EmulateJoystickAxisMove(void) {
  23. ResetModes(MOUSE_MOTION);
  24.  
  25. if (emulate_joy_step_x != 0 || emulate_joy_step_y != 0) {
  26. mouse_cu.x += emulate_joy_step_x / 0x10;
  27. mouse_cu.y += emulate_joy_step_y / 0x10;
  28. SetModes(MOUSE_MOTION);
  29.  
  30. if(mouse_cu.x < 0) mouse_cu.x = 0;
  31. if(mouse_cu.y < 0) mouse_cu.y = 0;
  32. if(mouse_cu.x > Display::Get().w()) mouse_cu.x = Display::Get().w();
  33. if(mouse_cu.y > Display::Get().h()) mouse_cu.y = Display::Get().h();
  34.  
  35. if((modes & MOUSE_MOTION) && redraw_cursor_func)
  36. {
  37. if(modes & MOUSE_OFFSET)
  38. (*(redraw_cursor_func))(mouse_cu.x + mouse_st.x, mouse_cu.y + mouse_st.y);
  39. else
  40. (*(redraw_cursor_func))(mouse_cu.x, mouse_cu.y);
  41. }
  42. return true;
  43. }
  44.  
  45. return false;
  46. }
Add Comment
Please, Sign In to add comment