home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / VBSamples / Demos / AirHockey / frmInput.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-10-08  |  9.2 KB  |  255 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Begin VB.Form frmInput 
  4.    BorderStyle     =   4  'Fixed ToolWindow
  5.    Caption         =   "Input Options"
  6.    ClientHeight    =   3360
  7.    ClientLeft      =   45
  8.    ClientTop       =   285
  9.    ClientWidth     =   6405
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   3360
  14.    ScaleWidth      =   6405
  15.    ShowInTaskbar   =   0   'False
  16.    StartUpPosition =   1  'CenterOwner
  17.    Begin VB.Frame Frame1 
  18.       Caption         =   "Controllers"
  19.       Height          =   2715
  20.       Left            =   60
  21.       TabIndex        =   8
  22.       Top             =   120
  23.       Width           =   6255
  24.       Begin MSComctlLib.Slider sldSens 
  25.          Height          =   195
  26.          Left            =   1080
  27.          TabIndex        =   5
  28.          Top             =   2400
  29.          Width           =   4995
  30.          _ExtentX        =   8811
  31.          _ExtentY        =   344
  32.          _Version        =   393216
  33.          Min             =   1
  34.          Max             =   50
  35.          SelStart        =   1
  36.          TickFrequency   =   5
  37.          Value           =   1
  38.       End
  39.       Begin VB.ComboBox cboJoy 
  40.          Height          =   315
  41.          Left            =   300
  42.          Style           =   2  'Dropdown List
  43.          TabIndex        =   4
  44.          Top             =   1980
  45.          Width           =   5775
  46.       End
  47.       Begin VB.CheckBox chkJoy 
  48.          Caption         =   "Joystick"
  49.          Height          =   315
  50.          Left            =   60
  51.          TabIndex        =   3
  52.          Top             =   1665
  53.          Width           =   5655
  54.       End
  55.       Begin VB.CheckBox chkKeyboard 
  56.          Caption         =   "Keyboard"
  57.          Height          =   315
  58.          Left            =   60
  59.          TabIndex        =   2
  60.          Top             =   1080
  61.          Width           =   5655
  62.       End
  63.       Begin VB.CheckBox chkMouse 
  64.          Caption         =   "Mouse"
  65.          Height          =   315
  66.          Left            =   120
  67.          TabIndex        =   0
  68.          Top             =   420
  69.          Width           =   5655
  70.       End
  71.       Begin MSComctlLib.Slider sldMouseSens 
  72.          Height          =   195
  73.          Left            =   1140
  74.          TabIndex        =   1
  75.          Top             =   780
  76.          Width           =   4935
  77.          _ExtentX        =   8705
  78.          _ExtentY        =   344
  79.          _Version        =   393216
  80.          Min             =   1
  81.          Max             =   50
  82.          SelStart        =   1
  83.          TickFrequency   =   5
  84.          Value           =   1
  85.       End
  86.       Begin MSComctlLib.Slider sldKeyboard 
  87.          Height          =   195
  88.          Left            =   1125
  89.          TabIndex        =   12
  90.          Top             =   1410
  91.          Width           =   4935
  92.          _ExtentX        =   8705
  93.          _ExtentY        =   344
  94.          _Version        =   393216
  95.          Min             =   1
  96.          Max             =   100
  97.          SelStart        =   1
  98.          TickFrequency   =   5
  99.          Value           =   1
  100.       End
  101.       Begin VB.Label lblKeySens 
  102.          BackStyle       =   0  'Transparent
  103.          Caption         =   "Sensitivity"
  104.          Height          =   255
  105.          Left            =   345
  106.          TabIndex        =   13
  107.          Top             =   1410
  108.          Width           =   735
  109.       End
  110.       Begin VB.Label lblMouseSens 
  111.          BackStyle       =   0  'Transparent
  112.          Caption         =   "Sensitivity"
  113.          Height          =   255
  114.          Left            =   360
  115.          TabIndex        =   11
  116.          Top             =   780
  117.          Width           =   735
  118.       End
  119.       Begin VB.Label lblSens 
  120.          BackStyle       =   0  'Transparent
  121.          Caption         =   "Sensitivity"
  122.          Height          =   255
  123.          Left            =   300
  124.          TabIndex        =   10
  125.          Top             =   2400
  126.          Width           =   735
  127.       End
  128.       Begin VB.Label Label2 
  129.          BackStyle       =   0  'Transparent
  130.          Caption         =   "Here you will select the controllers you wish to use during gameplay."
  131.          Height          =   255
  132.          Index           =   0
  133.          Left            =   120
  134.          TabIndex        =   9
  135.          Top             =   180
  136.          Width           =   4875
  137.       End
  138.    End
  139.    Begin VB.CommandButton cmdOk 
  140.       Caption         =   "OK"
  141.       Default         =   -1  'True
  142.       Height          =   375
  143.       Left            =   5340
  144.       TabIndex        =   7
  145.       Top             =   2940
  146.       Width           =   975
  147.    End
  148.    Begin VB.CommandButton cmdCancel 
  149.       Cancel          =   -1  'True
  150.       Caption         =   "Cancel"
  151.       Height          =   375
  152.       Left            =   4260
  153.       TabIndex        =   6
  154.       Top             =   2940
  155.       Width           =   975
  156.    End
  157. Attribute VB_Name = "frmInput"
  158. Attribute VB_GlobalNameSpace = False
  159. Attribute VB_Creatable = False
  160. Attribute VB_PredeclaredId = True
  161. Attribute VB_Exposed = False
  162. Option Explicit
  163. Private diDevEnum As DirectInputEnumDevices8
  164. Private Sub chkJoy_Click()
  165.     cboJoy.Enabled = (chkJoy.Value = vbChecked)
  166.     lblSens.Enabled = (chkJoy.Value = vbChecked)
  167.     sldSens.Enabled = (chkJoy.Value = vbChecked)
  168. End Sub
  169. Private Sub chkKeyboard_Click()
  170.     If chkMouse.Value = vbUnchecked And chkKeyboard.Value = vbUnchecked Then
  171.         MsgBox "You must leave at least the keyboard or the mouse enabled.", vbOKOnly Or vbInformation, "No basic input"
  172.         chkKeyboard.Value = vbChecked
  173.     End If
  174.     lblKeySens.Enabled = (chkKeyboard.Value = vbChecked)
  175.     sldKeyboard.Enabled = (chkKeyboard.Value = vbChecked)
  176. End Sub
  177. Private Sub chkMouse_Click()
  178.     If chkMouse.Value = vbUnchecked And chkKeyboard.Value = vbUnchecked Then
  179.         MsgBox "You must leave at least the keyboard or the mouse enabled.", vbOKOnly Or vbInformation, "No basic input"
  180.         chkMouse.Value = vbChecked
  181.     End If
  182.     lblMouseSens.Enabled = (chkMouse.Value = vbChecked)
  183.     sldMouseSens.Enabled = (chkMouse.Value = vbChecked)
  184. End Sub
  185. Private Sub cmdCancel_Click()
  186.     Unload Me
  187. End Sub
  188. Private Sub cmdOk_Click()
  189.     SaveAudioSettings
  190.     Unload Me
  191. End Sub
  192. Private Sub Form_Load()
  193.     Dim lIndex As Long
  194.     'Now update the display
  195.     chkMouse.Value = Abs(goInput.UseMouse)
  196.     chkKeyboard.Value = Abs(goInput.UseKeyboard)
  197.     chkJoy.Value = Abs(goInput.UseJoystick)
  198.     sldSens.Value = (goInput.JoystickSensitivity * 100000)
  199.     sldMouseSens.Value = (goInput.MouseSensitivity * 1000)
  200.     sldKeyboard.Value = (goInput.KeyboardSensitivity * 1000)
  201.     cboJoy.Enabled = (chkJoy.Value = vbChecked)
  202.     lblSens.Enabled = (chkJoy.Value = vbChecked)
  203.     sldSens.Enabled = (chkJoy.Value = vbChecked)
  204.     lblMouseSens.Enabled = (chkMouse.Value = vbChecked)
  205.     sldMouseSens.Enabled = (chkMouse.Value = vbChecked)
  206.     lblKeySens.Enabled = (chkKeyboard.Value = vbChecked)
  207.     sldKeyboard.Enabled = (chkKeyboard.Value = vbChecked)
  208.     'Now, let's fill up the ui for the joysticks
  209.     Set diDevEnum = goInput.InputObject.GetDIDevices(DI8DEVCLASS_GAMECTRL, DIEDFL_ATTACHEDONLY)
  210.     If diDevEnum.GetCount = 0 Then
  211.         chkJoy.Enabled = False
  212.         cboJoy.Enabled = False
  213.     Else
  214.         'Ok, there *are* joysticks.  Load them into the combo box
  215.         Dim lCount As Long
  216.         lIndex = 0
  217.         For lCount = 1 To diDevEnum.GetCount
  218.             cboJoy.AddItem diDevEnum.GetItem(lCount).GetInstanceName
  219.             If diDevEnum.GetItem(lCount).GetGuidInstance = goInput.JoystickGuid Then lIndex = lCount - 1
  220.         Next
  221.         cboJoy.ListIndex = lIndex
  222.     End If
  223. End Sub
  224. Private Sub SaveAudioSettings()
  225.     goInput.UseMouse = (chkMouse.Value = vbChecked)
  226.     If goInput.UseMouse Then
  227.         goInput.MouseSensitivity = sldMouseSens.Value / 1000
  228.     End If
  229.     goInput.UseKeyboard = (chkKeyboard.Value = vbChecked)
  230.     If goInput.UseKeyboard Then
  231.         goInput.KeyboardSensitivity = sldKeyboard.Value / 1000
  232.     End If
  233.     goInput.UseJoystick = (chkJoy.Value = vbChecked)
  234.     If goInput.UseJoystick Then
  235.         goInput.JoystickGuid = diDevEnum.GetItem(cboJoy.ListIndex + 1).GetGuidInstance
  236.         goInput.JoystickSensitivity = sldSens.Value / 100000
  237.     End If
  238. End Sub
  239. Private Sub Form_Unload(Cancel As Integer)
  240.     'We're leaving the form, save the settings
  241.     SaveSetting gsKeyName, gsSubKeyInput, "UseMouse", goInput.UseMouse
  242.     SaveSetting gsKeyName, gsSubKeyInput, "UseKeyboard", goInput.UseKeyboard
  243.     SaveSetting gsKeyName, gsSubKeyInput, "UseJoystick", goInput.UseJoystick
  244.     If goInput.UseJoystick Then
  245.         SaveSetting gsKeyName, gsSubKeyInput, "JoystickGuid", goInput.JoystickGuid
  246.         SaveSetting gsKeyName, gsSubKeyInput, "JoystickSensitivity", goInput.JoystickSensitivity
  247.     End If
  248.     If goInput.UseMouse Then
  249.         SaveSetting gsKeyName, gsSubKeyInput, "MouseSensitivity", goInput.MouseSensitivity
  250.     End If
  251.     If goInput.UseKeyboard Then
  252.         SaveSetting gsKeyName, gsSubKeyInput, "KeyboardSensitivity", goInput.KeyboardSensitivity
  253.     End If
  254. End Sub
  255.