Advertisement
Guest User

Untitled

a guest
Oct 1st, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. gLastX = deviceaxis(deviceHandle, 0); // 0 = X axis (left/right)
  2. gLastY = deviceaxis(deviceHandle, 1); // 1 = Y axis (up/down)
  3. gLastZ = deviceaxis(deviceHandle, 2); // 2 = Z axis (in/out)
  4.  
  5. gSendW = inputsender(KEY_W);
  6. gSendA = inputsender(KEY_A);
  7. gSendS = inputsender(KEY_S);
  8. gSendD = inputsender(KEY_D);
  9.  
  10. function HapticsThink (deviceHandle)
  11. {
  12. local currentX = deviceaxis(deviceHandle, 0); // 0 = X axis (left/right)
  13. local currentY = deviceaxis(deviceHandle, 1); // 1 = Y axis (up/down)
  14. local currentZ = deviceaxis(deviceHandle, 2); // 2 = Z axis (in/out)
  15.  
  16. // Just crossed left edge
  17. if (gLastX > -100 && currentX <= -100)
  18. {
  19. gSendA.press();
  20. }
  21. else if (gLastX <= -100 && currentX > -100) //uncrossed left edge
  22. {
  23. gSendA.release();
  24. }
  25.  
  26. // Just crossed right edge
  27. if (gLastX < 100 && currentX >= 100)
  28. {
  29. gSendD.press();
  30. }
  31. else if (gLastX >= 100 && currentX < 100) //uncrossed right edge
  32. {
  33. gSendD.release();
  34. }
  35.  
  36. // Just crossed top edge
  37. if (gLastY < 100 && currentY >= 100)
  38. {
  39. gSendW.press();
  40. }
  41. else if (gLastY >= 100 && currentY < 100) //uncrossed top edge
  42. {
  43. gSendW.release();
  44. }
  45.  
  46. // Just crossed bottom edge
  47. if (gLastY > -100 && currentY <= -100)
  48. {
  49. gSendS.press();
  50. }
  51. else if (gLastY <= -100 && currentY > -100) //uncrossed bottom edge
  52. {
  53. gSendS.release();
  54. }
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement