VERSION 5.00
Begin VB.Form Form1 
   ClientHeight    =   4515
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   9885
   LinkTopic       =   "Form1"
   ScaleHeight     =   4515
   ScaleWidth      =   9885
   StartUpPosition =   3  'Windows の既定値
   Begin VB.CommandButton cmdDisconnect 
      Caption         =   "Disconnect"
      Enabled         =   0   'False
      Height          =   345
      Left            =   8280
      TabIndex        =   39
      Top             =   240
      Width           =   1515
   End
   Begin VB.CommandButton cmdConnect 
      Caption         =   "Connect"
      Height          =   345
      Left            =   6690
      TabIndex        =   38
      Top             =   240
      Width           =   1515
   End
   Begin VB.Frame Frame4 
      Caption         =   "Provider"
      Height          =   645
      Left            =   180
      TabIndex        =   35
      Top             =   60
      Width           =   6375
      Begin VB.OptionButton optProvider 
         Caption         =   "CaoProv.VBGateway"
         Height          =   315
         Index           =   1
         Left            =   3390
         TabIndex        =   37
         Top             =   210
         Width           =   2775
      End
      Begin VB.OptionButton optProvider 
         Caption         =   "CaoProv.3DConnexion.3DMouse"
         Height          =   315
         Index           =   0
         Left            =   360
         TabIndex        =   36
         Top             =   210
         Value           =   -1  'True
         Width           =   2715
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "Value"
      Height          =   3555
      Left            =   180
      TabIndex        =   0
      Top             =   780
      Width           =   9585
      Begin VB.Timer Timer1 
         Enabled         =   0   'False
         Interval        =   100
         Left            =   5490
         Top             =   2460
      End
      Begin VB.Frame Frame3 
         Caption         =   "Translation"
         Height          =   1845
         Left            =   6570
         TabIndex        =   26
         Top             =   270
         Width           =   2895
         Begin VB.TextBox Text1 
            Height          =   300
            Index           =   15
            Left            =   870
            TabIndex        =   30
            Top             =   1350
            Width           =   1875
         End
         Begin VB.TextBox Text1 
            Height          =   300
            Index           =   14
            Left            =   870
            TabIndex        =   29
            Top             =   990
            Width           =   1875
         End
         Begin VB.TextBox Text1 
            Height          =   300
            Index           =   13
            Left            =   870
            TabIndex        =   28
            Top             =   630
            Width           =   1875
         End
         Begin VB.TextBox Text1 
            Height          =   300
            Index           =   12
            Left            =   870
            TabIndex        =   27
            Top             =   270
            Width           =   1875
         End
         Begin VB.Label Label15 
            Alignment       =   1  '右揃え
            Caption         =   "Length : "
            Height          =   165
            Left            =   180
            TabIndex        =   34
            Top             =   1440
            Width           =   615
         End
         Begin VB.Label Label16 
            Alignment       =   1  '右揃え
            Caption         =   "Z : "
            Height          =   165
            Left            =   180
            TabIndex        =   33
            Top             =   1080
            Width           =   615
         End
         Begin VB.Label Label17 
            Alignment       =   1  '右揃え
            Caption         =   "Y : "
            Height          =   165
            Left            =   180
            TabIndex        =   32
            Top             =   690
            Width           =   645
         End
         Begin VB.Label Label18 
            Alignment       =   1  '右揃え
            Caption         =   "X : "
            Height          =   165
            Left            =   120
            TabIndex        =   31
            Top             =   330
            Width           =   705
         End
      End
      Begin VB.Frame Frame2 
         Caption         =   "Rotation"
         Height          =   1845
         Left            =   3540
         TabIndex        =   17
         Top             =   270
         Width           =   2895
         Begin VB.TextBox Text1 
            Height          =   300
            Index           =   8
            Left            =   840
            TabIndex        =   21
            Top             =   300
            Width           =   1875
         End
         Begin VB.TextBox Text1 
            Height          =   300
            Index           =   9
            Left            =   840
            TabIndex        =   20
            Top             =   660
            Width           =   1875
         End
         Begin VB.TextBox Text1 
            Height          =   300
            Index           =   10
            Left            =   840
            TabIndex        =   19
            Top             =   1020
            Width           =   1875
         End
         Begin VB.TextBox Text1 
            Height          =   300
            Index           =   11
            Left            =   840
            TabIndex        =   18
            Top             =   1380
            Width           =   1875
         End
         Begin VB.Label Label14 
            Alignment       =   1  '右揃え
            Caption         =   "Angle : "
            Height          =   165
            Left            =   180
            TabIndex        =   25
            Top             =   1440
            Width           =   615
         End
         Begin VB.Label Label13 
            Alignment       =   1  '右揃え
            Caption         =   "Z : "
            Height          =   165
            Left            =   180
            TabIndex        =   24
            Top             =   1080
            Width           =   615
         End
         Begin VB.Label Label12 
            Alignment       =   1  '右揃え
            Caption         =   "Y : "
            Height          =   165
            Left            =   180
            TabIndex        =   23
            Top             =   690
            Width           =   645
         End
         Begin VB.Label Label11 
            Alignment       =   1  '右揃え
            Caption         =   "X : "
            Height          =   165
            Left            =   120
            TabIndex        =   22
            Top             =   330
            Width           =   705
         End
      End
      Begin VB.TextBox Text1 
         Height          =   300
         Index           =   0
         Left            =   1410
         TabIndex        =   8
         Top             =   570
         Width           =   1875
      End
      Begin VB.TextBox Text1 
         Height          =   300
         Index           =   1
         Left            =   1410
         TabIndex        =   7
         Top             =   930
         Width           =   1875
      End
      Begin VB.TextBox Text1 
         Height          =   300
         Index           =   2
         Left            =   1410
         TabIndex        =   6
         Top             =   1290
         Width           =   1875
      End
      Begin VB.TextBox Text1 
         Height          =   300
         Index           =   3
         Left            =   1410
         TabIndex        =   5
         Top             =   1650
         Width           =   1875
      End
      Begin VB.TextBox Text1 
         Height          =   300
         Index           =   4
         Left            =   1410
         TabIndex        =   4
         Top             =   2010
         Width           =   1875
      End
      Begin VB.TextBox Text1 
         Height          =   300
         Index           =   5
         Left            =   1410
         TabIndex        =   3
         Top             =   2370
         Width           =   1875
      End
      Begin VB.TextBox Text1 
         Height          =   300
         Index           =   6
         Left            =   1410
         TabIndex        =   2
         Top             =   2730
         Width           =   1875
      End
      Begin VB.TextBox Text1 
         Height          =   300
         Index           =   7
         Left            =   1410
         TabIndex        =   1
         Top             =   3090
         Width           =   1875
      End
      Begin VB.Label Label5 
         Alignment       =   1  '右揃え
         Caption         =   "Version : "
         Height          =   165
         Left            =   330
         TabIndex        =   16
         Top             =   3150
         Width           =   1035
      End
      Begin VB.Label Label6 
         Alignment       =   1  '右揃え
         Caption         =   "SensorPeriod : "
         Height          =   165
         Left            =   210
         TabIndex        =   15
         Top             =   2790
         Width           =   1095
      End
      Begin VB.Label Label7 
         Alignment       =   1  '右揃え
         Caption         =   "ProgKeyCnt : "
         Height          =   165
         Left            =   270
         TabIndex        =   14
         Top             =   2430
         Width           =   1035
      End
      Begin VB.Label Label8 
         Alignment       =   1  '右揃え
         Caption         =   "KeyCnt : "
         Height          =   165
         Left            =   330
         TabIndex        =   13
         Top             =   2070
         Width           =   1035
      End
      Begin VB.Label Label9 
         Alignment       =   1  '右揃え
         Caption         =   "KeyName1 : "
         Height          =   165
         Left            =   330
         TabIndex        =   12
         Top             =   1710
         Width           =   1035
      End
      Begin VB.Label Label10 
         Alignment       =   1  '右揃え
         Caption         =   "KeyLabel1 : "
         Height          =   165
         Left            =   330
         TabIndex        =   11
         Top             =   1350
         Width           =   1035
      End
      Begin VB.Label Label2 
         Alignment       =   1  '右揃え
         Caption         =   "KeyState1 : "
         Height          =   165
         Left            =   330
         TabIndex        =   10
         Top             =   960
         Width           =   1035
      End
      Begin VB.Label Label1 
         Alignment       =   1  '右揃え
         Caption         =   "DeviceType : "
         Height          =   165
         Left            =   270
         TabIndex        =   9
         Top             =   600
         Width           =   1035
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim eng As CaoEngine
Dim ctrl As CaoController
Attribute ctrl.VB_VarHelpID = -1
Dim CaoVar(9) As CaoVariable

