#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#Extends: anywheresoftware.b4a.objects.ActivityEx
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim Main_Cycle As Timer
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private Output As Label
Dim Global_Key_Code As Int
Dim GME As String
Dim X As Float
Dim Y As Float
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Layout1")
Output.Left = 0%x
Output.Top = 0%y
Output.Width = 100%x
Output.Height = 100%y
Main_Cycle.Initialize("Main_Cycle", 1000/60)
Main_Cycle.Enabled = True
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Main_Cycle_Tick
Output.text = GME & CRLF & CRLF & _
"Last KeyCode: " & Global_Key_Code & CRLF & CRLF & _
"X: " & Round2(x, 2) & " Y: " & Round2(y, 2)
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean
Global_Key_Code = KeyCode
Return True
End Sub
Sub Activity_OnGenericMotionEvent(event As Object)
GME = event
For i = 0 To (GME.Length - 1)
If GME.SubString2(i, i + 5) = "x[0]=" Then
Dim tempX As String
For j = i + 5 To (GME.Length - 1)
If GME.CharAt(j) = "," Then
Exit
Else
tempX = tempX & GME.CharAt(j)
End If
Next
If tempX <> "" Then Exit
End If
Next
x = tempX
For i = 0 To (GME.Length - 1)
If GME.SubString2(i, i + 5) = "y[0]=" Then
Dim tempY As String
For j = i + 5 To (GME.Length - 1)
If GME.CharAt(j) = "," Then
Exit
Else
tempY = tempY & GME.CharAt(j)
End If
Next
If tempY <> "" Then Exit
End If
Next
y = tempY
End Sub