#Region Module Attributes
	#FullScreen: False
	#IncludeTitle: True
	#ApplicationLabel: Gestures Demo
	#VersionCode: 1
	#VersionName: 
	#SupportedOrientations: unspecified
	#CanInstallToExternalStorage: True
#End Region

'Activity module
Sub Process_Globals
	'These global variables will be declared once when the application starts.
	'These variables can be accessed from all modules.

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.

	Dim gest As Gestures
	Dim pnl As Panel
	Dim movecount As Int
	
End Sub

Sub Activity_Create(FirstTime As Boolean)
	pnl.Initialize("pnl")
	pnl.Tag = "pnl"
	pnl.Color = Colors.LightGray
	gest.SetOnTouchListener(pnl, "pnl_gesture")
	Activity.AddView(pnl, 5dip, 5dip, 310dip, 310dip)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

' Connect to filtered LogCat to view the output of this demo

Sub pnl_gesture(o As Object, ptrID As Int, action As Int, x As Float, y As Float) As Boolean
	If action = gest.ACTION_MOVE Then
		movecount = movecount + 1
		' noise on the touch screen electroincs can cause lots of apparent move events
		' this loop slows the rate down to one comfortable for LogCat
		' adjust the value for your device if necessary
		If movecount < 10 Then 
			Return ' need to return true otherwise we don't get any other events in the gesture
		End If
		movecount = 0
	End If
	Dim v As View
	v = o	
	a = action
	Select action
		Case gest.ACTION_DOWN
			a = "Down "
			Log("Gesture started")
		Case gest.ACTION_UP
			a = "Up "
		Case gest.ACTION_POINTER_DOWN
			a = "PtrDown "
		Case gest.ACTION_POINTER_UP
			a = "PtrUp "
		Case gest.ACTION_MOVE
			a = "Move "
	End Select	
	Dim ix, iy, count As Int
	ix = x
	iy = y
	count = gest.GetPointerCount
	msg = v.Tag & " id" & ptrID & " " & a & " x" & ix & " y" & iy & " cnt" & count' event parameters
	For i = 0 To count -1
		id = gest.GetPointerID(i)
		ix = gest.GetX(id)
		iy = gest.GetY(id)
	 	msg = msg & " : id" & id & " x" & ix & " y" & iy ' retrieved data
	Next
	Log(msg)
	If action = gest.ACTION_UP Then
		Log("Gesture ended")
	End If
	Return True ' need to return true otherwise we don't get any other events in the gesture
End Sub