Private Sub Form_Load()

    Set eng = New CaoEngine

End Sub

Private Sub cmdConnect_Click()

    If optProvider(0).Value Then
        Set ctrl = eng.Workspaces(0).AddController("3DMouse", "CaoProv.3DConnexion.3DMouse")
    Else
        Set ctrl = eng.Workspaces(0).AddController("3DMouse", "CaoProv.VBGateway", "", "VBP=CaoProv_3DMouseVB")
    End If
        
    Set CaoVar(0) = ctrl.AddVariable("DeviceType")
    Set CaoVar(1) = ctrl.AddVariable("KeyState1")
    Set CaoVar(2) = ctrl.AddVariable("KeyLabel1")
    Set CaoVar(3) = ctrl.AddVariable("KeyName1")
    Set CaoVar(4) = ctrl.AddVariable("KeyCount")
    Set CaoVar(5) = ctrl.AddVariable("ProgrammableKeyCount")
    Set CaoVar(6) = ctrl.AddVariable("SensorPeriod")
    Set CaoVar(7) = ctrl.AddVariable("Version")
    Set CaoVar(8) = ctrl.AddVariable("Rotation")
    Set CaoVar(9) = ctrl.AddVariable("Translation")

    Timer1.Enabled = True
    cmdConnect.Enabled = False
    cmdDisconnect.Enabled = True

End Sub

Private Sub cmdDisconnect_Click()
    
    For i = 0 To 9
        Set CaoVar(i) = Nothing
    Next
    
    If Not ctrl Is Nothing Then
        eng.Workspaces(0).Controllers.Remove ctrl.Index
        Set ctrl = Nothing
    End If
        
    Timer1.Enabled = False
    cmdConnect.Enabled = True
    cmdDisconnect.Enabled = False

End Sub

Private Sub Timer1_Timer()
    
    Dim i  As Long
    Dim tempVal As Variant
    
    For i = 0 To 7
        Text1(i).Text = CaoVar(i).Value
    Next
    
    tempVal = CaoVar(8).Value
    For i = 0 To 3
        Text1(i + 8).Text = tempVal(i)
    Next
    
    tempVal = CaoVar(9).Value
    For i = 0 To 3
        Text1(i + 12).Text = tempVal(i)
    Next
    
    
End Sub
