Advertisement
apolloandmatt

Modified GetMouseGesture function thanks to GPT :)

Feb 13th, 2023
1,266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. GetMouseGesture(reset := false) {
  2.   Static
  3.   mousegetpos, xpos2, ypos2
  4.   dx := xpos2 - xpos1
  5.   dy := ypos1 - ypos2
  6.   if (gesture = "") {
  7.       if (abs(dx) > abs(dy)) {
  8.           axis := "h"
  9.       } else {
  10.           axis := "v"
  11.       }
  12.   }
  13.   if (axis = "h" and abs(dy) >= abs(dx)) {
  14.       track := ""
  15.   } else if (axis = "v" and abs(dx) >= abs(dy)) {
  16.       track := ""
  17.   } else {
  18.       if (abs(dy) >= abs(dx)) {
  19.           track := (dy > 0 ? "U" : "D")
  20.       } else {
  21.           track := (dx > 0 ? "R" : "L")
  22.       }
  23.   }
  24.   xpos1 := xpos2
  25.   ypos1 := ypos2
  26.   if (track <> SubStr(gesture, 0, 1)) {
  27.       gesture := gesture . track
  28.   }
  29.   gesture := reset ? "" : gesture
  30.   Return gesture
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement