#Region Module Attributes
#FullScreen: True
#IncludeTitle: False
#ApplicationLabel: UpClicker
#VersionCode: 1
#VersionName:
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
'Activity module
Sub Process_Globals
Dim AStreams As AsyncStreams
Dim Server As ServerSocket
Dim Socket1 As Socket
End Sub
Sub Globals
Dim bgd As Panel
Dim G As Gestures
Dim Canvas As Canvas
Dim LastS As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
Server.Initialize(2222, "Server")
Server.Listen
Log("MyIp = " & Server.GetMyIP)
End If
'Create a panel and add it to the activity
bgd.Initialize("")
Activity.AddView(bgd, 0, 0, 100%x, 100%y)
Canvas.Initialize(bgd)
'Add a listener for this panel
G.SetOnTouchListener(bgd, "GesturesTouch")
End Sub
Sub Activity_Pause (UserClosed As Boolean)
If UserClosed Then
Log("closing")
AStreams.Close
Socket1.Close
End If
End Sub
Sub GesturesTouch(View As Object, PointerID As Int, Action As Int, X As Float, Y As Float) As Boolean
Dim buffer() As Byte
Dim s As String
Dim st As String
Dim px, py As Int 'could send float x and y if you want
Dim tx, ty As Int 'could send float x and y if you want
tx = x
ty = Y
For i = 0 To 4 'change 4 to suit your needs
px = g.GetX(i)
py = g.GetY(i)
If px<>-1 AND py<>-1 Then
s = s & " " & i & ": " & px & " x " & py
End If
Next
s = s & " PID " & PointerID & " Act " & Action
st = s & " " & tx & " x " & ty & " " & DateTime.Now & Chr(13) & Chr(10)
If AStreams.IsInitialized = True AND LastS <> s Then
buffer = st.GetBytes("UTF8")
AStreams.Write(buffer)
End If
LastS = s
Return True
End Sub
Sub Server_NewConnection (Successful As Boolean, NewSocket As Socket)
If Successful Then
ToastMessageShow("Connected", False)
Socket1 = NewSocket
'AStreams.InitializePrefix(Socket1.InputStream, False, Socket1.OutputStream, "AStreams")
AStreams.Initialize(Socket1.InputStream, Socket1.OutputStream, "AStreams")
Else
ToastMessageShow(LastException.Message, True)
End If
Server.Listen
End Sub
Sub AStreams_NewData (Buffer() As Byte)
Dim msg As String
msg = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
ToastMessageShow(msg, False)
Log(msg)
End Sub
Sub AStreams_Error
ToastMessageShow(LastException.Message, True)
End Sub