home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / joystick / convert.bas < prev    next >
BASIC Source File  |  1993-08-23  |  1KB  |  40 lines

  1. DefInt A-Z
  2. Dim lpoint As pointapi
  3.  
  4. Sub convert (x As Integer, y As Integer, thisform As Form)
  5. '***************************************
  6. ' Convert joystick coordinates to client window coordinates
  7. ' Returns client windows coordinates in type winpoint
  8. '***************************************
  9. 'width=8175,height=6105
  10.  
  11. If need_calibrate Then
  12.     deltax = thisform.ScaleWidth / xmax
  13.     deltay = thisform.ScaleHeight / ymax
  14. End If
  15.  
  16. winpoint.x = winxmin + Int(x * deltax)
  17. 'Debug.Print "winx="; winpoint.x; "winxmax="; winxmax
  18.  
  19.  
  20. winpoint.y = winymin + Int(y * deltay)
  21. 'Debug.Print "winy="; winpoint.y; "winymax="; winymax
  22. If Not need_calibrate Then
  23.     If winpoint.x > winxmax Then
  24.         winpoint.x = winxmax - 10
  25.         'x = xmax
  26.     End If
  27.     If winpoint.x < winxmin Then winpoint.x = winxmin + 1
  28.     If winpoint.y < winymin Then winpoint.y = winymin + 1
  29.     If winpoint.y > winymax Then winpoint.y = winymax - 10
  30. End If
  31. lpoint.x = winpoint.x / screen.TwipsPerPixelX
  32. lpoint.y = winpoint.y / screen.TwipsPerPixelY
  33. clienttoscreen thisform.hWnd, lpoint' set to screen coords
  34. setcursorpos lpoint.x, lpoint.y' set cursor
  35.  
  36.  
  37.  
  38. End Sub
  39.  
  40.