home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / VISUAL_B / CODIGO_1 / JOYSTICK / JOYTEST.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-09-05  |  7.6 KB  |  230 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   5220
  5.    ClientLeft      =   1245
  6.    ClientTop       =   1815
  7.    ClientWidth     =   8175
  8.    FillStyle       =   0  'Solid
  9.    Height          =   5880
  10.    Left            =   1200
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   5220
  13.    ScaleWidth      =   8175
  14.    Top             =   1200
  15.    Width           =   8265
  16.    Begin CommandButton Command1 
  17.       Caption         =   "Capture Joystick"
  18.       Height          =   315
  19.       Left            =   2760
  20.       TabIndex        =   4
  21.       Top             =   2040
  22.       Width           =   1785
  23.    End
  24.    Begin PictureBox Picture1 
  25.       AutoSize        =   -1  'True
  26.       BorderStyle     =   0  'None
  27.       Height          =   420
  28.       Left            =   210
  29.       Picture         =   JOYTEST.FRX:0000
  30.       ScaleHeight     =   420
  31.       ScaleWidth      =   420
  32.       TabIndex        =   0
  33.       Top             =   180
  34.       Width           =   420
  35.    End
  36.    Begin Joystick Joystick1 
  37.       Left            =   3900
  38.       Top             =   180
  39.    End
  40.    Begin Label Label7 
  41.       Alignment       =   1  'Right Justify
  42.       Caption         =   "Judy Summers"
  43.       Height          =   255
  44.       Index           =   1
  45.       Left            =   5280
  46.       TabIndex        =   11
  47.       Top             =   480
  48.       Width           =   2655
  49.    End
  50.    Begin Label Label7 
  51.       Alignment       =   1  'Right Justify
  52.       Caption         =   "Zane Thomas"
  53.       Height          =   255
  54.       Index           =   0
  55.       Left            =   5280
  56.       TabIndex        =   10
  57.       Top             =   120
  58.       Width           =   2655
  59.    End
  60.    Begin Label Label6 
  61.       Caption         =   "The property named Period is used to set the amount of time in milliseconds that the joystick driver uses for checking position and button status. The other properties should be more-or-less obvious. You can expirement by setting Capture to True in the Properties Window and changing/observing the other properties. Good Luck!"
  62.       Height          =   765
  63.       Left            =   210
  64.       TabIndex        =   9
  65.       Top             =   4140
  66.       Width           =   7785
  67.    End
  68.    Begin Label Label5 
  69.       Caption         =   "Joystick_ButtonUp( Button As Integer )"
  70.       Height          =   285
  71.       Left            =   360
  72.       TabIndex        =   8
  73.       Top             =   3720
  74.       Width           =   6795
  75.    End
  76.    Begin Label Label4 
  77.       Caption         =   "Joystick_ButtonDown( Button As Integer )"
  78.       Height          =   285
  79.       Left            =   360
  80.       TabIndex        =   7
  81.       Top             =   3300
  82.       Width           =   6705
  83.    End
  84.    Begin Label Label2 
  85.       Caption         =   "Joystick_Move( X As Integer, Y As Integer, Z As Integer)"
  86.       Height          =   285
  87.       Left            =   360
  88.       TabIndex        =   6
  89.       Top             =   2880
  90.       Width           =   6675
  91.    End
  92.    Begin Label Label1 
  93.       Caption         =   "Once the joystick has been captured there are three events that may be generated:"
  94.       Height          =   285
  95.       Index           =   2
  96.       Left            =   240
  97.       TabIndex        =   5
  98.       Top             =   2460
  99.       Width           =   7755
  100.    End
  101.    Begin Label Label1 
  102.       Caption         =   "Before the control will generate events, or update the position properties you must enable it by setting Capture to True. Press the following button to set Capture to True/False. "
  103.       Height          =   495
  104.       Index           =   1
  105.       Left            =   210
  106.       TabIndex        =   3
  107.       Top             =   1470
  108.       Width           =   7815
  109.    End
  110.    Begin Label Label1 
  111.       Caption         =   "Joystick.Vbx contains a fully functional joystick control. Using this control you can easily  respond to joystick movements and button presses."
  112.       Height          =   495
  113.       Index           =   0
  114.       Left            =   210
  115.       TabIndex        =   2
  116.       Top             =   870
  117.       Width           =   7785
  118.    End
  119.    Begin Label Label3 
  120.       Caption         =   "Joystick Control"
  121.       FontBold        =   -1  'True
  122.       FontItalic      =   0   'False
  123.       FontName        =   "MS Sans Serif"
  124.       FontSize        =   18
  125.       FontStrikethru  =   0   'False
  126.       FontUnderline   =   0   'False
  127.       Height          =   495
  128.       Left            =   810
  129.       TabIndex        =   1
  130.       Top             =   150
  131.       Width           =   2925
  132.    End
  133.    Begin Menu mnucalibrate 
  134.       Caption         =   "&Calibrate"
  135.    End
  136.    Begin Menu mnujoy 
  137.       Caption         =   "&Joystick"
  138.       Begin Menu mnucapture 
  139.          Caption         =   "&Capture"
  140.       End
  141.       Begin Menu mnurelease 
  142.          Caption         =   "&Release"
  143.       End
  144.    End
  145.    Begin Menu mnugame 
  146.       Caption         =   "&Game"
  147.    End
  148. Dim lpoint As pointapi
  149. Sub Command1_Click ()
  150.     joystick1.Capture = Not joystick1.Capture
  151.     If (joystick1.Capture) Then
  152.         command1.Caption = "Release Joystick"
  153.     Else
  154.         command1.Caption = "Capture Joystick"
  155.     End If
  156. End Sub
  157. Sub Form_Load ()
  158. command1.Value = True
  159. winxmax = form1.ScaleLeft + form1.ScaleWidth
  160. winxmin = form1.ScaleLeft
  161. winymin = form1.ScaleTop
  162. winymax = form1.ScaleTop + form1.ScaleHeight
  163. mnugame.Enabled = False
  164. mousepointer = 2
  165. xmax = getprivateprofileint("joytest", "xmax", -1, "joytest.ini")
  166. If xmax = -1 Then
  167.     xmax = 10000
  168.     ymax = 10000
  169.     need_calibrate = True
  170.     Exit Sub
  171. End If
  172. xmin = getprivateprofileint("joytest", "xmin", -1, "joytest.ini")
  173. ymax = getprivateprofileint("joytest", "ymax", -1, "joytest.ini")
  174. ymin = getprivateprofileint("joytest", "ymin", -1, "joytest.ini")
  175. deltax = form1.ScaleWidth / xmax
  176. deltay = form1.ScaleHeight / ymax
  177. mnugame.Enabled = True
  178. End Sub
  179. Sub Joystick1_ButtonDown (button As Integer)
  180.     button_mark = True
  181.     Label4.Caption = "Joystick_ButtonDown(" & Str(button) & " )"
  182.     Label4.ForeColor = RGB(255, 0, 0)
  183.     If need_calibrate Then Exit Sub
  184.     Select Case button
  185.         Case 1
  186.             Circle (winpoint.x, winpoint.y), 80, RGB(0, 0, 0)
  187.             fillcolor = RGB(255, 0, 0)
  188.         Case 2
  189.             Circle (winpoint.x, winpoint.y), 80, RGB(0, 0, 0)
  190.             fillcolor = RGB(0, 255, 0)
  191.     End Select
  192. End Sub
  193. Sub Joystick1_ButtonUp (button As Integer)
  194.     Label5.Caption = "Joystick_ButtonUp(" & Str(button) & " )"
  195.     Label4.ForeColor = 0
  196. End Sub
  197. Sub Joystick1_Move (x As Integer, y As Integer, z As Integer)
  198.     calx = x
  199.     caly = y
  200.     If need_calibrate Then
  201.         Call calibrate(form1)
  202.         If need_calibrate <> True Then
  203.             t = writeprivateprofilestring("joytest", "xmax", ByVal Format$(xmax), "joytest.ini")
  204.             t = writeprivateprofilestring("joytest", "ymax", ByVal Format$(ymax), "joytest.ini")
  205.             t = writeprivateprofilestring("joytest", "xmin", ByVal Format$(xmin), "joytest.ini")
  206.             t = writeprivateprofilestring("joytest", "ymin", ByVal Format$(ymin), "joytest.ini")
  207.         End If
  208.         mnugame.Enabled = True
  209.         Exit Sub
  210.     End If
  211.     label2.Caption = "Joystick1_Move(" & Str(x) & "," & Str(y) & "," & Str(z) & ")"
  212.     convert x, y, form1
  213. End Sub
  214. Sub mnucalibrate_Click ()
  215.     xmax = 10000
  216.     ymax = 10000
  217.     need_calibrate = True
  218. End Sub
  219. Sub mnucapture_Click ()
  220. joystick1.Capture = True
  221. End Sub
  222. Sub mnugame_Click ()
  223. joystick1.Capture = False
  224. Unload form1
  225. gameform.Show
  226. End Sub
  227. Sub mnurelease_Click ()
  228. joystick1.Capture = False
  229. End Sub
  230.